@editora/core 1.0.3 → 1.0.4
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 +34 -0
- package/dist/{A11yCheckerPlugin.native-CZKpi3uF.mjs → A11yCheckerPlugin.native-BRdGYMju.mjs} +225 -173
- package/dist/AnchorPlugin.native-C1Rw5m04.mjs +404 -0
- package/dist/BackgroundColorPlugin.native-BE-p9DRd.mjs +489 -0
- package/dist/ChecklistPlugin.native-nuSSEFNI.mjs +309 -0
- package/dist/ClearFormattingPlugin.native-Bq_XcTh2.mjs +140 -0
- package/dist/{CodePlugin.native-CK9d8rmt.mjs → CodePlugin.native-0Zari_zp.mjs} +329 -310
- package/dist/CodeSamplePlugin.native-B-KS1pOl.mjs +384 -0
- package/dist/CommentsPlugin.native-tMnWn8a2.mjs +723 -0
- package/dist/DirectionPlugin.native-CDnbdNyl.mjs +130 -0
- package/dist/{EmbedIframePlugin.native-ifr9KLdN.mjs → EmbedIframePlugin.native-CSWIB1jm.mjs} +154 -50
- package/dist/{EmojisPlugin.native-D6mJSnSR.mjs → EmojisPlugin.native-DxTm_DL-.mjs} +156 -103
- package/dist/FontFamilyPlugin.native-j8hMTbg4.mjs +158 -0
- package/dist/FontSizePlugin.native-B_jCh7dY.mjs +286 -0
- package/dist/FootnotePlugin.native-D730OGRm.mjs +425 -0
- package/dist/HistoryPlugin.native-DCrPdeSW.mjs +257 -0
- package/dist/IndentPlugin.native-BHixp8sP.mjs +150 -0
- package/dist/LineHeightPlugin.native-CM7iXdQj.mjs +151 -0
- package/dist/{LinkPlugin.native-BdAOV-iu.mjs → LinkPlugin.native-CS2g-G18.mjs} +128 -53
- package/dist/{ListPlugin.native-CLFU5AUQ.mjs → ListPlugin.native-V7EZC1lM.mjs} +59 -12
- package/dist/MathPlugin.native-KUxz0o8C.mjs +251 -0
- package/dist/MediaManagerPlugin.native-CgP5iInD.mjs +970 -0
- package/dist/MergeTagPlugin.native-CU9LtsfD.mjs +416 -0
- package/dist/PageBreakPlugin.native-CGiQxXqR.mjs +297 -0
- package/dist/{PrintPlugin.native-BUpm52VJ.mjs → PrintPlugin.native-7qt5v7L5.mjs} +10 -10
- package/dist/{SpecialCharactersPlugin.native-x7a2SWXc.mjs → SpecialCharactersPlugin.native-DANrbExJ.mjs} +143 -97
- package/dist/SpellCheckPlugin.native-C8bPvRHy.mjs +1019 -0
- package/dist/StrikethroughPlugin.native-0Be7j49s.mjs +73 -0
- package/dist/{TablePlugin.native-EEWXn1-s.mjs → TablePlugin.native-DrHX-efe.mjs} +149 -145
- package/dist/TemplatePlugin.native-4lKEm-WY.mjs +578 -0
- package/dist/TextAlignmentPlugin.native-sM_1s00t.mjs +108 -0
- package/dist/{TextColorPlugin.native-D6SmTglm.mjs → TextColorPlugin.native-Clgtb50j.mjs} +173 -92
- package/dist/colorSelectionApply-CK1My9N2.mjs +67 -0
- package/dist/core.css +1 -1
- package/dist/editora.min.js +31 -29
- package/dist/editora.umd.js +31 -29
- package/dist/index-CqWQFb3D.js +10 -0
- package/dist/index-OwnkG39N.mjs +2227 -0
- package/dist/index.cjs.js +14 -18
- package/dist/index.esm.js +204 -521
- package/dist/plugin-loader.js +26 -26
- package/dist/webcomponent-core.js +1286 -295
- package/dist/webcomponent-core.min.css +1 -1
- package/dist/webcomponent-core.min.js +100 -75
- package/dist/webcomponent.cjs.js +1 -1
- package/dist/webcomponent.esm.js +1 -1
- package/dist/webcomponent.js +1252 -261
- package/dist/webcomponent.min.css +1 -1
- package/dist/webcomponent.min.js +3616 -2109
- package/index.d.ts +355 -0
- package/package.json +19 -17
- package/dist/A11yCheckerPlugin.native-CZKpi3uF.mjs.map +0 -1
- package/dist/AnchorPlugin.native-7es9PVZ9.mjs +0 -340
- package/dist/AnchorPlugin.native-7es9PVZ9.mjs.map +0 -1
- package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs +0 -449
- package/dist/BackgroundColorPlugin.native-Dip5uqTg.mjs.map +0 -1
- package/dist/BlockquotePlugin.native-JFmOLsxN.mjs.map +0 -1
- package/dist/BoldPlugin.native-BAzzoqU5.mjs.map +0 -1
- package/dist/CapitalizationPlugin.native-DOMsh5R7.mjs.map +0 -1
- package/dist/ChecklistPlugin.native-Dccs3nLe.mjs +0 -153
- package/dist/ChecklistPlugin.native-Dccs3nLe.mjs.map +0 -1
- package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs +0 -27
- package/dist/ClearFormattingPlugin.native-BZPDHswo.mjs.map +0 -1
- package/dist/CodePlugin.native-CK9d8rmt.mjs.map +0 -1
- package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs +0 -326
- package/dist/CodeSamplePlugin.native-DMbEdO9j.mjs.map +0 -1
- package/dist/CommentsPlugin.native-2zQV8Ia4.mjs +0 -473
- package/dist/CommentsPlugin.native-2zQV8Ia4.mjs.map +0 -1
- package/dist/DirectionPlugin.native-Be7wCzkI.mjs +0 -59
- package/dist/DirectionPlugin.native-Be7wCzkI.mjs.map +0 -1
- package/dist/DocumentManagerPlugin.native-BvZL5CSG.mjs.map +0 -1
- package/dist/EmbedIframePlugin.native-ifr9KLdN.mjs.map +0 -1
- package/dist/EmojisPlugin.native-D6mJSnSR.mjs.map +0 -1
- package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs +0 -106
- package/dist/FontFamilyPlugin.native-BzS_9qbM.mjs.map +0 -1
- package/dist/FontSizePlugin.native-DkLMLPue.mjs +0 -186
- package/dist/FontSizePlugin.native-DkLMLPue.mjs.map +0 -1
- package/dist/FootnotePlugin.native-BciVc9W6.mjs +0 -128
- package/dist/FootnotePlugin.native-BciVc9W6.mjs.map +0 -1
- package/dist/FullscreenPlugin.native-ChXyxeNw.mjs.map +0 -1
- package/dist/HeadingPlugin.native-DrLYwQnQ.mjs.map +0 -1
- package/dist/HistoryPlugin.native-DoDRifCf.mjs +0 -89
- package/dist/HistoryPlugin.native-DoDRifCf.mjs.map +0 -1
- package/dist/IndentPlugin.native-CbFugPoi.mjs +0 -133
- package/dist/IndentPlugin.native-CbFugPoi.mjs.map +0 -1
- package/dist/ItalicPlugin.native-CQjjDyUL.mjs.map +0 -1
- package/dist/LineHeightPlugin.native-CWQT2FIa.mjs +0 -73
- package/dist/LineHeightPlugin.native-CWQT2FIa.mjs.map +0 -1
- package/dist/LinkPlugin.native-BdAOV-iu.mjs.map +0 -1
- package/dist/ListPlugin.native-CLFU5AUQ.mjs.map +0 -1
- package/dist/MathPlugin.native-DE_ii-LA.mjs +0 -182
- package/dist/MathPlugin.native-DE_ii-LA.mjs.map +0 -1
- package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs +0 -533
- package/dist/MediaManagerPlugin.native-DaYFDzNM.mjs.map +0 -1
- package/dist/MergeTagPlugin.native-CrxyThyn.mjs +0 -178
- package/dist/MergeTagPlugin.native-CrxyThyn.mjs.map +0 -1
- package/dist/PageBreakPlugin.native-DDjcDyRW.mjs +0 -172
- package/dist/PageBreakPlugin.native-DDjcDyRW.mjs.map +0 -1
- package/dist/PreviewPlugin.native-DBvfpmIv.mjs.map +0 -1
- package/dist/PrintPlugin.native-BUpm52VJ.mjs.map +0 -1
- package/dist/SpecialCharactersPlugin.native-x7a2SWXc.mjs.map +0 -1
- package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs +0 -465
- package/dist/SpellCheckPlugin.native-B7yTh0iE.mjs.map +0 -1
- package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs +0 -43
- package/dist/StrikethroughPlugin.native-ChaZLaXw.mjs.map +0 -1
- package/dist/TablePlugin.native-EEWXn1-s.mjs.map +0 -1
- package/dist/TemplatePlugin.native-BlSn1c9h.mjs +0 -564
- package/dist/TemplatePlugin.native-BlSn1c9h.mjs.map +0 -1
- package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs +0 -97
- package/dist/TextAlignmentPlugin.native-CQIs1m7R.mjs.map +0 -1
- package/dist/TextColorPlugin.native-D6SmTglm.mjs.map +0 -1
- package/dist/UnderlinePlugin.native-QpIcK4L2.mjs.map +0 -1
- package/dist/documentManager-irzj9n3V.mjs.map +0 -1
- package/dist/editorContainerHelpers-C7kdWnS0.mjs.map +0 -1
- package/dist/editora.min.js.map +0 -1
- package/dist/editora.umd.js.map +0 -1
- package/dist/index-BF5RBhL9.js +0 -4
- package/dist/index-BF5RBhL9.js.map +0 -1
- package/dist/index-BPsf460l.mjs +0 -1243
- package/dist/index-BPsf460l.mjs.map +0 -1
- package/dist/index.cjs.js.map +0 -1
- package/dist/index.es-CuicffkQ.mjs.map +0 -1
- package/dist/index.esm.js.map +0 -1
- package/dist/plugin-loader.js.map +0 -1
- package/dist/purify.es-CKpwg8Tk.mjs.map +0 -1
- package/dist/webcomponent-core.js.map +0 -1
- package/dist/webcomponent-core.min.js.map +0 -1
- package/dist/webcomponent.cjs.js.map +0 -1
- package/dist/webcomponent.esm.js.map +0 -1
- package/dist/webcomponent.js.map +0 -1
- package/dist/webcomponent.min.js.map +0 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { P as g, E as y, a as
|
|
2
|
-
import { C as
|
|
3
|
-
class
|
|
1
|
+
import { P as g, E as y, a as b, T as f, R as v } from "./index-OwnkG39N.mjs";
|
|
2
|
+
import { C as G, h as O, F as V, K, i as B, S as W, b as X, e as _, d as Y, g as J, f as Q, c as Z } from "./index-OwnkG39N.mjs";
|
|
3
|
+
class L {
|
|
4
4
|
constructor(e) {
|
|
5
5
|
if (this.listeners = [], e instanceof g)
|
|
6
6
|
this.pluginManager = e;
|
|
7
7
|
else {
|
|
8
8
|
const i = e;
|
|
9
|
-
this.pluginManager = new g(), i.plugins && Array.isArray(i.plugins) && i.plugins.forEach((
|
|
10
|
-
this.pluginManager.register(
|
|
9
|
+
this.pluginManager = new g(), i.plugins && Array.isArray(i.plugins) && i.plugins.forEach((n) => {
|
|
10
|
+
this.pluginManager.register(n);
|
|
11
11
|
}), i.element && (this.domElement = i.element, this.setupDOMElement(i));
|
|
12
12
|
}
|
|
13
13
|
const t = this.pluginManager.buildSchema();
|
|
@@ -25,15 +25,15 @@ class k {
|
|
|
25
25
|
}), document.addEventListener("keydown", (i) => {
|
|
26
26
|
if (this.contentElement !== document.activeElement && !(document.activeElement instanceof HTMLElement && document.activeElement.contentEditable === "true"))
|
|
27
27
|
return;
|
|
28
|
-
const
|
|
29
|
-
(i.ctrlKey || i.metaKey) &&
|
|
30
|
-
const
|
|
31
|
-
|
|
28
|
+
const n = [];
|
|
29
|
+
(i.ctrlKey || i.metaKey) && n.push("ctrl"), i.shiftKey && n.push("shift"), i.altKey && n.push("alt");
|
|
30
|
+
const o = i.key.toLowerCase(), s = n.length > 0 ? `${n.join("+")}+${o}` : o, a = t[s];
|
|
31
|
+
a && (i.preventDefault(), this.execCommand(a));
|
|
32
32
|
});
|
|
33
33
|
}
|
|
34
34
|
handleToolbarCommand(e, t) {
|
|
35
|
-
const
|
|
36
|
-
|
|
35
|
+
const n = this.pluginManager.getToolbarItems().find((o) => o.id && o.id === e || o.command === e);
|
|
36
|
+
n != null && n.command && (t !== void 0 ? this.execCommand(n.command, t) : this.execCommand(n.command));
|
|
37
37
|
}
|
|
38
38
|
setState(e) {
|
|
39
39
|
this.state = e, this.listeners.forEach((t) => t(e));
|
|
@@ -55,8 +55,12 @@ class k {
|
|
|
55
55
|
const i = this.commands[e];
|
|
56
56
|
if (!i)
|
|
57
57
|
return console.warn(`Command not found: ${e}`), !1;
|
|
58
|
-
let
|
|
59
|
-
return t !== void 0 ?
|
|
58
|
+
let n;
|
|
59
|
+
return t !== void 0 ? n = i(this.state, t) : n = i(this.state), n instanceof Promise ? (n.then((o) => {
|
|
60
|
+
o && typeof o == "object" && "doc" in o && "selection" in o && this.setState(o);
|
|
61
|
+
}).catch((o) => {
|
|
62
|
+
console.error(`Async command failed: ${e}`, o);
|
|
63
|
+
}), !0) : n && typeof n == "object" && "doc" in n && "selection" in n ? (this.setState(n), !0) : n !== !1 && n != null;
|
|
60
64
|
}
|
|
61
65
|
setContent(e) {
|
|
62
66
|
typeof e == "string" ? this.contentElement && (this.contentElement.innerHTML = e) : this.setState(this.state.apply(e));
|
|
@@ -82,8 +86,8 @@ class E {
|
|
|
82
86
|
return console.warn(`Plugin "${this.plugin.name}" already initialized`), !1;
|
|
83
87
|
try {
|
|
84
88
|
return this.context = e, (t = this.plugin.context) != null && t.initialize && this.plugin.context.initialize(), (i = this.plugin.context) != null && i.onEditorReady && e.provider && this.plugin.context.onEditorReady(e), this.initialized = !0, !0;
|
|
85
|
-
} catch (
|
|
86
|
-
return console.error(`Failed to initialize plugin "${this.plugin.name}":`,
|
|
89
|
+
} catch (n) {
|
|
90
|
+
return console.error(`Failed to initialize plugin "${this.plugin.name}":`, n), !1;
|
|
87
91
|
}
|
|
88
92
|
}
|
|
89
93
|
/**
|
|
@@ -107,10 +111,10 @@ class E {
|
|
|
107
111
|
if (!this.initialized)
|
|
108
112
|
return console.warn(`Plugin "${this.plugin.name}" not initialized, cannot execute command "${e}"`), null;
|
|
109
113
|
try {
|
|
110
|
-
const
|
|
111
|
-
return
|
|
112
|
-
} catch (
|
|
113
|
-
return console.error(`Error executing command "${e}" in plugin "${this.plugin.name}":`,
|
|
114
|
+
const n = (i = this.plugin.commands) == null ? void 0 : i[e];
|
|
115
|
+
return n ? n(...t) : (console.warn(`Command "${e}" not found in plugin "${this.plugin.name}"`), null);
|
|
116
|
+
} catch (n) {
|
|
117
|
+
return console.error(`Error executing command "${e}" in plugin "${this.plugin.name}":`, n), null;
|
|
114
118
|
}
|
|
115
119
|
}
|
|
116
120
|
/**
|
|
@@ -138,355 +142,20 @@ class E {
|
|
|
138
142
|
return this.context;
|
|
139
143
|
}
|
|
140
144
|
}
|
|
141
|
-
function
|
|
142
|
-
return new E(
|
|
143
|
-
}
|
|
144
|
-
class L {
|
|
145
|
-
constructor(e) {
|
|
146
|
-
this.shortcuts = /* @__PURE__ */ new Map(), this.enabled = !0, this.isMac = typeof navigator != "undefined" && navigator.platform.toUpperCase().indexOf("MAC") >= 0, (e == null ? void 0 : e.enabled) === !1 && (this.enabled = !1), this.registerDefaultShortcuts(), e != null && e.shortcuts && e.shortcuts.forEach((t) => this.registerShortcut(t)), e != null && e.customShortcuts && Object.values(e.customShortcuts).forEach((t) => {
|
|
147
|
-
this.registerShortcut(t);
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
registerDefaultShortcuts() {
|
|
151
|
-
this.registerShortcut({
|
|
152
|
-
key: "b",
|
|
153
|
-
ctrl: !this.isMac,
|
|
154
|
-
meta: this.isMac,
|
|
155
|
-
command: "toggleBold",
|
|
156
|
-
description: "Bold",
|
|
157
|
-
preventDefault: !0
|
|
158
|
-
}), this.registerShortcut({
|
|
159
|
-
key: "i",
|
|
160
|
-
ctrl: !this.isMac,
|
|
161
|
-
meta: this.isMac,
|
|
162
|
-
command: "toggleItalic",
|
|
163
|
-
description: "Italic",
|
|
164
|
-
preventDefault: !0
|
|
165
|
-
}), this.registerShortcut({
|
|
166
|
-
key: "u",
|
|
167
|
-
ctrl: !this.isMac,
|
|
168
|
-
meta: this.isMac,
|
|
169
|
-
command: "toggleUnderline",
|
|
170
|
-
description: "Underline",
|
|
171
|
-
preventDefault: !0
|
|
172
|
-
}), this.registerShortcut({
|
|
173
|
-
key: "d",
|
|
174
|
-
ctrl: !this.isMac,
|
|
175
|
-
meta: this.isMac,
|
|
176
|
-
command: "toggleStrikethrough",
|
|
177
|
-
description: "Strikethrough",
|
|
178
|
-
preventDefault: !0
|
|
179
|
-
}), this.registerShortcut({
|
|
180
|
-
key: "z",
|
|
181
|
-
ctrl: !this.isMac,
|
|
182
|
-
meta: this.isMac,
|
|
183
|
-
command: "undo",
|
|
184
|
-
description: "Undo",
|
|
185
|
-
preventDefault: !0
|
|
186
|
-
}), this.registerShortcut({
|
|
187
|
-
key: "z",
|
|
188
|
-
ctrl: !this.isMac,
|
|
189
|
-
meta: this.isMac,
|
|
190
|
-
shift: !0,
|
|
191
|
-
command: "redo",
|
|
192
|
-
description: "Redo",
|
|
193
|
-
preventDefault: !0
|
|
194
|
-
}), this.registerShortcut({
|
|
195
|
-
key: "y",
|
|
196
|
-
ctrl: !this.isMac,
|
|
197
|
-
meta: this.isMac,
|
|
198
|
-
command: "redo",
|
|
199
|
-
description: "Redo",
|
|
200
|
-
preventDefault: !0
|
|
201
|
-
});
|
|
202
|
-
for (let e = 1; e <= 6; e++)
|
|
203
|
-
this.registerShortcut({
|
|
204
|
-
key: String(e),
|
|
205
|
-
ctrl: !this.isMac,
|
|
206
|
-
meta: this.isMac,
|
|
207
|
-
alt: !0,
|
|
208
|
-
command: "setBlockType",
|
|
209
|
-
params: `h${e}`,
|
|
210
|
-
description: `Heading ${e}`,
|
|
211
|
-
preventDefault: !0
|
|
212
|
-
});
|
|
213
|
-
this.registerShortcut({
|
|
214
|
-
key: "7",
|
|
215
|
-
ctrl: !this.isMac,
|
|
216
|
-
meta: this.isMac,
|
|
217
|
-
alt: !0,
|
|
218
|
-
command: "setBlockType",
|
|
219
|
-
params: "p",
|
|
220
|
-
description: "Paragraph",
|
|
221
|
-
preventDefault: !0
|
|
222
|
-
}), this.registerShortcut({
|
|
223
|
-
key: "7",
|
|
224
|
-
ctrl: !this.isMac,
|
|
225
|
-
meta: this.isMac,
|
|
226
|
-
shift: !0,
|
|
227
|
-
command: "toggleOrderedList",
|
|
228
|
-
description: "Numbered List",
|
|
229
|
-
preventDefault: !0
|
|
230
|
-
}), this.registerShortcut({
|
|
231
|
-
key: "8",
|
|
232
|
-
ctrl: !this.isMac,
|
|
233
|
-
meta: this.isMac,
|
|
234
|
-
shift: !0,
|
|
235
|
-
command: "toggleBulletList",
|
|
236
|
-
description: "Bullet List",
|
|
237
|
-
preventDefault: !0
|
|
238
|
-
}), this.registerShortcut({
|
|
239
|
-
key: "k",
|
|
240
|
-
ctrl: !this.isMac,
|
|
241
|
-
meta: this.isMac,
|
|
242
|
-
command: "openLinkDialog",
|
|
243
|
-
description: "Insert/Edit Link",
|
|
244
|
-
preventDefault: !0
|
|
245
|
-
}), this.registerShortcut({
|
|
246
|
-
key: "e",
|
|
247
|
-
ctrl: !this.isMac,
|
|
248
|
-
meta: this.isMac,
|
|
249
|
-
alt: !0,
|
|
250
|
-
command: "insertCodeBlock",
|
|
251
|
-
description: "Code Block",
|
|
252
|
-
preventDefault: !0
|
|
253
|
-
}), this.registerShortcut({
|
|
254
|
-
key: "q",
|
|
255
|
-
ctrl: !this.isMac,
|
|
256
|
-
meta: this.isMac,
|
|
257
|
-
shift: !0,
|
|
258
|
-
command: "toggleBlockquote",
|
|
259
|
-
description: "Blockquote",
|
|
260
|
-
preventDefault: !0
|
|
261
|
-
}), this.registerShortcut({
|
|
262
|
-
key: "l",
|
|
263
|
-
ctrl: !this.isMac,
|
|
264
|
-
meta: this.isMac,
|
|
265
|
-
shift: !0,
|
|
266
|
-
command: "setTextAlignment",
|
|
267
|
-
params: "left",
|
|
268
|
-
description: "Align Left",
|
|
269
|
-
preventDefault: !0
|
|
270
|
-
}), this.registerShortcut({
|
|
271
|
-
key: "e",
|
|
272
|
-
ctrl: !this.isMac,
|
|
273
|
-
meta: this.isMac,
|
|
274
|
-
shift: !0,
|
|
275
|
-
alt: !0,
|
|
276
|
-
command: "setTextAlignment",
|
|
277
|
-
params: "center",
|
|
278
|
-
description: "Align Center",
|
|
279
|
-
preventDefault: !0
|
|
280
|
-
}), this.registerShortcut({
|
|
281
|
-
key: "r",
|
|
282
|
-
ctrl: !this.isMac,
|
|
283
|
-
meta: this.isMac,
|
|
284
|
-
shift: !0,
|
|
285
|
-
command: "setTextAlignment",
|
|
286
|
-
params: "right",
|
|
287
|
-
description: "Align Right",
|
|
288
|
-
preventDefault: !0
|
|
289
|
-
}), this.registerShortcut({
|
|
290
|
-
key: "j",
|
|
291
|
-
ctrl: !this.isMac,
|
|
292
|
-
meta: this.isMac,
|
|
293
|
-
shift: !0,
|
|
294
|
-
command: "setTextAlignment",
|
|
295
|
-
params: "justify",
|
|
296
|
-
description: "Justify",
|
|
297
|
-
preventDefault: !0
|
|
298
|
-
}), this.registerShortcut({
|
|
299
|
-
key: "\\",
|
|
300
|
-
ctrl: !this.isMac,
|
|
301
|
-
meta: this.isMac,
|
|
302
|
-
command: "clearFormatting",
|
|
303
|
-
description: "Clear Formatting",
|
|
304
|
-
preventDefault: !0
|
|
305
|
-
}), this.registerShortcut({
|
|
306
|
-
key: "]",
|
|
307
|
-
ctrl: !this.isMac,
|
|
308
|
-
meta: this.isMac,
|
|
309
|
-
command: "increaseIndent",
|
|
310
|
-
description: "Indent",
|
|
311
|
-
preventDefault: !0
|
|
312
|
-
}), this.registerShortcut({
|
|
313
|
-
key: "[",
|
|
314
|
-
ctrl: !this.isMac,
|
|
315
|
-
meta: this.isMac,
|
|
316
|
-
command: "decreaseIndent",
|
|
317
|
-
description: "Outdent",
|
|
318
|
-
preventDefault: !0
|
|
319
|
-
}), this.registerShortcut({
|
|
320
|
-
key: "g",
|
|
321
|
-
ctrl: !this.isMac,
|
|
322
|
-
meta: this.isMac,
|
|
323
|
-
shift: !0,
|
|
324
|
-
command: "insertImage",
|
|
325
|
-
description: "Insert Image",
|
|
326
|
-
preventDefault: !0
|
|
327
|
-
}), this.registerShortcut({
|
|
328
|
-
key: "t",
|
|
329
|
-
ctrl: !this.isMac,
|
|
330
|
-
meta: this.isMac,
|
|
331
|
-
shift: !0,
|
|
332
|
-
alt: !0,
|
|
333
|
-
command: "insertTable",
|
|
334
|
-
description: "Insert Table",
|
|
335
|
-
preventDefault: !0
|
|
336
|
-
}), this.registerShortcut({
|
|
337
|
-
key: "f11",
|
|
338
|
-
command: "toggleFullscreen",
|
|
339
|
-
description: "Toggle Fullscreen",
|
|
340
|
-
preventDefault: !0
|
|
341
|
-
}), this.registerShortcut({
|
|
342
|
-
key: "p",
|
|
343
|
-
ctrl: !this.isMac,
|
|
344
|
-
meta: this.isMac,
|
|
345
|
-
shift: !0,
|
|
346
|
-
command: "togglePreview",
|
|
347
|
-
description: "Preview",
|
|
348
|
-
preventDefault: !0
|
|
349
|
-
}), this.registerShortcut({
|
|
350
|
-
key: "p",
|
|
351
|
-
ctrl: !this.isMac,
|
|
352
|
-
meta: this.isMac,
|
|
353
|
-
command: "print",
|
|
354
|
-
description: "Print",
|
|
355
|
-
preventDefault: !0
|
|
356
|
-
}), this.registerShortcut({
|
|
357
|
-
key: "s",
|
|
358
|
-
ctrl: !this.isMac,
|
|
359
|
-
meta: this.isMac,
|
|
360
|
-
shift: !0,
|
|
361
|
-
alt: !0,
|
|
362
|
-
command: "insertSpecialCharacter",
|
|
363
|
-
description: "Insert Special Character",
|
|
364
|
-
preventDefault: !0
|
|
365
|
-
}), this.registerShortcut({
|
|
366
|
-
key: "m",
|
|
367
|
-
ctrl: !this.isMac,
|
|
368
|
-
meta: this.isMac,
|
|
369
|
-
shift: !0,
|
|
370
|
-
command: "insertEmoji",
|
|
371
|
-
description: "Insert Emoji",
|
|
372
|
-
preventDefault: !0
|
|
373
|
-
}), this.registerShortcut({
|
|
374
|
-
key: "9",
|
|
375
|
-
ctrl: !this.isMac,
|
|
376
|
-
meta: this.isMac,
|
|
377
|
-
shift: !0,
|
|
378
|
-
command: "toggleChecklist",
|
|
379
|
-
description: "Checklist",
|
|
380
|
-
preventDefault: !0
|
|
381
|
-
}), this.registerShortcut({
|
|
382
|
-
key: "a",
|
|
383
|
-
ctrl: !this.isMac,
|
|
384
|
-
meta: this.isMac,
|
|
385
|
-
shift: !0,
|
|
386
|
-
alt: !0,
|
|
387
|
-
command: "toggleA11yChecker",
|
|
388
|
-
description: "Accessibility Checker",
|
|
389
|
-
preventDefault: !0
|
|
390
|
-
}), this.registerShortcut({
|
|
391
|
-
key: "F7",
|
|
392
|
-
command: "toggleSpellCheck",
|
|
393
|
-
description: "Spell Check",
|
|
394
|
-
preventDefault: !0
|
|
395
|
-
}), this.registerShortcut({
|
|
396
|
-
key: "m",
|
|
397
|
-
ctrl: !this.isMac,
|
|
398
|
-
meta: this.isMac,
|
|
399
|
-
alt: !0,
|
|
400
|
-
command: "insertMath",
|
|
401
|
-
description: "Insert Math",
|
|
402
|
-
preventDefault: !0
|
|
403
|
-
}), this.registerShortcut({
|
|
404
|
-
key: "f",
|
|
405
|
-
ctrl: !this.isMac,
|
|
406
|
-
meta: this.isMac,
|
|
407
|
-
alt: !0,
|
|
408
|
-
command: "insertFootnote",
|
|
409
|
-
description: "Insert Footnote",
|
|
410
|
-
preventDefault: !0
|
|
411
|
-
});
|
|
412
|
-
}
|
|
413
|
-
registerShortcut(e) {
|
|
414
|
-
const t = this.getShortcutKey(e);
|
|
415
|
-
this.shortcuts.set(t, e);
|
|
416
|
-
}
|
|
417
|
-
unregisterShortcut(e) {
|
|
418
|
-
const t = this.getShortcutKey(e);
|
|
419
|
-
this.shortcuts.delete(t);
|
|
420
|
-
}
|
|
421
|
-
getShortcutKey(e) {
|
|
422
|
-
const t = [];
|
|
423
|
-
return e.ctrl && t.push("ctrl"), e.alt && t.push("alt"), e.shift && t.push("shift"), e.meta && t.push("meta"), t.push(e.key.toLowerCase()), t.join("+");
|
|
424
|
-
}
|
|
425
|
-
getEventKey(e) {
|
|
426
|
-
const t = [];
|
|
427
|
-
return e.ctrlKey && t.push("ctrl"), e.altKey && t.push("alt"), e.shiftKey && t.push("shift"), e.metaKey && t.push("meta"), t.push(e.key.toLowerCase()), t.join("+");
|
|
428
|
-
}
|
|
429
|
-
handleKeyDown(e, t) {
|
|
430
|
-
if (!this.enabled) return !1;
|
|
431
|
-
const i = this.getEventKey(e), s = this.shortcuts.get(i);
|
|
432
|
-
return s ? (s.preventDefault !== !1 && (e.preventDefault(), e.stopPropagation()), t(s.command, s.params), !0) : !1;
|
|
433
|
-
}
|
|
434
|
-
enable() {
|
|
435
|
-
this.enabled = !0;
|
|
436
|
-
}
|
|
437
|
-
disable() {
|
|
438
|
-
this.enabled = !1;
|
|
439
|
-
}
|
|
440
|
-
isEnabled() {
|
|
441
|
-
return this.enabled;
|
|
442
|
-
}
|
|
443
|
-
getAllShortcuts() {
|
|
444
|
-
return Array.from(this.shortcuts.values());
|
|
445
|
-
}
|
|
446
|
-
getShortcutForCommand(e) {
|
|
447
|
-
return Array.from(this.shortcuts.values()).find((t) => t.command === e);
|
|
448
|
-
}
|
|
449
|
-
getShortcutDescription(e) {
|
|
450
|
-
const t = [];
|
|
451
|
-
this.isMac ? (e.meta && t.push("⌘"), e.ctrl && t.push("⌃"), e.alt && t.push("⌥"), e.shift && t.push("⇧")) : (e.ctrl && t.push("Ctrl"), e.alt && t.push("Alt"), e.shift && t.push("Shift"));
|
|
452
|
-
const i = e.key.length === 1 ? e.key.toUpperCase() : e.key;
|
|
453
|
-
return t.push(i), t.join("+");
|
|
454
|
-
}
|
|
455
|
-
getShortcutsHelp() {
|
|
456
|
-
const e = this.getAllShortcuts(), t = /* @__PURE__ */ new Map();
|
|
457
|
-
e.forEach((s) => {
|
|
458
|
-
const n = this.getShortcutCategory(s.command);
|
|
459
|
-
t.has(n) || t.set(n, []), t.get(n).push(s);
|
|
460
|
-
});
|
|
461
|
-
let i = `# Keyboard Shortcuts
|
|
462
|
-
|
|
463
|
-
`;
|
|
464
|
-
return t.forEach((s, n) => {
|
|
465
|
-
i += `## ${n}
|
|
466
|
-
|
|
467
|
-
`, s.forEach((o) => {
|
|
468
|
-
const r = this.getShortcutDescription(o);
|
|
469
|
-
i += `- **${r}**: ${o.description || o.command}
|
|
470
|
-
`;
|
|
471
|
-
}), i += `
|
|
472
|
-
`;
|
|
473
|
-
}), i;
|
|
474
|
-
}
|
|
475
|
-
getShortcutCategory(e) {
|
|
476
|
-
return e.includes("toggle") && (e.includes("Bold") || e.includes("Italic") || e.includes("Underline") || e.includes("Strike") || e.includes("Code") || e.includes("Super") || e.includes("Sub")) ? "Text Formatting" : e.includes("Heading") || e.includes("Paragraph") ? "Block Formatting" : e.includes("List") || e.includes("Checklist") ? "Lists" : e.includes("Alignment") || e.includes("Indent") ? "Alignment & Indentation" : e.includes("undo") || e.includes("redo") ? "History" : e.includes("insert") ? "Insert" : e.includes("find") || e.includes("replace") ? "Find & Replace" : e.includes("Accessibility") || e.includes("spell") ? "Tools" : "Other";
|
|
477
|
-
}
|
|
145
|
+
function k(l) {
|
|
146
|
+
return new E(l);
|
|
478
147
|
}
|
|
479
|
-
function T(
|
|
148
|
+
function T(l = {}) {
|
|
480
149
|
const {
|
|
481
150
|
enabled: e = !1,
|
|
482
151
|
provider: t = "browser",
|
|
483
152
|
apiUrl: i = "",
|
|
484
|
-
apiHeaders:
|
|
485
|
-
language:
|
|
486
|
-
customDictionary:
|
|
487
|
-
ignoreAllCaps:
|
|
488
|
-
ignoreNumbers:
|
|
489
|
-
} =
|
|
153
|
+
apiHeaders: n = {},
|
|
154
|
+
language: o = "en",
|
|
155
|
+
customDictionary: s = [],
|
|
156
|
+
ignoreAllCaps: a = !0,
|
|
157
|
+
ignoreNumbers: r = !0
|
|
158
|
+
} = l;
|
|
490
159
|
return {
|
|
491
160
|
name: "spellcheck",
|
|
492
161
|
context: {
|
|
@@ -494,7 +163,7 @@ function T(a = {}) {
|
|
|
494
163
|
if (e)
|
|
495
164
|
switch (console.log("[Spellcheck Plugin] Initialized", {
|
|
496
165
|
provider: t,
|
|
497
|
-
language:
|
|
166
|
+
language: o
|
|
498
167
|
}), t) {
|
|
499
168
|
case "browser":
|
|
500
169
|
console.log("[Spellcheck] Using browser spellcheck");
|
|
@@ -529,22 +198,22 @@ function T(a = {}) {
|
|
|
529
198
|
] : []
|
|
530
199
|
};
|
|
531
200
|
}
|
|
532
|
-
function I(
|
|
201
|
+
function I(l = {}) {
|
|
533
202
|
const {
|
|
534
203
|
uploadUrl: e = "",
|
|
535
204
|
libraryUrl: t = "",
|
|
536
205
|
maxFileSize: i = 10 * 1024 * 1024,
|
|
537
206
|
// 10MB
|
|
538
|
-
allowedTypes:
|
|
539
|
-
headers:
|
|
540
|
-
withCredentials:
|
|
541
|
-
chunkSize:
|
|
207
|
+
allowedTypes: n = ["image/jpeg", "image/png", "image/gif", "image/webp"],
|
|
208
|
+
headers: o = {},
|
|
209
|
+
withCredentials: s = !1,
|
|
210
|
+
chunkSize: a = 1024 * 1024,
|
|
542
211
|
// 1MB chunks
|
|
543
|
-
enableChunking:
|
|
212
|
+
enableChunking: r = !0,
|
|
544
213
|
onProgress: d,
|
|
545
214
|
onError: h,
|
|
546
|
-
onSuccess:
|
|
547
|
-
} =
|
|
215
|
+
onSuccess: C
|
|
216
|
+
} = l;
|
|
548
217
|
return {
|
|
549
218
|
name: "media",
|
|
550
219
|
context: {
|
|
@@ -553,7 +222,7 @@ function I(a = {}) {
|
|
|
553
222
|
uploadUrl: e,
|
|
554
223
|
libraryUrl: t,
|
|
555
224
|
maxFileSize: i,
|
|
556
|
-
allowedTypes:
|
|
225
|
+
allowedTypes: n
|
|
557
226
|
}), e || console.warn("[Media] No uploadUrl provided - upload will not work");
|
|
558
227
|
},
|
|
559
228
|
destroy: () => {
|
|
@@ -567,7 +236,7 @@ function I(a = {}) {
|
|
|
567
236
|
insertImage: async (c) => {
|
|
568
237
|
if (console.log("[Media] Insert image command (not implemented)", c), !c)
|
|
569
238
|
return console.log("[Media] No file provided - should open picker"), null;
|
|
570
|
-
if (!
|
|
239
|
+
if (!n.includes(c.type)) {
|
|
571
240
|
const p = new Error(`File type ${c.type} not allowed`);
|
|
572
241
|
return h == null || h(p), null;
|
|
573
242
|
}
|
|
@@ -648,7 +317,12 @@ class u {
|
|
|
648
317
|
}
|
|
649
318
|
createElement() {
|
|
650
319
|
const e = document.createElement("dialog");
|
|
651
|
-
|
|
320
|
+
e.className = "editora-dialog", this.config.width && (e.style.width = this.config.width), this.config.height && (e.style.height = this.config.height);
|
|
321
|
+
const t = this.config.buttons && this.config.buttons.length > 0 ? this.config.buttons.map((i, n) => `<button type="button" class="editora-btn ${i.type === "danger" ? "editora-btn-danger" : i.type === "primary" || i.primary ? "editora-btn-primary" : "editora-btn-cancel"}" data-dialog-button="${n}">${i.label}</button>`).join("") : `
|
|
322
|
+
<button type="button" class="editora-btn editora-btn-cancel" data-dialog-default="cancel">Cancel</button>
|
|
323
|
+
<button type="button" class="editora-btn editora-btn-primary" data-dialog-default="ok">OK</button>
|
|
324
|
+
`;
|
|
325
|
+
if (e.innerHTML = `
|
|
652
326
|
<div class="editora-dialog-container">
|
|
653
327
|
<div class="editora-dialog-header">
|
|
654
328
|
<h3>${this.config.title}</h3>
|
|
@@ -658,43 +332,52 @@ class u {
|
|
|
658
332
|
${typeof this.config.content == "string" ? this.config.content : ""}
|
|
659
333
|
</div>
|
|
660
334
|
<div class="editora-dialog-footer">
|
|
661
|
-
|
|
662
|
-
<button type="button" class="editora-btn editora-btn-primary">OK</button>
|
|
335
|
+
${t}
|
|
663
336
|
</div>
|
|
664
337
|
</div>
|
|
665
338
|
`, typeof this.config.content != "string") {
|
|
666
|
-
const
|
|
667
|
-
|
|
339
|
+
const i = e.querySelector(".editora-dialog-body");
|
|
340
|
+
i && (i.innerHTML = "", i.appendChild(this.config.content));
|
|
668
341
|
}
|
|
669
342
|
return e;
|
|
670
343
|
}
|
|
671
344
|
attachEventListeners() {
|
|
672
345
|
const e = this.element.querySelector(".editora-dialog-close");
|
|
673
|
-
e == null || e.addEventListener("click", () => this.close())
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
346
|
+
if (e == null || e.addEventListener("click", () => this.close()), this.config.buttons && this.config.buttons.length > 0)
|
|
347
|
+
this.element.querySelectorAll("[data-dialog-button]").forEach((i) => {
|
|
348
|
+
i.addEventListener("click", () => {
|
|
349
|
+
var s, a;
|
|
350
|
+
const n = Number(i.getAttribute("data-dialog-button")), o = (s = this.config.buttons) == null ? void 0 : s[n];
|
|
351
|
+
(a = o == null ? void 0 : o.onClick) == null || a.call(o);
|
|
352
|
+
});
|
|
353
|
+
});
|
|
354
|
+
else {
|
|
355
|
+
const t = this.element.querySelector('[data-dialog-default="cancel"]');
|
|
356
|
+
t == null || t.addEventListener("click", () => {
|
|
357
|
+
var n, o;
|
|
358
|
+
(o = (n = this.config).onCancel) == null || o.call(n), this.close();
|
|
359
|
+
});
|
|
360
|
+
const i = this.element.querySelector('[data-dialog-default="ok"]');
|
|
361
|
+
i == null || i.addEventListener("click", () => this.handleSubmit());
|
|
362
|
+
}
|
|
363
|
+
this.config.closeOnEscape && this.element.addEventListener("cancel", (t) => {
|
|
364
|
+
t.preventDefault(), this.close();
|
|
365
|
+
}), this.config.closeOnBackdrop && this.element.addEventListener("click", (t) => {
|
|
366
|
+
const i = this.element.getBoundingClientRect();
|
|
367
|
+
(t.clientX < i.left || t.clientX > i.right || t.clientY < i.top || t.clientY > i.bottom) && this.close();
|
|
685
368
|
});
|
|
686
369
|
}
|
|
687
370
|
handleSubmit() {
|
|
688
|
-
var t, i,
|
|
371
|
+
var t, i, n, o;
|
|
689
372
|
const e = this.element.querySelector("form");
|
|
690
373
|
if (e) {
|
|
691
|
-
const
|
|
692
|
-
(i = (t = this.config).onSubmit) == null || i.call(t,
|
|
374
|
+
const s = new FormData(e);
|
|
375
|
+
(i = (t = this.config).onSubmit) == null || i.call(t, s);
|
|
693
376
|
} else {
|
|
694
|
-
const
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
}), (
|
|
377
|
+
const s = this.element.querySelectorAll("input, select, textarea"), a = new FormData();
|
|
378
|
+
s.forEach((r) => {
|
|
379
|
+
r.name && a.append(r.name, r.value);
|
|
380
|
+
}), (o = (n = this.config).onSubmit) == null || o.call(n, a);
|
|
698
381
|
}
|
|
699
382
|
this.close();
|
|
700
383
|
}
|
|
@@ -708,24 +391,24 @@ class u {
|
|
|
708
391
|
this.close();
|
|
709
392
|
}
|
|
710
393
|
}
|
|
711
|
-
class
|
|
394
|
+
class F {
|
|
712
395
|
constructor(e) {
|
|
713
396
|
this.isOpen = !1, this.config = e, this.selectedValue = e.value, this.element = this.createElement(), this.attachEventListeners();
|
|
714
397
|
}
|
|
715
398
|
createElement() {
|
|
716
399
|
const e = document.createElement("div");
|
|
717
400
|
e.className = "editora-dropdown", this.config.width && (e.style.width = this.config.width);
|
|
718
|
-
const t = this.config.options.find((
|
|
401
|
+
const t = this.config.options.find((n) => n.value === this.selectedValue), i = (t == null ? void 0 : t.label) || this.config.placeholder || "Select...";
|
|
719
402
|
return e.innerHTML = `
|
|
720
403
|
<button class="editora-dropdown-toggle" type="button">
|
|
721
404
|
<span class="editora-dropdown-label">${i}</span>
|
|
722
405
|
<span class="editora-dropdown-arrow">▼</span>
|
|
723
406
|
</button>
|
|
724
407
|
<div class="editora-dropdown-menu" style="display: none;">
|
|
725
|
-
${this.config.options.map((
|
|
726
|
-
<div class="editora-dropdown-item" data-value="${
|
|
727
|
-
${
|
|
728
|
-
<span>${
|
|
408
|
+
${this.config.options.map((n) => `
|
|
409
|
+
<div class="editora-dropdown-item" data-value="${n.value}">
|
|
410
|
+
${n.icon ? `<span class="editora-dropdown-icon">${n.icon}</span>` : ""}
|
|
411
|
+
<span>${n.label}</span>
|
|
729
412
|
</div>
|
|
730
413
|
`).join("")}
|
|
731
414
|
</div>
|
|
@@ -733,21 +416,21 @@ class D {
|
|
|
733
416
|
}
|
|
734
417
|
attachEventListeners() {
|
|
735
418
|
const e = this.element.querySelector(".editora-dropdown-toggle"), t = this.element.querySelector(".editora-dropdown-menu");
|
|
736
|
-
e.addEventListener("click", (
|
|
737
|
-
|
|
738
|
-
}), this.element.querySelectorAll(".editora-dropdown-item").forEach((
|
|
739
|
-
|
|
740
|
-
var
|
|
741
|
-
const
|
|
742
|
-
|
|
419
|
+
e.addEventListener("click", (n) => {
|
|
420
|
+
n.stopPropagation(), this.isOpen = !this.isOpen, t.style.display = this.isOpen ? "block" : "none";
|
|
421
|
+
}), this.element.querySelectorAll(".editora-dropdown-item").forEach((n) => {
|
|
422
|
+
n.addEventListener("click", () => {
|
|
423
|
+
var s, a;
|
|
424
|
+
const o = n.getAttribute("data-value");
|
|
425
|
+
o && (this.setValue(o), (a = (s = this.config).onChange) == null || a.call(s, o), this.close());
|
|
743
426
|
});
|
|
744
|
-
}), document.addEventListener("click", (
|
|
745
|
-
this.element.contains(
|
|
427
|
+
}), document.addEventListener("click", (n) => {
|
|
428
|
+
this.element.contains(n.target) || this.close();
|
|
746
429
|
});
|
|
747
430
|
}
|
|
748
431
|
setValue(e) {
|
|
749
432
|
this.selectedValue = e;
|
|
750
|
-
const t = this.config.options.find((
|
|
433
|
+
const t = this.config.options.find((n) => n.value === e), i = this.element.querySelector(".editora-dropdown-label");
|
|
751
434
|
i && t && (i.textContent = t.label);
|
|
752
435
|
}
|
|
753
436
|
getValue() {
|
|
@@ -765,7 +448,7 @@ class D {
|
|
|
765
448
|
this.element.remove();
|
|
766
449
|
}
|
|
767
450
|
}
|
|
768
|
-
class
|
|
451
|
+
class M {
|
|
769
452
|
constructor(e) {
|
|
770
453
|
this.defaultPresets = [
|
|
771
454
|
"#000000",
|
|
@@ -825,19 +508,19 @@ class F {
|
|
|
825
508
|
}
|
|
826
509
|
attachEventListeners() {
|
|
827
510
|
const e = this.element.querySelector('input[type="color"]'), t = this.element.querySelector('input[type="text"]');
|
|
828
|
-
e.addEventListener("input", (
|
|
829
|
-
var
|
|
830
|
-
const
|
|
831
|
-
t.value =
|
|
832
|
-
}), t.addEventListener("input", (
|
|
833
|
-
var
|
|
834
|
-
const
|
|
835
|
-
/^#[0-9A-Fa-f]{6}$/.test(
|
|
836
|
-
}), this.element.querySelectorAll(".editora-color-preset").forEach((
|
|
837
|
-
|
|
838
|
-
var
|
|
839
|
-
const
|
|
840
|
-
|
|
511
|
+
e.addEventListener("input", (n) => {
|
|
512
|
+
var s, a;
|
|
513
|
+
const o = n.target.value;
|
|
514
|
+
t.value = o, this.selectedColor = o, (a = (s = this.config).onChange) == null || a.call(s, o);
|
|
515
|
+
}), t.addEventListener("input", (n) => {
|
|
516
|
+
var s, a;
|
|
517
|
+
const o = n.target.value;
|
|
518
|
+
/^#[0-9A-Fa-f]{6}$/.test(o) && (e.value = o, this.selectedColor = o, (a = (s = this.config).onChange) == null || a.call(s, o));
|
|
519
|
+
}), this.element.querySelectorAll(".editora-color-preset").forEach((n) => {
|
|
520
|
+
n.addEventListener("click", () => {
|
|
521
|
+
var s, a;
|
|
522
|
+
const o = n.getAttribute("data-color");
|
|
523
|
+
o && (e.value = o, t.value = o, this.selectedColor = o, (a = (s = this.config).onChange) == null || a.call(s, o));
|
|
841
524
|
});
|
|
842
525
|
});
|
|
843
526
|
}
|
|
@@ -856,22 +539,22 @@ class F {
|
|
|
856
539
|
this.element.remove();
|
|
857
540
|
}
|
|
858
541
|
}
|
|
859
|
-
class
|
|
542
|
+
class q {
|
|
860
543
|
constructor(e) {
|
|
861
|
-
const { initialUrl: t = "", initialText: i = "", onSubmit:
|
|
544
|
+
const { initialUrl: t = "", initialText: i = "", onSubmit: n, onCancel: o } = e;
|
|
862
545
|
this.dialog = new u({
|
|
863
546
|
title: "Insert/Edit Link",
|
|
864
547
|
content: this.createFormHTML(t, i),
|
|
865
|
-
onSubmit: (
|
|
866
|
-
const
|
|
867
|
-
if (!
|
|
548
|
+
onSubmit: (s) => {
|
|
549
|
+
const a = (s.get("url") || "").trim(), r = (s.get("text") || "").trim(), d = s.get("openInNewTab") === "on";
|
|
550
|
+
if (!a) {
|
|
868
551
|
alert("Please enter a URL");
|
|
869
552
|
return;
|
|
870
553
|
}
|
|
871
|
-
|
|
554
|
+
n({ url: a, text: r, openInNewTab: d }), this.dialog.close();
|
|
872
555
|
},
|
|
873
556
|
onCancel: () => {
|
|
874
|
-
|
|
557
|
+
o == null || o(), this.dialog.close();
|
|
875
558
|
},
|
|
876
559
|
width: "500px"
|
|
877
560
|
});
|
|
@@ -938,23 +621,23 @@ class j {
|
|
|
938
621
|
this.dialog.close();
|
|
939
622
|
}
|
|
940
623
|
}
|
|
941
|
-
class
|
|
624
|
+
class j {
|
|
942
625
|
constructor(e) {
|
|
943
626
|
const { onSubmit: t, onCancel: i } = e;
|
|
944
627
|
this.dialog = new u({
|
|
945
628
|
title: "Insert Table",
|
|
946
629
|
content: this.createFormHTML(),
|
|
947
|
-
onSubmit: (
|
|
948
|
-
const
|
|
949
|
-
if (
|
|
630
|
+
onSubmit: (n) => {
|
|
631
|
+
const o = parseInt(n.get("rows"), 10), s = parseInt(n.get("cols"), 10), a = n.get("headerRow") === "on";
|
|
632
|
+
if (o < 1 || o > 100) {
|
|
950
633
|
alert("Please enter a valid number of rows (1-100)");
|
|
951
634
|
return;
|
|
952
635
|
}
|
|
953
|
-
if (
|
|
636
|
+
if (s < 1 || s > 20) {
|
|
954
637
|
alert("Please enter a valid number of columns (1-20)");
|
|
955
638
|
return;
|
|
956
639
|
}
|
|
957
|
-
t({ rows:
|
|
640
|
+
t({ rows: o, cols: s, headerRow: a }), this.dialog.close();
|
|
958
641
|
},
|
|
959
642
|
onCancel: () => {
|
|
960
643
|
i == null || i(), this.dialog.close();
|
|
@@ -1033,31 +716,31 @@ class q {
|
|
|
1033
716
|
attachPreviewListeners() {
|
|
1034
717
|
const e = document.querySelector(".table-dialog-form");
|
|
1035
718
|
if (!e) return;
|
|
1036
|
-
const t = e.querySelector("#table-rows"), i = e.querySelector("#table-cols"),
|
|
1037
|
-
const
|
|
1038
|
-
|
|
719
|
+
const t = e.querySelector("#table-rows"), i = e.querySelector("#table-cols"), n = e.querySelector("#table-header"), o = e.querySelector("#table-preview-content"), s = () => {
|
|
720
|
+
const a = parseInt((t == null ? void 0 : t.value) || "3", 10), r = parseInt((i == null ? void 0 : i.value) || "3", 10), d = n == null ? void 0 : n.checked;
|
|
721
|
+
o && (o.textContent = `${a} rows × ${r} columns${d ? " with header" : ""}`);
|
|
1039
722
|
};
|
|
1040
|
-
t == null || t.addEventListener("input",
|
|
723
|
+
t == null || t.addEventListener("input", s), i == null || i.addEventListener("input", s), n == null || n.addEventListener("change", s);
|
|
1041
724
|
}
|
|
1042
725
|
}
|
|
1043
|
-
class
|
|
726
|
+
class $ {
|
|
1044
727
|
constructor(e) {
|
|
1045
728
|
this.config = e;
|
|
1046
729
|
const { onSubmit: t, onCancel: i } = e;
|
|
1047
730
|
this.dialog = new u({
|
|
1048
731
|
title: "Insert Image",
|
|
1049
732
|
content: this.createFormHTML(),
|
|
1050
|
-
onSubmit: (
|
|
1051
|
-
const
|
|
1052
|
-
if (!
|
|
733
|
+
onSubmit: (n) => {
|
|
734
|
+
const o = (n.get("src") || "").trim(), s = (n.get("alt") || "").trim(), a = (n.get("width") || "").trim(), r = (n.get("height") || "").trim();
|
|
735
|
+
if (!o) {
|
|
1053
736
|
alert("Please enter an image URL or upload an image");
|
|
1054
737
|
return;
|
|
1055
738
|
}
|
|
1056
739
|
t({
|
|
1057
|
-
src:
|
|
1058
|
-
alt:
|
|
1059
|
-
width:
|
|
1060
|
-
height:
|
|
740
|
+
src: o,
|
|
741
|
+
alt: s,
|
|
742
|
+
width: a || void 0,
|
|
743
|
+
height: r || void 0
|
|
1061
744
|
}), this.dialog.close();
|
|
1062
745
|
},
|
|
1063
746
|
onCancel: () => {
|
|
@@ -1152,10 +835,10 @@ class A {
|
|
|
1152
835
|
attachImagePreview() {
|
|
1153
836
|
const e = document.querySelector(".image-dialog-form");
|
|
1154
837
|
if (!e) return;
|
|
1155
|
-
const t = e.querySelector("#image-src"), i = e.querySelector("#image-preview"),
|
|
838
|
+
const t = e.querySelector("#image-src"), i = e.querySelector("#image-preview"), n = e.querySelector("#preview-img");
|
|
1156
839
|
t == null || t.addEventListener("input", () => {
|
|
1157
|
-
const
|
|
1158
|
-
|
|
840
|
+
const o = t.value.trim();
|
|
841
|
+
o && this.isValidImageUrl(o) ? (n.src = o, i.style.display = "block", n.onerror = () => {
|
|
1159
842
|
i.style.display = "none";
|
|
1160
843
|
}) : i.style.display = "none";
|
|
1161
844
|
});
|
|
@@ -1165,16 +848,16 @@ class A {
|
|
|
1165
848
|
const e = document.querySelector(".image-dialog-form");
|
|
1166
849
|
if (!e) return;
|
|
1167
850
|
const t = e.querySelector("#image-upload"), i = e.querySelector("#image-src");
|
|
1168
|
-
t == null || t.addEventListener("change", async (
|
|
1169
|
-
var
|
|
1170
|
-
const
|
|
1171
|
-
if (!
|
|
1172
|
-
const
|
|
1173
|
-
|
|
851
|
+
t == null || t.addEventListener("change", async (n) => {
|
|
852
|
+
var a;
|
|
853
|
+
const o = (a = n.target.files) == null ? void 0 : a[0];
|
|
854
|
+
if (!o) return;
|
|
855
|
+
const s = new FileReader();
|
|
856
|
+
s.onload = (r) => {
|
|
1174
857
|
var h;
|
|
1175
|
-
const d = (h =
|
|
858
|
+
const d = (h = r.target) == null ? void 0 : h.result;
|
|
1176
859
|
i.value = d, i.dispatchEvent(new Event("input"));
|
|
1177
|
-
},
|
|
860
|
+
}, s.readAsDataURL(o);
|
|
1178
861
|
});
|
|
1179
862
|
}
|
|
1180
863
|
isValidImageUrl(e) {
|
|
@@ -1320,12 +1003,12 @@ class P {
|
|
|
1320
1003
|
</select>
|
|
1321
1004
|
</div>
|
|
1322
1005
|
`, e.querySelectorAll(".math-symbol-btn").forEach((i) => {
|
|
1323
|
-
i.addEventListener("click", (
|
|
1324
|
-
|
|
1325
|
-
const
|
|
1326
|
-
if (
|
|
1327
|
-
const
|
|
1328
|
-
this.latexInput.value =
|
|
1006
|
+
i.addEventListener("click", (n) => {
|
|
1007
|
+
n.preventDefault();
|
|
1008
|
+
const o = i.getAttribute("data-symbol");
|
|
1009
|
+
if (o && this.latexInput) {
|
|
1010
|
+
const s = this.latexInput.selectionStart, a = this.latexInput.selectionEnd, r = this.latexInput.value;
|
|
1011
|
+
this.latexInput.value = r.substring(0, s) + o + r.substring(a), this.latexInput.focus(), this.latexInput.selectionStart = this.latexInput.selectionEnd = s + o.length, this.updatePreview();
|
|
1329
1012
|
}
|
|
1330
1013
|
});
|
|
1331
1014
|
}), e;
|
|
@@ -1355,7 +1038,7 @@ class P {
|
|
|
1355
1038
|
this.dialog.close();
|
|
1356
1039
|
}
|
|
1357
1040
|
}
|
|
1358
|
-
class
|
|
1041
|
+
class H {
|
|
1359
1042
|
constructor(e) {
|
|
1360
1043
|
this.characters = {
|
|
1361
1044
|
common: ["©", "®", "™", "§", "¶", "†", "‡", "•", "‣", "⁃", "◦", "▪", "▫", "◊", "○", "●", "□", "■", "△", "▲", "▽", "▼", "◇", "◆", "★", "☆"],
|
|
@@ -1475,17 +1158,17 @@ class $ {
|
|
|
1475
1158
|
this.charactersGrid.innerHTML = "";
|
|
1476
1159
|
let t = [];
|
|
1477
1160
|
e === "all" ? t = Object.values(this.characters).flat() : t = this.characters[e] || [], t.forEach((i) => {
|
|
1478
|
-
const
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
}), this.charactersGrid.appendChild(
|
|
1161
|
+
const n = document.createElement("button");
|
|
1162
|
+
n.className = "char-button", n.textContent = i, n.title = `Insert ${i} (U+${i.charCodeAt(0).toString(16).toUpperCase()})`, n.addEventListener("click", (o) => {
|
|
1163
|
+
o.preventDefault(), this.handleSelect(i);
|
|
1164
|
+
}), this.charactersGrid.appendChild(n);
|
|
1482
1165
|
});
|
|
1483
1166
|
}
|
|
1484
1167
|
filterCharacters() {
|
|
1485
1168
|
const e = this.searchInput.value.toLowerCase();
|
|
1486
1169
|
this.charactersGrid.querySelectorAll(".char-button").forEach((i) => {
|
|
1487
|
-
const
|
|
1488
|
-
i.style.display =
|
|
1170
|
+
const n = i.textContent || "", o = `u+${n.charCodeAt(0).toString(16)}`, s = !e || n.includes(e) || o.includes(e);
|
|
1171
|
+
i.style.display = s ? "flex" : "none";
|
|
1489
1172
|
});
|
|
1490
1173
|
}
|
|
1491
1174
|
handleSelect(e) {
|
|
@@ -1498,7 +1181,7 @@ class $ {
|
|
|
1498
1181
|
this.dialog.close();
|
|
1499
1182
|
}
|
|
1500
1183
|
}
|
|
1501
|
-
class
|
|
1184
|
+
class A {
|
|
1502
1185
|
constructor(e) {
|
|
1503
1186
|
this.emojis = {
|
|
1504
1187
|
popular: ["😀", "😃", "😄", "😁", "😊", "😍", "🤩", "😘", "😗", "😚", "😙", "🙂", "🤗", "🤔", "🤨", "😐", "😑", "😶", "🙄", "😏", "👍", "👎", "👌", "✌️", "🤞", "🤝", "👏", "🙌", "👋", "🤚", "✋", "🖐️", "🖖", "👊", "✊", "🤛", "🤜", "💪"],
|
|
@@ -1624,17 +1307,17 @@ class H {
|
|
|
1624
1307
|
this.emojisGrid.innerHTML = "";
|
|
1625
1308
|
let t = [];
|
|
1626
1309
|
e === "all" ? t = Object.values(this.emojis).flat() : t = this.emojis[e] || [], t.forEach((i) => {
|
|
1627
|
-
const
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
}), this.emojisGrid.appendChild(
|
|
1310
|
+
const n = document.createElement("button");
|
|
1311
|
+
n.className = "emoji-button", n.textContent = i, n.title = `Insert ${i}`, n.addEventListener("click", (o) => {
|
|
1312
|
+
o.preventDefault(), this.handleSelect(i);
|
|
1313
|
+
}), this.emojisGrid.appendChild(n);
|
|
1631
1314
|
});
|
|
1632
1315
|
}
|
|
1633
1316
|
filterEmojis() {
|
|
1634
1317
|
const e = this.searchInput.value.toLowerCase();
|
|
1635
1318
|
this.emojisGrid.querySelectorAll(".emoji-button").forEach((i) => {
|
|
1636
|
-
const
|
|
1637
|
-
i.style.display =
|
|
1319
|
+
const n = i.textContent || "", o = !e || n.includes(e);
|
|
1320
|
+
i.style.display = o ? "flex" : "none";
|
|
1638
1321
|
});
|
|
1639
1322
|
}
|
|
1640
1323
|
handleSelect(e) {
|
|
@@ -1647,9 +1330,9 @@ class H {
|
|
|
1647
1330
|
this.dialog.close();
|
|
1648
1331
|
}
|
|
1649
1332
|
}
|
|
1650
|
-
class
|
|
1333
|
+
class x {
|
|
1651
1334
|
constructor(e = {}) {
|
|
1652
|
-
this.changeListeners = [], this.options = e, this.engine = new
|
|
1335
|
+
this.changeListeners = [], this.options = e, this.engine = new b({
|
|
1653
1336
|
content: e.content,
|
|
1654
1337
|
plugins: e.plugins || [],
|
|
1655
1338
|
readonly: e.readonly
|
|
@@ -1662,16 +1345,16 @@ class S {
|
|
|
1662
1345
|
* Mount editor to DOM elements
|
|
1663
1346
|
*/
|
|
1664
1347
|
mount(e, t) {
|
|
1665
|
-
this.contentElement = e, this.toolbarElement = t, this.contentElement.contentEditable = this.options.readonly ? "false" : "true", this.contentElement.className = "rte-content", this.options.content && (this.contentElement.innerHTML = this.options.content), this.options.toolbar !== !1 && this.toolbarElement && (this.toolbar = new
|
|
1348
|
+
this.contentElement = e, this.toolbarElement = t, this.contentElement.contentEditable = this.options.readonly ? "false" : "true", this.contentElement.className = "rte-content", this.options.content && (this.contentElement.innerHTML = this.options.content), this.options.toolbar !== !1 && this.toolbarElement && (this.toolbar = new f(
|
|
1666
1349
|
{
|
|
1667
1350
|
items: typeof this.options.toolbar == "string" ? this.options.toolbar : void 0
|
|
1668
1351
|
},
|
|
1669
1352
|
this.options.plugins || []
|
|
1670
|
-
), this.toolbar.setCommandHandler((i,
|
|
1671
|
-
this.execCommand(i,
|
|
1353
|
+
), this.toolbar.setCommandHandler((i, n) => {
|
|
1354
|
+
this.execCommand(i, n);
|
|
1672
1355
|
}), this.toolbar.render(this.toolbarElement)), this.contentElement.addEventListener("input", () => {
|
|
1673
1356
|
const i = this.getHTML();
|
|
1674
|
-
this.changeListeners.forEach((
|
|
1357
|
+
this.changeListeners.forEach((n) => n(i));
|
|
1675
1358
|
}), this.options.onInit && this.options.onInit(this.getAPI());
|
|
1676
1359
|
}
|
|
1677
1360
|
/**
|
|
@@ -1764,14 +1447,14 @@ class S {
|
|
|
1764
1447
|
this.engine.destroy(), (e = this.toolbar) == null || e.destroy(), this.changeListeners = [], this.options.onDestroy && this.options.onDestroy();
|
|
1765
1448
|
}
|
|
1766
1449
|
}
|
|
1767
|
-
function
|
|
1768
|
-
return new
|
|
1450
|
+
function D(l) {
|
|
1451
|
+
return new x(l);
|
|
1769
1452
|
}
|
|
1770
|
-
class
|
|
1453
|
+
class w {
|
|
1771
1454
|
constructor(e) {
|
|
1772
1455
|
this.options = e, this.containerElement = e.element;
|
|
1773
1456
|
const t = this.resolvePlugins(e.plugins);
|
|
1774
|
-
this.engine = new
|
|
1457
|
+
this.engine = new b({
|
|
1775
1458
|
content: e.content,
|
|
1776
1459
|
plugins: t,
|
|
1777
1460
|
readonly: e.readonly
|
|
@@ -1787,7 +1470,7 @@ class x {
|
|
|
1787
1470
|
* Initialize DOM elements
|
|
1788
1471
|
*/
|
|
1789
1472
|
initializeDOM() {
|
|
1790
|
-
this.containerElement.innerHTML = "", this.containerElement.classList.add("editora-editor"), this.options.enableToolbar !== !1 && this.options.toolbar !== !1 && (this.toolbarElement = document.createElement("div"), this.toolbarElement.className = "editora-toolbar-container", this.containerElement.appendChild(this.toolbarElement), this.toolbar = new
|
|
1473
|
+
this.containerElement.innerHTML = "", this.containerElement.classList.add("editora-editor"), this.options.enableToolbar !== !1 && this.options.toolbar !== !1 && (this.toolbarElement = document.createElement("div"), this.toolbarElement.className = "editora-toolbar-container", this.containerElement.appendChild(this.toolbarElement), this.toolbar = new f(
|
|
1791
1474
|
{
|
|
1792
1475
|
items: typeof this.options.toolbar == "string" ? this.options.toolbar : void 0
|
|
1793
1476
|
},
|
|
@@ -1830,8 +1513,8 @@ class x {
|
|
|
1830
1513
|
* Add event listener
|
|
1831
1514
|
*/
|
|
1832
1515
|
on(e, t) {
|
|
1833
|
-
const i = (
|
|
1834
|
-
t(
|
|
1516
|
+
const i = (n) => {
|
|
1517
|
+
t(n.detail);
|
|
1835
1518
|
};
|
|
1836
1519
|
return this.containerElement.addEventListener(e, i), () => {
|
|
1837
1520
|
this.containerElement.removeEventListener(e, i);
|
|
@@ -1845,49 +1528,49 @@ class x {
|
|
|
1845
1528
|
this.engine.destroy(), (e = this.toolbar) == null || e.destroy(), this.containerElement.innerHTML = "";
|
|
1846
1529
|
}
|
|
1847
1530
|
}
|
|
1848
|
-
function
|
|
1849
|
-
return new
|
|
1531
|
+
function z(l) {
|
|
1532
|
+
return new w(l);
|
|
1850
1533
|
}
|
|
1851
|
-
function
|
|
1534
|
+
function U() {
|
|
1852
1535
|
typeof window != "undefined" && !customElements.get("editora-editor") && customElements.define("editora-editor", v);
|
|
1853
1536
|
}
|
|
1854
1537
|
export {
|
|
1855
|
-
|
|
1856
|
-
|
|
1857
|
-
|
|
1858
|
-
|
|
1538
|
+
H as CharacterDialog,
|
|
1539
|
+
M as ColorPicker,
|
|
1540
|
+
G as CommandRegistry,
|
|
1541
|
+
O as ConfigResolver,
|
|
1859
1542
|
u as Dialog,
|
|
1860
1543
|
m as DocumentModel,
|
|
1861
|
-
|
|
1862
|
-
|
|
1863
|
-
|
|
1544
|
+
F as Dropdown,
|
|
1545
|
+
L as Editor,
|
|
1546
|
+
b as EditorEngine,
|
|
1864
1547
|
y as EditorState,
|
|
1865
|
-
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1548
|
+
A as EmojiDialog,
|
|
1549
|
+
V as FloatingToolbar,
|
|
1550
|
+
$ as ImageDialog,
|
|
1551
|
+
K as KeyboardShortcutManager,
|
|
1552
|
+
q as LinkDialog,
|
|
1870
1553
|
P as MathDialog,
|
|
1871
1554
|
I as MediaPlugin,
|
|
1872
|
-
|
|
1555
|
+
B as PluginLoader,
|
|
1873
1556
|
g as PluginManager,
|
|
1874
1557
|
E as PluginRuntime,
|
|
1875
|
-
|
|
1558
|
+
x as ReactAdapter,
|
|
1876
1559
|
v as RichTextEditorElement,
|
|
1877
1560
|
W as Schema,
|
|
1878
1561
|
T as SpellcheckPlugin,
|
|
1879
1562
|
X as StatusBar,
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
1563
|
+
j as TableDialog,
|
|
1564
|
+
f as ToolbarRenderer,
|
|
1565
|
+
w as VanillaAdapter,
|
|
1883
1566
|
_ as calculateTextStats,
|
|
1884
1567
|
Y as countLines,
|
|
1885
|
-
|
|
1886
|
-
|
|
1887
|
-
|
|
1568
|
+
z as createEditor,
|
|
1569
|
+
k as createPluginRuntime,
|
|
1570
|
+
D as createReactAdapter,
|
|
1888
1571
|
J as getCursorPosition,
|
|
1889
1572
|
Q as getSelectionInfo,
|
|
1890
1573
|
Z as getTextOffset,
|
|
1891
|
-
|
|
1574
|
+
U as initWebComponent
|
|
1892
1575
|
};
|
|
1893
1576
|
//# sourceMappingURL=index.esm.js.map
|