Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
ruibaby committed Jan 2, 2024
2 parents 76ed183 + 5a51c5d commit ab11907
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 68 deletions.
14 changes: 7 additions & 7 deletions console/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@
"@codemirror/state": "^6.1.4",
"@codemirror/view": "^6.5.1",
"@emoji-mart/data": "^1.0.8",
"@formkit/core": "^1.3.0",
"@formkit/i18n": "^1.3.0",
"@formkit/inputs": "^1.3.0",
"@formkit/themes": "^1.3.0",
"@formkit/utils": "^1.3.0",
"@formkit/validation": "1.3.0",
"@formkit/vue": "^1.3.0",
"@formkit/core": "^1.4.0",
"@formkit/i18n": "^1.4.0",
"@formkit/inputs": "^1.4.0",
"@formkit/themes": "^1.4.0",
"@formkit/utils": "^1.4.0",
"@formkit/validation": "^1.4.0",
"@formkit/vue": "^1.4.0",
"@halo-dev/api-client": "workspace:*",
"@halo-dev/components": "workspace:*",
"@halo-dev/console-shared": "workspace:*",
Expand Down
1 change: 1 addition & 0 deletions console/packages/editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
"@tiptap/extension-italic": "^2.1.10",
"@tiptap/extension-link": "^2.1.10",
"@tiptap/extension-list-item": "^2.1.10",
"@tiptap/extension-list-keymap": "^2.1.10",
"@tiptap/extension-ordered-list": "^2.1.10",
"@tiptap/extension-paragraph": "^2.1.10",
"@tiptap/extension-placeholder": "^2.1.10",
Expand Down
2 changes: 2 additions & 0 deletions console/packages/editor/src/dev/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import {
ExtensionColumn,
ExtensionNodeSelected,
ExtensionTrailingNode,
ExtensionListKeymap,
} from "../index";
const content = useLocalStorage("content", "");
Expand Down Expand Up @@ -107,6 +108,7 @@ const editor = useEditor({
ExtensionColumn,
ExtensionNodeSelected,
ExtensionTrailingNode,
ExtensionListKeymap,
],
onUpdate: () => {
content.value = editor.value?.getHTML() + "";
Expand Down
2 changes: 2 additions & 0 deletions console/packages/editor/src/extensions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import ExtensionSubscript from "./subscript";
import ExtensionBulletList from "./bullet-list";
import ExtensionOrderedList from "./ordered-list";
import ExtensionTaskList from "./task-list";
import ExtensionListKeymap from "./list-keymap";
import ExtensionTable from "./table";
import ExtensionTextAlign from "./text-align";
import ExtensionTextStyle from "@tiptap/extension-text-style";
Expand Down Expand Up @@ -142,4 +143,5 @@ export {
ExtensionColumn,
ExtensionNodeSelected,
ExtensionTrailingNode,
ExtensionListKeymap,
};
48 changes: 48 additions & 0 deletions console/packages/editor/src/extensions/list-keymap/index.ts
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;
133 changes: 72 additions & 61 deletions console/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions console/src/components/editor/DefaultEditor.vue
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import {
Plugin,
PluginKey,
DecorationSet,
ExtensionListKeymap,
} from "@halo-dev/richtext-editor";
import {
IconCalendar,
Expand Down Expand Up @@ -318,6 +319,7 @@ onMounted(() => {
];
},
}),
ExtensionListKeymap,
],
autofocus: "start",
onUpdate: () => {
Expand Down

0 comments on commit ab11907

Please sign in to comment.