@domternal/extension-block-menu 0.7.1 → 0.7.2

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/dist/index.d.cts CHANGED
@@ -247,9 +247,9 @@ interface BlockHandleOptions {
247
247
  * `posAtCoords` can disagree with our resolver in the side gutter /
248
248
  * inter-block gap). While dragging, the editor gets a
249
249
  * `dm-block-handle-dragging` class so the theme can hide the native
250
- * `.ProseMirror-dropcursor` for this drag only; non-handle drags
251
- * (text selection, external file drops) keep the native cursor.
252
- * Set to `false` to use the native dropcursor instead.
250
+ * `.prosemirror-dropcursor-block`/`-inline` for this drag only;
251
+ * non-handle drags (text selection, external file drops) keep the
252
+ * native cursor. Set to `false` to use the native dropcursor instead.
253
253
  * @default true
254
254
  */
255
255
  dropIndicator?: boolean;
package/dist/index.d.ts CHANGED
@@ -247,9 +247,9 @@ interface BlockHandleOptions {
247
247
  * `posAtCoords` can disagree with our resolver in the side gutter /
248
248
  * inter-block gap). While dragging, the editor gets a
249
249
  * `dm-block-handle-dragging` class so the theme can hide the native
250
- * `.ProseMirror-dropcursor` for this drag only; non-handle drags
251
- * (text selection, external file drops) keep the native cursor.
252
- * Set to `false` to use the native dropcursor instead.
250
+ * `.prosemirror-dropcursor-block`/`-inline` for this drag only;
251
+ * non-handle drags (text selection, external file drops) keep the
252
+ * native cursor. Set to `false` to use the native dropcursor instead.
253
253
  * @default true
254
254
  */
255
255
  dropIndicator?: boolean;
package/dist/index.js CHANGED
@@ -115,6 +115,11 @@ function createFloatingMenuPlugin(options) {
115
115
  cleanupFloating = null;
116
116
  element.removeAttribute("data-show");
117
117
  };
118
+ const clearTriggeredFlag = (view) => {
119
+ if (!requireExplicitTrigger) return;
120
+ const triggered = pluginKey.getState(view.state)?.triggered ?? false;
121
+ if (triggered) view.dispatch(view.state.tr.setMeta(FLOATING_MENU_META, "hide"));
122
+ };
118
123
  const focusFirstItem = () => {
119
124
  const first = element.querySelector('[data-floating-menu-item]:not([aria-disabled="true"])') ?? element.querySelector('button, [tabindex]:not([tabindex="-1"])');
120
125
  if (!first) return false;
@@ -164,12 +169,7 @@ function createFloatingMenuPlugin(options) {
164
169
  }
165
170
  const dismiss = () => {
166
171
  hideMenu();
167
- if (requireExplicitTrigger) {
168
- const triggered = pluginKey.getState(editor.view.state)?.triggered ?? false;
169
- if (triggered) {
170
- editor.view.dispatch(editor.view.state.tr.setMeta(FLOATING_MENU_META, "hide"));
171
- }
172
- }
172
+ clearTriggeredFlag(editor.view);
173
173
  };
174
174
  const onFocus = () => {
175
175
  if (isVisibleNow(editor.view)) updatePosition(editor.view);
@@ -202,12 +202,7 @@ function createFloatingMenuPlugin(options) {
202
202
  if (isVisibleNow(view)) updatePosition(view);
203
203
  else {
204
204
  hideMenu();
205
- if (requireExplicitTrigger) {
206
- const triggered = pluginKey.getState(view.state)?.triggered ?? false;
207
- if (triggered) {
208
- view.dispatch(view.state.tr.setMeta(FLOATING_MENU_META, "hide"));
209
- }
210
- }
205
+ clearTriggeredFlag(view);
211
206
  }
212
207
  },
213
208
  destroy: () => {
@@ -1819,11 +1814,9 @@ function createBlockContextMenuPlugin(options) {
1819
1814
  editorEl.dispatchEvent(new Event("dm:dismiss-overlays", { bubbles: false }));
1820
1815
  root.setAttribute("data-show", "");
1821
1816
  lockScroll();
1822
- {
1823
- const tr = editor.view.state.tr.setMeta(pluginKey, { activeBlockPos: detail.blockPos });
1824
- tr.setMeta("addToHistory", false);
1825
- editor.view.dispatch(tr);
1826
- }
1817
+ const openTr = editor.view.state.tr.setMeta(pluginKey, { activeBlockPos: detail.blockPos });
1818
+ openTr.setMeta("addToHistory", false);
1819
+ editor.view.dispatch(openTr);
1827
1820
  cleanupFloating?.();
1828
1821
  let anchorEl = detail.anchorElement;
1829
1822
  const bubbleMenuRef = anchorEl.closest(".dm-bubble-menu");