forked from AppFlowy-IO/appflowy-editor
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* main: chore: bump version 1.5.0 (AppFlowy-IO#551) feat: convert = and > to ⇒ (AppFlowy-IO#523) feat: support overriding i18n (AppFlowy-IO#550) feat: table html encoder and decoder added (AppFlowy-IO#449)
- Loading branch information
Showing
56 changed files
with
789 additions
and
165 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 10 additions & 11 deletions
21
...itor_component/service/shortcuts/character_shortcut_events/character_shortcut_events.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,12 @@ | ||
export 'insert_newline.dart'; | ||
export 'slash_command.dart'; | ||
export 'markdown_syntax_character_shortcut_events.dart'; | ||
|
||
export 'format_single_character/format_single_character.dart'; | ||
export 'format_single_character/format_italic.dart'; | ||
export 'format_single_character/format_code.dart'; | ||
export 'format_single_character/format_strikethrough.dart'; | ||
|
||
export 'format_double_characters/format_double_characters.dart'; | ||
export 'format_double_characters/format_bold.dart'; | ||
export 'format_double_characters/format_strikethrough.dart'; | ||
export 'format_double_characters/format_double_characters.dart'; | ||
export 'format_double_characters/format_double_hyphen.dart'; | ||
export 'format_double_characters/format_equal_greater_character.dart'; | ||
export 'format_double_characters/format_strikethrough.dart'; | ||
export 'format_single_character/format_code.dart'; | ||
export 'format_single_character/format_italic.dart'; | ||
export 'format_single_character/format_single_character.dart'; | ||
export 'format_single_character/format_strikethrough.dart'; | ||
export 'insert_newline.dart'; | ||
export 'markdown_syntax_character_shortcut_events.dart'; | ||
export 'slash_command.dart'; |
75 changes: 75 additions & 0 deletions
75
...ts/character_shortcut_events/format_double_characters/format_equal_greater_character.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import 'package:appflowy_editor/appflowy_editor.dart'; | ||
|
||
const _greater = '>'; | ||
const _equals = '='; | ||
const _arrow = '⇒'; | ||
|
||
/// format '=' + '>' into an ⇒ | ||
/// | ||
/// - support | ||
/// - desktop | ||
/// - mobile | ||
/// - web | ||
/// | ||
final CharacterShortcutEvent formatGreaterEqual = CharacterShortcutEvent( | ||
key: 'format = + > into ⇒', | ||
character: _greater, | ||
handler: (editorState) async => handleEqualGreaterReplacement( | ||
editorState: editorState, | ||
character: _greater, | ||
replacement: _arrow, | ||
), | ||
); | ||
|
||
// TODO(Xazin): Combine two character replacement methods into | ||
// a helper function | ||
Future<bool> handleEqualGreaterReplacement({ | ||
required EditorState editorState, | ||
required String character, | ||
required String replacement, | ||
}) async { | ||
assert(character.length == 1); | ||
|
||
Selection? selection = editorState.selection; | ||
if (selection == null) { | ||
return false; | ||
} | ||
|
||
if (!selection.isCollapsed) { | ||
await editorState.deleteSelection(selection); | ||
} | ||
|
||
selection = editorState.selection; | ||
if (selection == null) { | ||
return false; | ||
} | ||
|
||
final node = editorState.getNodeAtPath(selection.end.path); | ||
final delta = node?.delta; | ||
if (node == null || delta == null || delta.isEmpty) { | ||
return false; | ||
} | ||
|
||
if (selection.end.offset > 0) { | ||
final plain = delta.toPlainText(); | ||
|
||
final previousCharacter = plain[selection.end.offset - 1]; | ||
if (previousCharacter != _equals) { | ||
return false; | ||
} | ||
|
||
final replace = editorState.transaction | ||
..replaceText( | ||
node, | ||
selection.end.offset - 1, | ||
1, | ||
_arrow, | ||
); | ||
|
||
await editorState.apply(replace); | ||
|
||
return true; | ||
} | ||
|
||
return false; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.