@tiptap/vue-2 3.0.0-beta.1 → 3.0.0-beta.3

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.
@@ -1,5 +1,5 @@
1
- import { offset, flip, shift, arrow, size, autoPlacement, hide, inline } from '@floating-ui/dom';
2
1
  import { Editor } from '@tiptap/core';
2
+ import { offset, flip, shift, arrow, size, autoPlacement, hide, inline } from '@floating-ui/dom';
3
3
  import { PluginKey, EditorState } from '@tiptap/pm/state';
4
4
  import { EditorView } from '@tiptap/pm/view';
5
5
  import Vue, { Component } from 'vue';
@@ -1,5 +1,5 @@
1
- import { offset, flip, shift, arrow, size, autoPlacement, hide, inline } from '@floating-ui/dom';
2
1
  import { Editor } from '@tiptap/core';
2
+ import { offset, flip, shift, arrow, size, autoPlacement, hide, inline } from '@floating-ui/dom';
3
3
  import { PluginKey, EditorState } from '@tiptap/pm/state';
4
4
  import { EditorView } from '@tiptap/pm/view';
5
5
  import Vue, { Component } from 'vue';
@@ -1,3 +1,6 @@
1
+ // ../extension-bubble-menu/dist/index.js
2
+ import { Extension } from "@tiptap/core";
3
+
1
4
  // ../../node_modules/.pnpm/@floating-ui+utils@0.2.9/node_modules/@floating-ui/utils/dist/floating-ui.utils.mjs
2
5
  var sides = ["top", "right", "bottom", "left"];
3
6
  var alignments = ["start", "end"];
@@ -1581,7 +1584,7 @@ var computePosition2 = (reference, floating, options) => {
1581
1584
  });
1582
1585
  };
1583
1586
 
1584
- // ../extension-bubble-menu/src/bubble-menu-plugin.ts
1587
+ // ../extension-bubble-menu/dist/index.js
1585
1588
  import { isTextSelection, posToDOMRect } from "@tiptap/core";
1586
1589
  import { Plugin, PluginKey } from "@tiptap/pm/state";
1587
1590
  var BubbleMenuView = class {
@@ -1607,12 +1610,12 @@ var BubbleMenuView = class {
1607
1610
  hide: false,
1608
1611
  inline: false
1609
1612
  };
1610
- this.shouldShow = ({ view, state, from, to }) => {
1613
+ this.shouldShow = ({ view: view2, state, from, to }) => {
1611
1614
  const { doc, selection } = state;
1612
1615
  const { empty } = selection;
1613
1616
  const isEmptyTextBlock = !doc.textBetween(from, to).length && isTextSelection(state.selection);
1614
1617
  const isChildOfMenu = this.element.contains(document.activeElement);
1615
- const hasEditorFocus = view.hasFocus() || isChildOfMenu;
1618
+ const hasEditorFocus = view2.hasFocus() || isChildOfMenu;
1616
1619
  if (!hasEditorFocus || empty || isEmptyTextBlock || !this.editor.isEditable) {
1617
1620
  return false;
1618
1621
  }
@@ -1641,9 +1644,9 @@ var BubbleMenuView = class {
1641
1644
  }
1642
1645
  this.hide();
1643
1646
  };
1644
- this.handleDebouncedUpdate = (view, oldState) => {
1645
- const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view.state.selection));
1646
- const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view.state.doc));
1647
+ this.handleDebouncedUpdate = (view2, oldState) => {
1648
+ const selectionChanged = !(oldState == null ? void 0 : oldState.selection.eq(view2.state.selection));
1649
+ const docChanged = !(oldState == null ? void 0 : oldState.doc.eq(view2.state.doc));
1647
1650
  if (!selectionChanged && !docChanged) {
1648
1651
  return;
1649
1652
  }
@@ -1651,17 +1654,17 @@ var BubbleMenuView = class {
1651
1654
  clearTimeout(this.updateDebounceTimer);
1652
1655
  }
1653
1656
  this.updateDebounceTimer = window.setTimeout(() => {
1654
- this.updateHandler(view, selectionChanged, docChanged, oldState);
1657
+ this.updateHandler(view2, selectionChanged, docChanged, oldState);
1655
1658
  }, this.updateDelay);
1656
1659
  };
