@domternal/vue 1.0.2 → 1.1.0
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.js +26 -26
- package/dist/index.js.map +1 -1
- package/package.json +12 -12
package/README.md
CHANGED
|
@@ -19,7 +19,7 @@ editor is created in `onMounted`. Requires Vue 3.3+ and the Composition API.
|
|
|
19
19
|
pnpm add @domternal/vue @domternal/core @domternal/theme vue
|
|
20
20
|
```
|
|
21
21
|
|
|
22
|
-
`vue` (>=3.3) and `@domternal/core` (>=1.
|
|
22
|
+
`vue` (>=3.3) and `@domternal/core` (>=1.1.0 <2.0.0) are peer dependencies. `@domternal/theme`
|
|
23
23
|
supplies the editor styles.
|
|
24
24
|
|
|
25
25
|
## Usage
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { defineComponent, h, computed, Fragment, ref, watch, shallowRef, onMounted, nextTick, onScopeDispose,
|
|
1
|
+
import { defineComponent, h, computed, Fragment, ref, watch, shallowRef, onMounted, nextTick, onScopeDispose, Teleport, inject, provide, getCurrentInstance, watchEffect, customRef, markRaw, shallowReactive, render } from 'vue';
|
|
2
2
|
import { positionFloatingOnce, PluginKey, positionFloating, ToolbarController, refocusEditorAfterCommand, createFloatingMenuPlugin, FloatingMenuController, defaultIcons, defaultBubbleContexts, buildBubbleItemMaps, createBubbleShouldShow, createBubbleMenuPlugin, resolveBubbleNames, Document, Paragraph, Text, BaseKeymap, History, Editor, resolveBubbleMenuItems } from '@domternal/core';
|
|
3
3
|
export { Editor, generateHTML, generateJSON, generateText } from '@domternal/core';
|
|
4
4
|
|
|
@@ -68,10 +68,7 @@ function useEditor(options = {}) {
|
|
|
68
68
|
const ed = editor.value;
|
|
69
69
|
if (ed) {
|
|
70
70
|
const mount = editorRef.value;
|
|
71
|
-
if (mount
|
|
72
|
-
mount.appendChild(ed.view.dom);
|
|
73
|
-
ed.adoptPresetClass();
|
|
74
|
-
}
|
|
71
|
+
if (mount) ed.adoptDom(mount);
|
|
75
72
|
return;
|
|
76
73
|
}
|
|
77
74
|
const element = editorRef.value ?? document.createElement("div");
|
|
@@ -701,6 +698,7 @@ var ToolbarDropdownPanel = defineComponent({
|
|
|
701
698
|
},
|
|
702
699
|
emits: ["itemClick"],
|
|
703
700
|
setup(props, { emit }) {
|
|
701
|
+
const { getTooltip } = useTooltip();
|
|
704
702
|
return () => {
|
|
705
703
|
const { dropdown, isActive, getCachedItemContent } = props;
|
|
706
704
|
if (dropdown.layout === "grid") {
|
|
@@ -719,7 +717,7 @@ var ToolbarDropdownPanel = defineComponent({
|
|
|
719
717
|
role: "menuitem",
|
|
720
718
|
tabindex: -1,
|
|
721
719
|
"aria-label": sub.label,
|
|
722
|
-
title: sub
|
|
720
|
+
title: getTooltip(sub),
|
|
723
721
|
style: { backgroundColor: sub.color },
|
|
724
722
|
onMousedown: (e) => {
|
|
725
723
|
e.preventDefault();
|
|
@@ -734,6 +732,7 @@ var ToolbarDropdownPanel = defineComponent({
|
|
|
734
732
|
role: "menuitem",
|
|
735
733
|
tabindex: -1,
|
|
736
734
|
"aria-label": sub.label,
|
|
735
|
+
title: getTooltip(sub),
|
|
737
736
|
innerHTML: getCachedItemContent(sub.icon, sub.label),
|
|
738
737
|
onMousedown: (e) => {
|
|
739
738
|
e.preventDefault();
|
|
@@ -760,7 +759,7 @@ var ToolbarDropdownPanel = defineComponent({
|
|
|
760
759
|
role: "menuitem",
|
|
761
760
|
tabindex: -1,
|
|
762
761
|
"aria-label": sub.label,
|
|
763
|
-
title: sub
|
|
762
|
+
title: getTooltip(sub),
|
|
764
763
|
innerHTML: getCachedItemContent(sub.icon, sub.label, dropdown.displayMode),
|
|
765
764
|
onVnodeMounted: (vnode) => {
|
|
766
765
|
if (sub.style && vnode.el) vnode.el.setAttribute("style", sub.style);
|
|
@@ -1669,7 +1668,10 @@ var DomternalFloatingMenu = defineComponent({
|
|
|
1669
1668
|
"aria-hidden": "true",
|
|
1670
1669
|
innerHTML: iconHtml
|
|
1671
1670
|
}) : null,
|
|
1672
|
-
h("span", { class: "dm-floating-menu-item-
|
|
1671
|
+
item.description ? h("span", { class: "dm-floating-menu-item-text" }, [
|
|
1672
|
+
h("span", { class: "dm-floating-menu-item-label" }, item.label),
|
|
1673
|
+
h("span", { class: "dm-floating-menu-item-description" }, item.description)
|
|
1674
|
+
]) : h("span", { class: "dm-floating-menu-item-label" }, item.label),
|
|
1673
1675
|
item.shortcut ? h("span", { class: "dm-floating-menu-item-shortcut", "aria-hidden": "true" }, item.shortcut) : null
|
|
1674
1676
|
]
|
|
1675
1677
|
);
|
|
@@ -2119,16 +2121,15 @@ var DomternalContent = defineComponent({
|
|
|
2119
2121
|
setup(props) {
|
|
2120
2122
|
const { editor } = useCurrentEditor();
|
|
2121
2123
|
const containerRef = ref();
|
|
2122
|
-
|
|
2123
|
-
const container = containerRef.value;
|
|
2124
|
-
const ed = editor.value;
|
|
2124
|
+
watch([containerRef, editor], ([container, ed], _previous, onCleanup) => {
|
|
2125
2125
|
if (!container || !ed || ed.isDestroyed) return;
|
|
2126
|
-
|
|
2127
|
-
|
|
2128
|
-
container
|
|
2129
|
-
|
|
2130
|
-
|
|
2131
|
-
|
|
2126
|
+
ed.adoptDom(container);
|
|
2127
|
+
onCleanup(() => {
|
|
2128
|
+
if (!ed.isDestroyed && ed.view.dom.parentElement === container) {
|
|
2129
|
+
ed.adoptDom(document.createElement("div"));
|
|
2130
|
+
}
|
|
2131
|
+
});
|
|
2132
|
+
}, { immediate: true });
|
|
2132
2133
|
return () => {
|
|
2133
2134
|
const classes = props.class ? `dm-editor ${props.class}` : "dm-editor";
|
|
2134
2135
|
return h("div", { class: classes, "data-dm-editor-ui": "" }, [h("div", { ref: containerRef })]);
|
|
@@ -2258,16 +2259,15 @@ var EditorContent = defineComponent({
|
|
|
2258
2259
|
},
|
|
2259
2260
|
setup(props) {
|
|
2260
2261
|
const containerRef = ref();
|
|
2261
|
-
|
|
2262
|
-
const container = containerRef.value;
|
|
2263
|
-
const editor = props.editor;
|
|
2262
|
+
watch([containerRef, () => props.editor], ([container, editor], _previous, onCleanup) => {
|
|
2264
2263
|
if (!container || !editor || editor.isDestroyed) return;
|
|
2265
|
-
|
|
2266
|
-
|
|
2267
|
-
container
|
|
2268
|
-
|
|
2269
|
-
|
|
2270
|
-
|
|
2264
|
+
editor.adoptDom(container);
|
|
2265
|
+
onCleanup(() => {
|
|
2266
|
+
if (!editor.isDestroyed && editor.view.dom.parentElement === container) {
|
|
2267
|
+
editor.adoptDom(document.createElement("div"));
|
|
2268
|
+
}
|
|
2269
|
+
});
|
|
2270
|
+
}, { immediate: true });
|
|
2271
2271
|
return () => h("div", {
|
|
2272
2272
|
ref: containerRef,
|
|
2273
2273
|
class: props.class,
|