@tiptap/vue-3 3.0.0-next.2 → 3.0.0-next.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE.md ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024, Tiptap GmbH
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,14 +1,18 @@
1
1
  # @tiptap/vue-3
2
+
2
3
  [![Version](https://img.shields.io/npm/v/@tiptap/vue-3.svg?label=version)](https://www.npmjs.com/package/@tiptap/vue-3)
3
4
  [![Downloads](https://img.shields.io/npm/dm/@tiptap/vue-3.svg)](https://npmcharts.com/compare/tiptap?minimal=true)
4
5
  [![License](https://img.shields.io/npm/l/@tiptap/vue-3.svg)](https://www.npmjs.com/package/@tiptap/vue-3)
5
6
  [![Sponsor](https://img.shields.io/static/v1?label=Sponsor&message=%E2%9D%A4&logo=GitHub)](https://github.com/sponsors/ueberdosis)
6
7
 
7
8
  ## Introduction
8
- Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as *New York Times*, *The Guardian* or *Atlassian*.
9
+
10
+ Tiptap is a headless wrapper around [ProseMirror](https://ProseMirror.net) – a toolkit for building rich text WYSIWYG editors, which is already in use at many well-known companies such as _New York Times_, _The Guardian_ or _Atlassian_.
9
11
 
10
12
  ## Official Documentation
13
+
11
14
  Documentation can be found on the [Tiptap website](https://tiptap.dev).
12
15
 
13
16
  ## License
17
+
14
18
  Tiptap is open sourced software licensed under the [MIT license](https://github.com/ueberdosis/tiptap/blob/main/LICENSE.md).
package/dist/index.cjs CHANGED
@@ -19,8 +19,8 @@ var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "defau
19
19
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
20
20
 
21
21
  // src/index.ts
22
- var src_exports = {};
23
- __export(src_exports, {
22
+ var index_exports = {};
23
+ __export(index_exports, {
24
24
  BubbleMenu: () => BubbleMenu,
25
25
  Editor: () => Editor,
26
26
  EditorContent: () => EditorContent,
@@ -32,7 +32,7 @@ __export(src_exports, {
32
32
  nodeViewProps: () => nodeViewProps,
33
33
  useEditor: () => useEditor
34
34
  });
35
- module.exports = __toCommonJS(src_exports);
35
+ module.exports = __toCommonJS(index_exports);
36
36
 
37
37
  // src/BubbleMenu.ts
38
38
  var import_extension_bubble_menu = require("@tiptap/extension-bubble-menu");
@@ -68,29 +68,24 @@ var BubbleMenu = (0, import_vue.defineComponent)({
68
68
  setup(props, { slots }) {
69
69
  const root = (0, import_vue.ref)(null);
70
70
  (0, import_vue.onMounted)(() => {
71
- const {
72
- editor,
73
- options,
74
- pluginKey,
75
- resizeDelay,
76
- shouldShow,
77
- updateDelay
78
- } = props;
71
+ const { editor, options, pluginKey, resizeDelay, shouldShow, updateDelay } = props;
79
72
  if (!root.value) {
80
73
  return;
81
74
  }
82
75
  root.value.style.visibility = "hidden";
83
76
  root.value.style.position = "absolute";
84
77
  root.value.remove();
85
- editor.registerPlugin((0, import_extension_bubble_menu.BubbleMenuPlugin)({
86
- editor,
87
- element: root.value,
88
- options,
89
- pluginKey,
90
- resizeDelay,
91
- shouldShow,
92
- updateDelay
93
- }));
78
+ editor.registerPlugin(
79
+ (0, import_extension_bubble_menu.BubbleMenuPlugin)({
80
+ editor,
81
+ element: root.value,
82
+ options,
83
+ pluginKey,
84
+ resizeDelay,
85
+ shouldShow,
86
+ updateDelay
87
+ })
88
+ );
94
89
  });
95
90
  (0, import_vue.onBeforeUnmount)(() => {
96
91
  const { pluginKey, editor } = props;
@@ -215,14 +210,11 @@ var EditorContent = (0, import_vue3.defineComponent)({
215
210
  return { rootEl };
216
211
  },
217
212
  render() {
218
- return (0, import_vue3.h)(
219
- "div",
220
- {
221
- ref: (el) => {
222
- this.rootEl = el;
223
- }
213
+ return (0, import_vue3.h)("div", {
214
+ ref: (el) => {
215
+ this.rootEl = el;
224
216
  }
225
- );
217
+ });
226
218
  }
227
219
  });
228
220
 
@@ -254,25 +246,22 @@ var FloatingMenu = (0, import_vue4.defineComponent)({
254
246
  setup(props, { slots }) {
255
247
  const root = (0, import_vue4.ref)(null);
256
248
  (0, import_vue4.onMounted)(() => {
257
- const {
258
- pluginKey,
259
- editor,
260
- options,
261
- shouldShow
262
- } = props;
249
+ const { pluginKey, editor, options, shouldShow } = props;
263
250
  if (!root.value) {
264
251
  return;
265
252
  }
266
253
  root.value.style.visibility = "hidden";
267
254
  root.value.style.position = "absolute";
268
255
  root.value.remove();
269
- editor.registerPlugin((0, import_extension_floating_menu.FloatingMenuPlugin)({
270
- pluginKey,
271
- editor,
272
- element: root.value,
273
- options,
274
- shouldShow
275
- }));
256
+ editor.registerPlugin(
257
+ (0, import_extension_floating_menu.FloatingMenuPlugin)({
258
+ pluginKey,
259
+ editor,
260
+ element: root.value,
261
+ options,
262
+ shouldShow
263
+ })
264
+ );
276
265
  });
277
266
  (0, import_vue4.onBeforeUnmount)(() => {
278
267
  const { pluginKey, editor } = props;
@@ -614,7 +603,7 @@ function VueNodeViewRenderer(component, options) {
614
603
  }
615
604
 
616
605
  // src/index.ts
617
- __reExport(src_exports, require("@tiptap/core"), module.exports);
606
+ __reExport(index_exports, require("@tiptap/core"), module.exports);
618
607
  // Annotate the CommonJS export names for ESM import in node:
619
608
  0 && (module.exports = {
620
609
  BubbleMenu,
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/BubbleMenu.ts","../src/Editor.ts","../src/EditorContent.ts","../src/FloatingMenu.ts","../src/NodeViewContent.ts","../src/NodeViewWrapper.ts","../src/useEditor.ts","../src/VueNodeViewRenderer.ts","../src/VueRenderer.ts"],"sourcesContent":["export * from './BubbleMenu.js'\nexport { Editor } from './Editor.js'\nexport * from './EditorContent.js'\nexport * from './FloatingMenu.js'\nexport * from './NodeViewContent.js'\nexport * from './NodeViewWrapper.js'\nexport * from './useEditor.js'\nexport * from './VueNodeViewRenderer.js'\nexport * from './VueRenderer.js'\nexport * from '@tiptap/core'\n","import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n PropType,\n ref,\n Teleport,\n} from 'vue'\n\nexport const BubbleMenu = defineComponent({\n name: 'BubbleMenu',\n\n props: {\n pluginKey: {\n type: [String, Object] as PropType<BubbleMenuPluginProps['pluginKey']>,\n default: 'bubbleMenu',\n },\n\n editor: {\n type: Object as PropType<BubbleMenuPluginProps['editor']>,\n required: true,\n },\n\n updateDelay: {\n type: Number as PropType<BubbleMenuPluginProps['updateDelay']>,\n default: undefined,\n },\n\n resizeDelay: {\n type: Number as PropType<BubbleMenuPluginProps['resizeDelay']>,\n default: undefined,\n },\n\n options: {\n type: Object as PropType<BubbleMenuPluginProps['options']>,\n default: () => ({}),\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<BubbleMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n },\n\n setup(props, { slots }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const {\n editor,\n options,\n pluginKey,\n resizeDelay,\n shouldShow,\n updateDelay,\n } = props\n\n if (!root.value) {\n return\n }\n\n root.value.style.visibility = 'hidden'\n root.value.style.position = 'absolute'\n\n // remove the element from the DOM\n root.value.remove()\n\n editor.registerPlugin(BubbleMenuPlugin({\n editor,\n element: root.value as HTMLElement,\n options,\n pluginKey,\n resizeDelay,\n shouldShow,\n updateDelay,\n }))\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n return () => h(Teleport, { to: 'body' }, h('div', { ref: root }, slots.default?.()))\n },\n})\n","/* eslint-disable react-hooks/rules-of-hooks */\nimport { Editor as CoreEditor, EditorOptions } from '@tiptap/core'\nimport { EditorState, Plugin, PluginKey } from '@tiptap/pm/state'\nimport {\n AppContext,\n ComponentInternalInstance,\n ComponentPublicInstance,\n customRef,\n markRaw,\n Ref,\n} from 'vue'\n\nfunction useDebouncedRef<T>(value: T) {\n return customRef<T>((track, trigger) => {\n return {\n get() {\n track()\n return value\n },\n set(newValue) {\n // update state\n value = newValue\n\n // update view as soon as possible\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n trigger()\n })\n })\n },\n }\n })\n}\n\nexport type ContentComponent = ComponentInternalInstance & {\n ctx: ComponentPublicInstance\n}\n\nexport class Editor extends CoreEditor {\n private reactiveState: Ref<EditorState>\n\n private reactiveExtensionStorage: Ref<Record<string, any>>\n\n public contentComponent: ContentComponent | null = null\n\n public appContext: AppContext | null = null\n\n constructor(options: Partial<EditorOptions> = {}) {\n super(options)\n\n this.reactiveState = useDebouncedRef(this.view.state)\n this.reactiveExtensionStorage = useDebouncedRef(this.extensionStorage)\n\n this.on('beforeTransaction', ({ nextState }) => {\n this.reactiveState.value = nextState\n this.reactiveExtensionStorage.value = this.extensionStorage\n })\n\n return markRaw(this) // eslint-disable-line\n }\n\n get state() {\n return this.reactiveState ? this.reactiveState.value : this.view.state\n }\n\n get storage() {\n return this.reactiveExtensionStorage ? this.reactiveExtensionStorage.value : super.storage\n }\n\n /**\n * Register a ProseMirror plugin.\n */\n public registerPlugin(\n plugin: Plugin,\n handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[],\n ): EditorState {\n const nextState = super.registerPlugin(plugin, handlePlugins)\n\n if (this.reactiveState) {\n this.reactiveState.value = nextState\n }\n\n return nextState\n }\n\n /**\n * Unregister a ProseMirror plugin.\n */\n public unregisterPlugin(nameOrPluginKey: string | PluginKey): EditorState | undefined {\n const nextState = super.unregisterPlugin(nameOrPluginKey)\n\n if (this.reactiveState && nextState) {\n this.reactiveState.value = nextState\n }\n\n return nextState\n }\n}\n","import {\n defineComponent,\n getCurrentInstance,\n h,\n nextTick,\n onBeforeUnmount,\n PropType,\n Ref,\n ref,\n unref,\n watchEffect,\n} from 'vue'\n\nimport { Editor } from './Editor.js'\n\nexport const EditorContent = defineComponent({\n name: 'EditorContent',\n\n props: {\n editor: {\n default: null,\n type: Object as PropType<Editor>,\n },\n },\n\n setup(props) {\n const rootEl: Ref<Element | undefined> = ref()\n const instance = getCurrentInstance()\n\n watchEffect(() => {\n const editor = props.editor\n\n if (editor && editor.options.element && rootEl.value) {\n nextTick(() => {\n if (!rootEl.value || !editor.options.element.firstChild) {\n return\n }\n\n const element = unref(rootEl.value)\n\n rootEl.value.append(...editor.options.element.childNodes)\n\n // @ts-ignore\n editor.contentComponent = instance.ctx._\n\n if (instance) {\n editor.appContext = {\n ...instance.appContext,\n // Vue internally uses prototype chain to forward/shadow injects across the entire component chain\n // so don't use object spread operator or 'Object.assign' and just set `provides` as is on editor's appContext\n // @ts-expect-error forward instance's 'provides' into appContext\n provides: instance.provides,\n }\n }\n\n editor.setOptions({\n element,\n })\n\n editor.createNodeViews()\n })\n }\n })\n\n onBeforeUnmount(() => {\n const editor = props.editor\n\n if (!editor) {\n return\n }\n\n editor.contentComponent = null\n editor.appContext = null\n })\n\n return { rootEl }\n },\n\n render() {\n return h(\n 'div',\n {\n ref: (el: any) => { this.rootEl = el },\n },\n )\n },\n})\n","import type { BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\nimport { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n PropType,\n ref,\n Teleport,\n} from 'vue'\n\nexport const FloatingMenu = defineComponent({\n name: 'FloatingMenu',\n\n props: {\n pluginKey: {\n // TODO: TypeScript breaks :(\n // type: [String, Object as PropType<Exclude<FloatingMenuPluginProps['pluginKey'], string>>],\n type: null,\n default: 'floatingMenu',\n },\n\n editor: {\n type: Object as PropType<FloatingMenuPluginProps['editor']>,\n required: true,\n },\n\n options: {\n type: Object as PropType<BubbleMenuPluginProps['options']>,\n default: () => ({}),\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<FloatingMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n },\n\n setup(props, { slots }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const {\n pluginKey,\n editor,\n options,\n shouldShow,\n } = props\n\n if (!root.value) {\n return\n }\n\n root.value.style.visibility = 'hidden'\n root.value.style.position = 'absolute'\n\n // remove the element from the DOM\n root.value.remove()\n\n editor.registerPlugin(FloatingMenuPlugin({\n pluginKey,\n editor,\n element: root.value as HTMLElement,\n options,\n shouldShow,\n }))\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n return () => h(Teleport, { to: 'body' }, h('div', { ref: root }, slots.default?.()))\n },\n})\n","import { defineComponent, h } from 'vue'\n\nexport const NodeViewContent = defineComponent({\n name: 'NodeViewContent',\n\n props: {\n as: {\n type: String,\n default: 'div',\n },\n },\n\n render() {\n return h(this.as, {\n style: {\n whiteSpace: 'pre-wrap',\n },\n 'data-node-view-content': '',\n })\n },\n})\n","import { defineComponent, h } from 'vue'\n\nexport const NodeViewWrapper = defineComponent({\n name: 'NodeViewWrapper',\n\n props: {\n as: {\n type: String,\n default: 'div',\n },\n },\n\n inject: ['onDragStart', 'decorationClasses'],\n\n render() {\n return h(\n this.as,\n {\n // @ts-ignore\n class: this.decorationClasses,\n style: {\n whiteSpace: 'normal',\n },\n 'data-node-view-wrapper': '',\n // @ts-ignore (https://github.com/vuejs/vue-next/issues/3031)\n onDragstart: this.onDragStart,\n },\n this.$slots.default?.(),\n )\n },\n})\n","import { EditorOptions } from '@tiptap/core'\nimport { onBeforeUnmount, onMounted, shallowRef } from 'vue'\n\nimport { Editor } from './Editor.js'\n\nexport const useEditor = (options: Partial<EditorOptions> = {}) => {\n const editor = shallowRef<Editor>()\n\n onMounted(() => {\n editor.value = new Editor(options)\n })\n\n onBeforeUnmount(() => {\n // Cloning root node (and its children) to avoid content being lost by destroy\n const nodes = editor.value?.options.element\n const newEl = nodes?.cloneNode(true) as HTMLElement\n\n nodes?.parentNode?.replaceChild(newEl, nodes)\n\n editor.value?.destroy()\n })\n\n return editor\n}\n","/* eslint-disable no-underscore-dangle */\nimport {\n DecorationWithType,\n NodeView,\n NodeViewProps,\n NodeViewRenderer,\n NodeViewRendererOptions,\n} from '@tiptap/core'\nimport { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { Decoration, DecorationSource, NodeView as ProseMirrorNodeView } from '@tiptap/pm/view'\nimport {\n Component, defineComponent, PropType, provide, Ref, ref,\n} from 'vue'\n\nimport { Editor } from './Editor.js'\nimport { VueRenderer } from './VueRenderer.js'\n\nexport const nodeViewProps = {\n editor: {\n type: Object as PropType<NodeViewProps['editor']>,\n required: true as const,\n },\n node: {\n type: Object as PropType<NodeViewProps['node']>,\n required: true as const,\n },\n decorations: {\n type: Object as PropType<NodeViewProps['decorations']>,\n required: true as const,\n },\n selected: {\n type: Boolean as PropType<NodeViewProps['selected']>,\n required: true as const,\n },\n extension: {\n type: Object as PropType<NodeViewProps['extension']>,\n required: true as const,\n },\n getPos: {\n type: Function as PropType<NodeViewProps['getPos']>,\n required: true as const,\n },\n updateAttributes: {\n type: Function as PropType<NodeViewProps['updateAttributes']>,\n required: true as const,\n },\n deleteNode: {\n type: Function as PropType<NodeViewProps['deleteNode']>,\n required: true as const,\n },\n}\n\nexport interface VueNodeViewRendererOptions extends NodeViewRendererOptions {\n update:\n | ((props: {\n oldNode: ProseMirrorNode;\n oldDecorations: readonly Decoration[];\n oldInnerDecorations: DecorationSource;\n newNode: ProseMirrorNode;\n newDecorations: readonly Decoration[];\n innerDecorations: DecorationSource;\n updateProps: () => void;\n }) => boolean)\n | null;\n}\n\nclass VueNodeView extends NodeView<Component, Editor, VueNodeViewRendererOptions> {\n renderer!: VueRenderer\n\n decorationClasses!: Ref<string>\n\n mount() {\n const props = {\n editor: this.editor,\n node: this.node,\n decorations: this.decorations as DecorationWithType[],\n innerDecorations: this.innerDecorations,\n view: this.view,\n selected: false,\n extension: this.extension,\n HTMLAttributes: this.HTMLAttributes,\n getPos: () => this.getPos(),\n updateAttributes: (attributes = {}) => this.updateAttributes(attributes),\n deleteNode: () => this.deleteNode(),\n } satisfies NodeViewProps\n\n const onDragStart = this.onDragStart.bind(this)\n\n this.decorationClasses = ref(this.getDecorationClasses())\n\n const extendedComponent = defineComponent({\n extends: { ...this.component },\n props: Object.keys(props),\n template: (this.component as any).template,\n setup: reactiveProps => {\n provide('onDragStart', onDragStart)\n provide('decorationClasses', this.decorationClasses)\n\n return (this.component as any).setup?.(reactiveProps, {\n expose: () => undefined,\n })\n },\n // add support for scoped styles\n // @ts-ignore\n // eslint-disable-next-line\n __scopeId: this.component.__scopeId,\n // add support for CSS Modules\n // @ts-ignore\n // eslint-disable-next-line\n __cssModules: this.component.__cssModules,\n // add support for vue devtools\n // @ts-ignore\n // eslint-disable-next-line\n __name: this.component.__name,\n // @ts-ignore\n // eslint-disable-next-line\n __file: this.component.__file,\n })\n\n this.handleSelectionUpdate = this.handleSelectionUpdate.bind(this)\n this.editor.on('selectionUpdate', this.handleSelectionUpdate)\n\n this.renderer = new VueRenderer(extendedComponent, {\n editor: this.editor,\n props,\n })\n }\n\n /**\n * Return the DOM element.\n * This is the element that will be used to display the node view.\n */\n get dom() {\n if (!this.renderer.element || !this.renderer.element.hasAttribute('data-node-view-wrapper')) {\n throw Error('Please use the NodeViewWrapper component for your node view.')\n }\n\n return this.renderer.element as HTMLElement\n }\n\n /**\n * Return the content DOM element.\n * This is the element that will be used to display the rich-text content of the node.\n */\n get contentDOM() {\n if (this.node.isLeaf) {\n return null\n }\n\n return this.dom.querySelector('[data-node-view-content]') as HTMLElement | null\n }\n\n /**\n * On editor selection update, check if the node is selected.\n * If it is, call `selectNode`, otherwise call `deselectNode`.\n */\n handleSelectionUpdate() {\n const { from, to } = this.editor.state.selection\n const pos = this.getPos()\n\n if (typeof pos !== 'number') {\n return\n }\n\n if (from <= pos && to >= pos + this.node.nodeSize) {\n if (this.renderer.props.selected) {\n return\n }\n\n this.selectNode()\n } else {\n if (!this.renderer.props.selected) {\n return\n }\n\n this.deselectNode()\n }\n }\n\n /**\n * On update, update the React component.\n * To prevent unnecessary updates, the `update` option can be used.\n */\n update(\n node: ProseMirrorNode,\n decorations: readonly Decoration[],\n innerDecorations: DecorationSource,\n ): boolean {\n const rerenderComponent = (props?: Record<string, any>) => {\n this.decorationClasses.value = this.getDecorationClasses()\n this.renderer.updateProps(props)\n }\n\n if (typeof this.options.update === 'function') {\n const oldNode = this.node\n const oldDecorations = this.decorations\n const oldInnerDecorations = this.innerDecorations\n\n this.node = node\n this.decorations = decorations\n this.innerDecorations = innerDecorations\n\n return this.options.update({\n oldNode,\n oldDecorations,\n newNode: node,\n newDecorations: decorations,\n oldInnerDecorations,\n innerDecorations,\n updateProps: () => rerenderComponent({ node, decorations, innerDecorations }),\n })\n }\n\n if (node.type !== this.node.type) {\n return false\n }\n\n if (node === this.node && this.decorations === decorations && this.innerDecorations === innerDecorations) {\n return true\n }\n\n this.node = node\n this.decorations = decorations\n this.innerDecorations = innerDecorations\n\n rerenderComponent({ node, decorations, innerDecorations })\n\n return true\n }\n\n /**\n * Select the node.\n * Add the `selected` prop and the `ProseMirror-selectednode` class.\n */\n selectNode() {\n this.renderer.updateProps({\n selected: true,\n })\n if (this.renderer.element) {\n this.renderer.element.classList.add('ProseMirror-selectednode')\n }\n }\n\n /**\n * Deselect the node.\n * Remove the `selected` prop and the `ProseMirror-selectednode` class.\n */\n deselectNode() {\n this.renderer.updateProps({\n selected: false,\n })\n if (this.renderer.element) {\n this.renderer.element.classList.remove('ProseMirror-selectednode')\n }\n }\n\n getDecorationClasses() {\n return (\n this.decorations\n // @ts-ignore\n .map(item => item.type.attrs.class)\n .flat()\n .join(' ')\n )\n }\n\n destroy() {\n this.renderer.destroy()\n this.editor.off('selectionUpdate', this.handleSelectionUpdate)\n }\n}\n\nexport function VueNodeViewRenderer(\n component: Component<NodeViewProps>,\n options?: Partial<VueNodeViewRendererOptions>,\n): NodeViewRenderer {\n return props => {\n // try to get the parent component\n // this is important for vue devtools to show the component hierarchy correctly\n // maybe it’s `undefined` because <editor-content> isn’t rendered yet\n if (!(props.editor as Editor).contentComponent) {\n return {} as unknown as ProseMirrorNodeView\n }\n // check for class-component and normalize if neccessary\n const normalizedComponent = typeof component === 'function' && '__vccOpts' in component\n ? (component.__vccOpts as Component)\n : component\n\n return new VueNodeView(normalizedComponent, props, options)\n }\n}\n","import { Editor } from '@tiptap/core'\nimport {\n Component, DefineComponent, h, markRaw, reactive, render,\n} from 'vue'\n\nimport { Editor as ExtendedEditor } from './Editor.js'\n\nexport interface VueRendererOptions {\n editor: Editor;\n props?: Record<string, any>;\n}\n\ntype ExtendedVNode = ReturnType<typeof h> | null;\n\ninterface RenderedComponent {\n vNode: ExtendedVNode;\n destroy: () => void;\n el: Element | null;\n}\n\n/**\n * This class is used to render Vue components inside the editor.\n */\nexport class VueRenderer {\n renderedComponent!: RenderedComponent\n\n editor: ExtendedEditor\n\n component: Component\n\n el: Element | null\n\n props: Record<string, any>\n\n constructor(component: Component, { props = {}, editor }: VueRendererOptions) {\n this.editor = editor as ExtendedEditor\n this.component = markRaw(component)\n this.el = document.createElement('div')\n this.props = reactive(props)\n this.renderedComponent = this.renderComponent()\n }\n\n get element(): Element | null {\n return this.renderedComponent.el\n }\n\n get ref(): any {\n // Composition API\n if (this.renderedComponent.vNode?.component?.exposed) {\n return this.renderedComponent.vNode.component.exposed\n }\n // Option API\n return this.renderedComponent.vNode?.component?.proxy\n }\n\n renderComponent() {\n let vNode: ExtendedVNode = h(this.component as DefineComponent, this.props)\n\n if (this.editor.appContext) {\n vNode.appContext = this.editor.appContext\n }\n if (typeof document !== 'undefined' && this.el) {\n render(vNode, this.el)\n }\n\n const destroy = () => {\n if (this.el) {\n render(null, this.el)\n }\n this.el = null\n vNode = null\n }\n\n return { vNode, destroy, el: this.el ? this.el.firstElementChild : null }\n }\n\n updateProps(props: Record<string, any> = {}): void {\n Object.entries(props).forEach(([key, value]) => {\n this.props[key] = value\n })\n this.renderComponent()\n }\n\n destroy(): void {\n this.renderedComponent.destroy()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mCAAwD;AACxD,iBAQO;AAEA,IAAM,iBAAa,4BAAgB;AAAA,EACxC,MAAM;AAAA,EAEN,OAAO;AAAA,IACL,WAAW;AAAA,MACT,MAAM,CAAC,QAAQ,MAAM;AAAA,MACrB,SAAS;AAAA,IACX;AAAA,IAEA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IAEA,aAAa;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IAEA,aAAa;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IAEA,SAAS;AAAA,MACP,MAAM;AAAA,MACN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AAAA,EAC5D;AACF;;;ARzRA,wBAAc,yBATd;","names":["import_vue","CoreEditor","import_vue","import_vue","import_vue","import_vue","import_vue","import_core","import_vue","import_vue"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/BubbleMenu.ts","../src/Editor.ts","../src/EditorContent.ts","../src/FloatingMenu.ts","../src/NodeViewContent.ts","../src/NodeViewWrapper.ts","../src/useEditor.ts","../src/VueNodeViewRenderer.ts","../src/VueRenderer.ts"],"sourcesContent":["export * from './BubbleMenu.js'\nexport { Editor } from './Editor.js'\nexport * from './EditorContent.js'\nexport * from './FloatingMenu.js'\nexport * from './NodeViewContent.js'\nexport * from './NodeViewWrapper.js'\nexport * from './useEditor.js'\nexport * from './VueNodeViewRenderer.js'\nexport * from './VueRenderer.js'\nexport * from '@tiptap/core'\n","import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\nimport { defineComponent, h, onBeforeUnmount, onMounted, PropType, ref, Teleport } from 'vue'\n\nexport const BubbleMenu = defineComponent({\n name: 'BubbleMenu',\n\n props: {\n pluginKey: {\n type: [String, Object] as PropType<BubbleMenuPluginProps['pluginKey']>,\n default: 'bubbleMenu',\n },\n\n editor: {\n type: Object as PropType<BubbleMenuPluginProps['editor']>,\n required: true,\n },\n\n updateDelay: {\n type: Number as PropType<BubbleMenuPluginProps['updateDelay']>,\n default: undefined,\n },\n\n resizeDelay: {\n type: Number as PropType<BubbleMenuPluginProps['resizeDelay']>,\n default: undefined,\n },\n\n options: {\n type: Object as PropType<BubbleMenuPluginProps['options']>,\n default: () => ({}),\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<BubbleMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n },\n\n setup(props, { slots }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const { editor, options, pluginKey, resizeDelay, shouldShow, updateDelay } = props\n\n if (!root.value) {\n return\n }\n\n root.value.style.visibility = 'hidden'\n root.value.style.position = 'absolute'\n\n // remove the element from the DOM\n root.value.remove()\n\n editor.registerPlugin(\n BubbleMenuPlugin({\n editor,\n element: root.value as HTMLElement,\n options,\n pluginKey,\n resizeDelay,\n shouldShow,\n updateDelay,\n }),\n )\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n return () => h(Teleport, { to: 'body' }, h('div', { ref: root }, slots.default?.()))\n },\n})\n","/* eslint-disable react-hooks/rules-of-hooks */\nimport { Editor as CoreEditor, EditorOptions } from '@tiptap/core'\nimport { EditorState, Plugin, PluginKey } from '@tiptap/pm/state'\nimport { AppContext, ComponentInternalInstance, ComponentPublicInstance, customRef, markRaw, Ref } from 'vue'\n\nfunction useDebouncedRef<T>(value: T) {\n return customRef<T>((track, trigger) => {\n return {\n get() {\n track()\n return value\n },\n set(newValue) {\n // update state\n value = newValue\n\n // update view as soon as possible\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n trigger()\n })\n })\n },\n }\n })\n}\n\nexport type ContentComponent = ComponentInternalInstance & {\n ctx: ComponentPublicInstance\n}\n\nexport class Editor extends CoreEditor {\n private reactiveState: Ref<EditorState>\n\n private reactiveExtensionStorage: Ref<Record<string, any>>\n\n public contentComponent: ContentComponent | null = null\n\n public appContext: AppContext | null = null\n\n constructor(options: Partial<EditorOptions> = {}) {\n super(options)\n\n this.reactiveState = useDebouncedRef(this.view.state)\n this.reactiveExtensionStorage = useDebouncedRef(this.extensionStorage)\n\n this.on('beforeTransaction', ({ nextState }) => {\n this.reactiveState.value = nextState\n this.reactiveExtensionStorage.value = this.extensionStorage\n })\n\n return markRaw(this) // eslint-disable-line\n }\n\n get state() {\n return this.reactiveState ? this.reactiveState.value : this.view.state\n }\n\n get storage() {\n return this.reactiveExtensionStorage ? this.reactiveExtensionStorage.value : super.storage\n }\n\n /**\n * Register a ProseMirror plugin.\n */\n public registerPlugin(\n plugin: Plugin,\n handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[],\n ): EditorState {\n const nextState = super.registerPlugin(plugin, handlePlugins)\n\n if (this.reactiveState) {\n this.reactiveState.value = nextState\n }\n\n return nextState\n }\n\n /**\n * Unregister a ProseMirror plugin.\n */\n public unregisterPlugin(nameOrPluginKey: string | PluginKey): EditorState | undefined {\n const nextState = super.unregisterPlugin(nameOrPluginKey)\n\n if (this.reactiveState && nextState) {\n this.reactiveState.value = nextState\n }\n\n return nextState\n }\n}\n","import {\n defineComponent,\n getCurrentInstance,\n h,\n nextTick,\n onBeforeUnmount,\n PropType,\n Ref,\n ref,\n unref,\n watchEffect,\n} from 'vue'\n\nimport { Editor } from './Editor.js'\n\nexport const EditorContent = defineComponent({\n name: 'EditorContent',\n\n props: {\n editor: {\n default: null,\n type: Object as PropType<Editor>,\n },\n },\n\n setup(props) {\n const rootEl: Ref<Element | undefined> = ref()\n const instance = getCurrentInstance()\n\n watchEffect(() => {\n const editor = props.editor\n\n if (editor && editor.options.element && rootEl.value) {\n nextTick(() => {\n if (!rootEl.value || !editor.options.element.firstChild) {\n return\n }\n\n const element = unref(rootEl.value)\n\n rootEl.value.append(...editor.options.element.childNodes)\n\n // @ts-ignore\n editor.contentComponent = instance.ctx._\n\n if (instance) {\n editor.appContext = {\n ...instance.appContext,\n // Vue internally uses prototype chain to forward/shadow injects across the entire component chain\n // so don't use object spread operator or 'Object.assign' and just set `provides` as is on editor's appContext\n // @ts-expect-error forward instance's 'provides' into appContext\n provides: instance.provides,\n }\n }\n\n editor.setOptions({\n element,\n })\n\n editor.createNodeViews()\n })\n }\n })\n\n onBeforeUnmount(() => {\n const editor = props.editor\n\n if (!editor) {\n return\n }\n\n editor.contentComponent = null\n editor.appContext = null\n })\n\n return { rootEl }\n },\n\n render() {\n return h('div', {\n ref: (el: any) => {\n this.rootEl = el\n },\n })\n },\n})\n","import { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\nimport { defineComponent, h, onBeforeUnmount, onMounted, PropType, ref, Teleport } from 'vue'\n\nexport const FloatingMenu = defineComponent({\n name: 'FloatingMenu',\n\n props: {\n pluginKey: {\n // TODO: TypeScript breaks :(\n // type: [String, Object as PropType<Exclude<FloatingMenuPluginProps['pluginKey'], string>>],\n type: null,\n default: 'floatingMenu',\n },\n\n editor: {\n type: Object as PropType<FloatingMenuPluginProps['editor']>,\n required: true,\n },\n\n options: {\n type: Object as PropType<FloatingMenuPluginProps['options']>,\n default: () => ({}),\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<FloatingMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n },\n\n setup(props, { slots }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const { pluginKey, editor, options, shouldShow } = props\n\n if (!root.value) {\n return\n }\n\n root.value.style.visibility = 'hidden'\n root.value.style.position = 'absolute'\n\n // remove the element from the DOM\n root.value.remove()\n\n editor.registerPlugin(\n FloatingMenuPlugin({\n pluginKey,\n editor,\n element: root.value as HTMLElement,\n options,\n shouldShow,\n }),\n )\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n return () => h(Teleport, { to: 'body' }, h('div', { ref: root }, slots.default?.()))\n },\n})\n","import { defineComponent, h } from 'vue'\n\nexport const NodeViewContent = defineComponent({\n name: 'NodeViewContent',\n\n props: {\n as: {\n type: String,\n default: 'div',\n },\n },\n\n render() {\n return h(this.as, {\n style: {\n whiteSpace: 'pre-wrap',\n },\n 'data-node-view-content': '',\n })\n },\n})\n","import { defineComponent, h } from 'vue'\n\nexport const NodeViewWrapper = defineComponent({\n name: 'NodeViewWrapper',\n\n props: {\n as: {\n type: String,\n default: 'div',\n },\n },\n\n inject: ['onDragStart', 'decorationClasses'],\n\n render() {\n return h(\n this.as,\n {\n // @ts-ignore\n class: this.decorationClasses,\n style: {\n whiteSpace: 'normal',\n },\n 'data-node-view-wrapper': '',\n // @ts-ignore (https://github.com/vuejs/vue-next/issues/3031)\n onDragstart: this.onDragStart,\n },\n this.$slots.default?.(),\n )\n },\n})\n","import { EditorOptions } from '@tiptap/core'\nimport { onBeforeUnmount, onMounted, shallowRef } from 'vue'\n\nimport { Editor } from './Editor.js'\n\nexport const useEditor = (options: Partial<EditorOptions> = {}) => {\n const editor = shallowRef<Editor>()\n\n onMounted(() => {\n editor.value = new Editor(options)\n })\n\n onBeforeUnmount(() => {\n // Cloning root node (and its children) to avoid content being lost by destroy\n const nodes = editor.value?.options.element\n const newEl = nodes?.cloneNode(true) as HTMLElement\n\n nodes?.parentNode?.replaceChild(newEl, nodes)\n\n editor.value?.destroy()\n })\n\n return editor\n}\n","/* eslint-disable no-underscore-dangle */\nimport { DecorationWithType, NodeView, NodeViewProps, NodeViewRenderer, NodeViewRendererOptions } from '@tiptap/core'\nimport { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { Decoration, DecorationSource, NodeView as ProseMirrorNodeView } from '@tiptap/pm/view'\nimport { Component, defineComponent, PropType, provide, Ref, ref } from 'vue'\n\nimport { Editor } from './Editor.js'\nimport { VueRenderer } from './VueRenderer.js'\n\nexport const nodeViewProps = {\n editor: {\n type: Object as PropType<NodeViewProps['editor']>,\n required: true as const,\n },\n node: {\n type: Object as PropType<NodeViewProps['node']>,\n required: true as const,\n },\n decorations: {\n type: Object as PropType<NodeViewProps['decorations']>,\n required: true as const,\n },\n selected: {\n type: Boolean as PropType<NodeViewProps['selected']>,\n required: true as const,\n },\n extension: {\n type: Object as PropType<NodeViewProps['extension']>,\n required: true as const,\n },\n getPos: {\n type: Function as PropType<NodeViewProps['getPos']>,\n required: true as const,\n },\n updateAttributes: {\n type: Function as PropType<NodeViewProps['updateAttributes']>,\n required: true as const,\n },\n deleteNode: {\n type: Function as PropType<NodeViewProps['deleteNode']>,\n required: true as const,\n },\n}\n\nexport interface VueNodeViewRendererOptions extends NodeViewRendererOptions {\n update:\n | ((props: {\n oldNode: ProseMirrorNode\n oldDecorations: readonly Decoration[]\n oldInnerDecorations: DecorationSource\n newNode: ProseMirrorNode\n newDecorations: readonly Decoration[]\n innerDecorations: DecorationSource\n updateProps: () => void\n }) => boolean)\n | null\n}\n\nclass VueNodeView extends NodeView<Component, Editor, VueNodeViewRendererOptions> {\n renderer!: VueRenderer\n\n decorationClasses!: Ref<string>\n\n mount() {\n const props = {\n editor: this.editor,\n node: this.node,\n decorations: this.decorations as DecorationWithType[],\n innerDecorations: this.innerDecorations,\n view: this.view,\n selected: false,\n extension: this.extension,\n HTMLAttributes: this.HTMLAttributes,\n getPos: () => this.getPos(),\n updateAttributes: (attributes = {}) => this.updateAttributes(attributes),\n deleteNode: () => this.deleteNode(),\n } satisfies NodeViewProps\n\n const onDragStart = this.onDragStart.bind(this)\n\n this.decorationClasses = ref(this.getDecorationClasses())\n\n const extendedComponent = defineComponent({\n extends: { ...this.component },\n props: Object.keys(props),\n template: (this.component as any).template,\n setup: reactiveProps => {\n provide('onDragStart', onDragStart)\n provide('decorationClasses', this.decorationClasses)\n\n return (this.component as any).setup?.(reactiveProps, {\n expose: () => undefined,\n })\n },\n // add support for scoped styles\n // @ts-ignore\n // eslint-disable-next-line\n __scopeId: this.component.__scopeId,\n // add support for CSS Modules\n // @ts-ignore\n // eslint-disable-next-line\n __cssModules: this.component.__cssModules,\n // add support for vue devtools\n // @ts-ignore\n // eslint-disable-next-line\n __name: this.component.__name,\n // @ts-ignore\n // eslint-disable-next-line\n __file: this.component.__file,\n })\n\n this.handleSelectionUpdate = this.handleSelectionUpdate.bind(this)\n this.editor.on('selectionUpdate', this.handleSelectionUpdate)\n\n this.renderer = new VueRenderer(extendedComponent, {\n editor: this.editor,\n props,\n })\n }\n\n /**\n * Return the DOM element.\n * This is the element that will be used to display the node view.\n */\n get dom() {\n if (!this.renderer.element || !this.renderer.element.hasAttribute('data-node-view-wrapper')) {\n throw Error('Please use the NodeViewWrapper component for your node view.')\n }\n\n return this.renderer.element as HTMLElement\n }\n\n /**\n * Return the content DOM element.\n * This is the element that will be used to display the rich-text content of the node.\n */\n get contentDOM() {\n if (this.node.isLeaf) {\n return null\n }\n\n return this.dom.querySelector('[data-node-view-content]') as HTMLElement | null\n }\n\n /**\n * On editor selection update, check if the node is selected.\n * If it is, call `selectNode`, otherwise call `deselectNode`.\n */\n handleSelectionUpdate() {\n const { from, to } = this.editor.state.selection\n const pos = this.getPos()\n\n if (typeof pos !== 'number') {\n return\n }\n\n if (from <= pos && to >= pos + this.node.nodeSize) {\n if (this.renderer.props.selected) {\n return\n }\n\n this.selectNode()\n } else {\n if (!this.renderer.props.selected) {\n return\n }\n\n this.deselectNode()\n }\n }\n\n /**\n * On update, update the React component.\n * To prevent unnecessary updates, the `update` option can be used.\n */\n update(node: ProseMirrorNode, decorations: readonly Decoration[], innerDecorations: DecorationSource): boolean {\n const rerenderComponent = (props?: Record<string, any>) => {\n this.decorationClasses.value = this.getDecorationClasses()\n this.renderer.updateProps(props)\n }\n\n if (typeof this.options.update === 'function') {\n const oldNode = this.node\n const oldDecorations = this.decorations\n const oldInnerDecorations = this.innerDecorations\n\n this.node = node\n this.decorations = decorations\n this.innerDecorations = innerDecorations\n\n return this.options.update({\n oldNode,\n oldDecorations,\n newNode: node,\n newDecorations: decorations,\n oldInnerDecorations,\n innerDecorations,\n updateProps: () => rerenderComponent({ node, decorations, innerDecorations }),\n })\n }\n\n if (node.type !== this.node.type) {\n return false\n }\n\n if (node === this.node && this.decorations === decorations && this.innerDecorations === innerDecorations) {\n return true\n }\n\n this.node = node\n this.decorations = decorations\n this.innerDecorations = innerDecorations\n\n rerenderComponent({ node, decorations, innerDecorations })\n\n return true\n }\n\n /**\n * Select the node.\n * Add the `selected` prop and the `ProseMirror-selectednode` class.\n */\n selectNode() {\n this.renderer.updateProps({\n selected: true,\n })\n if (this.renderer.element) {\n this.renderer.element.classList.add('ProseMirror-selectednode')\n }\n }\n\n /**\n * Deselect the node.\n * Remove the `selected` prop and the `ProseMirror-selectednode` class.\n */\n deselectNode() {\n this.renderer.updateProps({\n selected: false,\n })\n if (this.renderer.element) {\n this.renderer.element.classList.remove('ProseMirror-selectednode')\n }\n }\n\n getDecorationClasses() {\n return (\n this.decorations\n // @ts-ignore\n .map(item => item.type.attrs.class)\n .flat()\n .join(' ')\n )\n }\n\n destroy() {\n this.renderer.destroy()\n this.editor.off('selectionUpdate', this.handleSelectionUpdate)\n }\n}\n\nexport function VueNodeViewRenderer(\n component: Component<NodeViewProps>,\n options?: Partial<VueNodeViewRendererOptions>,\n): NodeViewRenderer {\n return props => {\n // try to get the parent component\n // this is important for vue devtools to show the component hierarchy correctly\n // maybe it’s `undefined` because <editor-content> isn’t rendered yet\n if (!(props.editor as Editor).contentComponent) {\n return {} as unknown as ProseMirrorNodeView\n }\n // check for class-component and normalize if neccessary\n const normalizedComponent =\n typeof component === 'function' && '__vccOpts' in component ? (component.__vccOpts as Component) : component\n\n return new VueNodeView(normalizedComponent, props, options)\n }\n}\n","import { Editor } from '@tiptap/core'\nimport { Component, DefineComponent, h, markRaw, reactive, render } from 'vue'\n\nimport { Editor as ExtendedEditor } from './Editor.js'\n\nexport interface VueRendererOptions {\n editor: Editor\n props?: Record<string, any>\n}\n\ntype ExtendedVNode = ReturnType<typeof h> | null\n\ninterface RenderedComponent {\n vNode: ExtendedVNode\n destroy: () => void\n el: Element | null\n}\n\n/**\n * This class is used to render Vue components inside the editor.\n */\nexport class VueRenderer {\n renderedComponent!: RenderedComponent\n\n editor: ExtendedEditor\n\n component: Component\n\n el: Element | null\n\n props: Record<string, any>\n\n constructor(component: Component, { props = {}, editor }: VueRendererOptions) {\n this.editor = editor as ExtendedEditor\n this.component = markRaw(component)\n this.el = document.createElement('div')\n this.props = reactive(props)\n this.renderedComponent = this.renderComponent()\n }\n\n get element(): Element | null {\n return this.renderedComponent.el\n }\n\n get ref(): any {\n // Composition API\n if (this.renderedComponent.vNode?.component?.exposed) {\n return this.renderedComponent.vNode.component.exposed\n }\n // Option API\n return this.renderedComponent.vNode?.component?.proxy\n }\n\n renderComponent() {\n let vNode: ExtendedVNode = h(this.component as DefineComponent, this.props)\n\n if (this.editor.appContext) {\n vNode.appContext = this.editor.appContext\n }\n if (typeof document !== 'undefined' && this.el) {\n render(vNode, this.el)\n }\n\n const destroy = () => {\n if (this.el) {\n render(null, this.el)\n }\n this.el = null\n vNode = null\n }\n\n return { vNode, destroy, el: this.el ? this.el.firstElementChild : null }\n }\n\n updateProps(props: Record<string, any> = {}): void {\n Object.entries(props).forEach(([key, value]) => {\n this.props[key] = value\n })\n this.renderComponent()\n }\n\n destroy(): void {\n this.renderedComponent.destroy()\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,mCAAwD;AACxD,iBAAwF;AAEjF,IAAM,iBAAa,4BAAgB;AAAA,EACxC,MAAM;AAAA,EAEN,OAAO;AAAA,IACL,WAAW;AAAA,MACT,MAAM,CAAC,QAAQ,MAAM;AAAA,MACrB,SAAS;AAAA,IACX;AAAA,IAEA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IAEA,aAAa;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IAEA,aAAa;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IAEA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS,OAAO,CAAC;AAAA,IACnB;AAAA,IAEA,YAAY;AAAA,MACV,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,EACF;AAAA,EAEA,MAAM,OAAO,EAAE,MAAM,GAAG;AACtB,UAAM,WAAO,gBAAwB,IAAI;AAEzC,8BAAU,MAAM;AACd,YAAM,EAAE,QAAQ,SAAS,WAAW,aAAa,YAAY,YAAY,IAAI;AAE7E,UAAI,CAAC,KAAK,OAAO;AACf;AAAA,MACF;AAEA,WAAK,MAAM,MAAM,aAAa;AAC9B,WAAK,MAAM,MAAM,WAAW;AAG5B,WAA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,aAAa;AACX,SAAK,SAAS,YAAY;AAAA,MACxB,UAAU;AAAA,IACZ,CAAC;AACD,QAAI,KAAK,SAAS,SAAS;AACzB,WAAK,SAAS,QAAQ,UAAU,IAAI,0BAA0B;AAAA,IAChE;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,eAAe;AACb,SAAK,SAAS,YAAY;AAAA,MACxB,UAAU;AAAA,IACZ,CAAC;AACD,QAAI,KAAK,SAAS,SAAS;AACzB,WAAK,SAAS,QAAQ,UAAU,OAAO,0BAA0B;AAAA,IACnE;AAAA,EACF;AAAA,EAEA,uBAAuB;AACrB,WACE,KAAK,YAEF,IAAI,UAAQ,KAAK,KAAK,MAAM,KAAK,EACjC,KAAK,EACL,KAAK,GAAG;AAAA,EAEf;AAAA,EAEA,UAAU;AACR,SAAK,SAAS,QAAQ;AACtB,SAAK,OAAO,IAAI,mBAAmB,KAAK,qBAAqB;AAAA,EAC/D;AACF;AAEO,SAAS,oBACd,WACA,SACkB;AAClB,SAAO,WAAS;AAId,QAAI,CAAE,MAAM,OAAkB,kBAAkB;AAC9C,aAAO,CAAC;AAAA,IACV;AAEA,UAAM,sBACJ,OAAO,cAAc,cAAc,eAAe,YAAa,UAAU,YAA0B;AAErG,WAAO,IAAI,YAAY,qBAAqB,OAAO,OAAO;AAAA,EAC5D;AACF;;;AR5QA,0BAAc,yBATd;","names":["import_vue","CoreEditor","import_vue","import_vue","import_vue","import_vue","import_vue","import_core","import_vue","import_vue"]}
package/dist/index.d.cts CHANGED
@@ -1,15 +1,13 @@
1
- import * as prosemirror_view from 'prosemirror-view';
1
+ import * as _floating_ui_dom from '@floating-ui/dom';
2
+ import { EditorState, PluginKey } from 'prosemirror-state';
3
+ import { EditorView } from 'prosemirror-view';
2
4
  import * as _tiptap_core from '@tiptap/core';
3
5
  import { Editor as Editor$1, EditorOptions, NodeViewProps, NodeViewRendererOptions, NodeViewRenderer } from '@tiptap/core';
4
6
  export * from '@tiptap/core';
5
- import * as _floating_ui_core from '@floating-ui/core';
6
- import * as _floating_ui_dom from '@floating-ui/dom';
7
- import * as _floating_ui_utils from '@floating-ui/utils';
8
- import * as prosemirror_state from 'prosemirror-state';
9
7
  import * as vue from 'vue';
10
8
  import { PropType, AppContext, ComponentInternalInstance, ComponentPublicInstance, Ref, Component, h } from 'vue';
11
9
  import { BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu';
12
- import { EditorState, Plugin, PluginKey } from '@tiptap/pm/state';
10
+ import { EditorState as EditorState$1, Plugin, PluginKey as PluginKey$1 } from '@tiptap/pm/state';
13
11
  import { FloatingMenuPluginProps } from '@tiptap/extension-floating-menu';
14
12
  import { Node } from '@tiptap/pm/model';
15
13
  import { Decoration, DecorationSource } from '@tiptap/pm/view';
@@ -67,30 +65,30 @@ declare const BubbleMenu: vue.DefineComponent<vue.ExtractPropTypes<{
67
65
  default: null;
68
66
  };
69
67
  }>> & Readonly<{}>, {
70
- pluginKey: string | prosemirror_state.PluginKey<any>;
71
68
  updateDelay: number | undefined;
72
69
  resizeDelay: number | undefined;
73
- options: {
74
- strategy?: _floating_ui_utils.Strategy;
75
- placement?: _floating_ui_utils.Placement;
76
- offset?: _floating_ui_dom.OffsetOptions | boolean;
77
- flip?: _floating_ui_dom.FlipOptions | boolean;
78
- shift?: _floating_ui_dom.ShiftOptions | boolean;
79
- arrow?: _floating_ui_dom.ArrowOptions | false;
80
- size?: _floating_ui_dom.SizeOptions | boolean;
81
- autoPlacement?: _floating_ui_dom.AutoPlacementOptions | boolean;
82
- hide?: _floating_ui_dom.HideOptions | boolean;
83
- inline?: _floating_ui_core.InlineOptions | boolean;
84
- } | undefined;
85
70
  shouldShow: (props: {
86
71
  editor: _tiptap_core.Editor;
87
72
  element: HTMLElement;
88
- view: prosemirror_view.EditorView;
89
- state: prosemirror_state.EditorState;
90
- oldState?: prosemirror_state.EditorState;
73
+ view: EditorView;
74
+ state: EditorState;
75
+ oldState?: EditorState;
91
76
  from: number;
92
77
  to: number;
93
78
  }) => boolean;
79
+ options: {
80
+ strategy?: "absolute" | "fixed";
81
+ placement?: "top" | "right" | "bottom" | "left" | "top-start" | "top-end" | "right-start" | "right-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end";
82
+ offset?: Parameters<typeof _floating_ui_dom.offset>[0] | boolean;
83
+ flip?: Parameters<typeof _floating_ui_dom.flip>[0] | boolean;
84
+ shift?: Parameters<typeof _floating_ui_dom.shift>[0] | boolean;
85
+ arrow?: Parameters<typeof _floating_ui_dom.arrow>[0] | false;
86
+ size?: Parameters<typeof _floating_ui_dom.size>[0] | boolean;
87
+ autoPlacement?: Parameters<typeof _floating_ui_dom.autoPlacement>[0] | boolean;
88
+ hide?: Parameters<typeof _floating_ui_dom.hide>[0] | boolean;
89
+ inline?: Parameters<typeof _floating_ui_dom.inline>[0] | boolean;
90
+ } | undefined;
91
+ pluginKey: string | PluginKey<any>;
94
92
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
95
93
 
96
94
  type ContentComponent = ComponentInternalInstance & {
@@ -102,16 +100,16 @@ declare class Editor extends Editor$1 {
102
100
  contentComponent: ContentComponent | null;
103
101
  appContext: AppContext | null;
104
102
  constructor(options?: Partial<EditorOptions>);
105
- get state(): EditorState;
103
+ get state(): EditorState$1;
106
104
  get storage(): Record<string, any>;
107
105
  /**
108
106
  * Register a ProseMirror plugin.
109
107
  */
110
- registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): EditorState;
108
+ registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): EditorState$1;
111
109
  /**
112
110
  * Unregister a ProseMirror plugin.
113
111
  */
114
- unregisterPlugin(nameOrPluginKey: string | PluginKey): EditorState | undefined;
112
+ unregisterPlugin(nameOrPluginKey: string | PluginKey$1): EditorState$1 | undefined;
115
113
  }
116
114
 
117
115
  declare const EditorContent: vue.DefineComponent<vue.ExtractPropTypes<{
@@ -140,7 +138,7 @@ declare const FloatingMenu: vue.DefineComponent<vue.ExtractPropTypes<{
140
138
  required: true;
141
139
  };
142
140
  options: {
143
- type: PropType<BubbleMenuPluginProps["options"]>;
141
+ type: PropType<FloatingMenuPluginProps["options"]>;
144
142
  default: () => {};
145
143
  };
146
144
  shouldShow: {
@@ -159,7 +157,7 @@ declare const FloatingMenu: vue.DefineComponent<vue.ExtractPropTypes<{
159
157
  required: true;
160
158
  };
161
159
  options: {
162
- type: PropType<BubbleMenuPluginProps["options"]>;
160
+ type: PropType<FloatingMenuPluginProps["options"]>;
163
161
  default: () => {};
164
162
  };
165
163
  shouldShow: {
@@ -167,27 +165,27 @@ declare const FloatingMenu: vue.DefineComponent<vue.ExtractPropTypes<{
167
165
  default: null;
168
166
  };
169
167
  }>> & Readonly<{}>, {
170
- pluginKey: any;
171
- options: {
172
- strategy?: _floating_ui_utils.Strategy;
173
- placement?: _floating_ui_utils.Placement;
174
- offset?: _floating_ui_dom.OffsetOptions | boolean;
175
- flip?: _floating_ui_dom.FlipOptions | boolean;
176
- shift?: _floating_ui_dom.ShiftOptions | boolean;
177
- arrow?: _floating_ui_dom.ArrowOptions | false;
178
- size?: _floating_ui_dom.SizeOptions | boolean;
179
- autoPlacement?: _floating_ui_dom.AutoPlacementOptions | boolean;
180
- hide?: _floating_ui_dom.HideOptions | boolean;
181
- inline?: _floating_ui_core.InlineOptions | boolean;
182
- } | undefined;
183
168
  shouldShow: (props: {
184
169
  editor: _tiptap_core.Editor;
185
- view: prosemirror_view.EditorView;
186
- state: prosemirror_state.EditorState;
187
- oldState?: prosemirror_state.EditorState;
170
+ view: EditorView;
171
+ state: EditorState;
172
+ oldState?: EditorState;
188
173
  from: number;
189
174
  to: number;
190
175
  }) => boolean;
176
+ options: {
177
+ strategy?: "absolute" | "fixed";
178
+ placement?: "top" | "right" | "bottom" | "left" | "top-start" | "top-end" | "right-start" | "right-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end";
179
+ offset?: Parameters<typeof _floating_ui_dom.offset>[0] | boolean;
180
+ flip?: Parameters<typeof _floating_ui_dom.flip>[0] | boolean;
181
+ shift?: Parameters<typeof _floating_ui_dom.shift>[0] | boolean;
182
+ arrow?: Parameters<typeof _floating_ui_dom.arrow>[0] | false;
183
+ size?: Parameters<typeof _floating_ui_dom.size>[0] | boolean;
184
+ autoPlacement?: Parameters<typeof _floating_ui_dom.autoPlacement>[0] | boolean;
185
+ hide?: Parameters<typeof _floating_ui_dom.hide>[0] | boolean;
186
+ inline?: Parameters<typeof _floating_ui_dom.inline>[0] | boolean;
187
+ } | undefined;
188
+ pluginKey: any;
191
189
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
192
190
 
193
191
  declare const NodeViewContent: vue.DefineComponent<vue.ExtractPropTypes<{
package/dist/index.d.ts CHANGED
@@ -1,15 +1,13 @@
1
- import * as prosemirror_view from 'prosemirror-view';
1
+ import * as _floating_ui_dom from '@floating-ui/dom';
2
+ import { EditorState, PluginKey } from 'prosemirror-state';
3
+ import { EditorView } from 'prosemirror-view';
2
4
  import * as _tiptap_core from '@tiptap/core';
3
5
  import { Editor as Editor$1, EditorOptions, NodeViewProps, NodeViewRendererOptions, NodeViewRenderer } from '@tiptap/core';
4
6
  export * from '@tiptap/core';
5
- import * as _floating_ui_core from '@floating-ui/core';
6
- import * as _floating_ui_dom from '@floating-ui/dom';
7
- import * as _floating_ui_utils from '@floating-ui/utils';
8
- import * as prosemirror_state from 'prosemirror-state';
9
7
  import * as vue from 'vue';
10
8
  import { PropType, AppContext, ComponentInternalInstance, ComponentPublicInstance, Ref, Component, h } from 'vue';
11
9
  import { BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu';
12
- import { EditorState, Plugin, PluginKey } from '@tiptap/pm/state';
10
+ import { EditorState as EditorState$1, Plugin, PluginKey as PluginKey$1 } from '@tiptap/pm/state';
13
11
  import { FloatingMenuPluginProps } from '@tiptap/extension-floating-menu';
14
12
  import { Node } from '@tiptap/pm/model';
15
13
  import { Decoration, DecorationSource } from '@tiptap/pm/view';
@@ -67,30 +65,30 @@ declare const BubbleMenu: vue.DefineComponent<vue.ExtractPropTypes<{
67
65
  default: null;
68
66
  };
69
67
  }>> & Readonly<{}>, {
70
- pluginKey: string | prosemirror_state.PluginKey<any>;
71
68
  updateDelay: number | undefined;
72
69
  resizeDelay: number | undefined;
73
- options: {
74
- strategy?: _floating_ui_utils.Strategy;
75
- placement?: _floating_ui_utils.Placement;
76
- offset?: _floating_ui_dom.OffsetOptions | boolean;
77
- flip?: _floating_ui_dom.FlipOptions | boolean;
78
- shift?: _floating_ui_dom.ShiftOptions | boolean;
79
- arrow?: _floating_ui_dom.ArrowOptions | false;
80
- size?: _floating_ui_dom.SizeOptions | boolean;
81
- autoPlacement?: _floating_ui_dom.AutoPlacementOptions | boolean;
82
- hide?: _floating_ui_dom.HideOptions | boolean;
83
- inline?: _floating_ui_core.InlineOptions | boolean;
84
- } | undefined;
85
70
  shouldShow: (props: {
86
71
  editor: _tiptap_core.Editor;
87
72
  element: HTMLElement;
88
- view: prosemirror_view.EditorView;
89
- state: prosemirror_state.EditorState;
90
- oldState?: prosemirror_state.EditorState;
73
+ view: EditorView;
74
+ state: EditorState;
75
+ oldState?: EditorState;
91
76
  from: number;
92
77
  to: number;
93
78
  }) => boolean;
79
+ options: {
80
+ strategy?: "absolute" | "fixed";
81
+ placement?: "top" | "right" | "bottom" | "left" | "top-start" | "top-end" | "right-start" | "right-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end";
82
+ offset?: Parameters<typeof _floating_ui_dom.offset>[0] | boolean;
83
+ flip?: Parameters<typeof _floating_ui_dom.flip>[0] | boolean;
84
+ shift?: Parameters<typeof _floating_ui_dom.shift>[0] | boolean;
85
+ arrow?: Parameters<typeof _floating_ui_dom.arrow>[0] | false;
86
+ size?: Parameters<typeof _floating_ui_dom.size>[0] | boolean;
87
+ autoPlacement?: Parameters<typeof _floating_ui_dom.autoPlacement>[0] | boolean;
88
+ hide?: Parameters<typeof _floating_ui_dom.hide>[0] | boolean;
89
+ inline?: Parameters<typeof _floating_ui_dom.inline>[0] | boolean;
90
+ } | undefined;
91
+ pluginKey: string | PluginKey<any>;
94
92
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
95
93
 
96
94
  type ContentComponent = ComponentInternalInstance & {
@@ -102,16 +100,16 @@ declare class Editor extends Editor$1 {
102
100
  contentComponent: ContentComponent | null;
103
101
  appContext: AppContext | null;
104
102
  constructor(options?: Partial<EditorOptions>);
105
- get state(): EditorState;
103
+ get state(): EditorState$1;
106
104
  get storage(): Record<string, any>;
107
105
  /**
108
106
  * Register a ProseMirror plugin.
109
107
  */
110
- registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): EditorState;
108
+ registerPlugin(plugin: Plugin, handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[]): EditorState$1;
111
109
  /**
112
110
  * Unregister a ProseMirror plugin.
113
111
  */
114
- unregisterPlugin(nameOrPluginKey: string | PluginKey): EditorState | undefined;
112
+ unregisterPlugin(nameOrPluginKey: string | PluginKey$1): EditorState$1 | undefined;
115
113
  }
116
114
 
117
115
  declare const EditorContent: vue.DefineComponent<vue.ExtractPropTypes<{
@@ -140,7 +138,7 @@ declare const FloatingMenu: vue.DefineComponent<vue.ExtractPropTypes<{
140
138
  required: true;
141
139
  };
142
140
  options: {
143
- type: PropType<BubbleMenuPluginProps["options"]>;
141
+ type: PropType<FloatingMenuPluginProps["options"]>;
144
142
  default: () => {};
145
143
  };
146
144
  shouldShow: {
@@ -159,7 +157,7 @@ declare const FloatingMenu: vue.DefineComponent<vue.ExtractPropTypes<{
159
157
  required: true;
160
158
  };
161
159
  options: {
162
- type: PropType<BubbleMenuPluginProps["options"]>;
160
+ type: PropType<FloatingMenuPluginProps["options"]>;
163
161
  default: () => {};
164
162
  };
165
163
  shouldShow: {
@@ -167,27 +165,27 @@ declare const FloatingMenu: vue.DefineComponent<vue.ExtractPropTypes<{
167
165
  default: null;
168
166
  };
169
167
  }>> & Readonly<{}>, {
170
- pluginKey: any;
171
- options: {
172
- strategy?: _floating_ui_utils.Strategy;
173
- placement?: _floating_ui_utils.Placement;
174
- offset?: _floating_ui_dom.OffsetOptions | boolean;
175
- flip?: _floating_ui_dom.FlipOptions | boolean;
176
- shift?: _floating_ui_dom.ShiftOptions | boolean;
177
- arrow?: _floating_ui_dom.ArrowOptions | false;
178
- size?: _floating_ui_dom.SizeOptions | boolean;
179
- autoPlacement?: _floating_ui_dom.AutoPlacementOptions | boolean;
180
- hide?: _floating_ui_dom.HideOptions | boolean;
181
- inline?: _floating_ui_core.InlineOptions | boolean;
182
- } | undefined;
183
168
  shouldShow: (props: {
184
169
  editor: _tiptap_core.Editor;
185
- view: prosemirror_view.EditorView;
186
- state: prosemirror_state.EditorState;
187
- oldState?: prosemirror_state.EditorState;
170
+ view: EditorView;
171
+ state: EditorState;
172
+ oldState?: EditorState;
188
173
  from: number;
189
174
  to: number;
190
175
  }) => boolean;
176
+ options: {
177
+ strategy?: "absolute" | "fixed";
178
+ placement?: "top" | "right" | "bottom" | "left" | "top-start" | "top-end" | "right-start" | "right-end" | "bottom-start" | "bottom-end" | "left-start" | "left-end";
179
+ offset?: Parameters<typeof _floating_ui_dom.offset>[0] | boolean;
180
+ flip?: Parameters<typeof _floating_ui_dom.flip>[0] | boolean;
181
+ shift?: Parameters<typeof _floating_ui_dom.shift>[0] | boolean;
182
+ arrow?: Parameters<typeof _floating_ui_dom.arrow>[0] | false;
183
+ size?: Parameters<typeof _floating_ui_dom.size>[0] | boolean;
184
+ autoPlacement?: Parameters<typeof _floating_ui_dom.autoPlacement>[0] | boolean;
185
+ hide?: Parameters<typeof _floating_ui_dom.hide>[0] | boolean;
186
+ inline?: Parameters<typeof _floating_ui_dom.inline>[0] | boolean;
187
+ } | undefined;
188
+ pluginKey: any;
191
189
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
192
190
 
193
191
  declare const NodeViewContent: vue.DefineComponent<vue.ExtractPropTypes<{
package/dist/index.js CHANGED
@@ -1,13 +1,6 @@
1
1
  // src/BubbleMenu.ts
2
2
  import { BubbleMenuPlugin } from "@tiptap/extension-bubble-menu";
3
- import {
4
- defineComponent,
5
- h,
6
- onBeforeUnmount,
7
- onMounted,
8
- ref,
9
- Teleport
10
- } from "vue";
3
+ import { defineComponent, h, onBeforeUnmount, onMounted, ref, Teleport } from "vue";
11
4
  var BubbleMenu = defineComponent({
12
5
  name: "BubbleMenu",
13
6
  props: {
@@ -39,29 +32,24 @@ var BubbleMenu = defineComponent({
39
32
  setup(props, { slots }) {
40
33
  const root = ref(null);
41
34
  onMounted(() => {
42
- const {
43
- editor,
44
- options,
45
- pluginKey,
46
- resizeDelay,
47
- shouldShow,
48
- updateDelay
49
- } = props;
35
+ const { editor, options, pluginKey, resizeDelay, shouldShow, updateDelay } = props;
50
36
  if (!root.value) {
51
37
  return;
52
38
  }
53
39
  root.value.style.visibility = "hidden";
54
40
  root.value.style.position = "absolute";
55
41
  root.value.remove();
56
- editor.registerPlugin(BubbleMenuPlugin({
57
- editor,
58
- element: root.value,
59
- options,
60
- pluginKey,
61
- resizeDelay,
62
- shouldShow,
63
- updateDelay
64
- }));
42
+ editor.registerPlugin(
43
+ BubbleMenuPlugin({
44
+ editor,
45
+ element: root.value,
46
+ options,
47
+ pluginKey,
48
+ resizeDelay,
49
+ shouldShow,
50
+ updateDelay
51
+ })
52
+ );
65
53
  });
66
54
  onBeforeUnmount(() => {
67
55
  const { pluginKey, editor } = props;
@@ -76,10 +64,7 @@ var BubbleMenu = defineComponent({
76
64
 
77
65
  // src/Editor.ts
78
66
  import { Editor as CoreEditor } from "@tiptap/core";
79
- import {
80
- customRef,
81
- markRaw
82
- } from "vue";
67
+ import { customRef, markRaw } from "vue";
83
68
  function useDebouncedRef(value) {
84
69
  return customRef((track, trigger) => {
85
70
  return {
@@ -198,27 +183,17 @@ var EditorContent = defineComponent2({
198
183
  return { rootEl };
199
184
  },
200
185
  render() {
201
- return h2(
202
- "div",
203
- {
204
- ref: (el) => {
205
- this.rootEl = el;
206
- }
186
+ return h2("div", {
187
+ ref: (el) => {
188
+ this.rootEl = el;
207
189
  }
208
- );
190
+ });
209
191
  }
210
192
  });
211
193
 
212
194
  // src/FloatingMenu.ts
213
195
  import { FloatingMenuPlugin } from "@tiptap/extension-floating-menu";
214
- import {
215
- defineComponent as defineComponent3,
216
- h as h3,
217
- onBeforeUnmount as onBeforeUnmount3,
218
- onMounted as onMounted2,
219
- ref as ref3,
220
- Teleport as Teleport2
221
- } from "vue";
196
+ import { defineComponent as defineComponent3, h as h3, onBeforeUnmount as onBeforeUnmount3, onMounted as onMounted2, ref as ref3, Teleport as Teleport2 } from "vue";
222
197
  var FloatingMenu = defineComponent3({
223
198
  name: "FloatingMenu",
224
199
  props: {
@@ -244,25 +219,22 @@ var FloatingMenu = defineComponent3({
244
219
  setup(props, { slots }) {
245
220
  const root = ref3(null);
246
221
  onMounted2(() => {
247
- const {
248
- pluginKey,
249
- editor,
250
- options,
251
- shouldShow
252
- } = props;
222
+ const { pluginKey, editor, options, shouldShow } = props;
253
223
  if (!root.value) {
254
224
  return;
255
225
  }
256
226
  root.value.style.visibility = "hidden";
257
227
  root.value.style.position = "absolute";
258
228
  root.value.remove();
259
- editor.registerPlugin(FloatingMenuPlugin({
260
- pluginKey,
261
- editor,
262
- element: root.value,
263
- options,
264
- shouldShow
265
- }));
229
+ editor.registerPlugin(
230
+ FloatingMenuPlugin({
231
+ pluginKey,
232
+ editor,
233
+ element: root.value,
234
+ options,
235
+ shouldShow
236
+ })
237
+ );
266
238
  });
267
239
  onBeforeUnmount3(() => {
268
240
  const { pluginKey, editor } = props;
@@ -343,22 +315,11 @@ var useEditor = (options = {}) => {
343
315
  };
344
316
 
345
317
  // src/VueNodeViewRenderer.ts
346
- import {
347
- NodeView
348
- } from "@tiptap/core";
349
- import {
350
- defineComponent as defineComponent6,
351
- provide,
352
- ref as ref4
353
- } from "vue";
318
+ import { NodeView } from "@tiptap/core";
319
+ import { defineComponent as defineComponent6, provide, ref as ref4 } from "vue";
354
320
 
355
321
  // src/VueRenderer.ts
356
- import {
357
- h as h6,
358
- markRaw as markRaw2,
359
- reactive,
360
- render
361
- } from "vue";
322
+ import { h as h6, markRaw as markRaw2, reactive, render } from "vue";
362
323
  var VueRenderer = class {
363
324
  constructor(component, { props = {}, editor }) {
364
325
  this.editor = editor;
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/BubbleMenu.ts","../src/Editor.ts","../src/EditorContent.ts","../src/FloatingMenu.ts","../src/NodeViewContent.ts","../src/NodeViewWrapper.ts","../src/useEditor.ts","../src/VueNodeViewRenderer.ts","../src/VueRenderer.ts","../src/index.ts"],"sourcesContent":["import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n PropType,\n ref,\n Teleport,\n} from 'vue'\n\nexport const BubbleMenu = defineComponent({\n name: 'BubbleMenu',\n\n props: {\n pluginKey: {\n type: [String, Object] as PropType<BubbleMenuPluginProps['pluginKey']>,\n default: 'bubbleMenu',\n },\n\n editor: {\n type: Object as PropType<BubbleMenuPluginProps['editor']>,\n required: true,\n },\n\n updateDelay: {\n type: Number as PropType<BubbleMenuPluginProps['updateDelay']>,\n default: undefined,\n },\n\n resizeDelay: {\n type: Number as PropType<BubbleMenuPluginProps['resizeDelay']>,\n default: undefined,\n },\n\n options: {\n type: Object as PropType<BubbleMenuPluginProps['options']>,\n default: () => ({}),\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<BubbleMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n },\n\n setup(props, { slots }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const {\n editor,\n options,\n pluginKey,\n resizeDelay,\n shouldShow,\n updateDelay,\n } = props\n\n if (!root.value) {\n return\n }\n\n root.value.style.visibility = 'hidden'\n root.value.style.position = 'absolute'\n\n // remove the element from the DOM\n root.value.remove()\n\n editor.registerPlugin(BubbleMenuPlugin({\n editor,\n element: root.value as HTMLElement,\n options,\n pluginKey,\n resizeDelay,\n shouldShow,\n updateDelay,\n }))\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n return () => h(Teleport, { to: 'body' }, h('div', { ref: root }, slots.default?.()))\n },\n})\n","/* eslint-disable react-hooks/rules-of-hooks */\nimport { Editor as CoreEditor, EditorOptions } from '@tiptap/core'\nimport { EditorState, Plugin, PluginKey } from '@tiptap/pm/state'\nimport {\n AppContext,\n ComponentInternalInstance,\n ComponentPublicInstance,\n customRef,\n markRaw,\n Ref,\n} from 'vue'\n\nfunction useDebouncedRef<T>(value: T) {\n return customRef<T>((track, trigger) => {\n return {\n get() {\n track()\n return value\n },\n set(newValue) {\n // update state\n value = newValue\n\n // update view as soon as possible\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n trigger()\n })\n })\n },\n }\n })\n}\n\nexport type ContentComponent = ComponentInternalInstance & {\n ctx: ComponentPublicInstance\n}\n\nexport class Editor extends CoreEditor {\n private reactiveState: Ref<EditorState>\n\n private reactiveExtensionStorage: Ref<Record<string, any>>\n\n public contentComponent: ContentComponent | null = null\n\n public appContext: AppContext | null = null\n\n constructor(options: Partial<EditorOptions> = {}) {\n super(options)\n\n this.reactiveState = useDebouncedRef(this.view.state)\n this.reactiveExtensionStorage = useDebouncedRef(this.extensionStorage)\n\n this.on('beforeTransaction', ({ nextState }) => {\n this.reactiveState.value = nextState\n this.reactiveExtensionStorage.value = this.extensionStorage\n })\n\n return markRaw(this) // eslint-disable-line\n }\n\n get state() {\n return this.reactiveState ? this.reactiveState.value : this.view.state\n }\n\n get storage() {\n return this.reactiveExtensionStorage ? this.reactiveExtensionStorage.value : super.storage\n }\n\n /**\n * Register a ProseMirror plugin.\n */\n public registerPlugin(\n plugin: Plugin,\n handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[],\n ): EditorState {\n const nextState = super.registerPlugin(plugin, handlePlugins)\n\n if (this.reactiveState) {\n this.reactiveState.value = nextState\n }\n\n return nextState\n }\n\n /**\n * Unregister a ProseMirror plugin.\n */\n public unregisterPlugin(nameOrPluginKey: string | PluginKey): EditorState | undefined {\n const nextState = super.unregisterPlugin(nameOrPluginKey)\n\n if (this.reactiveState && nextState) {\n this.reactiveState.value = nextState\n }\n\n return nextState\n }\n}\n","import {\n defineComponent,\n getCurrentInstance,\n h,\n nextTick,\n onBeforeUnmount,\n PropType,\n Ref,\n ref,\n unref,\n watchEffect,\n} from 'vue'\n\nimport { Editor } from './Editor.js'\n\nexport const EditorContent = defineComponent({\n name: 'EditorContent',\n\n props: {\n editor: {\n default: null,\n type: Object as PropType<Editor>,\n },\n },\n\n setup(props) {\n const rootEl: Ref<Element | undefined> = ref()\n const instance = getCurrentInstance()\n\n watchEffect(() => {\n const editor = props.editor\n\n if (editor && editor.options.element && rootEl.value) {\n nextTick(() => {\n if (!rootEl.value || !editor.options.element.firstChild) {\n return\n }\n\n const element = unref(rootEl.value)\n\n rootEl.value.append(...editor.options.element.childNodes)\n\n // @ts-ignore\n editor.contentComponent = instance.ctx._\n\n if (instance) {\n editor.appContext = {\n ...instance.appContext,\n // Vue internally uses prototype chain to forward/shadow injects across the entire component chain\n // so don't use object spread operator or 'Object.assign' and just set `provides` as is on editor's appContext\n // @ts-expect-error forward instance's 'provides' into appContext\n provides: instance.provides,\n }\n }\n\n editor.setOptions({\n element,\n })\n\n editor.createNodeViews()\n })\n }\n })\n\n onBeforeUnmount(() => {\n const editor = props.editor\n\n if (!editor) {\n return\n }\n\n editor.contentComponent = null\n editor.appContext = null\n })\n\n return { rootEl }\n },\n\n render() {\n return h(\n 'div',\n {\n ref: (el: any) => { this.rootEl = el },\n },\n )\n },\n})\n","import type { BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\nimport { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\nimport {\n defineComponent,\n h,\n onBeforeUnmount,\n onMounted,\n PropType,\n ref,\n Teleport,\n} from 'vue'\n\nexport const FloatingMenu = defineComponent({\n name: 'FloatingMenu',\n\n props: {\n pluginKey: {\n // TODO: TypeScript breaks :(\n // type: [String, Object as PropType<Exclude<FloatingMenuPluginProps['pluginKey'], string>>],\n type: null,\n default: 'floatingMenu',\n },\n\n editor: {\n type: Object as PropType<FloatingMenuPluginProps['editor']>,\n required: true,\n },\n\n options: {\n type: Object as PropType<BubbleMenuPluginProps['options']>,\n default: () => ({}),\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<FloatingMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n },\n\n setup(props, { slots }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const {\n pluginKey,\n editor,\n options,\n shouldShow,\n } = props\n\n if (!root.value) {\n return\n }\n\n root.value.style.visibility = 'hidden'\n root.value.style.position = 'absolute'\n\n // remove the element from the DOM\n root.value.remove()\n\n editor.registerPlugin(FloatingMenuPlugin({\n pluginKey,\n editor,\n element: root.value as HTMLElement,\n options,\n shouldShow,\n }))\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n return () => h(Teleport, { to: 'body' }, h('div', { ref: root }, slots.default?.()))\n },\n})\n","import { defineComponent, h } from 'vue'\n\nexport const NodeViewContent = defineComponent({\n name: 'NodeViewContent',\n\n props: {\n as: {\n type: String,\n default: 'div',\n },\n },\n\n render() {\n return h(this.as, {\n style: {\n whiteSpace: 'pre-wrap',\n },\n 'data-node-view-content': '',\n })\n },\n})\n","import { defineComponent, h } from 'vue'\n\nexport const NodeViewWrapper = defineComponent({\n name: 'NodeViewWrapper',\n\n props: {\n as: {\n type: String,\n default: 'div',\n },\n },\n\n inject: ['onDragStart', 'decorationClasses'],\n\n render() {\n return h(\n this.as,\n {\n // @ts-ignore\n class: this.decorationClasses,\n style: {\n whiteSpace: 'normal',\n },\n 'data-node-view-wrapper': '',\n // @ts-ignore (https://github.com/vuejs/vue-next/issues/3031)\n onDragstart: this.onDragStart,\n },\n this.$slots.default?.(),\n )\n },\n})\n","import { EditorOptions } from '@tiptap/core'\nimport { onBeforeUnmount, onMounted, shallowRef } from 'vue'\n\nimport { Editor } from './Editor.js'\n\nexport const useEditor = (options: Partial<EditorOptions> = {}) => {\n const editor = shallowRef<Editor>()\n\n onMounted(() => {\n editor.value = new Editor(options)\n })\n\n onBeforeUnmount(() => {\n // Cloning root node (and its children) to avoid content being lost by destroy\n const nodes = editor.value?.options.element\n const newEl = nodes?.cloneNode(true) as HTMLElement\n\n nodes?.parentNode?.replaceChild(newEl, nodes)\n\n editor.value?.destroy()\n })\n\n return editor\n}\n","/* eslint-disable no-underscore-dangle */\nimport {\n DecorationWithType,\n NodeView,\n NodeViewProps,\n NodeViewRenderer,\n NodeViewRendererOptions,\n} from '@tiptap/core'\nimport { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { Decoration, DecorationSource, NodeView as ProseMirrorNodeView } from '@tiptap/pm/view'\nimport {\n Component, defineComponent, PropType, provide, Ref, ref,\n} from 'vue'\n\nimport { Editor } from './Editor.js'\nimport { VueRenderer } from './VueRenderer.js'\n\nexport const nodeViewProps = {\n editor: {\n type: Object as PropType<NodeViewProps['editor']>,\n required: true as const,\n },\n node: {\n type: Object as PropType<NodeViewProps['node']>,\n required: true as const,\n },\n decorations: {\n type: Object as PropType<NodeViewProps['decorations']>,\n required: true as const,\n },\n selected: {\n type: Boolean as PropType<NodeViewProps['selected']>,\n required: true as const,\n },\n extension: {\n type: Object as PropType<NodeViewProps['extension']>,\n required: true as const,\n },\n getPos: {\n type: Function as PropType<NodeViewProps['getPos']>,\n required: true as const,\n },\n updateAttributes: {\n type: Function as PropType<NodeViewProps['updateAttributes']>,\n required: true as const,\n },\n deleteNode: {\n type: Function as PropType<NodeViewProps['deleteNode']>,\n required: true as const,\n },\n}\n\nexport interface VueNodeViewRendererOptions extends NodeViewRendererOptions {\n update:\n | ((props: {\n oldNode: ProseMirrorNode;\n oldDecorations: readonly Decoration[];\n oldInnerDecorations: DecorationSource;\n newNode: ProseMirrorNode;\n newDecorations: readonly Decoration[];\n innerDecorations: DecorationSource;\n updateProps: () => void;\n }) => boolean)\n | null;\n}\n\nclass VueNodeView extends NodeView<Component, Editor, VueNodeViewRendererOptions> {\n renderer!: VueRenderer\n\n decorationClasses!: Ref<string>\n\n mount() {\n const props = {\n editor: this.editor,\n node: this.node,\n decorations: this.decorations as DecorationWithType[],\n innerDecorations: this.innerDecorations,\n view: this.view,\n selected: false,\n extension: this.extension,\n HTMLAttributes: this.HTMLAttributes,\n getPos: () => this.getPos(),\n updateAttributes: (attributes = {}) => this.updateAttributes(attributes),\n deleteNode: () => this.deleteNode(),\n } satisfies NodeViewProps\n\n const onDragStart = this.onDragStart.bind(this)\n\n this.decorationClasses = ref(this.getDecorationClasses())\n\n const extendedComponent = defineComponent({\n extends: { ...this.component },\n props: Object.keys(props),\n template: (this.component as any).template,\n setup: reactiveProps => {\n provide('onDragStart', onDragStart)\n provide('decorationClasses', this.decorationClasses)\n\n return (this.component as any).setup?.(reactiveProps, {\n expose: () => undefined,\n })\n },\n // add support for scoped styles\n // @ts-ignore\n // eslint-disable-next-line\n __scopeId: this.component.__scopeId,\n // add support for CSS Modules\n // @ts-ignore\n // eslint-disable-next-line\n __cssModules: this.component.__cssModules,\n // add support for vue devtools\n // @ts-ignore\n // eslint-disable-next-line\n __name: this.component.__name,\n // @ts-ignore\n // eslint-disable-next-line\n __file: this.component.__file,\n })\n\n this.handleSelectionUpdate = this.handleSelectionUpdate.bind(this)\n this.editor.on('selectionUpdate', this.handleSelectionUpdate)\n\n this.renderer = new VueRenderer(extendedComponent, {\n editor: this.editor,\n props,\n })\n }\n\n /**\n * Return the DOM element.\n * This is the element that will be used to display the node view.\n */\n get dom() {\n if (!this.renderer.element || !this.renderer.element.hasAttribute('data-node-view-wrapper')) {\n throw Error('Please use the NodeViewWrapper component for your node view.')\n }\n\n return this.renderer.element as HTMLElement\n }\n\n /**\n * Return the content DOM element.\n * This is the element that will be used to display the rich-text content of the node.\n */\n get contentDOM() {\n if (this.node.isLeaf) {\n return null\n }\n\n return this.dom.querySelector('[data-node-view-content]') as HTMLElement | null\n }\n\n /**\n * On editor selection update, check if the node is selected.\n * If it is, call `selectNode`, otherwise call `deselectNode`.\n */\n handleSelectionUpdate() {\n const { from, to } = this.editor.state.selection\n const pos = this.getPos()\n\n if (typeof pos !== 'number') {\n return\n }\n\n if (from <= pos && to >= pos + this.node.nodeSize) {\n if (this.renderer.props.selected) {\n return\n }\n\n this.selectNode()\n } else {\n if (!this.renderer.props.selected) {\n return\n }\n\n this.deselectNode()\n }\n }\n\n /**\n * On update, update the React component.\n * To prevent unnecessary updates, the `update` option can be used.\n */\n update(\n node: ProseMirrorNode,\n decorations: readonly Decoration[],\n innerDecorations: DecorationSource,\n ): boolean {\n const rerenderComponent = (props?: Record<string, any>) => {\n this.decorationClasses.value = this.getDecorationClasses()\n this.renderer.updateProps(props)\n }\n\n if (typeof this.options.update === 'function') {\n const oldNode = this.node\n const oldDecorations = this.decorations\n const oldInnerDecorations = this.innerDecorations\n\n this.node = node\n this.decorations = decorations\n this.innerDecorations = innerDecorations\n\n return this.options.update({\n oldNode,\n oldDecorations,\n newNode: node,\n newDecorations: decorations,\n oldInnerDecorations,\n innerDecorations,\n updateProps: () => rerenderComponent({ node, decorations, innerDecorations }),\n })\n }\n\n if (node.type !== this.node.type) {\n return false\n }\n\n if (node === this.node && this.decorations === decorations && this.innerDecorations === innerDecorations) {\n return true\n }\n\n this.node = node\n this.decorations = decorations\n this.innerDecorations = innerDecorations\n\n rerenderComponent({ node, decorations, innerDecorations })\n\n return true\n }\n\n /**\n * Select the node.\n * Add the `selected` prop and the `ProseMirror-selectednode` class.\n */\n selectNode() {\n this.renderer.updateProps({\n selected: true,\n })\n if (this.renderer.element) {\n this.renderer.element.classList.add('ProseMirror-selectednode')\n }\n }\n\n /**\n * Deselect the node.\n * Remove the `selected` prop and the `ProseMirror-selectednode` class.\n */\n deselectNode() {\n this.renderer.updateProps({\n selected: false,\n })\n if (this.renderer.element) {\n this.renderer.element.classList.remove('ProseMirror-selectednode')\n }\n }\n\n getDecorationClasses() {\n return (\n this.decorations\n // @ts-ignore\n .map(item => item.type.attrs.class)\n .flat()\n .join(' ')\n )\n }\n\n destroy() {\n this.renderer.destroy()\n this.editor.off('selectionUpdate', this.handleSelectionUpdate)\n }\n}\n\nexport function VueNodeViewRenderer(\n component: Component<NodeViewProps>,\n options?: Partial<VueNodeViewRendererOptions>,\n): NodeViewRenderer {\n return props => {\n // try to get the parent component\n // this is important for vue devtools to show the component hierarchy correctly\n // maybe it’s `undefined` because <editor-content> isn’t rendered yet\n if (!(props.editor as Editor).contentComponent) {\n return {} as unknown as ProseMirrorNodeView\n }\n // check for class-component and normalize if neccessary\n const normalizedComponent = typeof component === 'function' && '__vccOpts' in component\n ? (component.__vccOpts as Component)\n : component\n\n return new VueNodeView(normalizedComponent, props, options)\n }\n}\n","import { Editor } from '@tiptap/core'\nimport {\n Component, DefineComponent, h, markRaw, reactive, render,\n} from 'vue'\n\nimport { Editor as ExtendedEditor } from './Editor.js'\n\nexport interface VueRendererOptions {\n editor: Editor;\n props?: Record<string, any>;\n}\n\ntype ExtendedVNode = ReturnType<typeof h> | null;\n\ninterface RenderedComponent {\n vNode: ExtendedVNode;\n destroy: () => void;\n el: Element | null;\n}\n\n/**\n * This class is used to render Vue components inside the editor.\n */\nexport class VueRenderer {\n renderedComponent!: RenderedComponent\n\n editor: ExtendedEditor\n\n component: Component\n\n el: Element | null\n\n props: Record<string, any>\n\n constructor(component: Component, { props = {}, editor }: VueRendererOptions) {\n this.editor = editor as ExtendedEditor\n this.component = markRaw(component)\n this.el = document.createElement('div')\n this.props = reactive(props)\n this.renderedComponent = this.renderComponent()\n }\n\n get element(): Element | null {\n return this.renderedComponent.el\n }\n\n get ref(): any {\n // Composition API\n if (this.renderedComponent.vNode?.component?.exposed) {\n return this.renderedComponent.vNode.component.exposed\n }\n // Option API\n return this.renderedComponent.vNode?.component?.proxy\n }\n\n renderComponent() {\n let vNode: ExtendedVNode = h(this.component as DefineComponent, this.props)\n\n if (this.editor.appContext) {\n vNode.appContext = this.editor.appContext\n }\n if (typeof document !== 'undefined' && this.el) {\n render(vNode, this.el)\n }\n\n const destroy = () => {\n if (this.el) {\n render(null, this.el)\n }\n this.el = null\n vNode = null\n }\n\n return { vNode, destroy, el: this.el ? this.el.firstElementChild : null }\n }\n\n updateProps(props: Record<string, any> = {}): void {\n Object.entries(props).forEach(([key, value]) => {\n this.props[key] = value\n })\n this.renderComponent()\n }\n\n destroy(): void {\n this.renderedComponent.destroy()\n }\n}\n","export * from './BubbleMenu.js'\nexport { Editor } from './Editor.js'\nexport * from './EditorContent.js'\nexport * from './FloatingMenu.js'\nexport * from './NodeViewContent.js'\nexport * from './NodeViewWrapper.js'\nexport * from './useEditor.js'\nexport * from './VueNodeViewRenderer.js'\nexport * from './VueRenderer.js'\nexport * from '@tiptap/core'\n"],"mappings":";AAAA,SAAS,wBAA+C;AACxD;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EAEA;AAAA,EACA;AAAA,OACK;AAEA,IAAM,aAAa,gBAAgB;AAAA,EACxC,MAAM;AAAA,EAEN,OAAO;AAAA,IACL,WAAW;AAAA,MACT,MAAM,CAAC,QAAQ,MAAM;AAAA,MACrB,SAAS;AAAA,IACX;AAAA,IAEA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IAEA,aAAa;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IAEA,aAAa;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IAEA,SAAS;AAAA,MACP,MAAM;AAAA,MACN,SAAS,OAAO,CAAC;AAAA,IACnB;A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AA,EACF;AAAA,EAEA,uBAAuB;AACrB,WACE,KAAK,YAEF,IAAI,UAAQ,KAAK,KAAK,MAAM,KAAK,EACjC,KAAK,EACL,KAAK,GAAG;AAAA,EAEf;AAAA,EAEA,UAAU;AACR,SAAK,SAAS,QAAQ;AACtB,SAAK,OAAO,IAAI,mBAAmB,KAAK,qBAAqB;AAAA,EAC/D;AACF;AAEO,SAAS,oBACd,WACA,SACkB;AAClB,SAAO,WAAS;AAId,QAAI,CAAE,MAAM,OAAkB,kBAAkB;AAC9C,aAAO,CAAC;AAAA,IACV;AAEA,UAAM,sBAAsB,OAAO,cAAc,cAAc,eAAe,YACzE,UAAU,YACX;AAEJ,WAAO,IAAI,YAAY,qBAAqB,OAAO,OAAO;AAAA,EAC5D;AACF;;;AEzRA,cAAc;","names":["defineComponent","h","onBeforeUnmount","ref","defineComponent","h","onBeforeUnmount","onMounted","ref","Teleport","defineComponent","h","defineComponent","h","onBeforeUnmount","onMounted","onMounted","onBeforeUnmount","defineComponent","ref","h","markRaw","ref","defineComponent"]}
1
+ {"version":3,"sources":["../src/BubbleMenu.ts","../src/Editor.ts","../src/EditorContent.ts","../src/FloatingMenu.ts","../src/NodeViewContent.ts","../src/NodeViewWrapper.ts","../src/useEditor.ts","../src/VueNodeViewRenderer.ts","../src/VueRenderer.ts","../src/index.ts"],"sourcesContent":["import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'\nimport { defineComponent, h, onBeforeUnmount, onMounted, PropType, ref, Teleport } from 'vue'\n\nexport const BubbleMenu = defineComponent({\n name: 'BubbleMenu',\n\n props: {\n pluginKey: {\n type: [String, Object] as PropType<BubbleMenuPluginProps['pluginKey']>,\n default: 'bubbleMenu',\n },\n\n editor: {\n type: Object as PropType<BubbleMenuPluginProps['editor']>,\n required: true,\n },\n\n updateDelay: {\n type: Number as PropType<BubbleMenuPluginProps['updateDelay']>,\n default: undefined,\n },\n\n resizeDelay: {\n type: Number as PropType<BubbleMenuPluginProps['resizeDelay']>,\n default: undefined,\n },\n\n options: {\n type: Object as PropType<BubbleMenuPluginProps['options']>,\n default: () => ({}),\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<BubbleMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n },\n\n setup(props, { slots }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const { editor, options, pluginKey, resizeDelay, shouldShow, updateDelay } = props\n\n if (!root.value) {\n return\n }\n\n root.value.style.visibility = 'hidden'\n root.value.style.position = 'absolute'\n\n // remove the element from the DOM\n root.value.remove()\n\n editor.registerPlugin(\n BubbleMenuPlugin({\n editor,\n element: root.value as HTMLElement,\n options,\n pluginKey,\n resizeDelay,\n shouldShow,\n updateDelay,\n }),\n )\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n return () => h(Teleport, { to: 'body' }, h('div', { ref: root }, slots.default?.()))\n },\n})\n","/* eslint-disable react-hooks/rules-of-hooks */\nimport { Editor as CoreEditor, EditorOptions } from '@tiptap/core'\nimport { EditorState, Plugin, PluginKey } from '@tiptap/pm/state'\nimport { AppContext, ComponentInternalInstance, ComponentPublicInstance, customRef, markRaw, Ref } from 'vue'\n\nfunction useDebouncedRef<T>(value: T) {\n return customRef<T>((track, trigger) => {\n return {\n get() {\n track()\n return value\n },\n set(newValue) {\n // update state\n value = newValue\n\n // update view as soon as possible\n requestAnimationFrame(() => {\n requestAnimationFrame(() => {\n trigger()\n })\n })\n },\n }\n })\n}\n\nexport type ContentComponent = ComponentInternalInstance & {\n ctx: ComponentPublicInstance\n}\n\nexport class Editor extends CoreEditor {\n private reactiveState: Ref<EditorState>\n\n private reactiveExtensionStorage: Ref<Record<string, any>>\n\n public contentComponent: ContentComponent | null = null\n\n public appContext: AppContext | null = null\n\n constructor(options: Partial<EditorOptions> = {}) {\n super(options)\n\n this.reactiveState = useDebouncedRef(this.view.state)\n this.reactiveExtensionStorage = useDebouncedRef(this.extensionStorage)\n\n this.on('beforeTransaction', ({ nextState }) => {\n this.reactiveState.value = nextState\n this.reactiveExtensionStorage.value = this.extensionStorage\n })\n\n return markRaw(this) // eslint-disable-line\n }\n\n get state() {\n return this.reactiveState ? this.reactiveState.value : this.view.state\n }\n\n get storage() {\n return this.reactiveExtensionStorage ? this.reactiveExtensionStorage.value : super.storage\n }\n\n /**\n * Register a ProseMirror plugin.\n */\n public registerPlugin(\n plugin: Plugin,\n handlePlugins?: (newPlugin: Plugin, plugins: Plugin[]) => Plugin[],\n ): EditorState {\n const nextState = super.registerPlugin(plugin, handlePlugins)\n\n if (this.reactiveState) {\n this.reactiveState.value = nextState\n }\n\n return nextState\n }\n\n /**\n * Unregister a ProseMirror plugin.\n */\n public unregisterPlugin(nameOrPluginKey: string | PluginKey): EditorState | undefined {\n const nextState = super.unregisterPlugin(nameOrPluginKey)\n\n if (this.reactiveState && nextState) {\n this.reactiveState.value = nextState\n }\n\n return nextState\n }\n}\n","import {\n defineComponent,\n getCurrentInstance,\n h,\n nextTick,\n onBeforeUnmount,\n PropType,\n Ref,\n ref,\n unref,\n watchEffect,\n} from 'vue'\n\nimport { Editor } from './Editor.js'\n\nexport const EditorContent = defineComponent({\n name: 'EditorContent',\n\n props: {\n editor: {\n default: null,\n type: Object as PropType<Editor>,\n },\n },\n\n setup(props) {\n const rootEl: Ref<Element | undefined> = ref()\n const instance = getCurrentInstance()\n\n watchEffect(() => {\n const editor = props.editor\n\n if (editor && editor.options.element && rootEl.value) {\n nextTick(() => {\n if (!rootEl.value || !editor.options.element.firstChild) {\n return\n }\n\n const element = unref(rootEl.value)\n\n rootEl.value.append(...editor.options.element.childNodes)\n\n // @ts-ignore\n editor.contentComponent = instance.ctx._\n\n if (instance) {\n editor.appContext = {\n ...instance.appContext,\n // Vue internally uses prototype chain to forward/shadow injects across the entire component chain\n // so don't use object spread operator or 'Object.assign' and just set `provides` as is on editor's appContext\n // @ts-expect-error forward instance's 'provides' into appContext\n provides: instance.provides,\n }\n }\n\n editor.setOptions({\n element,\n })\n\n editor.createNodeViews()\n })\n }\n })\n\n onBeforeUnmount(() => {\n const editor = props.editor\n\n if (!editor) {\n return\n }\n\n editor.contentComponent = null\n editor.appContext = null\n })\n\n return { rootEl }\n },\n\n render() {\n return h('div', {\n ref: (el: any) => {\n this.rootEl = el\n },\n })\n },\n})\n","import { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'\nimport { defineComponent, h, onBeforeUnmount, onMounted, PropType, ref, Teleport } from 'vue'\n\nexport const FloatingMenu = defineComponent({\n name: 'FloatingMenu',\n\n props: {\n pluginKey: {\n // TODO: TypeScript breaks :(\n // type: [String, Object as PropType<Exclude<FloatingMenuPluginProps['pluginKey'], string>>],\n type: null,\n default: 'floatingMenu',\n },\n\n editor: {\n type: Object as PropType<FloatingMenuPluginProps['editor']>,\n required: true,\n },\n\n options: {\n type: Object as PropType<FloatingMenuPluginProps['options']>,\n default: () => ({}),\n },\n\n shouldShow: {\n type: Function as PropType<Exclude<Required<FloatingMenuPluginProps>['shouldShow'], null>>,\n default: null,\n },\n },\n\n setup(props, { slots }) {\n const root = ref<HTMLElement | null>(null)\n\n onMounted(() => {\n const { pluginKey, editor, options, shouldShow } = props\n\n if (!root.value) {\n return\n }\n\n root.value.style.visibility = 'hidden'\n root.value.style.position = 'absolute'\n\n // remove the element from the DOM\n root.value.remove()\n\n editor.registerPlugin(\n FloatingMenuPlugin({\n pluginKey,\n editor,\n element: root.value as HTMLElement,\n options,\n shouldShow,\n }),\n )\n })\n\n onBeforeUnmount(() => {\n const { pluginKey, editor } = props\n\n editor.unregisterPlugin(pluginKey)\n })\n\n return () => h(Teleport, { to: 'body' }, h('div', { ref: root }, slots.default?.()))\n },\n})\n","import { defineComponent, h } from 'vue'\n\nexport const NodeViewContent = defineComponent({\n name: 'NodeViewContent',\n\n props: {\n as: {\n type: String,\n default: 'div',\n },\n },\n\n render() {\n return h(this.as, {\n style: {\n whiteSpace: 'pre-wrap',\n },\n 'data-node-view-content': '',\n })\n },\n})\n","import { defineComponent, h } from 'vue'\n\nexport const NodeViewWrapper = defineComponent({\n name: 'NodeViewWrapper',\n\n props: {\n as: {\n type: String,\n default: 'div',\n },\n },\n\n inject: ['onDragStart', 'decorationClasses'],\n\n render() {\n return h(\n this.as,\n {\n // @ts-ignore\n class: this.decorationClasses,\n style: {\n whiteSpace: 'normal',\n },\n 'data-node-view-wrapper': '',\n // @ts-ignore (https://github.com/vuejs/vue-next/issues/3031)\n onDragstart: this.onDragStart,\n },\n this.$slots.default?.(),\n )\n },\n})\n","import { EditorOptions } from '@tiptap/core'\nimport { onBeforeUnmount, onMounted, shallowRef } from 'vue'\n\nimport { Editor } from './Editor.js'\n\nexport const useEditor = (options: Partial<EditorOptions> = {}) => {\n const editor = shallowRef<Editor>()\n\n onMounted(() => {\n editor.value = new Editor(options)\n })\n\n onBeforeUnmount(() => {\n // Cloning root node (and its children) to avoid content being lost by destroy\n const nodes = editor.value?.options.element\n const newEl = nodes?.cloneNode(true) as HTMLElement\n\n nodes?.parentNode?.replaceChild(newEl, nodes)\n\n editor.value?.destroy()\n })\n\n return editor\n}\n","/* eslint-disable no-underscore-dangle */\nimport { DecorationWithType, NodeView, NodeViewProps, NodeViewRenderer, NodeViewRendererOptions } from '@tiptap/core'\nimport { Node as ProseMirrorNode } from '@tiptap/pm/model'\nimport { Decoration, DecorationSource, NodeView as ProseMirrorNodeView } from '@tiptap/pm/view'\nimport { Component, defineComponent, PropType, provide, Ref, ref } from 'vue'\n\nimport { Editor } from './Editor.js'\nimport { VueRenderer } from './VueRenderer.js'\n\nexport const nodeViewProps = {\n editor: {\n type: Object as PropType<NodeViewProps['editor']>,\n required: true as const,\n },\n node: {\n type: Object as PropType<NodeViewProps['node']>,\n required: true as const,\n },\n decorations: {\n type: Object as PropType<NodeViewProps['decorations']>,\n required: true as const,\n },\n selected: {\n type: Boolean as PropType<NodeViewProps['selected']>,\n required: true as const,\n },\n extension: {\n type: Object as PropType<NodeViewProps['extension']>,\n required: true as const,\n },\n getPos: {\n type: Function as PropType<NodeViewProps['getPos']>,\n required: true as const,\n },\n updateAttributes: {\n type: Function as PropType<NodeViewProps['updateAttributes']>,\n required: true as const,\n },\n deleteNode: {\n type: Function as PropType<NodeViewProps['deleteNode']>,\n required: true as const,\n },\n}\n\nexport interface VueNodeViewRendererOptions extends NodeViewRendererOptions {\n update:\n | ((props: {\n oldNode: ProseMirrorNode\n oldDecorations: readonly Decoration[]\n oldInnerDecorations: DecorationSource\n newNode: ProseMirrorNode\n newDecorations: readonly Decoration[]\n innerDecorations: DecorationSource\n updateProps: () => void\n }) => boolean)\n | null\n}\n\nclass VueNodeView extends NodeView<Component, Editor, VueNodeViewRendererOptions> {\n renderer!: VueRenderer\n\n decorationClasses!: Ref<string>\n\n mount() {\n const props = {\n editor: this.editor,\n node: this.node,\n decorations: this.decorations as DecorationWithType[],\n innerDecorations: this.innerDecorations,\n view: this.view,\n selected: false,\n extension: this.extension,\n HTMLAttributes: this.HTMLAttributes,\n getPos: () => this.getPos(),\n updateAttributes: (attributes = {}) => this.updateAttributes(attributes),\n deleteNode: () => this.deleteNode(),\n } satisfies NodeViewProps\n\n const onDragStart = this.onDragStart.bind(this)\n\n this.decorationClasses = ref(this.getDecorationClasses())\n\n const extendedComponent = defineComponent({\n extends: { ...this.component },\n props: Object.keys(props),\n template: (this.component as any).template,\n setup: reactiveProps => {\n provide('onDragStart', onDragStart)\n provide('decorationClasses', this.decorationClasses)\n\n return (this.component as any).setup?.(reactiveProps, {\n expose: () => undefined,\n })\n },\n // add support for scoped styles\n // @ts-ignore\n // eslint-disable-next-line\n __scopeId: this.component.__scopeId,\n // add support for CSS Modules\n // @ts-ignore\n // eslint-disable-next-line\n __cssModules: this.component.__cssModules,\n // add support for vue devtools\n // @ts-ignore\n // eslint-disable-next-line\n __name: this.component.__name,\n // @ts-ignore\n // eslint-disable-next-line\n __file: this.component.__file,\n })\n\n this.handleSelectionUpdate = this.handleSelectionUpdate.bind(this)\n this.editor.on('selectionUpdate', this.handleSelectionUpdate)\n\n this.renderer = new VueRenderer(extendedComponent, {\n editor: this.editor,\n props,\n })\n }\n\n /**\n * Return the DOM element.\n * This is the element that will be used to display the node view.\n */\n get dom() {\n if (!this.renderer.element || !this.renderer.element.hasAttribute('data-node-view-wrapper')) {\n throw Error('Please use the NodeViewWrapper component for your node view.')\n }\n\n return this.renderer.element as HTMLElement\n }\n\n /**\n * Return the content DOM element.\n * This is the element that will be used to display the rich-text content of the node.\n */\n get contentDOM() {\n if (this.node.isLeaf) {\n return null\n }\n\n return this.dom.querySelector('[data-node-view-content]') as HTMLElement | null\n }\n\n /**\n * On editor selection update, check if the node is selected.\n * If it is, call `selectNode`, otherwise call `deselectNode`.\n */\n handleSelectionUpdate() {\n const { from, to } = this.editor.state.selection\n const pos = this.getPos()\n\n if (typeof pos !== 'number') {\n return\n }\n\n if (from <= pos && to >= pos + this.node.nodeSize) {\n if (this.renderer.props.selected) {\n return\n }\n\n this.selectNode()\n } else {\n if (!this.renderer.props.selected) {\n return\n }\n\n this.deselectNode()\n }\n }\n\n /**\n * On update, update the React component.\n * To prevent unnecessary updates, the `update` option can be used.\n */\n update(node: ProseMirrorNode, decorations: readonly Decoration[], innerDecorations: DecorationSource): boolean {\n const rerenderComponent = (props?: Record<string, any>) => {\n this.decorationClasses.value = this.getDecorationClasses()\n this.renderer.updateProps(props)\n }\n\n if (typeof this.options.update === 'function') {\n const oldNode = this.node\n const oldDecorations = this.decorations\n const oldInnerDecorations = this.innerDecorations\n\n this.node = node\n this.decorations = decorations\n this.innerDecorations = innerDecorations\n\n return this.options.update({\n oldNode,\n oldDecorations,\n newNode: node,\n newDecorations: decorations,\n oldInnerDecorations,\n innerDecorations,\n updateProps: () => rerenderComponent({ node, decorations, innerDecorations }),\n })\n }\n\n if (node.type !== this.node.type) {\n return false\n }\n\n if (node === this.node && this.decorations === decorations && this.innerDecorations === innerDecorations) {\n return true\n }\n\n this.node = node\n this.decorations = decorations\n this.innerDecorations = innerDecorations\n\n rerenderComponent({ node, decorations, innerDecorations })\n\n return true\n }\n\n /**\n * Select the node.\n * Add the `selected` prop and the `ProseMirror-selectednode` class.\n */\n selectNode() {\n this.renderer.updateProps({\n selected: true,\n })\n if (this.renderer.element) {\n this.renderer.element.classList.add('ProseMirror-selectednode')\n }\n }\n\n /**\n * Deselect the node.\n * Remove the `selected` prop and the `ProseMirror-selectednode` class.\n */\n deselectNode() {\n this.renderer.updateProps({\n selected: false,\n })\n if (this.renderer.element) {\n this.renderer.element.classList.remove('ProseMirror-selectednode')\n }\n }\n\n getDecorationClasses() {\n return (\n this.decorations\n // @ts-ignore\n .map(item => item.type.attrs.class)\n .flat()\n .join(' ')\n )\n }\n\n destroy() {\n this.renderer.destroy()\n this.editor.off('selectionUpdate', this.handleSelectionUpdate)\n }\n}\n\nexport function VueNodeViewRenderer(\n component: Component<NodeViewProps>,\n options?: Partial<VueNodeViewRendererOptions>,\n): NodeViewRenderer {\n return props => {\n // try to get the parent component\n // this is important for vue devtools to show the component hierarchy correctly\n // maybe it’s `undefined` because <editor-content> isn’t rendered yet\n if (!(props.editor as Editor).contentComponent) {\n return {} as unknown as ProseMirrorNodeView\n }\n // check for class-component and normalize if neccessary\n const normalizedComponent =\n typeof component === 'function' && '__vccOpts' in component ? (component.__vccOpts as Component) : component\n\n return new VueNodeView(normalizedComponent, props, options)\n }\n}\n","import { Editor } from '@tiptap/core'\nimport { Component, DefineComponent, h, markRaw, reactive, render } from 'vue'\n\nimport { Editor as ExtendedEditor } from './Editor.js'\n\nexport interface VueRendererOptions {\n editor: Editor\n props?: Record<string, any>\n}\n\ntype ExtendedVNode = ReturnType<typeof h> | null\n\ninterface RenderedComponent {\n vNode: ExtendedVNode\n destroy: () => void\n el: Element | null\n}\n\n/**\n * This class is used to render Vue components inside the editor.\n */\nexport class VueRenderer {\n renderedComponent!: RenderedComponent\n\n editor: ExtendedEditor\n\n component: Component\n\n el: Element | null\n\n props: Record<string, any>\n\n constructor(component: Component, { props = {}, editor }: VueRendererOptions) {\n this.editor = editor as ExtendedEditor\n this.component = markRaw(component)\n this.el = document.createElement('div')\n this.props = reactive(props)\n this.renderedComponent = this.renderComponent()\n }\n\n get element(): Element | null {\n return this.renderedComponent.el\n }\n\n get ref(): any {\n // Composition API\n if (this.renderedComponent.vNode?.component?.exposed) {\n return this.renderedComponent.vNode.component.exposed\n }\n // Option API\n return this.renderedComponent.vNode?.component?.proxy\n }\n\n renderComponent() {\n let vNode: ExtendedVNode = h(this.component as DefineComponent, this.props)\n\n if (this.editor.appContext) {\n vNode.appContext = this.editor.appContext\n }\n if (typeof document !== 'undefined' && this.el) {\n render(vNode, this.el)\n }\n\n const destroy = () => {\n if (this.el) {\n render(null, this.el)\n }\n this.el = null\n vNode = null\n }\n\n return { vNode, destroy, el: this.el ? this.el.firstElementChild : null }\n }\n\n updateProps(props: Record<string, any> = {}): void {\n Object.entries(props).forEach(([key, value]) => {\n this.props[key] = value\n })\n this.renderComponent()\n }\n\n destroy(): void {\n this.renderedComponent.destroy()\n }\n}\n","export * from './BubbleMenu.js'\nexport { Editor } from './Editor.js'\nexport * from './EditorContent.js'\nexport * from './FloatingMenu.js'\nexport * from './NodeViewContent.js'\nexport * from './NodeViewWrapper.js'\nexport * from './useEditor.js'\nexport * from './VueNodeViewRenderer.js'\nexport * from './VueRenderer.js'\nexport * from '@tiptap/core'\n"],"mappings":";AAAA,SAAS,wBAA+C;AACxD,SAAS,iBAAiB,GAAG,iBAAiB,WAAqB,KAAK,gBAAgB;AAEjF,IAAM,aAAa,gBAAgB;AAAA,EACxC,MAAM;AAAA,EAEN,OAAO;AAAA,IACL,WAAW;AAAA,MACT,MAAM,CAAC,QAAQ,MAAM;AAAA,MACrB,SAAS;AAAA,IACX;AAAA,IAEA,QAAQ;AAAA,MACN,MAAM;AAAA,MACN,UAAU;AAAA,IACZ;AAAA,IAEA,aAAa;AAAA,MACX,MAAM;AAAA,MACN,SAAS;AAAA,IACX;AAAA,IAEA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EA,uBAAuB;AACrB,WACE,KAAK,YAEF,IAAI,UAAQ,KAAK,KAAK,MAAM,KAAK,EACjC,KAAK,EACL,KAAK,GAAG;AAAA,EAEf;AAAA,EAEA,UAAU;AACR,SAAK,SAAS,QAAQ;AACtB,SAAK,OAAO,IAAI,mBAAmB,KAAK,qBAAqB;AAAA,EAC/D;AACF;AAEO,SAAS,oBACd,WACA,SACkB;AAClB,SAAO,WAAS;AAId,QAAI,CAAE,MAAM,OAAkB,kBAAkB;AAC9C,aAAO,CAAC;AAAA,IACV;AAEA,UAAM,sBACJ,OAAO,cAAc,cAAc,eAAe,YAAa,UAAU,YAA0B;AAErG,WAAO,IAAI,YAAY,qBAAqB,OAAO,OAAO;AAAA,EAC5D;AACF;;;AE5QA,cAAc;","names":["defineComponent","h","onBeforeUnmount","ref","defineComponent","h","onBeforeUnmount","onMounted","ref","Teleport","defineComponent","h","defineComponent","h","onBeforeUnmount","onMounted","onMounted","onBeforeUnmount","defineComponent","ref","h","markRaw","ref","defineComponent"]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@tiptap/vue-3",
3
3
  "description": "Vue components for tiptap",
4
- "version": "3.0.0-next.2",
4
+ "version": "3.0.0-next.4",
5
5
  "homepage": "https://tiptap.dev",
6
6
  "keywords": [
7
7
  "tiptap",
@@ -14,7 +14,10 @@
14
14
  },
15
15
  "exports": {
16
16
  ".": {
17
- "types": "./dist/index.d.ts",
17
+ "types": {
18
+ "import": "./dist/index.d.ts",
19
+ "require": "./dist/index.d.cts"
20
+ },
18
21
  "import": "./dist/index.js",
19
22
  "require": "./dist/index.cjs"
20
23
  }
@@ -28,18 +31,19 @@
28
31
  "dist"
29
32
  ],
30
33
  "dependencies": {
31
- "@tiptap/extension-bubble-menu": "^3.0.0-next.2",
32
- "@tiptap/extension-floating-menu": "^3.0.0-next.2"
34
+ "@tiptap/extension-bubble-menu": "^3.0.0-next.4",
35
+ "@tiptap/extension-floating-menu": "^3.0.0-next.4"
33
36
  },
34
37
  "devDependencies": {
35
- "@tiptap/core": "^3.0.0-next.2",
36
- "@tiptap/pm": "^3.0.0-next.2",
37
- "vue": "^3.0.0"
38
+ "@tiptap/core": "^3.0.0-next.4",
39
+ "@tiptap/pm": "^3.0.0-next.4",
40
+ "vue": "^3.5.13"
38
41
  },
39
42
  "peerDependencies": {
40
43
  "@tiptap/core": "^3.0.0-next.1",
41
44
  "@tiptap/pm": "^3.0.0-next.1",
42
- "vue": "^3.0.0"
45
+ "vue": "^3.0.0",
46
+ "@floating-ui/dom": "^1.0.0"
43
47
  },
44
48
  "repository": {
45
49
  "type": "git",
@@ -48,6 +52,7 @@
48
52
  },
49
53
  "sideEffects": false,
50
54
  "scripts": {
51
- "build": "tsup"
55
+ "build": "tsup",
56
+ "lint": "prettier ./src/ --check && eslint --cache --quiet --no-error-on-unmatched-pattern ./src/"
52
57
  }
53
- }
58
+ }
package/src/BubbleMenu.ts CHANGED
@@ -1,13 +1,5 @@
1
1
  import { BubbleMenuPlugin, BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'
2
- import {
3
- defineComponent,
4
- h,
5
- onBeforeUnmount,
6
- onMounted,
7
- PropType,
8
- ref,
9
- Teleport,
10
- } from 'vue'
2
+ import { defineComponent, h, onBeforeUnmount, onMounted, PropType, ref, Teleport } from 'vue'
11
3
 
12
4
  export const BubbleMenu = defineComponent({
13
5
  name: 'BubbleMenu',
@@ -48,14 +40,7 @@ export const BubbleMenu = defineComponent({
48
40
  const root = ref<HTMLElement | null>(null)
49
41
 
50
42
  onMounted(() => {
51
- const {
52
- editor,
53
- options,
54
- pluginKey,
55
- resizeDelay,
56
- shouldShow,
57
- updateDelay,
58
- } = props
43
+ const { editor, options, pluginKey, resizeDelay, shouldShow, updateDelay } = props
59
44
 
60
45
  if (!root.value) {
61
46
  return
@@ -67,15 +52,17 @@ export const BubbleMenu = defineComponent({
67
52
  // remove the element from the DOM
68
53
  root.value.remove()
69
54
 
70
- editor.registerPlugin(BubbleMenuPlugin({
71
- editor,
72
- element: root.value as HTMLElement,
73
- options,
74
- pluginKey,
75
- resizeDelay,
76
- shouldShow,
77
- updateDelay,
78
- }))
55
+ editor.registerPlugin(
56
+ BubbleMenuPlugin({
57
+ editor,
58
+ element: root.value as HTMLElement,
59
+ options,
60
+ pluginKey,
61
+ resizeDelay,
62
+ shouldShow,
63
+ updateDelay,
64
+ }),
65
+ )
79
66
  })
80
67
 
81
68
  onBeforeUnmount(() => {
package/src/Editor.ts CHANGED
@@ -1,14 +1,7 @@
1
1
  /* eslint-disable react-hooks/rules-of-hooks */
2
2
  import { Editor as CoreEditor, EditorOptions } from '@tiptap/core'
3
3
  import { EditorState, Plugin, PluginKey } from '@tiptap/pm/state'
4
- import {
5
- AppContext,
6
- ComponentInternalInstance,
7
- ComponentPublicInstance,
8
- customRef,
9
- markRaw,
10
- Ref,
11
- } from 'vue'
4
+ import { AppContext, ComponentInternalInstance, ComponentPublicInstance, customRef, markRaw, Ref } from 'vue'
12
5
 
13
6
  function useDebouncedRef<T>(value: T) {
14
7
  return customRef<T>((track, trigger) => {
@@ -77,11 +77,10 @@ export const EditorContent = defineComponent({
77
77
  },
78
78
 
79
79
  render() {
80
- return h(
81
- 'div',
82
- {
83
- ref: (el: any) => { this.rootEl = el },
80
+ return h('div', {
81
+ ref: (el: any) => {
82
+ this.rootEl = el
84
83
  },
85
- )
84
+ })
86
85
  },
87
86
  })
@@ -1,14 +1,5 @@
1
- import type { BubbleMenuPluginProps } from '@tiptap/extension-bubble-menu'
2
1
  import { FloatingMenuPlugin, FloatingMenuPluginProps } from '@tiptap/extension-floating-menu'
3
- import {
4
- defineComponent,
5
- h,
6
- onBeforeUnmount,
7
- onMounted,
8
- PropType,
9
- ref,
10
- Teleport,
11
- } from 'vue'
2
+ import { defineComponent, h, onBeforeUnmount, onMounted, PropType, ref, Teleport } from 'vue'
12
3
 
13
4
  export const FloatingMenu = defineComponent({
14
5
  name: 'FloatingMenu',
@@ -27,7 +18,7 @@ export const FloatingMenu = defineComponent({
27
18
  },
28
19
 
29
20
  options: {
30
- type: Object as PropType<BubbleMenuPluginProps['options']>,
21
+ type: Object as PropType<FloatingMenuPluginProps['options']>,
31
22
  default: () => ({}),
32
23
  },
33
24
 
@@ -41,12 +32,7 @@ export const FloatingMenu = defineComponent({
41
32
  const root = ref<HTMLElement | null>(null)
42
33
 
43
34
  onMounted(() => {
44
- const {
45
- pluginKey,
46
- editor,
47
- options,
48
- shouldShow,
49
- } = props
35
+ const { pluginKey, editor, options, shouldShow } = props
50
36
 
51
37
  if (!root.value) {
52
38
  return
@@ -58,13 +44,15 @@ export const FloatingMenu = defineComponent({
58
44
  // remove the element from the DOM
59
45
  root.value.remove()
60
46
 
61
- editor.registerPlugin(FloatingMenuPlugin({
62
- pluginKey,
63
- editor,
64
- element: root.value as HTMLElement,
65
- options,
66
- shouldShow,
67
- }))
47
+ editor.registerPlugin(
48
+ FloatingMenuPlugin({
49
+ pluginKey,
50
+ editor,
51
+ element: root.value as HTMLElement,
52
+ options,
53
+ shouldShow,
54
+ }),
55
+ )
68
56
  })
69
57
 
70
58
  onBeforeUnmount(() => {
@@ -1,16 +1,8 @@
1
1
  /* eslint-disable no-underscore-dangle */
2
- import {
3
- DecorationWithType,
4
- NodeView,
5
- NodeViewProps,
6
- NodeViewRenderer,
7
- NodeViewRendererOptions,
8
- } from '@tiptap/core'
2
+ import { DecorationWithType, NodeView, NodeViewProps, NodeViewRenderer, NodeViewRendererOptions } from '@tiptap/core'
9
3
  import { Node as ProseMirrorNode } from '@tiptap/pm/model'
10
4
  import { Decoration, DecorationSource, NodeView as ProseMirrorNodeView } from '@tiptap/pm/view'
11
- import {
12
- Component, defineComponent, PropType, provide, Ref, ref,
13
- } from 'vue'
5
+ import { Component, defineComponent, PropType, provide, Ref, ref } from 'vue'
14
6
 
15
7
  import { Editor } from './Editor.js'
16
8
  import { VueRenderer } from './VueRenderer.js'
@@ -53,15 +45,15 @@ export const nodeViewProps = {
53
45
  export interface VueNodeViewRendererOptions extends NodeViewRendererOptions {
54
46
  update:
55
47
  | ((props: {
56
- oldNode: ProseMirrorNode;
57
- oldDecorations: readonly Decoration[];
58
- oldInnerDecorations: DecorationSource;
59
- newNode: ProseMirrorNode;
60
- newDecorations: readonly Decoration[];
61
- innerDecorations: DecorationSource;
62
- updateProps: () => void;
48
+ oldNode: ProseMirrorNode
49
+ oldDecorations: readonly Decoration[]
50
+ oldInnerDecorations: DecorationSource
51
+ newNode: ProseMirrorNode
52
+ newDecorations: readonly Decoration[]
53
+ innerDecorations: DecorationSource
54
+ updateProps: () => void
63
55
  }) => boolean)
64
- | null;
56
+ | null
65
57
  }
66
58
 
67
59
  class VueNodeView extends NodeView<Component, Editor, VueNodeViewRendererOptions> {
@@ -181,11 +173,7 @@ class VueNodeView extends NodeView<Component, Editor, VueNodeViewRendererOptions
181
173
  * On update, update the React component.
182
174
  * To prevent unnecessary updates, the `update` option can be used.
183
175
  */
184
- update(
185
- node: ProseMirrorNode,
186
- decorations: readonly Decoration[],
187
- innerDecorations: DecorationSource,
188
- ): boolean {
176
+ update(node: ProseMirrorNode, decorations: readonly Decoration[], innerDecorations: DecorationSource): boolean {
189
177
  const rerenderComponent = (props?: Record<string, any>) => {
190
178
  this.decorationClasses.value = this.getDecorationClasses()
191
179
  this.renderer.updateProps(props)
@@ -282,9 +270,8 @@ export function VueNodeViewRenderer(
282
270
  return {} as unknown as ProseMirrorNodeView
283
271
  }
284
272
  // check for class-component and normalize if neccessary
285
- const normalizedComponent = typeof component === 'function' && '__vccOpts' in component
286
- ? (component.__vccOpts as Component)
287
- : component
273
+ const normalizedComponent =
274
+ typeof component === 'function' && '__vccOpts' in component ? (component.__vccOpts as Component) : component
288
275
 
289
276
  return new VueNodeView(normalizedComponent, props, options)
290
277
  }
@@ -1,21 +1,19 @@
1
1
  import { Editor } from '@tiptap/core'
2
- import {
3
- Component, DefineComponent, h, markRaw, reactive, render,
4
- } from 'vue'
2
+ import { Component, DefineComponent, h, markRaw, reactive, render } from 'vue'
5
3
 
6
4
  import { Editor as ExtendedEditor } from './Editor.js'
7
5
 
8
6
  export interface VueRendererOptions {
9
- editor: Editor;
10
- props?: Record<string, any>;
7
+ editor: Editor
8
+ props?: Record<string, any>
11
9
  }
12
10
 
13
- type ExtendedVNode = ReturnType<typeof h> | null;
11
+ type ExtendedVNode = ReturnType<typeof h> | null
14
12
 
15
13
  interface RenderedComponent {
16
- vNode: ExtendedVNode;
17
- destroy: () => void;
18
- el: Element | null;
14
+ vNode: ExtendedVNode
15
+ destroy: () => void
16
+ el: Element | null
19
17
  }
20
18
 
21
19
  /**