mirror of
https://github.com/docmost/docmost.git
synced 2025-11-25 09:41:10 +10:00
* feat: emoji picker * fix: lazy load emoji data * loading animation (for slow connection) * parsing :shortcode: and replace with emoji + add extension to title-editor * fix * Remove title editor support * Remove shortcuts support * Cleanup --------- Co-authored-by: Philipinho <16838612+Philipinho@users.noreply.github.com>
41 lines
1001 B
TypeScript
41 lines
1001 B
TypeScript
import { Extension } from "@tiptap/core";
|
|
import { PluginKey } from "@tiptap/pm/state";
|
|
import Suggestion, { SuggestionOptions } from "@tiptap/suggestion";
|
|
import getEmojiItems from "../components/emoji-menu/emoji-items";
|
|
import renderEmojiItems from "../components/emoji-menu/render-emoji-items";
|
|
export const emojiMenuPluginKey = new PluginKey("emoji-command");
|
|
|
|
const Command = Extension.create({
|
|
name: "emoji-command",
|
|
|
|
addOptions() {
|
|
return {
|
|
suggestion: {
|
|
char: ":",
|
|
command: ({ editor, range, props }) => {
|
|
props.command({ editor, range, props });
|
|
},
|
|
} as Partial<SuggestionOptions>,
|
|
};
|
|
},
|
|
|
|
addProseMirrorPlugins() {
|
|
return [
|
|
Suggestion({
|
|
pluginKey: emojiMenuPluginKey,
|
|
...this.options.suggestion,
|
|
editor: this.editor,
|
|
}),
|
|
];
|
|
},
|
|
});
|
|
|
|
const EmojiCommand = Command.configure({
|
|
suggestion: {
|
|
items: getEmojiItems,
|
|
render: renderEmojiItems,
|
|
},
|
|
});
|
|
|
|
export default EmojiCommand;
|