@opencloud-eu/web-pkg 6.1.0 → 7.0.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/dist/assets/worker-B8V6K8WY.js +25 -0
- package/dist/assets/worker-BjLAp2qA.js +25 -0
- package/dist/assets/worker-Cz7k4ET0.js +25 -0
- package/dist/{composables-TkULFBg4.js → components-DGm07xAo.js} +8229 -10761
- package/dist/src/components/AppBar/AppBar.vue.d.ts +34 -91
- package/dist/src/components/AppTemplates/AppWrapper.vue.d.ts +1 -9
- package/dist/src/components/AppTopBar.vue.d.ts +3 -11
- package/dist/src/components/Avatars/AvatarUpload.vue.d.ts +0 -1
- package/dist/src/components/Avatars/UserAvatar.vue.d.ts +1 -9
- package/dist/src/components/ContextActions/ActionMenuDropItem.vue.d.ts +1 -9
- package/dist/src/components/ContextActions/ContextActionMenu.vue.d.ts +9 -27
- package/dist/src/components/ContextActions/ContextMenuQuickAction.vue.d.ts +30 -134
- package/dist/src/components/CreateLinkModal.vue.d.ts +6 -14
- package/dist/src/components/CreateShortcutModal.vue.d.ts +34 -142
- package/dist/src/components/CustomComponentTarget.vue.d.ts +1 -9
- package/dist/src/components/FilesList/ContextActions.vue.d.ts +9 -27
- package/dist/src/components/FilesList/ResourceGhostElement.vue.d.ts +7 -17
- package/dist/src/components/FilesList/ResourceIcon.vue.d.ts +1 -9
- package/dist/src/components/FilesList/ResourceListItem.vue.d.ts +5 -12
- package/dist/src/components/FilesList/ResourceName.vue.d.ts +3 -9
- package/dist/src/components/FilesList/ResourceStatusIndicators.vue.d.ts +1 -9
- package/dist/src/components/FilesList/ResourceTable.vue.d.ts +8 -16
- package/dist/src/components/FilesList/ResourceTile.vue.d.ts +6 -14
- package/dist/src/components/FilesList/ResourceTiles.vue.d.ts +7 -15
- package/dist/src/components/Filters/DateFilter.vue.d.ts +5 -13
- package/dist/src/components/ImageCropper.vue.d.ts +12 -0
- package/dist/src/components/ItemFilter.vue.d.ts +5 -13
- package/dist/src/components/NoContentMessage.vue.d.ts +1 -9
- package/dist/src/components/Search/ResourcePreview.vue.d.ts +1 -9
- package/dist/src/components/SideBar/CompareSaveDialog.vue.d.ts +1 -1
- package/dist/src/components/SideBar/FileSideBar.vue.d.ts +1 -9
- package/dist/src/components/SideBar/Files/FileInfo.vue.d.ts +1 -9
- package/dist/src/components/SideBar/SideBar.vue.d.ts +5 -13
- package/dist/src/components/SideBar/SideBarPanels.vue.d.ts +6 -14
- package/dist/src/components/SideBar/Spaces/Details/SpaceDetails.vue.d.ts +1 -9
- package/dist/src/components/SideBar/Spaces/Details/SpaceDetailsMultiple.vue.d.ts +1 -9
- package/dist/src/components/SideBar/Spaces/SpaceInfo.vue.d.ts +5 -1
- package/dist/src/components/SpaceQuota.vue.d.ts +1 -9
- package/dist/src/components/Spaces/QuotaModal.vue.d.ts +3 -11
- package/dist/src/components/Spaces/SpaceImageModal.vue.d.ts +2 -11
- package/dist/src/components/ViewOptions.vue.d.ts +1 -9
- package/dist/src/components/index.d.ts +0 -2
- package/dist/src/composables/actions/files/index.d.ts +0 -21
- package/dist/src/composables/actions/spaces/index.d.ts +0 -12
- package/dist/src/composables/actions/types.d.ts +93 -2
- package/dist/src/composables/breadcrumbs/useBreadcrumbsFromPath.d.ts +1 -3
- package/dist/src/composables/driveResolver/useDriveResolver.d.ts +0 -1
- package/dist/src/composables/keyboardActions/useCropperKeyboardActions.d.ts +2 -1
- package/dist/src/composables/keyboardActions/useKeyboardActions.d.ts +1 -0
- package/dist/src/composables/piniaStores/auth.d.ts +24 -2
- package/dist/src/composables/piniaStores/avatars.d.ts +3 -3
- package/dist/src/composables/piniaStores/config/config.d.ts +1 -91
- package/dist/src/composables/piniaStores/config/types.d.ts +0 -20
- package/dist/src/composables/piniaStores/extensionRegistry/extensionRegistry.d.ts +4 -1
- package/dist/src/composables/piniaStores/messages.d.ts +12 -594
- package/dist/src/composables/piniaStores/spaces.d.ts +1 -3
- package/dist/src/composables/piniaStores/theme.d.ts +1 -1
- package/dist/src/composables/resources/useResourceViewDrag.d.ts +7 -17
- package/dist/src/composables/resources/useResourceViewHelpers.d.ts +7 -17
- package/dist/src/composables/router/useFileRouteReplace.d.ts +0 -2
- package/dist/src/composables/spaces/useGetMatchingSpace.d.ts +0 -4
- package/dist/src/editor/components/SlashCommandMenu.vue.d.ts +9 -0
- package/dist/src/editor/components/TextEditorContent.vue.d.ts +7 -0
- package/dist/src/editor/components/TextEditorProvider.vue.d.ts +17 -0
- package/dist/src/editor/composables/index.d.ts +3 -0
- package/dist/src/editor/composables/strategies/html.d.ts +3 -0
- package/dist/src/editor/composables/strategies/index.d.ts +5 -0
- package/dist/src/editor/composables/strategies/markdown.d.ts +3 -0
- package/dist/src/editor/composables/strategies/plainText.d.ts +3 -0
- package/dist/src/editor/composables/strategies/tiptapJson.d.ts +3 -0
- package/dist/src/editor/composables/strategies/types.d.ts +10 -0
- package/dist/src/editor/composables/useContentStrategy.d.ts +5 -0
- package/dist/src/editor/composables/useEditorActions.d.ts +75 -0
- package/dist/src/editor/composables/useTextEditor.d.ts +2 -0
- package/dist/src/editor/extensions/index.d.ts +1 -0
- package/dist/src/editor/extensions/slashCommands.d.ts +16 -0
- package/dist/src/editor/index.d.ts +5 -0
- package/dist/src/editor/types.d.ts +29 -0
- package/dist/src/helpers/groupwareResponse.d.ts +1 -0
- package/dist/src/helpers/index.d.ts +2 -0
- package/dist/src/helpers/router/routeOptions.d.ts +1 -7
- package/dist/src/helpers/virtualCursorElement.d.ts +1 -0
- package/dist/src/router/index.d.ts +2 -1
- package/dist/src/router/utils.d.ts +1 -6
- package/dist/src/types.d.ts +1 -0
- package/dist/src/utils/dummyGettext.d.ts +6 -0
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/web-pkg/editor.js +1360 -0
- package/dist/web-pkg.js +2956 -1661
- package/package.json +26 -9
- package/dist/TextEditor-B0ZZfO_w.js +0 -819
- package/dist/assets/worker-C-Nrpmiq.js +0 -24
- package/dist/assets/worker-CzI1mBNb.js +0 -24
- package/dist/assets/worker-DDmV-och.js +0 -24
- package/dist/src/components/Navigation/index.d.ts +0 -1
- package/dist/src/components/TextEditor/TextEditor.vue.d.ts +0 -26
- package/dist/src/components/TextEditor/index.d.ts +0 -39
- package/dist/src/components/TextEditor/l18n.d.ts +0 -3
- package/dist/src/composables/actions/files/useFileActionsCopy.d.ts +0 -4
- package/dist/src/composables/actions/files/useFileActionsCopyPermanentLink.d.ts +0 -4
- package/dist/src/composables/actions/files/useFileActionsCreateLink.d.ts +0 -6
- package/dist/src/composables/actions/files/useFileActionsCreateNewFile.d.ts +0 -10
- package/dist/src/composables/actions/files/useFileActionsCreateNewFolder.d.ts +0 -9
- package/dist/src/composables/actions/files/useFileActionsCreateNewShortcut.d.ts +0 -8
- package/dist/src/composables/actions/files/useFileActionsCreateSpaceFromResource.d.ts +0 -4
- package/dist/src/composables/actions/files/useFileActionsDisableSync.d.ts +0 -5
- package/dist/src/composables/actions/files/useFileActionsDownloadArchive.d.ts +0 -4
- package/dist/src/composables/actions/files/useFileActionsEmptyTrashBin.d.ts +0 -8
- package/dist/src/composables/actions/files/useFileActionsEnableSync.d.ts +0 -5
- package/dist/src/composables/actions/files/useFileActionsFavorite.d.ts +0 -4
- package/dist/src/composables/actions/files/useFileActionsMove.d.ts +0 -4
- package/dist/src/composables/actions/files/useFileActionsOpenShortcut.d.ts +0 -5
- package/dist/src/composables/actions/files/useFileActionsPaste.d.ts +0 -4
- package/dist/src/composables/actions/files/useFileActionsRename.d.ts +0 -6
- package/dist/src/composables/actions/files/useFileActionsSetImage.d.ts +0 -4
- package/dist/src/composables/actions/files/useFileActionsShowActions.d.ts +0 -4
- package/dist/src/composables/actions/files/useFileActionsShowDetails.d.ts +0 -4
- package/dist/src/composables/actions/files/useFileActionsShowShares.d.ts +0 -5
- package/dist/src/composables/actions/files/useFileActionsToggleHideShare.d.ts +0 -5
- package/dist/src/composables/actions/spaces/useSpaceActionsDelete.d.ts +0 -6
- package/dist/src/composables/actions/spaces/useSpaceActionsDeleteImage.d.ts +0 -8
- package/dist/src/composables/actions/spaces/useSpaceActionsDisable.d.ts +0 -6
- package/dist/src/composables/actions/spaces/useSpaceActionsDuplicate.d.ts +0 -6
- package/dist/src/composables/actions/spaces/useSpaceActionsEditDescription.d.ts +0 -6
- package/dist/src/composables/actions/spaces/useSpaceActionsEditQuota.d.ts +0 -4
- package/dist/src/composables/actions/spaces/useSpaceActionsEditReadmeContent.d.ts +0 -4
- package/dist/src/composables/actions/spaces/useSpaceActionsNavigateToTrash.d.ts +0 -4
- package/dist/src/composables/actions/spaces/useSpaceActionsRename.d.ts +0 -6
- package/dist/src/composables/actions/spaces/useSpaceActionsRestore.d.ts +0 -6
- package/dist/src/composables/actions/spaces/useSpaceActionsSetIcon.d.ts +0 -6
- package/dist/src/composables/actions/spaces/useSpaceActionsShowMembers.d.ts +0 -4
- /package/dist/src/{components/Navigation/MobileNav.vue.d.ts → editor/components/TextEditorToolbar.vue.d.ts} +0 -0
|
@@ -0,0 +1,1360 @@
|
|
|
1
|
+
import { Aa as e, Ba as t, Ea as n, Ia as r, Ja as i, La as a, Na as o, Oa as s, Pa as c, Ra as l, Sa as u, Ta as d, Ua as f, Va as p, Xa as m, Ya as h, ba as g, ca as _, eo as v, ga as y, ha as b, ja as x, no as S, o as C, pn as w, qa as T, va as E, xa as D, ya as O, za as k } from "../components-DGm07xAo.js";
|
|
2
|
+
import { useGettext as A } from "vue3-gettext";
|
|
3
|
+
import { EditorContent as j, VueRenderer as M, useEditor as N } from "@tiptap/vue-3";
|
|
4
|
+
import { Extension as P } from "@tiptap/core";
|
|
5
|
+
import F from "@tiptap/suggestion";
|
|
6
|
+
import I from "@tiptap/starter-kit";
|
|
7
|
+
import L from "@tiptap/extension-underline";
|
|
8
|
+
import R from "@tiptap/extension-link";
|
|
9
|
+
import z from "@tiptap/extension-image";
|
|
10
|
+
import { Table as B, TableCell as V, TableHeader as H, TableRow as U } from "@tiptap/extension-table";
|
|
11
|
+
import W from "@tiptap/extension-task-list";
|
|
12
|
+
import G from "@tiptap/extension-task-item";
|
|
13
|
+
import { BackgroundColor as K, Color as q, FontFamily as J, FontSize as Y, LineHeight as X, TextStyle as Z } from "@tiptap/extension-text-style";
|
|
14
|
+
import { Markdown as Q } from "@tiptap/markdown";
|
|
15
|
+
import ee from "@tiptap/extension-document";
|
|
16
|
+
import te from "@tiptap/extension-paragraph";
|
|
17
|
+
import ne from "@tiptap/extension-text";
|
|
18
|
+
import re from "@tiptap/extension-hard-break";
|
|
19
|
+
//#region src/editor/components/SlashCommandMenu.vue?vue&type=script&setup=true&lang.ts
|
|
20
|
+
var ie = { class: "text-editor-slash-menu" }, ae = ["textContent"], oe = { class: "text-editor-slash-menu__item-text" }, se = ["textContent"], ce = ["textContent"], le = {
|
|
21
|
+
key: 1,
|
|
22
|
+
class: "text-editor-slash-menu__empty"
|
|
23
|
+
}, ue = /* @__PURE__ */ n({
|
|
24
|
+
__name: "SlashCommandMenu",
|
|
25
|
+
props: {
|
|
26
|
+
editor: {},
|
|
27
|
+
range: {},
|
|
28
|
+
query: {},
|
|
29
|
+
text: {},
|
|
30
|
+
items: {},
|
|
31
|
+
command: { type: Function },
|
|
32
|
+
decorationNode: {},
|
|
33
|
+
clientRect: { type: [Function, null] }
|
|
34
|
+
},
|
|
35
|
+
setup(n, { expose: a }) {
|
|
36
|
+
let o = n, s = T("dropRef"), p = v(0);
|
|
37
|
+
i(() => o.items, () => {
|
|
38
|
+
p.value = 0;
|
|
39
|
+
});
|
|
40
|
+
let m = E(() => {
|
|
41
|
+
let e = [], t = null;
|
|
42
|
+
return o.items.forEach((n, r) => {
|
|
43
|
+
(!t || t.id !== n.groupId) && (t = {
|
|
44
|
+
id: n.groupId,
|
|
45
|
+
title: n.groupTitle,
|
|
46
|
+
entries: []
|
|
47
|
+
}, e.push(t)), t.entries.push({
|
|
48
|
+
item: n,
|
|
49
|
+
index: r
|
|
50
|
+
});
|
|
51
|
+
}), e;
|
|
52
|
+
}), _ = (e) => {
|
|
53
|
+
o.command(e);
|
|
54
|
+
}, b = (e) => {
|
|
55
|
+
let t = o.items.length;
|
|
56
|
+
if (t === 0) return !1;
|
|
57
|
+
switch (e.key) {
|
|
58
|
+
case "ArrowDown": return e.preventDefault(), p.value = (p.value + 1) % t, !0;
|
|
59
|
+
case "ArrowUp": return e.preventDefault(), p.value = (p.value - 1 + t) % t, !0;
|
|
60
|
+
case "Enter": return e.preventDefault(), _(o.items[p.value]), !0;
|
|
61
|
+
default: return !1;
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
i(p, async () => {
|
|
65
|
+
await e(), (s.value?.$el?.querySelector(".text-editor-slash-menu__item--selected"))?.scrollIntoView({ block: "nearest" });
|
|
66
|
+
});
|
|
67
|
+
let w = () => {
|
|
68
|
+
s.value?.update?.({ anchorElement: k() });
|
|
69
|
+
}, k = () => {
|
|
70
|
+
let e = o.clientRect?.();
|
|
71
|
+
return e ? { getBoundingClientRect: () => e } : null;
|
|
72
|
+
};
|
|
73
|
+
return c(async () => {
|
|
74
|
+
await e(), s.value?.show?.({
|
|
75
|
+
anchorElement: k(),
|
|
76
|
+
noFocus: !0
|
|
77
|
+
});
|
|
78
|
+
}), a({
|
|
79
|
+
onUpdate: w,
|
|
80
|
+
onKeyDown: b
|
|
81
|
+
}), (e, n) => {
|
|
82
|
+
let i = t("oc-icon"), a = t("oc-button");
|
|
83
|
+
return r(), g(S(C), {
|
|
84
|
+
ref_key: "dropRef",
|
|
85
|
+
ref: s,
|
|
86
|
+
mode: "manual",
|
|
87
|
+
"padding-size": "small",
|
|
88
|
+
class: "z-10001",
|
|
89
|
+
"enforce-drop-on-mobile": ""
|
|
90
|
+
}, {
|
|
91
|
+
default: h(() => [O("div", ie, [m.value.length ? (r(!0), u(y, { key: 0 }, l(m.value, (e) => (r(), u("div", {
|
|
92
|
+
key: e.id,
|
|
93
|
+
class: "text-editor-slash-menu__group"
|
|
94
|
+
}, [O("div", {
|
|
95
|
+
class: "text-editor-slash-menu__group-title",
|
|
96
|
+
textContent: f(e.title)
|
|
97
|
+
}, null, 8, ae), O("ul", null, [(r(!0), u(y, null, l(e.entries, (e) => (r(), u("li", { key: `slash-command-item-${e.item.id}` }, [d(a, {
|
|
98
|
+
appearance: "raw",
|
|
99
|
+
class: x(["text-editor-slash-menu__item", { "text-editor-slash-menu__item--selected": e.index === p.value }]),
|
|
100
|
+
onClick: (t) => _(e.item)
|
|
101
|
+
}, {
|
|
102
|
+
default: h(() => [e.item.icon ? (r(), g(i, {
|
|
103
|
+
key: 0,
|
|
104
|
+
name: e.item.icon,
|
|
105
|
+
"fill-type": e.item.iconFillType || "none",
|
|
106
|
+
size: "small",
|
|
107
|
+
class: "text-editor-slash-menu__item-icon"
|
|
108
|
+
}, null, 8, ["name", "fill-type"])) : D("", !0), O("span", oe, [O("span", {
|
|
109
|
+
class: "text-editor-slash-menu__item-title",
|
|
110
|
+
textContent: f(e.item.title)
|
|
111
|
+
}, null, 8, se), e.item.description ? (r(), u("span", {
|
|
112
|
+
key: 0,
|
|
113
|
+
class: "text-editor-slash-menu__item-description",
|
|
114
|
+
textContent: f(e.item.description)
|
|
115
|
+
}, null, 8, ce)) : D("", !0)])]),
|
|
116
|
+
_: 2
|
|
117
|
+
}, 1032, ["class", "onClick"])]))), 128))])]))), 128)) : (r(), u("div", le, f(e.$gettext("No matching commands")), 1))])]),
|
|
118
|
+
_: 1
|
|
119
|
+
}, 512);
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
//#endregion
|
|
124
|
+
//#region src/editor/extensions/slashCommands.ts
|
|
125
|
+
function de(e, t, n) {
|
|
126
|
+
let r = t.trim().toLowerCase(), i = [];
|
|
127
|
+
for (let t of e) for (let e of t.actions) if (!(e.showInSlashCommands === !1 || e.isEnabled && !e.isEnabled(n))) {
|
|
128
|
+
if (!r) {
|
|
129
|
+
i.push({
|
|
130
|
+
...e,
|
|
131
|
+
groupId: t.id,
|
|
132
|
+
groupTitle: t.title
|
|
133
|
+
});
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
[
|
|
137
|
+
e.title,
|
|
138
|
+
e.description ?? "",
|
|
139
|
+
...e.keywords ?? []
|
|
140
|
+
].join(" ").toLowerCase().includes(r) && i.push({
|
|
141
|
+
...e,
|
|
142
|
+
groupId: t.id,
|
|
143
|
+
groupTitle: t.title
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
return i;
|
|
147
|
+
}
|
|
148
|
+
var fe = P.create({
|
|
149
|
+
name: "slashCommands",
|
|
150
|
+
addOptions() {
|
|
151
|
+
return { getGroups: () => [] };
|
|
152
|
+
},
|
|
153
|
+
addProseMirrorPlugins() {
|
|
154
|
+
return [F({
|
|
155
|
+
editor: this.editor,
|
|
156
|
+
char: "/",
|
|
157
|
+
startOfLine: !1,
|
|
158
|
+
items: ({ query: e, editor: t }) => de(this.options.getGroups(), e, t),
|
|
159
|
+
command: ({ editor: e, range: t, props: n }) => {
|
|
160
|
+
n.slashCommandAction({
|
|
161
|
+
editor: e,
|
|
162
|
+
range: t
|
|
163
|
+
});
|
|
164
|
+
},
|
|
165
|
+
render: () => {
|
|
166
|
+
let e = null, t = () => e?.ref ?? null;
|
|
167
|
+
return {
|
|
168
|
+
onStart: (t) => {
|
|
169
|
+
e = new M(ue, {
|
|
170
|
+
props: t,
|
|
171
|
+
editor: t.editor
|
|
172
|
+
}), e.el && document.body.appendChild(e.el);
|
|
173
|
+
},
|
|
174
|
+
onUpdate: (n) => {
|
|
175
|
+
e?.updateProps(n), t()?.onUpdate(n);
|
|
176
|
+
},
|
|
177
|
+
onKeyDown: (e) => t()?.onKeyDown(e.event) ?? !1,
|
|
178
|
+
onExit: () => {
|
|
179
|
+
e?.el?.remove(), e?.destroy(), e = null;
|
|
180
|
+
}
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
})];
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
//#endregion
|
|
187
|
+
//#region src/editor/composables/useEditorActions.ts
|
|
188
|
+
function $(e, t = {}) {
|
|
189
|
+
let { $gettext: n } = A(), { dispatchModal: r } = w(), i = () => ({
|
|
190
|
+
id: "undo",
|
|
191
|
+
title: n("Undo"),
|
|
192
|
+
icon: "arrow-go-back",
|
|
193
|
+
iconFillType: "line",
|
|
194
|
+
toolbarAction: (e) => e.chain().focus().undo().run(),
|
|
195
|
+
isEnabled: (e) => e.can().undo(),
|
|
196
|
+
showInSlashCommands: !1
|
|
197
|
+
}), a = () => ({
|
|
198
|
+
id: "redo",
|
|
199
|
+
title: n("Redo"),
|
|
200
|
+
icon: "arrow-go-forward",
|
|
201
|
+
iconFillType: "line",
|
|
202
|
+
toolbarAction: (e) => e.chain().focus().redo().run(),
|
|
203
|
+
isEnabled: (e) => e.can().redo(),
|
|
204
|
+
showInSlashCommands: !1
|
|
205
|
+
}), o = () => ({
|
|
206
|
+
id: "source-mode",
|
|
207
|
+
title: n("Show source"),
|
|
208
|
+
icon: "code-s-slash",
|
|
209
|
+
iconFillType: "line",
|
|
210
|
+
toolbarAction: () => e.sourceMode.value = !e.sourceMode.value,
|
|
211
|
+
isActive: () => e.sourceMode.value,
|
|
212
|
+
showInSlashCommands: !1
|
|
213
|
+
}), s = () => ({
|
|
214
|
+
id: "font-size",
|
|
215
|
+
title: n("Font size"),
|
|
216
|
+
icon: "font-size-2",
|
|
217
|
+
showInSlashCommands: !1,
|
|
218
|
+
childActions: [
|
|
219
|
+
"12px",
|
|
220
|
+
"14px",
|
|
221
|
+
"16px",
|
|
222
|
+
"18px",
|
|
223
|
+
"20px",
|
|
224
|
+
"24px",
|
|
225
|
+
"28px",
|
|
226
|
+
"32px"
|
|
227
|
+
].map((e) => ({
|
|
228
|
+
id: `font-size-${e}`,
|
|
229
|
+
title: e,
|
|
230
|
+
icon: "font-size-2",
|
|
231
|
+
toolbarAction: (t) => t.chain().focus().setFontSize(e).run(),
|
|
232
|
+
isActive: (t) => t.getAttributes("textStyle").fontSize === e
|
|
233
|
+
}))
|
|
234
|
+
}), c = () => ({
|
|
235
|
+
id: "text-color",
|
|
236
|
+
title: n("Text color"),
|
|
237
|
+
icon: "font-color",
|
|
238
|
+
showInSlashCommands: !1,
|
|
239
|
+
childActions: [
|
|
240
|
+
{
|
|
241
|
+
value: "#000000",
|
|
242
|
+
label: n("Black")
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
value: "#e60000",
|
|
246
|
+
label: n("Red")
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
value: "#ff9900",
|
|
250
|
+
label: n("Orange")
|
|
251
|
+
},
|
|
252
|
+
{
|
|
253
|
+
value: "#ffff00",
|
|
254
|
+
label: n("Yellow")
|
|
255
|
+
},
|
|
256
|
+
{
|
|
257
|
+
value: "#008a00",
|
|
258
|
+
label: n("Green")
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
value: "#0066cc",
|
|
262
|
+
label: n("Blue")
|
|
263
|
+
},
|
|
264
|
+
{
|
|
265
|
+
value: "#9933ff",
|
|
266
|
+
label: n("Purple")
|
|
267
|
+
},
|
|
268
|
+
{
|
|
269
|
+
value: "#ffffff",
|
|
270
|
+
label: n("White")
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
value: "#facccc",
|
|
274
|
+
label: n("Light red")
|
|
275
|
+
},
|
|
276
|
+
{
|
|
277
|
+
value: "#ffebcc",
|
|
278
|
+
label: n("Light orange")
|
|
279
|
+
},
|
|
280
|
+
{
|
|
281
|
+
value: "#ffffcc",
|
|
282
|
+
label: n("Light yellow")
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
value: "#cce8cc",
|
|
286
|
+
label: n("Light green")
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
value: "#cce0f5",
|
|
290
|
+
label: n("Light blue")
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
value: "#ebd6ff",
|
|
294
|
+
label: n("Light purple")
|
|
295
|
+
}
|
|
296
|
+
].map(({ value: e, label: t }) => ({
|
|
297
|
+
id: `text-color-${e.replace("#", "")}`,
|
|
298
|
+
title: t,
|
|
299
|
+
icon: "font-color",
|
|
300
|
+
toolbarAction: (t) => t.chain().focus().setColor(e).run(),
|
|
301
|
+
isActive: (t) => t.getAttributes("textStyle").color === e
|
|
302
|
+
}))
|
|
303
|
+
}), l = () => ({
|
|
304
|
+
id: "background-color",
|
|
305
|
+
title: n("Background color"),
|
|
306
|
+
icon: "mark-pen",
|
|
307
|
+
iconFillType: "line",
|
|
308
|
+
showInSlashCommands: !1,
|
|
309
|
+
childActions: [
|
|
310
|
+
{
|
|
311
|
+
value: "transparent",
|
|
312
|
+
label: n("None")
|
|
313
|
+
},
|
|
314
|
+
{
|
|
315
|
+
value: "#facccc",
|
|
316
|
+
label: n("Light red")
|
|
317
|
+
},
|
|
318
|
+
{
|
|
319
|
+
value: "#ffebcc",
|
|
320
|
+
label: n("Light orange")
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
value: "#ffffcc",
|
|
324
|
+
label: n("Light yellow")
|
|
325
|
+
},
|
|
326
|
+
{
|
|
327
|
+
value: "#cce8cc",
|
|
328
|
+
label: n("Light green")
|
|
329
|
+
},
|
|
330
|
+
{
|
|
331
|
+
value: "#cce0f5",
|
|
332
|
+
label: n("Light blue")
|
|
333
|
+
},
|
|
334
|
+
{
|
|
335
|
+
value: "#ebd6ff",
|
|
336
|
+
label: n("Light purple")
|
|
337
|
+
},
|
|
338
|
+
{
|
|
339
|
+
value: "#e60000",
|
|
340
|
+
label: n("Red")
|
|
341
|
+
},
|
|
342
|
+
{
|
|
343
|
+
value: "#ff9900",
|
|
344
|
+
label: n("Orange")
|
|
345
|
+
},
|
|
346
|
+
{
|
|
347
|
+
value: "#ffff00",
|
|
348
|
+
label: n("Yellow")
|
|
349
|
+
},
|
|
350
|
+
{
|
|
351
|
+
value: "#008a00",
|
|
352
|
+
label: n("Green")
|
|
353
|
+
},
|
|
354
|
+
{
|
|
355
|
+
value: "#0066cc",
|
|
356
|
+
label: n("Blue")
|
|
357
|
+
},
|
|
358
|
+
{
|
|
359
|
+
value: "#9933ff",
|
|
360
|
+
label: n("Purple")
|
|
361
|
+
},
|
|
362
|
+
{
|
|
363
|
+
value: "#000000",
|
|
364
|
+
label: n("Black")
|
|
365
|
+
}
|
|
366
|
+
].map(({ value: e, label: t }) => ({
|
|
367
|
+
id: `background-color-${e.replace("#", "")}`,
|
|
368
|
+
title: t,
|
|
369
|
+
icon: "mark-pen",
|
|
370
|
+
iconFillType: "line",
|
|
371
|
+
toolbarAction: (t) => t.chain().focus().setBackgroundColor(e).run(),
|
|
372
|
+
isActive: (t) => t.getAttributes("textStyle").backgroundColor === e
|
|
373
|
+
}))
|
|
374
|
+
}), u = () => ({
|
|
375
|
+
id: "bold",
|
|
376
|
+
title: n("Bold"),
|
|
377
|
+
icon: "bold",
|
|
378
|
+
toolbarAction: (e) => e.chain().focus().toggleBold().run(),
|
|
379
|
+
slashCommandAction: ({ editor: e, range: t }) => e.chain().focus().deleteRange(t).toggleBold().run(),
|
|
380
|
+
isActive: (e) => e.isActive("bold")
|
|
381
|
+
}), d = () => ({
|
|
382
|
+
id: "italic",
|
|
383
|
+
title: n("Italic"),
|
|
384
|
+
icon: "italic",
|
|
385
|
+
toolbarAction: (e) => e.chain().focus().toggleItalic().run(),
|
|
386
|
+
slashCommandAction: ({ editor: e, range: t }) => e.chain().focus().deleteRange(t).toggleItalic().run(),
|
|
387
|
+
isActive: (e) => e.isActive("italic")
|
|
388
|
+
}), f = () => ({
|
|
389
|
+
id: "underline",
|
|
390
|
+
title: n("Underline"),
|
|
391
|
+
icon: "underline",
|
|
392
|
+
toolbarAction: (e) => e.chain().focus().toggleUnderline().run(),
|
|
393
|
+
slashCommandAction: ({ editor: e, range: t }) => e.chain().focus().deleteRange(t).toggleUnderline().run(),
|
|
394
|
+
isActive: (e) => e.isActive("underline")
|
|
395
|
+
}), p = () => ({
|
|
396
|
+
id: "strikethrough",
|
|
397
|
+
title: n("Strikethrough"),
|
|
398
|
+
icon: "strikethrough",
|
|
399
|
+
toolbarAction: (e) => e.chain().focus().toggleStrike().run(),
|
|
400
|
+
slashCommandAction: ({ editor: e, range: t }) => e.chain().focus().deleteRange(t).toggleStrike().run(),
|
|
401
|
+
isActive: (e) => e.isActive("strike")
|
|
402
|
+
}), m = () => ({
|
|
403
|
+
id: "code-inline",
|
|
404
|
+
title: n("Inline code"),
|
|
405
|
+
icon: "code-line",
|
|
406
|
+
toolbarAction: (e) => e.chain().focus().toggleCode().run(),
|
|
407
|
+
slashCommandAction: ({ editor: e, range: t }) => e.chain().focus().deleteRange(t).toggleCode().run(),
|
|
408
|
+
isActive: (e) => e.isActive("code")
|
|
409
|
+
}), h = () => ({
|
|
410
|
+
id: "heading",
|
|
411
|
+
title: n("Heading"),
|
|
412
|
+
icon: "heading",
|
|
413
|
+
activeIcon: (e) => {
|
|
414
|
+
for (let t of [
|
|
415
|
+
1,
|
|
416
|
+
2,
|
|
417
|
+
3,
|
|
418
|
+
4
|
|
419
|
+
]) if (e.isActive("heading", { level: t })) return { icon: `h-${t}` };
|
|
420
|
+
},
|
|
421
|
+
isActive: (e) => e.isActive("heading"),
|
|
422
|
+
showInSlashCommands: !1,
|
|
423
|
+
childActions: [
|
|
424
|
+
g(),
|
|
425
|
+
_(),
|
|
426
|
+
v(),
|
|
427
|
+
y()
|
|
428
|
+
]
|
|
429
|
+
}), g = () => ({
|
|
430
|
+
id: "heading-1",
|
|
431
|
+
title: n("Heading 1"),
|
|
432
|
+
description: n("Large section heading"),
|
|
433
|
+
icon: "h-1",
|
|
434
|
+
keywords: ["h1", "title"],
|
|
435
|
+
toolbarAction: (e) => e.chain().focus().toggleHeading({ level: 1 }).run(),
|
|
436
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
437
|
+
e.chain().focus().deleteRange(t).setNode("heading", { level: 1 }).run();
|
|
438
|
+
},
|
|
439
|
+
isActive: (e) => e.isActive("heading", { level: 1 }),
|
|
440
|
+
showInToolbar: !1
|
|
441
|
+
}), _ = () => ({
|
|
442
|
+
id: "heading-2",
|
|
443
|
+
title: n("Heading 2"),
|
|
444
|
+
description: n("Medium section heading"),
|
|
445
|
+
icon: "h-2",
|
|
446
|
+
keywords: ["h2", "subtitle"],
|
|
447
|
+
toolbarAction: (e) => e.chain().focus().toggleHeading({ level: 2 }).run(),
|
|
448
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
449
|
+
e.chain().focus().deleteRange(t).setNode("heading", { level: 2 }).run();
|
|
450
|
+
},
|
|
451
|
+
isActive: (e) => e.isActive("heading", { level: 2 }),
|
|
452
|
+
showInToolbar: !1
|
|
453
|
+
}), v = () => ({
|
|
454
|
+
id: "heading-3",
|
|
455
|
+
title: n("Heading 3"),
|
|
456
|
+
description: n("Small section heading"),
|
|
457
|
+
icon: "h-3",
|
|
458
|
+
keywords: ["h3"],
|
|
459
|
+
toolbarAction: (e) => e.chain().focus().toggleHeading({ level: 3 }).run(),
|
|
460
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
461
|
+
e.chain().focus().deleteRange(t).setNode("heading", { level: 3 }).run();
|
|
462
|
+
},
|
|
463
|
+
isActive: (e) => e.isActive("heading", { level: 3 }),
|
|
464
|
+
showInToolbar: !1
|
|
465
|
+
}), y = () => ({
|
|
466
|
+
id: "heading-4",
|
|
467
|
+
title: n("Heading 4"),
|
|
468
|
+
description: n("Extra small section heading"),
|
|
469
|
+
icon: "h-4",
|
|
470
|
+
keywords: ["h4"],
|
|
471
|
+
toolbarAction: (e) => e.chain().focus().toggleHeading({ level: 4 }).run(),
|
|
472
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
473
|
+
e.chain().focus().deleteRange(t).setNode("heading", { level: 4 }).run();
|
|
474
|
+
},
|
|
475
|
+
isActive: (e) => e.isActive("heading", { level: 4 }),
|
|
476
|
+
showInToolbar: !1
|
|
477
|
+
}), b = () => ({
|
|
478
|
+
id: "line-height",
|
|
479
|
+
title: n("Line height"),
|
|
480
|
+
icon: "line-height",
|
|
481
|
+
showInSlashCommands: !1,
|
|
482
|
+
childActions: [
|
|
483
|
+
"1",
|
|
484
|
+
"1.15",
|
|
485
|
+
"1.5",
|
|
486
|
+
"1.75",
|
|
487
|
+
"2",
|
|
488
|
+
"2.5",
|
|
489
|
+
"3"
|
|
490
|
+
].map((e) => ({
|
|
491
|
+
id: `line-height-${e}`,
|
|
492
|
+
title: e,
|
|
493
|
+
icon: "line-height",
|
|
494
|
+
toolbarAction: (t) => t.chain().focus().setLineHeight(e).run(),
|
|
495
|
+
isActive: (t) => t.getAttributes("textStyle").lineHeight === e
|
|
496
|
+
}))
|
|
497
|
+
}), x = () => ({
|
|
498
|
+
id: "blockquote",
|
|
499
|
+
title: n("Blockquote"),
|
|
500
|
+
description: n("Quote block"),
|
|
501
|
+
icon: "chat-quote-line",
|
|
502
|
+
keywords: ["quote"],
|
|
503
|
+
toolbarAction: (e) => e.chain().focus().toggleBlockquote().run(),
|
|
504
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
505
|
+
e.chain().focus().deleteRange(t).toggleBlockquote().run();
|
|
506
|
+
},
|
|
507
|
+
isActive: (e) => e.isActive("blockquote")
|
|
508
|
+
}), C = () => ({
|
|
509
|
+
id: "code-block",
|
|
510
|
+
title: n("Code block"),
|
|
511
|
+
description: n("Preformatted code block"),
|
|
512
|
+
icon: "code-box-line",
|
|
513
|
+
keywords: ["code", "pre"],
|
|
514
|
+
toolbarAction: (e) => e.chain().focus().toggleCodeBlock().run(),
|
|
515
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
516
|
+
e.chain().focus().deleteRange(t).toggleCodeBlock().run();
|
|
517
|
+
},
|
|
518
|
+
isActive: (e) => e.isActive("codeBlock")
|
|
519
|
+
}), T = () => ({
|
|
520
|
+
id: "bullet-list",
|
|
521
|
+
title: n("Bullet list"),
|
|
522
|
+
description: n("Unordered list of items"),
|
|
523
|
+
icon: "list-unordered",
|
|
524
|
+
keywords: ["ul", "unordered"],
|
|
525
|
+
toolbarAction: (e) => e.chain().focus().toggleBulletList().run(),
|
|
526
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
527
|
+
e.chain().focus().deleteRange(t).toggleBulletList().run();
|
|
528
|
+
},
|
|
529
|
+
isActive: (e) => e.isActive("bulletList")
|
|
530
|
+
}), E = () => ({
|
|
531
|
+
id: "ordered-list",
|
|
532
|
+
title: n("Ordered list"),
|
|
533
|
+
description: n("Numbered list of items"),
|
|
534
|
+
icon: "list-ordered-2",
|
|
535
|
+
keywords: ["ol", "numbered"],
|
|
536
|
+
toolbarAction: (e) => e.chain().focus().toggleOrderedList().run(),
|
|
537
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
538
|
+
e.chain().focus().deleteRange(t).toggleOrderedList().run();
|
|
539
|
+
},
|
|
540
|
+
isActive: (e) => e.isActive("orderedList")
|
|
541
|
+
}), D = () => ({
|
|
542
|
+
id: "task-list",
|
|
543
|
+
title: n("Task list"),
|
|
544
|
+
description: n("List with checkable items"),
|
|
545
|
+
icon: "list-check-3",
|
|
546
|
+
keywords: ["todo", "checklist"],
|
|
547
|
+
toolbarAction: (e) => e.chain().focus().toggleTaskList().run(),
|
|
548
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
549
|
+
e.chain().focus().deleteRange(t).toggleTaskList().run();
|
|
550
|
+
},
|
|
551
|
+
isActive: (e) => e.isActive("taskList")
|
|
552
|
+
}), O = () => ({
|
|
553
|
+
id: "link",
|
|
554
|
+
title: n("Link"),
|
|
555
|
+
icon: "link",
|
|
556
|
+
toolbarAction: (e) => {
|
|
557
|
+
let n = S(t);
|
|
558
|
+
if (n.onRequestLinkUrl) {
|
|
559
|
+
let t = e.getAttributes("link").href;
|
|
560
|
+
n.onRequestLinkUrl(e, t);
|
|
561
|
+
}
|
|
562
|
+
},
|
|
563
|
+
isActive: (e) => e.isActive("link"),
|
|
564
|
+
showInSlashCommands: !1
|
|
565
|
+
}), k = (e) => {
|
|
566
|
+
r({
|
|
567
|
+
title: n("Insert image from URL"),
|
|
568
|
+
hasInput: !0,
|
|
569
|
+
inputLabel: n("Image URL"),
|
|
570
|
+
confirmText: n("Insert"),
|
|
571
|
+
inputRequiredMark: !0,
|
|
572
|
+
onInput: (e, t) => {
|
|
573
|
+
let r = e.trim();
|
|
574
|
+
if (r && !/^https?:\/\//i.test(r)) {
|
|
575
|
+
t(n("URL must start with http:// or https://"));
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
t(null);
|
|
579
|
+
},
|
|
580
|
+
onConfirm: (t) => {
|
|
581
|
+
let n = t.trim();
|
|
582
|
+
!n || !/^https?:\/\//i.test(n) || e.chain().focus().setImage({ src: n }).run();
|
|
583
|
+
}
|
|
584
|
+
});
|
|
585
|
+
}, j = () => ({
|
|
586
|
+
id: "image-url",
|
|
587
|
+
title: n("Image from URL"),
|
|
588
|
+
description: n("Insert an image from a web URL"),
|
|
589
|
+
icon: "link-line",
|
|
590
|
+
keywords: [
|
|
591
|
+
"image",
|
|
592
|
+
"picture",
|
|
593
|
+
"url"
|
|
594
|
+
],
|
|
595
|
+
showInToolbar: !1,
|
|
596
|
+
toolbarAction: (e) => k(e),
|
|
597
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
598
|
+
e.chain().focus().deleteRange(t).run(), k(e);
|
|
599
|
+
},
|
|
600
|
+
isActive: () => !1
|
|
601
|
+
}), M = () => ({
|
|
602
|
+
id: "image-upload",
|
|
603
|
+
title: n("Image from file"),
|
|
604
|
+
description: n("Upload an image from your device"),
|
|
605
|
+
icon: "image-line",
|
|
606
|
+
keywords: [
|
|
607
|
+
"image",
|
|
608
|
+
"picture",
|
|
609
|
+
"upload",
|
|
610
|
+
"file"
|
|
611
|
+
],
|
|
612
|
+
showInToolbar: !1,
|
|
613
|
+
showInSlashCommands: !0,
|
|
614
|
+
toolbarAction: (e) => P(e),
|
|
615
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
616
|
+
e.chain().focus().deleteRange(t).run(), P(e);
|
|
617
|
+
},
|
|
618
|
+
isActive: () => !1
|
|
619
|
+
}), N = () => ({
|
|
620
|
+
id: "image",
|
|
621
|
+
title: n("Insert image"),
|
|
622
|
+
icon: "image-line",
|
|
623
|
+
keywords: [
|
|
624
|
+
"image",
|
|
625
|
+
"picture",
|
|
626
|
+
"upload",
|
|
627
|
+
"url"
|
|
628
|
+
],
|
|
629
|
+
showInSlashCommands: !1,
|
|
630
|
+
childActions: [M(), j()],
|
|
631
|
+
isActive: () => !1
|
|
632
|
+
}), P = (e) => {
|
|
633
|
+
let t = document.createElement("input");
|
|
634
|
+
t.type = "file", t.accept = "image/*", t.addEventListener("change", () => {
|
|
635
|
+
let n = t.files?.[0];
|
|
636
|
+
if (!n || !n.type.startsWith("image/") || n.size > 5242880) return;
|
|
637
|
+
let r = new FileReader();
|
|
638
|
+
r.addEventListener("load", () => {
|
|
639
|
+
let t = r.result;
|
|
640
|
+
e.chain().focus().setImage({ src: t }).run();
|
|
641
|
+
}), r.readAsDataURL(n);
|
|
642
|
+
}), t.click();
|
|
643
|
+
}, F = () => ({
|
|
644
|
+
id: "horizontal-rule",
|
|
645
|
+
title: n("Horizontal rule"),
|
|
646
|
+
description: n("Divider line"),
|
|
647
|
+
icon: "separator",
|
|
648
|
+
keywords: ["hr", "divider"],
|
|
649
|
+
toolbarAction: (e) => e.chain().focus().setHorizontalRule().run(),
|
|
650
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
651
|
+
e.chain().focus().deleteRange(t).setHorizontalRule().run();
|
|
652
|
+
},
|
|
653
|
+
isActive: () => !1
|
|
654
|
+
}), I = () => ({
|
|
655
|
+
id: "table",
|
|
656
|
+
title: n("Create a table"),
|
|
657
|
+
description: n("3×3 table with header row"),
|
|
658
|
+
icon: "table-line",
|
|
659
|
+
keywords: ["grid"],
|
|
660
|
+
showInToolbar: !1,
|
|
661
|
+
toolbarAction: (e) => e.chain().focus().insertTable({
|
|
662
|
+
rows: 3,
|
|
663
|
+
cols: 3,
|
|
664
|
+
withHeaderRow: !0
|
|
665
|
+
}).run(),
|
|
666
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
667
|
+
e.chain().focus().deleteRange(t).insertTable({
|
|
668
|
+
rows: 3,
|
|
669
|
+
cols: 3,
|
|
670
|
+
withHeaderRow: !0
|
|
671
|
+
}).run();
|
|
672
|
+
},
|
|
673
|
+
isActive: () => !1
|
|
674
|
+
}), L = () => ({
|
|
675
|
+
id: "add-row-before",
|
|
676
|
+
title: n("Add row above"),
|
|
677
|
+
description: n("Insert row before current"),
|
|
678
|
+
icon: "insert-row-top",
|
|
679
|
+
keywords: [
|
|
680
|
+
"table",
|
|
681
|
+
"row",
|
|
682
|
+
"above",
|
|
683
|
+
"before"
|
|
684
|
+
],
|
|
685
|
+
showInToolbar: !1,
|
|
686
|
+
toolbarAction: (e) => e.chain().focus().addRowBefore().run(),
|
|
687
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
688
|
+
e.chain().focus().deleteRange(t).addRowBefore().run();
|
|
689
|
+
},
|
|
690
|
+
isActive: () => !1,
|
|
691
|
+
isEnabled: (e) => e.isActive("table")
|
|
692
|
+
}), R = () => ({
|
|
693
|
+
id: "add-row-after",
|
|
694
|
+
title: n("Add row below"),
|
|
695
|
+
description: n("Insert row after current"),
|
|
696
|
+
icon: "insert-row-bottom",
|
|
697
|
+
keywords: [
|
|
698
|
+
"table",
|
|
699
|
+
"row",
|
|
700
|
+
"below",
|
|
701
|
+
"after"
|
|
702
|
+
],
|
|
703
|
+
showInToolbar: !1,
|
|
704
|
+
toolbarAction: (e) => e.chain().focus().addRowAfter().run(),
|
|
705
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
706
|
+
e.chain().focus().deleteRange(t).addRowAfter().run();
|
|
707
|
+
},
|
|
708
|
+
isActive: () => !1,
|
|
709
|
+
isEnabled: (e) => e.isActive("table")
|
|
710
|
+
}), z = () => ({
|
|
711
|
+
id: "delete-row",
|
|
712
|
+
title: n("Delete row"),
|
|
713
|
+
description: n("Remove current row"),
|
|
714
|
+
icon: "delete-row",
|
|
715
|
+
keywords: [
|
|
716
|
+
"table",
|
|
717
|
+
"row",
|
|
718
|
+
"remove"
|
|
719
|
+
],
|
|
720
|
+
showInToolbar: !1,
|
|
721
|
+
toolbarAction: (e) => {
|
|
722
|
+
!e.chain().focus().deleteRow().run() && e.isActive("table") && e.chain().focus().deleteTable().run();
|
|
723
|
+
},
|
|
724
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
725
|
+
!e.chain().focus().deleteRange(t).deleteRow().run() && e.isActive("table") && e.chain().focus().deleteTable().run();
|
|
726
|
+
},
|
|
727
|
+
isActive: () => !1,
|
|
728
|
+
isEnabled: (e) => e.isActive("table")
|
|
729
|
+
}), B = () => ({
|
|
730
|
+
id: "add-column-before",
|
|
731
|
+
title: n("Add column left"),
|
|
732
|
+
description: n("Insert column before current"),
|
|
733
|
+
icon: "insert-column-left",
|
|
734
|
+
keywords: [
|
|
735
|
+
"table",
|
|
736
|
+
"column",
|
|
737
|
+
"left",
|
|
738
|
+
"before"
|
|
739
|
+
],
|
|
740
|
+
showInToolbar: !1,
|
|
741
|
+
toolbarAction: (e) => e.chain().focus().addColumnBefore().run(),
|
|
742
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
743
|
+
e.chain().focus().deleteRange(t).addColumnBefore().run();
|
|
744
|
+
},
|
|
745
|
+
isActive: () => !1,
|
|
746
|
+
isEnabled: (e) => e.isActive("table")
|
|
747
|
+
}), V = () => ({
|
|
748
|
+
id: "add-column-after",
|
|
749
|
+
title: n("Add column right"),
|
|
750
|
+
description: n("Insert column after current"),
|
|
751
|
+
icon: "insert-column-right",
|
|
752
|
+
keywords: [
|
|
753
|
+
"table",
|
|
754
|
+
"column",
|
|
755
|
+
"right",
|
|
756
|
+
"after"
|
|
757
|
+
],
|
|
758
|
+
showInToolbar: !1,
|
|
759
|
+
toolbarAction: (e) => e.chain().focus().addColumnAfter().run(),
|
|
760
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
761
|
+
e.chain().focus().deleteRange(t).addColumnAfter().run();
|
|
762
|
+
},
|
|
763
|
+
isActive: () => !1,
|
|
764
|
+
isEnabled: (e) => e.isActive("table")
|
|
765
|
+
}), H = () => ({
|
|
766
|
+
id: "delete-column",
|
|
767
|
+
title: n("Delete column"),
|
|
768
|
+
description: n("Remove current column"),
|
|
769
|
+
icon: "delete-column",
|
|
770
|
+
keywords: [
|
|
771
|
+
"table",
|
|
772
|
+
"column",
|
|
773
|
+
"remove"
|
|
774
|
+
],
|
|
775
|
+
showInToolbar: !1,
|
|
776
|
+
toolbarAction: (e) => {
|
|
777
|
+
!e.chain().focus().deleteColumn().run() && e.isActive("table") && e.chain().focus().deleteTable().run();
|
|
778
|
+
},
|
|
779
|
+
slashCommandAction: ({ editor: e, range: t }) => {
|
|
780
|
+
!e.chain().focus().deleteRange(t).deleteColumn().run() && e.isActive("table") && e.chain().focus().deleteTable().run();
|
|
781
|
+
},
|
|
782
|
+
isActive: () => !1,
|
|
783
|
+
isEnabled: (e) => e.isActive("table")
|
|
784
|
+
});
|
|
785
|
+
return {
|
|
786
|
+
undo: i,
|
|
787
|
+
redo: a,
|
|
788
|
+
toggleSourceMode: o,
|
|
789
|
+
heading: h,
|
|
790
|
+
heading1: g,
|
|
791
|
+
heading2: _,
|
|
792
|
+
heading3: v,
|
|
793
|
+
heading4: y,
|
|
794
|
+
fontSize: s,
|
|
795
|
+
textColor: c,
|
|
796
|
+
backgroundColor: l,
|
|
797
|
+
bold: u,
|
|
798
|
+
italic: d,
|
|
799
|
+
underline: f,
|
|
800
|
+
strikethrough: p,
|
|
801
|
+
codeInline: m,
|
|
802
|
+
lineHeight: b,
|
|
803
|
+
blockquote: x,
|
|
804
|
+
codeBlock: C,
|
|
805
|
+
bulletList: T,
|
|
806
|
+
orderedList: E,
|
|
807
|
+
taskList: D,
|
|
808
|
+
link: O,
|
|
809
|
+
image: N,
|
|
810
|
+
imageUrl: j,
|
|
811
|
+
imageUpload: M,
|
|
812
|
+
horizontalRule: F,
|
|
813
|
+
tableMenu: () => ({
|
|
814
|
+
id: "table-menu",
|
|
815
|
+
title: n("Table"),
|
|
816
|
+
icon: "table-line",
|
|
817
|
+
showInSlashCommands: !1,
|
|
818
|
+
childActions: [
|
|
819
|
+
I(),
|
|
820
|
+
L(),
|
|
821
|
+
R(),
|
|
822
|
+
z(),
|
|
823
|
+
B(),
|
|
824
|
+
V(),
|
|
825
|
+
H()
|
|
826
|
+
]
|
|
827
|
+
}),
|
|
828
|
+
createTable: I,
|
|
829
|
+
addRowBefore: L,
|
|
830
|
+
addRowAfter: R,
|
|
831
|
+
deleteRow: z,
|
|
832
|
+
addColumnBefore: B,
|
|
833
|
+
addColumnAfter: V,
|
|
834
|
+
deleteColumn: H
|
|
835
|
+
};
|
|
836
|
+
}
|
|
837
|
+
//#endregion
|
|
838
|
+
//#region src/editor/composables/strategies/html.ts
|
|
839
|
+
var pe = (e) => {
|
|
840
|
+
let { $gettext: t } = A(), n = () => "html", r = (e) => e.getHTML(), i = (e) => e, a = () => [
|
|
841
|
+
I.configure({ link: !1 }),
|
|
842
|
+
R.configure({
|
|
843
|
+
openOnClick: !0,
|
|
844
|
+
autolink: !0,
|
|
845
|
+
linkOnPaste: !0,
|
|
846
|
+
HTMLAttributes: {
|
|
847
|
+
target: "_blank",
|
|
848
|
+
rel: "noopener noreferrer"
|
|
849
|
+
}
|
|
850
|
+
}),
|
|
851
|
+
z.configure({ inline: !1 }),
|
|
852
|
+
B.configure({ resizable: !1 }),
|
|
853
|
+
U,
|
|
854
|
+
V,
|
|
855
|
+
H,
|
|
856
|
+
W,
|
|
857
|
+
G.configure({ nested: !0 }),
|
|
858
|
+
J,
|
|
859
|
+
Z,
|
|
860
|
+
L,
|
|
861
|
+
q,
|
|
862
|
+
K,
|
|
863
|
+
Y,
|
|
864
|
+
X
|
|
865
|
+
], { undo: o, redo: s, fontSize: c, lineHeight: l, backgroundColor: u, textColor: d, bold: f, italic: p, underline: m, strikethrough: h, heading: g, heading1: _, heading2: v, heading3: y, heading4: b, bulletList: x, orderedList: S, taskList: C, blockquote: w, codeBlock: T, horizontalRule: E, tableMenu: D, createTable: O, addRowBefore: k, addRowAfter: j, deleteRow: M, addColumnBefore: N, addColumnAfter: P, deleteColumn: F } = $(e);
|
|
866
|
+
return {
|
|
867
|
+
editorContentType: n,
|
|
868
|
+
serialize: r,
|
|
869
|
+
deserialize: i,
|
|
870
|
+
extensions: a,
|
|
871
|
+
editorActionGroups: () => [
|
|
872
|
+
{
|
|
873
|
+
id: "history",
|
|
874
|
+
title: t("History"),
|
|
875
|
+
actions: [o(), s()]
|
|
876
|
+
},
|
|
877
|
+
{
|
|
878
|
+
id: "formatting",
|
|
879
|
+
title: t("Formatting"),
|
|
880
|
+
actions: [
|
|
881
|
+
g(),
|
|
882
|
+
_(),
|
|
883
|
+
v(),
|
|
884
|
+
y(),
|
|
885
|
+
b(),
|
|
886
|
+
c(),
|
|
887
|
+
l(),
|
|
888
|
+
u(),
|
|
889
|
+
d(),
|
|
890
|
+
f(),
|
|
891
|
+
p(),
|
|
892
|
+
m(),
|
|
893
|
+
h()
|
|
894
|
+
]
|
|
895
|
+
},
|
|
896
|
+
{
|
|
897
|
+
id: "lists",
|
|
898
|
+
title: t("Lists"),
|
|
899
|
+
actions: [
|
|
900
|
+
x(),
|
|
901
|
+
S(),
|
|
902
|
+
C()
|
|
903
|
+
]
|
|
904
|
+
},
|
|
905
|
+
{
|
|
906
|
+
id: "blocks",
|
|
907
|
+
title: t("Blocks"),
|
|
908
|
+
actions: [w(), T()]
|
|
909
|
+
},
|
|
910
|
+
{
|
|
911
|
+
id: "insert",
|
|
912
|
+
title: t("Insert"),
|
|
913
|
+
actions: [
|
|
914
|
+
D(),
|
|
915
|
+
O(),
|
|
916
|
+
P(),
|
|
917
|
+
N(),
|
|
918
|
+
j(),
|
|
919
|
+
k(),
|
|
920
|
+
F(),
|
|
921
|
+
M(),
|
|
922
|
+
E()
|
|
923
|
+
]
|
|
924
|
+
}
|
|
925
|
+
]
|
|
926
|
+
};
|
|
927
|
+
}, me = (e) => {
|
|
928
|
+
let { $gettext: t } = A(), n = () => "markdown", r = (e) => e.getMarkdown(), i = (e) => e, a = () => [
|
|
929
|
+
I.configure({ link: !1 }),
|
|
930
|
+
Q,
|
|
931
|
+
R.configure({
|
|
932
|
+
openOnClick: !0,
|
|
933
|
+
autolink: !0,
|
|
934
|
+
linkOnPaste: !0,
|
|
935
|
+
HTMLAttributes: {
|
|
936
|
+
target: "_blank",
|
|
937
|
+
rel: "noopener noreferrer"
|
|
938
|
+
}
|
|
939
|
+
}),
|
|
940
|
+
B.configure({ resizable: !1 }),
|
|
941
|
+
U,
|
|
942
|
+
V,
|
|
943
|
+
H,
|
|
944
|
+
W,
|
|
945
|
+
G.configure({ nested: !0 }),
|
|
946
|
+
z.configure({ inline: !1 })
|
|
947
|
+
], { undo: o, redo: s, toggleSourceMode: c, bold: l, italic: u, strikethrough: d, heading: f, heading1: p, heading2: m, heading3: h, heading4: g, bulletList: _, orderedList: v, taskList: y, blockquote: b, codeBlock: x, horizontalRule: S, image: C, imageUrl: w, imageUpload: T, tableMenu: E, createTable: D, addRowBefore: O, addRowAfter: k, deleteRow: j, addColumnBefore: M, addColumnAfter: N, deleteColumn: P } = $(e);
|
|
948
|
+
return {
|
|
949
|
+
editorContentType: n,
|
|
950
|
+
serialize: r,
|
|
951
|
+
deserialize: i,
|
|
952
|
+
extensions: a,
|
|
953
|
+
editorActionGroups: () => [
|
|
954
|
+
{
|
|
955
|
+
id: "history",
|
|
956
|
+
title: t("History"),
|
|
957
|
+
actions: [o(), s()]
|
|
958
|
+
},
|
|
959
|
+
{
|
|
960
|
+
id: "view-options",
|
|
961
|
+
title: t("View options"),
|
|
962
|
+
actions: [c()]
|
|
963
|
+
},
|
|
964
|
+
{
|
|
965
|
+
id: "formatting",
|
|
966
|
+
title: t("Formatting"),
|
|
967
|
+
actions: [
|
|
968
|
+
f(),
|
|
969
|
+
p(),
|
|
970
|
+
m(),
|
|
971
|
+
h(),
|
|
972
|
+
g(),
|
|
973
|
+
l(),
|
|
974
|
+
u(),
|
|
975
|
+
d()
|
|
976
|
+
]
|
|
977
|
+
},
|
|
978
|
+
{
|
|
979
|
+
id: "lists",
|
|
980
|
+
title: t("Lists"),
|
|
981
|
+
actions: [
|
|
982
|
+
_(),
|
|
983
|
+
v(),
|
|
984
|
+
y()
|
|
985
|
+
]
|
|
986
|
+
},
|
|
987
|
+
{
|
|
988
|
+
id: "blocks",
|
|
989
|
+
title: t("Blocks"),
|
|
990
|
+
actions: [b(), x()]
|
|
991
|
+
},
|
|
992
|
+
{
|
|
993
|
+
id: "insert",
|
|
994
|
+
title: t("Insert"),
|
|
995
|
+
actions: [
|
|
996
|
+
C(),
|
|
997
|
+
w(),
|
|
998
|
+
T(),
|
|
999
|
+
E(),
|
|
1000
|
+
D(),
|
|
1001
|
+
N(),
|
|
1002
|
+
M(),
|
|
1003
|
+
k(),
|
|
1004
|
+
O(),
|
|
1005
|
+
P(),
|
|
1006
|
+
j(),
|
|
1007
|
+
S()
|
|
1008
|
+
]
|
|
1009
|
+
}
|
|
1010
|
+
]
|
|
1011
|
+
};
|
|
1012
|
+
}, he = (e) => ({
|
|
1013
|
+
editorContentType: () => "plainText",
|
|
1014
|
+
serialize: (e) => e.getText(),
|
|
1015
|
+
deserialize: (e) => e ? {
|
|
1016
|
+
type: "doc",
|
|
1017
|
+
content: e.split("\n").map((e) => e ? {
|
|
1018
|
+
type: "paragraph",
|
|
1019
|
+
content: [{
|
|
1020
|
+
type: "text",
|
|
1021
|
+
text: e
|
|
1022
|
+
}]
|
|
1023
|
+
} : { type: "paragraph" })
|
|
1024
|
+
} : {
|
|
1025
|
+
type: "doc",
|
|
1026
|
+
content: [{ type: "paragraph" }]
|
|
1027
|
+
},
|
|
1028
|
+
extensions: () => [
|
|
1029
|
+
ee,
|
|
1030
|
+
te,
|
|
1031
|
+
ne,
|
|
1032
|
+
re
|
|
1033
|
+
],
|
|
1034
|
+
editorActionGroups: () => []
|
|
1035
|
+
}), ge = (e) => {
|
|
1036
|
+
let { $gettext: t } = A(), n = () => "json", r = (e) => JSON.stringify(e.getJSON()), i = (e) => JSON.parse(e), a = () => [
|
|
1037
|
+
I.configure({ link: !1 }),
|
|
1038
|
+
R.configure({
|
|
1039
|
+
openOnClick: !0,
|
|
1040
|
+
autolink: !0,
|
|
1041
|
+
linkOnPaste: !0,
|
|
1042
|
+
HTMLAttributes: {
|
|
1043
|
+
target: "_blank",
|
|
1044
|
+
rel: "noopener noreferrer"
|
|
1045
|
+
}
|
|
1046
|
+
}),
|
|
1047
|
+
z.configure({ inline: !1 }),
|
|
1048
|
+
B.configure({ resizable: !1 }),
|
|
1049
|
+
U,
|
|
1050
|
+
V,
|
|
1051
|
+
H,
|
|
1052
|
+
W,
|
|
1053
|
+
G.configure({ nested: !0 }),
|
|
1054
|
+
J,
|
|
1055
|
+
Z,
|
|
1056
|
+
L,
|
|
1057
|
+
q,
|
|
1058
|
+
K,
|
|
1059
|
+
Y,
|
|
1060
|
+
X
|
|
1061
|
+
], { undo: o, redo: s, fontSize: c, lineHeight: l, backgroundColor: u, textColor: d, bold: f, italic: p, underline: m, strikethrough: h, heading: g, heading1: _, heading2: v, heading3: y, heading4: b, bulletList: x, orderedList: S, taskList: C, blockquote: w, codeBlock: T, horizontalRule: E, image: D, imageUrl: O, imageUpload: k, tableMenu: j, createTable: M, addRowBefore: N, addRowAfter: P, deleteRow: F, addColumnBefore: Q, addColumnAfter: ee, deleteColumn: te } = $(e);
|
|
1062
|
+
return {
|
|
1063
|
+
editorContentType: n,
|
|
1064
|
+
serialize: r,
|
|
1065
|
+
deserialize: i,
|
|
1066
|
+
extensions: a,
|
|
1067
|
+
editorActionGroups: () => [
|
|
1068
|
+
{
|
|
1069
|
+
id: "history",
|
|
1070
|
+
title: t("History"),
|
|
1071
|
+
actions: [o(), s()]
|
|
1072
|
+
},
|
|
1073
|
+
{
|
|
1074
|
+
id: "formatting",
|
|
1075
|
+
title: t("Formatting"),
|
|
1076
|
+
actions: [
|
|
1077
|
+
g(),
|
|
1078
|
+
_(),
|
|
1079
|
+
v(),
|
|
1080
|
+
y(),
|
|
1081
|
+
b(),
|
|
1082
|
+
c(),
|
|
1083
|
+
u(),
|
|
1084
|
+
d(),
|
|
1085
|
+
f(),
|
|
1086
|
+
p(),
|
|
1087
|
+
m(),
|
|
1088
|
+
h()
|
|
1089
|
+
]
|
|
1090
|
+
},
|
|
1091
|
+
{
|
|
1092
|
+
id: "lists",
|
|
1093
|
+
title: t("Lists"),
|
|
1094
|
+
actions: [
|
|
1095
|
+
x(),
|
|
1096
|
+
S(),
|
|
1097
|
+
C()
|
|
1098
|
+
]
|
|
1099
|
+
},
|
|
1100
|
+
{
|
|
1101
|
+
id: "blocks",
|
|
1102
|
+
title: t("Blocks"),
|
|
1103
|
+
actions: [
|
|
1104
|
+
l(),
|
|
1105
|
+
w(),
|
|
1106
|
+
T()
|
|
1107
|
+
]
|
|
1108
|
+
},
|
|
1109
|
+
{
|
|
1110
|
+
id: "insert",
|
|
1111
|
+
title: t("Insert"),
|
|
1112
|
+
actions: [
|
|
1113
|
+
D(),
|
|
1114
|
+
O(),
|
|
1115
|
+
k(),
|
|
1116
|
+
j(),
|
|
1117
|
+
M(),
|
|
1118
|
+
ee(),
|
|
1119
|
+
Q(),
|
|
1120
|
+
P(),
|
|
1121
|
+
N(),
|
|
1122
|
+
te(),
|
|
1123
|
+
F(),
|
|
1124
|
+
E()
|
|
1125
|
+
]
|
|
1126
|
+
}
|
|
1127
|
+
]
|
|
1128
|
+
};
|
|
1129
|
+
}, _e = () => ({ resolveStrategy: (e, t) => {
|
|
1130
|
+
switch (e) {
|
|
1131
|
+
case "plain-text": return he(t);
|
|
1132
|
+
case "markdown": return me(t);
|
|
1133
|
+
case "html": return pe(t);
|
|
1134
|
+
case "tiptap-json": return ge(t);
|
|
1135
|
+
default: throw Error(`Unknown content type: ${e}`);
|
|
1136
|
+
}
|
|
1137
|
+
} });
|
|
1138
|
+
//#endregion
|
|
1139
|
+
//#region src/editor/composables/useTextEditor.ts
|
|
1140
|
+
function ve(e) {
|
|
1141
|
+
let { resolveStrategy: t } = _e(), n = { sourceMode: v(!1) }, r = v(e.contentType), a = v(e.readonly ?? !1), s = t(e.contentType, n), l = null, u = s.extensions();
|
|
1142
|
+
if (e.slashCommands !== !1) {
|
|
1143
|
+
let e = s.editorActionGroups();
|
|
1144
|
+
e.length > 0 && u.push(fe.configure({ getGroups: () => e }));
|
|
1145
|
+
}
|
|
1146
|
+
let d = {
|
|
1147
|
+
extensions: u,
|
|
1148
|
+
content: S(e.modelValue) ? s.deserialize(S(e.modelValue)) : "",
|
|
1149
|
+
editable: !a.value
|
|
1150
|
+
};
|
|
1151
|
+
i(e.modelValue, (e) => {
|
|
1152
|
+
!S(f) || S(f).options.editable || m(e);
|
|
1153
|
+
}), s.editorContentType && (d.contentType = s.editorContentType());
|
|
1154
|
+
let f = N({
|
|
1155
|
+
...d,
|
|
1156
|
+
onUpdate({ editor: t }) {
|
|
1157
|
+
e.onUpdate && (l && clearTimeout(l), l = setTimeout(() => {
|
|
1158
|
+
e.onUpdate(s.serialize(t));
|
|
1159
|
+
}, 250));
|
|
1160
|
+
}
|
|
1161
|
+
});
|
|
1162
|
+
i(a, (e) => {
|
|
1163
|
+
f.value?.setEditable(!e);
|
|
1164
|
+
});
|
|
1165
|
+
let p = () => f.value ? s.serialize(f.value) : "", m = (e) => {
|
|
1166
|
+
if (!f.value) return;
|
|
1167
|
+
let t = s.deserialize(e), n = { emitUpdate: !1 };
|
|
1168
|
+
s.editorContentType && (n.contentType = s.editorContentType()), f.value.commands.setContent(t, n);
|
|
1169
|
+
}, h = E(() => f.value?.isEmpty ?? !0), g = E(() => f.value?.isFocused ?? !1), _ = () => {
|
|
1170
|
+
f.value?.commands.focus("start");
|
|
1171
|
+
}, y = () => {
|
|
1172
|
+
f.value?.commands.blur();
|
|
1173
|
+
}, b = () => {
|
|
1174
|
+
l &&= (clearTimeout(l), e.onUpdate && f.value && e.onUpdate(s.serialize(f.value)), null), f.value?.destroy(), f.value = null;
|
|
1175
|
+
};
|
|
1176
|
+
return c(() => {
|
|
1177
|
+
S(a) || _();
|
|
1178
|
+
}), o(() => {
|
|
1179
|
+
b();
|
|
1180
|
+
}), {
|
|
1181
|
+
state: n,
|
|
1182
|
+
editor: f,
|
|
1183
|
+
contentType: r,
|
|
1184
|
+
readonly: a,
|
|
1185
|
+
actionGroups: s.editorActionGroups,
|
|
1186
|
+
getContent: p,
|
|
1187
|
+
isEmpty: h,
|
|
1188
|
+
isFocused: g,
|
|
1189
|
+
focus: _,
|
|
1190
|
+
blur: y,
|
|
1191
|
+
destroy: b
|
|
1192
|
+
};
|
|
1193
|
+
}
|
|
1194
|
+
//#endregion
|
|
1195
|
+
//#region src/editor/components/TextEditorProvider.vue?vue&type=script&setup=true&lang.ts
|
|
1196
|
+
var ye = { class: "text-editor-provider h-full flex flex-col" }, be = /* @__PURE__ */ n({
|
|
1197
|
+
__name: "TextEditorProvider",
|
|
1198
|
+
props: { editor: {} },
|
|
1199
|
+
setup(e) {
|
|
1200
|
+
return a("textEditor", e.editor), (e, t) => (r(), u("div", ye, [k(e.$slots, "default")]));
|
|
1201
|
+
}
|
|
1202
|
+
}), xe = /* @__PURE__ */ n({
|
|
1203
|
+
__name: "TextEditorContent",
|
|
1204
|
+
props: { editor: { default: () => void 0 } },
|
|
1205
|
+
setup(e) {
|
|
1206
|
+
let t = e.editor || s("textEditor"), n = E(() => S(t.contentType) === "markdown" && S(t.state.sourceMode));
|
|
1207
|
+
return (e, i) => S(t).editor.value ? (r(), g(S(j), {
|
|
1208
|
+
key: 0,
|
|
1209
|
+
class: x(["text-editor-content", { "markdown-source-mode": n.value }]),
|
|
1210
|
+
editor: S(t).editor.value
|
|
1211
|
+
}, null, 8, ["class", "editor"])) : D("", !0);
|
|
1212
|
+
}
|
|
1213
|
+
}), Se = {
|
|
1214
|
+
key: 0,
|
|
1215
|
+
class: "text-editor-toolbar relative border-b border-b-role-border py-1"
|
|
1216
|
+
}, Ce = { class: "oc-list" }, we = { class: "inline-flex items-center gap-2" }, Te = {
|
|
1217
|
+
key: 0,
|
|
1218
|
+
class: "pointer-events-none absolute inset-y-0 left-0 w-8 bg-gradient-to-r from-black/15 to-transparent"
|
|
1219
|
+
}, Ee = {
|
|
1220
|
+
key: 1,
|
|
1221
|
+
class: "pointer-events-none absolute inset-y-0 right-0 w-8 bg-gradient-to-l from-black/15 to-transparent"
|
|
1222
|
+
}, De = /* @__PURE__ */ _(/* @__PURE__ */ n({
|
|
1223
|
+
__name: "TextEditorToolbar",
|
|
1224
|
+
setup(n) {
|
|
1225
|
+
let a = s("textEditor"), o = T("scrollContainer"), _ = v(!1), C = v(!1), w = () => {
|
|
1226
|
+
let e = o.value;
|
|
1227
|
+
if (!e) {
|
|
1228
|
+
_.value = !1, C.value = !1;
|
|
1229
|
+
return;
|
|
1230
|
+
}
|
|
1231
|
+
_.value = e.scrollLeft > 0, C.value = e.scrollLeft + e.clientWidth < e.scrollWidth - 1;
|
|
1232
|
+
};
|
|
1233
|
+
c(async () => {
|
|
1234
|
+
await e(), w();
|
|
1235
|
+
});
|
|
1236
|
+
let k = E(() => S(a.readonly) || S(a.contentType) === "plain-text" ? !1 : !!S(a.editor)), A = v(0);
|
|
1237
|
+
i(() => S(a.editor), (e, t) => {
|
|
1238
|
+
t && (t.off("selectionUpdate", j), t.off("transaction", j)), e && (e.on("selectionUpdate", j), e.on("transaction", j));
|
|
1239
|
+
}, { immediate: !0 });
|
|
1240
|
+
let j = () => {
|
|
1241
|
+
A.value++;
|
|
1242
|
+
}, M = (e) => {
|
|
1243
|
+
A.value;
|
|
1244
|
+
let t = S(a.editor);
|
|
1245
|
+
return t ? e.isEnabled ? e.isEnabled(t) : !0 : !1;
|
|
1246
|
+
}, N = (e) => {
|
|
1247
|
+
A.value;
|
|
1248
|
+
let t = S(a.editor);
|
|
1249
|
+
return t && e.isActive ? e.isActive(t) : !1;
|
|
1250
|
+
}, P = (e) => {
|
|
1251
|
+
A.value;
|
|
1252
|
+
let t = S(a.editor);
|
|
1253
|
+
if (t && e.activeIcon) {
|
|
1254
|
+
let n = e.activeIcon(t);
|
|
1255
|
+
if (n) return n;
|
|
1256
|
+
}
|
|
1257
|
+
return {
|
|
1258
|
+
icon: e.icon,
|
|
1259
|
+
iconFillType: e.iconFillType
|
|
1260
|
+
};
|
|
1261
|
+
};
|
|
1262
|
+
return (e, n) => {
|
|
1263
|
+
let i = t("oc-icon"), o = t("oc-button"), s = t("oc-drop"), c = p("oc-tooltip");
|
|
1264
|
+
return k.value ? (r(), u("div", Se, [
|
|
1265
|
+
O("div", {
|
|
1266
|
+
ref: "scrollContainer",
|
|
1267
|
+
class: "flex items-center gap-1 overflow-x-auto before:grow after:grow",
|
|
1268
|
+
onScroll: w
|
|
1269
|
+
}, [(r(!0), u(y, null, l(S(a).actionGroups(), (e, t) => (r(), u("div", {
|
|
1270
|
+
key: `toolbar-group-${e.id}`,
|
|
1271
|
+
class: x(["text-editor-toolbar-group inline-flex items-stretch", { "border-l border-l-role-border pl-1": t > 0 }])
|
|
1272
|
+
}, [(r(!0), u(y, null, l(e.actions.filter((e) => e.showInToolbar !== !1), (e) => (r(), u(y, { key: `toolbar-item-${e.id}` }, [e.childActions ? (r(), u(y, { key: 0 }, [m((r(), g(o, {
|
|
1273
|
+
id: `toolbar-dropdown-trigger-${e.id}`,
|
|
1274
|
+
type: "button",
|
|
1275
|
+
appearance: "raw",
|
|
1276
|
+
class: x(["text-editor-toolbar-btn min-w-[52px] inline-flex items-center justify-center p-2", { "text-editor-toolbar-btn--active": N(e) }]),
|
|
1277
|
+
"aria-label": e.title
|
|
1278
|
+
}, {
|
|
1279
|
+
default: h(() => [d(i, {
|
|
1280
|
+
name: P(e).icon,
|
|
1281
|
+
"fill-type": P(e).iconFillType || "none",
|
|
1282
|
+
size: "small"
|
|
1283
|
+
}, null, 8, ["name", "fill-type"]), d(i, {
|
|
1284
|
+
name: "arrow-down-s",
|
|
1285
|
+
"fill-type": "line",
|
|
1286
|
+
size: "small"
|
|
1287
|
+
})]),
|
|
1288
|
+
_: 2
|
|
1289
|
+
}, 1032, [
|
|
1290
|
+
"id",
|
|
1291
|
+
"class",
|
|
1292
|
+
"aria-label"
|
|
1293
|
+
])), [[c, e.title]]), d(s, {
|
|
1294
|
+
"drop-id": `toolbar-dropdown-${e.id}`,
|
|
1295
|
+
toggle: `#toolbar-dropdown-trigger-${e.id}`,
|
|
1296
|
+
mode: "click",
|
|
1297
|
+
class: "text-editor-toolbar-dropdown w-auto min-w-40",
|
|
1298
|
+
"padding-size": "small",
|
|
1299
|
+
"close-on-click": ""
|
|
1300
|
+
}, {
|
|
1301
|
+
default: h(() => [O("ul", Ce, [(r(!0), u(y, null, l(e.childActions, (t) => (r(), u("li", {
|
|
1302
|
+
key: `${e.id}-${t.id}`,
|
|
1303
|
+
class: "oc-rounded oc-menu-item-hover"
|
|
1304
|
+
}, [d(o, {
|
|
1305
|
+
appearance: N(t) ? "filled" : "raw-inverse",
|
|
1306
|
+
"color-role": N(t) ? "secondaryContainer" : "surface",
|
|
1307
|
+
"no-hover": N(t),
|
|
1308
|
+
"justify-content": "space-between",
|
|
1309
|
+
class: "p-1",
|
|
1310
|
+
disabled: !M(t),
|
|
1311
|
+
onClick: (e) => t.toolbarAction?.(S(a).editor.value)
|
|
1312
|
+
}, {
|
|
1313
|
+
default: h(() => [O("span", we, [d(i, {
|
|
1314
|
+
name: t.icon,
|
|
1315
|
+
"fill-type": t.iconFillType || "none",
|
|
1316
|
+
size: "small"
|
|
1317
|
+
}, null, 8, ["name", "fill-type"]), O("span", null, f(t.title), 1)]), N(t) ? (r(), g(i, {
|
|
1318
|
+
key: 0,
|
|
1319
|
+
name: "check",
|
|
1320
|
+
"fill-type": "line",
|
|
1321
|
+
size: "small"
|
|
1322
|
+
})) : D("", !0)]),
|
|
1323
|
+
_: 2
|
|
1324
|
+
}, 1032, [
|
|
1325
|
+
"appearance",
|
|
1326
|
+
"color-role",
|
|
1327
|
+
"no-hover",
|
|
1328
|
+
"disabled",
|
|
1329
|
+
"onClick"
|
|
1330
|
+
])]))), 128))])]),
|
|
1331
|
+
_: 2
|
|
1332
|
+
}, 1032, ["drop-id", "toggle"])], 64)) : m((r(), g(o, {
|
|
1333
|
+
key: 1,
|
|
1334
|
+
type: "button",
|
|
1335
|
+
appearance: "raw",
|
|
1336
|
+
class: x(["text-editor-toolbar-btn min-w-[42px] inline-flex items-center justify-center p-2", { "text-editor-toolbar-btn--active": N(e) }]),
|
|
1337
|
+
"aria-label": e.title,
|
|
1338
|
+
disabled: !M(e),
|
|
1339
|
+
onClick: b((t) => e.toolbarAction?.(S(a).editor.value), ["stop"])
|
|
1340
|
+
}, {
|
|
1341
|
+
default: h(() => [d(i, {
|
|
1342
|
+
name: e.icon,
|
|
1343
|
+
"fill-type": e.iconFillType || "none",
|
|
1344
|
+
size: "small"
|
|
1345
|
+
}, null, 8, ["name", "fill-type"])]),
|
|
1346
|
+
_: 2
|
|
1347
|
+
}, 1032, [
|
|
1348
|
+
"class",
|
|
1349
|
+
"aria-label",
|
|
1350
|
+
"disabled",
|
|
1351
|
+
"onClick"
|
|
1352
|
+
])), [[c, e.title]])], 64))), 128))], 2))), 128))], 544),
|
|
1353
|
+
_.value ? (r(), u("div", Te)) : D("", !0),
|
|
1354
|
+
C.value ? (r(), u("div", Ee)) : D("", !0)
|
|
1355
|
+
])) : D("", !0);
|
|
1356
|
+
};
|
|
1357
|
+
}
|
|
1358
|
+
}), [["__scopeId", "data-v-5eabe917"]]);
|
|
1359
|
+
//#endregion
|
|
1360
|
+
export { xe as TextEditorContent, be as TextEditorProvider, De as TextEditorToolbar, ve as useTextEditor };
|