forked from halo-dev/halo
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main'
- Loading branch information
Showing
7 changed files
with
134 additions
and
68 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
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
48 changes: 48 additions & 0 deletions
48
console/packages/editor/src/extensions/list-keymap/index.ts
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,48 @@ | ||
import { | ||
listHelpers, | ||
ListKeymap, | ||
type ListKeymapOptions, | ||
} from "@tiptap/extension-list-keymap"; | ||
import { Editor } from "@tiptap/core"; | ||
|
||
/** | ||
* Optimize the listKeymap extension until the issue with @tiptap/extension-list-keymap is resolved. | ||
* https://github.com/ueberdosis/tiptap/issues/4395 | ||
*/ | ||
const ExtensionListKeymap = ListKeymap.extend<ListKeymapOptions>({ | ||
addKeyboardShortcuts() { | ||
const backspaceHandle = (editor: Editor) => { | ||
let handled = false; | ||
|
||
if (!editor.state.selection.empty) { | ||
editor.commands.deleteSelection(); | ||
return true; | ||
} | ||
|
||
this.options.listTypes.forEach( | ||
({ | ||
itemName, | ||
wrapperNames, | ||
}: { | ||
itemName: string; | ||
wrapperNames: string[]; | ||
}) => { | ||
if (listHelpers.handleBackspace(editor, itemName, wrapperNames)) { | ||
handled = true; | ||
} | ||
} | ||
); | ||
|
||
return handled; | ||
}; | ||
|
||
return { | ||
Backspace: ({ editor }: { editor: Editor }) => backspaceHandle(editor), | ||
|
||
"Mod-Backspace": ({ editor }: { editor: Editor }) => | ||
backspaceHandle(editor), | ||
}; | ||
}, | ||
}); | ||
|
||
export default ExtensionListKeymap; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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