* wip * Add more providers * icons * unify embed providers (Youtube) * fix case * YT music * remove redundant code
29 lines
709 B
TypeScript
29 lines
709 B
TypeScript
import TiptapLink from "@tiptap/extension-link";
|
|
import { Plugin } from "@tiptap/pm/state";
|
|
import { EditorView } from "@tiptap/pm/view";
|
|
|
|
export const LinkExtension = TiptapLink.extend({
|
|
inclusive: false,
|
|
|
|
addProseMirrorPlugins() {
|
|
const { editor } = this;
|
|
|
|
return [
|
|
...(this.parent?.() || []),
|
|
new Plugin({
|
|
props: {
|
|
handleKeyDown: (view: EditorView, event: KeyboardEvent) => {
|
|
const { selection } = editor.state;
|
|
|
|
if (event.key === "Escape" && selection.empty !== true) {
|
|
editor.commands.focus(selection.to, { scrollIntoView: false });
|
|
}
|
|
|
|
return false;
|
|
},
|
|
},
|
|
}),
|
|
];
|
|
},
|
|
});
|