@domternal/extension-block-menu 0.7.0 → 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/README.md +1 -1
- package/dist/index.cjs +13 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.js +13 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -242,14 +242,14 @@ interface BlockHandleOptions {
|
|
|
242
242
|
*/
|
|
243
243
|
nestThreshold?: number;
|
|
244
244
|
/**
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
* `
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
245
|
+
* Custom drop indicator that mirrors exactly where a handle-drag will
|
|
246
|
+
* land. Replaces `prosemirror-dropcursor` for handle drags (PM's
|
|
247
|
+
* `posAtCoords` can disagree with our resolver in the side gutter /
|
|
248
|
+
* inter-block gap). While dragging, the editor gets a
|
|
249
|
+
* `dm-block-handle-dragging` class so the theme can hide the native
|
|
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
|
@@ -242,14 +242,14 @@ interface BlockHandleOptions {
|
|
|
242
242
|
*/
|
|
243
243
|
nestThreshold?: number;
|
|
244
244
|
/**
|
|
245
|
-
*
|
|
246
|
-
*
|
|
247
|
-
* `
|
|
248
|
-
*
|
|
249
|
-
*
|
|
250
|
-
*
|
|
251
|
-
*
|
|
252
|
-
*
|
|
245
|
+
* Custom drop indicator that mirrors exactly where a handle-drag will
|
|
246
|
+
* land. Replaces `prosemirror-dropcursor` for handle drags (PM's
|
|
247
|
+
* `posAtCoords` can disagree with our resolver in the side gutter /
|
|
248
|
+
* inter-block gap). While dragging, the editor gets a
|
|
249
|
+
* `dm-block-handle-dragging` class so the theme can hide the native
|
|
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
|
-
|
|
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
|
-
|
|
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: () => {
|
|
@@ -1165,6 +1160,7 @@ function createBlockHandlePlugin(options) {
|
|
|
1165
1160
|
}, 0);
|
|
1166
1161
|
startAutoScroll();
|
|
1167
1162
|
startDragListeners();
|
|
1163
|
+
if (dropIndicator) editorEl?.classList.add("dm-block-handle-dragging");
|
|
1168
1164
|
};
|
|
1169
1165
|
const teardownDragPreview = () => {
|
|
1170
1166
|
if (dragPreview) {
|
|
@@ -1181,6 +1177,7 @@ function createBlockHandlePlugin(options) {
|
|
|
1181
1177
|
hideDropIndicator();
|
|
1182
1178
|
teardownDragPreview();
|
|
1183
1179
|
releaseDragPress();
|
|
1180
|
+
editorEl?.classList.remove("dm-block-handle-dragging");
|
|
1184
1181
|
};
|
|
1185
1182
|
return new Plugin({
|
|
1186
1183
|
key: pluginKey,
|
|
@@ -1276,6 +1273,7 @@ function createBlockHandlePlugin(options) {
|
|
|
1276
1273
|
dragBtn.removeEventListener("dragstart", onDragStart);
|
|
1277
1274
|
dragBtn.removeEventListener("dragend", onDragEnd);
|
|
1278
1275
|
editorEl?.classList.remove("dm-editor--has-block-handle");
|
|
1276
|
+
editorEl?.classList.remove("dm-block-handle-dragging");
|
|
1279
1277
|
root.remove();
|
|
1280
1278
|
editorEl = null;
|
|
1281
1279
|
hoverEl = null;
|
|
@@ -1816,11 +1814,9 @@ function createBlockContextMenuPlugin(options) {
|
|
|
1816
1814
|
editorEl.dispatchEvent(new Event("dm:dismiss-overlays", { bubbles: false }));
|
|
1817
1815
|
root.setAttribute("data-show", "");
|
|
1818
1816
|
lockScroll();
|
|
1819
|
-
{
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
editor.view.dispatch(tr);
|
|
1823
|
-
}
|
|
1817
|
+
const openTr = editor.view.state.tr.setMeta(pluginKey, { activeBlockPos: detail.blockPos });
|
|
1818
|
+
openTr.setMeta("addToHistory", false);
|
|
1819
|
+
editor.view.dispatch(openTr);
|
|
1824
1820
|
cleanupFloating?.();
|
|
1825
1821
|
let anchorEl = detail.anchorElement;
|
|
1826
1822
|
const bubbleMenuRef = anchorEl.closest(".dm-bubble-menu");
|