mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 06:23:06 +08:00
fe83557767
* wip * Space export * option to export pages with children * include attachments in exports * unified export UI * cleanup * fix: change export icon * add export button to space settings * cleanups * export name
48 lines
1.1 KiB
TypeScript
48 lines
1.1 KiB
TypeScript
import { mergeAttributes } from "@tiptap/core";
|
|
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,
|
|
|
|
parseHTML() {
|
|
return [
|
|
{
|
|
tag: 'a[href]:not([data-type="button"]):not([href *= "javascript:" i])',
|
|
},
|
|
];
|
|
},
|
|
|
|
renderHTML({ HTMLAttributes }) {
|
|
return [
|
|
"a",
|
|
mergeAttributes(this.options.HTMLAttributes, HTMLAttributes, {
|
|
class: "link",
|
|
}),
|
|
0,
|
|
];
|
|
},
|
|
|
|
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;
|
|
},
|
|
},
|
|
}),
|
|
];
|
|
},
|
|
});
|