1657
- this.updateHandler = (view, selectionChanged, docChanged, oldState) => {
1658
- const { composing } = view;
1660
+ this.updateHandler = (view2, selectionChanged, docChanged, oldState) => {
1661
+ const { composing } = view2;
1659
1662
  const isSame = !selectionChanged && !docChanged;
1660
1663
  if (composing || isSame) {
1661
1664
  return;
1662
1665
  }
1663
- const shouldShow = this.getShouldShow(oldState);
1664
- if (!shouldShow) {
1666
+ const shouldShow2 = this.getShouldShow(oldState);
1667
+ if (!shouldShow2) {
1665
1668
  this.hide();
1666
1669
  return;
1667
1670
  }
@@ -1805,9 +1808,34 @@ var BubbleMenuPlugin = (options) => {
1805
1808
  view: (view) => new BubbleMenuView({ view, ...options })
1806
1809
  });
1807
1810
  };
1811
+ var BubbleMenu = Extension.create({
1812
+ name: "bubbleMenu",
1813
+ addOptions() {
1814
+ return {
1815
+ element: null,
1816
+ pluginKey: "bubbleMenu",
1817
+ updateDelay: void 0,
1818
+ shouldShow: null
1819
+ };
1820
+ },
1821
+ addProseMirrorPlugins() {
1822
+ if (!this.options.element) {
1823
+ return [];
1824
+ }
1825
+ return [
1826
+ BubbleMenuPlugin({
1827
+ pluginKey: this.options.pluginKey,
1828
+ editor: this.editor,
1829
+ element: this.options.element,
1830
+ updateDelay: this.options.updateDelay,
1831
+ shouldShow: this.options.shouldShow
1832
+ })
1833
+ ];
1834
+ }
1835
+ });
1808
1836
 
1809
1837
  // src/menus/BubbleMenu.ts
1810
- var BubbleMenu = {
1838
+ var BubbleMenu2 = {
1811
1839
  name: "BubbleMenu",
1812
1840
  props: {
1813
1841
  pluginKey: {
@@ -1868,18 +1896,19 @@ var BubbleMenu = {
1868
1896
  }
1869
1897
  };
1870
1898
 
1871
- // ../extension-floating-menu/src/floating-menu-plugin.ts
1899
+ // ../extension-floating-menu/dist/index.js
1900
+ import { Extension as Extension2 } from "@tiptap/core";
1872
1901
  import { getText, getTextSerializersFromSchema, posToDOMRect as posToDOMRect2 } from "@tiptap/core";
1873
1902
  import { Plugin as Plugin2, PluginKey as PluginKey2 } from "@tiptap/pm/state";
1874
1903
  var FloatingMenuView = class {
1875
1904
  constructor({ editor, element, view, options, shouldShow }) {
1876
1905
  this.preventHide = false;
1877
- this.shouldShow = ({ view, state }) => {
1906
+ this.shouldShow = ({ view: view2, state }) => {
1878
1907
  const { selection } = state;
1879
1908
  const { $anchor, empty } = selection;
1880
1909
  const isRootDepth = $anchor.depth === 1;
1881
1910
  const isEmptyTextBlock = $anchor.parent.isTextblock && !$anchor.parent.type.spec.code && !$anchor.parent.textContent && $anchor.parent.childCount === 0 && !this.getTextContent($anchor.parent);
1882
- if (!view.hasFocus() || !empty || !isRootDepth || !isEmptyTextBlock || !this.editor.isEditable) {
1911
+ if (!view2.hasFocus() || !empty || !isRootDepth || !isEmptyTextBlock || !this.editor.isEditable) {
1883
1912
  return false;
1884
1913
  }
1885
1914
  return true;
@@ -1896,14 +1925,14 @@ var FloatingMenuView = class {
1896
1925
  hide: false,
1897
1926
  inline: false
1898
1927
  };
1899
- this.updateHandler = (view, selectionChanged, docChanged, oldState) => {
1900
- const { composing } = view;
1928
+ this.updateHandler = (view2, selectionChanged, docChanged, oldState) => {
1929
+ const { composing } = view2;
1901
1930
  const isSame = !selectionChanged && !docChanged;
1902
1931
  if (composing || isSame) {
1903
1932
  return;
1904
1933
  }
1905
- const shouldShow = this.getShouldShow(oldState);
1906
- if (!shouldShow) {
1934
+ const shouldShow2 = this.getShouldShow(oldState);
1935
+ if (!shouldShow2) {
1907
1936
  this.hide();
1908
1937
  return;
1909
1938
  }
@@ -2051,9 +2080,34 @@ var FloatingMenuPlugin = (options) => {
2051
2080
  view: (view) => new FloatingMenuView({ view, ...options })
2052
2081
  });
2053
2082
  };
2083
+ var FloatingMenu = Extension2.create({
2084
+ name: "floatingMenu",
2085
+ addOptions() {
2086
+ return {
2087
+ element: null,
2088
+ options: {},
2089
+ pluginKey: "floatingMenu",
2090
+ shouldShow: null
2091
+ };
2092
+ },
2093
+ addProseMirrorPlugins() {
2094
+ if (!this.options.element) {
2095
+ return [];
2096
+ }
2097
+ return [
2098
+ FloatingMenuPlugin({
2099
+ pluginKey: this.options.pluginKey,
2100
+ editor: this.editor,
2101
+ element: this.options.element,
2102
+ options: this.options.options,
2103
+ shouldShow: this.options.shouldShow
2104
+ })
2105
+ ];
2106
+ }
2107
+ });
2054
2108
 
2055
2109
  // src/menus/FloatingMenu.ts
2056
- var FloatingMenu = {
2110
+ var FloatingMenu2 = {
2057
2111
  name: "FloatingMenu",
2058
2112
  props: {
2059
2113
  pluginKey: {
@@ -2106,7 +2160,7 @@ var FloatingMenu = {
2106
2160
  }
2107
2161
  };
2108
2162
  export {
2109
- BubbleMenu,
2110
- FloatingMenu
2163
+ BubbleMenu2 as BubbleMenu,
2164
+ FloatingMenu2 as FloatingMenu
2111
2165
  };
2112
2166
  //# sourceMappingURL=index.js.map