@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/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Use it headless with vanilla JS/TS, add the built-in toolbar and theme, or drop
|
|
|
8
8
|
|
|
9
9
|
## Links
|
|
10
10
|
|
|
11
|
-
<u>[Website](https://domternal.dev)</u> • <u>[Documentation](https://domternal.dev/v1/introduction)</u>
|
|
11
|
+
<u>[Website](https://domternal.dev)</u> • <u>[Documentation](https://domternal.dev/v1/introduction)</u> •
|
|
12
12
|
<u>[StackBlitz (Angular)](https://stackblitz.com/edit/domternal-angular-full-example)</u> • <u>[StackBlitz (React)](https://stackblitz.com/edit/domternal-react-full-example)</u> • <u>[StackBlitz (Vue)](https://stackblitz.com/edit/domternal-vue-full-example)</u> • <u>[StackBlitz (Vanilla TS)](https://stackblitz.com/edit/domternal-vanilla-full-example)</u>
|
|
13
13
|
|
|
14
14
|
## Features
|
package/dist/index.cjs
CHANGED
|
@@ -117,6 +117,11 @@ function createFloatingMenuPlugin(options) {
|
|
|
117
117
|
cleanupFloating = null;
|
|
118
118
|
element.removeAttribute("data-show");
|
|
119
119
|
};
|
|
120
|
+
const clearTriggeredFlag = (view) => {
|
|
121
|
+
if (!requireExplicitTrigger) return;
|
|
122
|
+
const triggered = pluginKey.getState(view.state)?.triggered ?? false;
|
|
123
|
+
if (triggered) view.dispatch(view.state.tr.setMeta(FLOATING_MENU_META, "hide"));
|
|
124
|
+
};
|
|
120
125
|
const focusFirstItem = () => {
|
|
121
126
|
const first = element.querySelector('[data-floating-menu-item]:not([aria-disabled="true"])') ?? element.querySelector('button, [tabindex]:not([tabindex="-1"])');
|
|
122
127
|
if (!first) return false;
|
|
@@ -166,12 +171,7 @@ function createFloatingMenuPlugin(options) {
|
|
|
166
171
|
}
|
|
167
172
|
const dismiss = () => {
|
|
168
173
|
hideMenu();
|
|
169
|
-
|
|
170
|
-
const triggered = pluginKey.getState(editor.view.state)?.triggered ?? false;
|
|
171
|
-
if (triggered) {
|
|
172
|
-
editor.view.dispatch(editor.view.state.tr.setMeta(FLOATING_MENU_META, "hide"));
|
|
173
|
-
}
|
|
174
|
-
}
|
|
174
|
+
clearTriggeredFlag(editor.view);
|
|
175
175
|
};
|
|
176
176
|
const onFocus = () => {
|
|
177
177
|
if (isVisibleNow(editor.view)) updatePosition(editor.view);
|
|
@@ -204,12 +204,7 @@ function createFloatingMenuPlugin(options) {
|
|
|
204
204
|
if (isVisibleNow(view)) updatePosition(view);
|
|
205
205
|
else {
|
|
206
206
|
hideMenu();
|
|
207
|
-
|
|
208
|
-
const triggered = pluginKey.getState(view.state)?.triggered ?? false;
|
|
209
|
-
if (triggered) {
|
|
210
|
-
view.dispatch(view.state.tr.setMeta(FLOATING_MENU_META, "hide"));
|
|
211
|
-
}
|
|
212
|
-
}
|
|
207
|
+
clearTriggeredFlag(view);
|
|
213
208
|
}
|
|
214
209
|
},
|
|
215
210
|
destroy: () => {
|
|
@@ -1167,6 +1162,7 @@ function createBlockHandlePlugin(options) {
|
|
|
1167
1162
|
}, 0);
|
|
1168
1163
|
startAutoScroll();
|
|
1169
1164
|
startDragListeners();
|
|
1165
|
+
if (dropIndicator) editorEl?.classList.add("dm-block-handle-dragging");
|
|
1170
1166
|
};
|
|
1171
1167
|
const teardownDragPreview = () => {
|
|
1172
1168
|
if (dragPreview) {
|
|
@@ -1183,6 +1179,7 @@ function createBlockHandlePlugin(options) {
|
|
|
1183
1179
|
hideDropIndicator();
|
|
1184
1180
|
teardownDragPreview();
|
|
1185
1181
|
releaseDragPress();
|
|
1182
|
+
editorEl?.classList.remove("dm-block-handle-dragging");
|
|
1186
1183
|
};
|
|
1187
1184
|
return new state.Plugin({
|
|
1188
1185
|
key: pluginKey,
|
|
@@ -1278,6 +1275,7 @@ function createBlockHandlePlugin(options) {
|
|
|
1278
1275
|
dragBtn.removeEventListener("dragstart", onDragStart);
|
|
1279
1276
|
dragBtn.removeEventListener("dragend", onDragEnd);
|
|
1280
1277
|
editorEl?.classList.remove("dm-editor--has-block-handle");
|
|
1278
|
+
editorEl?.classList.remove("dm-block-handle-dragging");
|
|
1281
1279
|
root.remove();
|
|
1282
1280
|
editorEl = null;
|
|
1283
1281
|
hoverEl = null;
|
|
@@ -1818,11 +1816,9 @@ function createBlockContextMenuPlugin(options) {
|
|
|
1818
1816
|
editorEl.dispatchEvent(new Event("dm:dismiss-overlays", { bubbles: false }));
|
|
1819
1817
|
root.setAttribute("data-show", "");
|
|
1820
1818
|
lockScroll();
|
|
1821
|
-
{
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
editor.view.dispatch(tr);
|
|
1825
|
-
}
|
|
1819
|
+
const openTr = editor.view.state.tr.setMeta(pluginKey, { activeBlockPos: detail.blockPos });
|
|
1820
|
+
openTr.setMeta("addToHistory", false);
|
|
1821
|
+
editor.view.dispatch(openTr);
|
|
1826
1822
|
cleanupFloating?.();
|
|
1827
1823
|
let anchorEl = detail.anchorElement;
|
|
1828
1824
|
const bubbleMenuRef = anchorEl.closest(".dm-bubble-menu");
|