texditor 2.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/LICENSE.md +9 -0
- package/README.md +232 -0
- package/dist/core/base/base-model.d.ts +160 -0
- package/dist/core/base/base-model.d.ts.map +1 -0
- package/dist/core/base/event-manager.d.ts +20 -0
- package/dist/core/base/event-manager.d.ts.map +1 -0
- package/dist/core/base/index.d.ts +3 -0
- package/dist/core/base/index.d.ts.map +1 -0
- package/dist/core/base.d.ts +2 -0
- package/dist/core/base.mjs +1 -0
- package/dist/core/block-manager.d.ts +91 -0
- package/dist/core/block-manager.d.ts.map +1 -0
- package/dist/core/commands.d.ts +73 -0
- package/dist/core/commands.d.ts.map +1 -0
- package/dist/core/config.d.ts +11 -0
- package/dist/core/config.d.ts.map +1 -0
- package/dist/core/events.d.ts +121 -0
- package/dist/core/events.d.ts.map +1 -0
- package/dist/core/extensions.d.ts +23 -0
- package/dist/core/extensions.d.ts.map +1 -0
- package/dist/core/history-manager.d.ts +76 -0
- package/dist/core/history-manager.d.ts.map +1 -0
- package/dist/core/i18n.d.ts +29 -0
- package/dist/core/i18n.d.ts.map +1 -0
- package/dist/core/models/action-model.d.ts +54 -0
- package/dist/core/models/action-model.d.ts.map +1 -0
- package/dist/core/models/block-model.d.ts +396 -0
- package/dist/core/models/block-model.d.ts.map +1 -0
- package/dist/core/models/extension-model.d.ts +25 -0
- package/dist/core/models/extension-model.d.ts.map +1 -0
- package/dist/core/models/file-action-model.d.ts +20 -0
- package/dist/core/models/file-action-model.d.ts.map +1 -0
- package/dist/core/models/index.d.ts +7 -0
- package/dist/core/models/index.d.ts.map +1 -0
- package/dist/core/models/tool-model.d.ts +69 -0
- package/dist/core/models/tool-model.d.ts.map +1 -0
- package/dist/core/models.d.ts +2 -0
- package/dist/core/models.mjs +6 -0
- package/dist/core/security/sanitizer.d.ts +65 -0
- package/dist/core/security/sanitizer.d.ts.map +1 -0
- package/dist/core/selection-api.d.ts +52 -0
- package/dist/core/selection-api.d.ts.map +1 -0
- package/dist/core/tools.d.ts +27 -0
- package/dist/core/tools.d.ts.map +1 -0
- package/dist/core/ui/slider.d.ts +50 -0
- package/dist/core/ui/slider.d.ts.map +1 -0
- package/dist/core/ui/toasts.d.ts +23 -0
- package/dist/core/ui/toasts.d.ts.map +1 -0
- package/dist/core/ui/virtual-selection.d.ts +171 -0
- package/dist/core/ui/virtual-selection.d.ts.map +1 -0
- package/dist/entities/actions/convert-action.d.ts +9 -0
- package/dist/entities/actions/convert-action.d.ts.map +1 -0
- package/dist/entities/actions/create-action.d.ts +8 -0
- package/dist/entities/actions/create-action.d.ts.map +1 -0
- package/dist/entities/actions/delete-action.d.ts +8 -0
- package/dist/entities/actions/delete-action.d.ts.map +1 -0
- package/dist/entities/actions/index.d.ts +7 -0
- package/dist/entities/actions/index.d.ts.map +1 -0
- package/dist/entities/actions/move-down-action.d.ts +9 -0
- package/dist/entities/actions/move-down-action.d.ts.map +1 -0
- package/dist/entities/actions/move-up-action.d.ts +9 -0
- package/dist/entities/actions/move-up-action.d.ts.map +1 -0
- package/dist/entities/actions.d.ts +2 -0
- package/dist/entities/actions.mjs +6 -0
- package/dist/entities/blocks/code/index.d.ts +48 -0
- package/dist/entities/blocks/code/index.d.ts.map +1 -0
- package/dist/entities/blocks/code/languages.d.ts +4 -0
- package/dist/entities/blocks/code/languages.d.ts.map +1 -0
- package/dist/entities/blocks/files/actions/DeleteFileAction.d.ts +7 -0
- package/dist/entities/blocks/files/actions/DeleteFileAction.d.ts.map +1 -0
- package/dist/entities/blocks/files/actions/DownloadFileAction.d.ts +12 -0
- package/dist/entities/blocks/files/actions/DownloadFileAction.d.ts.map +1 -0
- package/dist/entities/blocks/files/actions/EditFileAction.d.ts +32 -0
- package/dist/entities/blocks/files/actions/EditFileAction.d.ts.map +1 -0
- package/dist/entities/blocks/files/actions/MoveLeftFileAction.d.ts +8 -0
- package/dist/entities/blocks/files/actions/MoveLeftFileAction.d.ts.map +1 -0
- package/dist/entities/blocks/files/actions/MoveRightFileAction.d.ts +8 -0
- package/dist/entities/blocks/files/actions/MoveRightFileAction.d.ts.map +1 -0
- package/dist/entities/blocks/files/index.d.ts +185 -0
- package/dist/entities/blocks/files/index.d.ts.map +1 -0
- package/dist/entities/blocks/gallery/index.d.ts +60 -0
- package/dist/entities/blocks/gallery/index.d.ts.map +1 -0
- package/dist/entities/blocks/header/H1.d.ts +4 -0
- package/dist/entities/blocks/header/H1.d.ts.map +1 -0
- package/dist/entities/blocks/header/H2.d.ts +6 -0
- package/dist/entities/blocks/header/H2.d.ts.map +1 -0
- package/dist/entities/blocks/header/H3.d.ts +6 -0
- package/dist/entities/blocks/header/H3.d.ts.map +1 -0
- package/dist/entities/blocks/header/H4.d.ts +6 -0
- package/dist/entities/blocks/header/H4.d.ts.map +1 -0
- package/dist/entities/blocks/header/H5.d.ts +6 -0
- package/dist/entities/blocks/header/H5.d.ts.map +1 -0
- package/dist/entities/blocks/header/H6.d.ts +6 -0
- package/dist/entities/blocks/header/H6.d.ts.map +1 -0
- package/dist/entities/blocks/header/index.d.ts +6 -0
- package/dist/entities/blocks/header/index.d.ts.map +1 -0
- package/dist/entities/blocks/index.d.ts +14 -0
- package/dist/entities/blocks/index.d.ts.map +1 -0
- package/dist/entities/blocks/list/index.d.ts +6 -0
- package/dist/entities/blocks/list/index.d.ts.map +1 -0
- package/dist/entities/blocks/list/ol.d.ts +6 -0
- package/dist/entities/blocks/list/ol.d.ts.map +1 -0
- package/dist/entities/blocks/paragraph/index.d.ts +6 -0
- package/dist/entities/blocks/paragraph/index.d.ts.map +1 -0
- package/dist/entities/blocks.d.ts +2 -0
- package/dist/entities/blocks.mjs +13 -0
- package/dist/entities/extensions/delete-selected.d.ts +9 -0
- package/dist/entities/extensions/delete-selected.d.ts.map +1 -0
- package/dist/entities/extensions/index.d.ts +5 -0
- package/dist/entities/extensions/index.d.ts.map +1 -0
- package/dist/entities/extensions/redo.d.ts +8 -0
- package/dist/entities/extensions/redo.d.ts.map +1 -0
- package/dist/entities/extensions/undo.d.ts +8 -0
- package/dist/entities/extensions/undo.d.ts.map +1 -0
- package/dist/entities/extensions.d.ts +2 -0
- package/dist/entities/extensions.mjs +4 -0
- package/dist/entities/tools/bold.d.ts +6 -0
- package/dist/entities/tools/bold.d.ts.map +1 -0
- package/dist/entities/tools/clear-formatting.d.ts +7 -0
- package/dist/entities/tools/clear-formatting.d.ts.map +1 -0
- package/dist/entities/tools/index.d.ts +10 -0
- package/dist/entities/tools/index.d.ts.map +1 -0
- package/dist/entities/tools/inline-code.d.ts +6 -0
- package/dist/entities/tools/inline-code.d.ts.map +1 -0
- package/dist/entities/tools/italic.d.ts +6 -0
- package/dist/entities/tools/italic.d.ts.map +1 -0
- package/dist/entities/tools/link.d.ts +35 -0
- package/dist/entities/tools/link.d.ts.map +1 -0
- package/dist/entities/tools/marker.d.ts +6 -0
- package/dist/entities/tools/marker.d.ts.map +1 -0
- package/dist/entities/tools/subscript.d.ts +6 -0
- package/dist/entities/tools/subscript.d.ts.map +1 -0
- package/dist/entities/tools/superscript.d.ts +6 -0
- package/dist/entities/tools/superscript.d.ts.map +1 -0
- package/dist/entities/tools.d.ts +2 -0
- package/dist/entities/tools.mjs +9 -0
- package/dist/icons/index.d.ts +42 -0
- package/dist/icons/index.d.ts.map +1 -0
- package/dist/locales/en.d.ts +66 -0
- package/dist/locales/en.d.ts.map +1 -0
- package/dist/locales/index.d.ts +4 -0
- package/dist/locales/index.d.ts.map +1 -0
- package/dist/locales/ru.d.ts +66 -0
- package/dist/locales/ru.d.ts.map +1 -0
- package/dist/locales.d.ts +2 -0
- package/dist/locales.mjs +3 -0
- package/dist/main.d.ts +6 -0
- package/dist/node_modules/snappykit/dist/snappykit.mjs +440 -0
- package/dist/node_modules/sortum/dist/sortum.mjs +588 -0
- package/dist/src/core/base/base-model.mjs +184 -0
- package/dist/src/core/base/event-manager.mjs +31 -0
- package/dist/src/core/block-manager.mjs +499 -0
- package/dist/src/core/commands.mjs +311 -0
- package/dist/src/core/config.mjs +12 -0
- package/dist/src/core/events.mjs +369 -0
- package/dist/src/core/extensions.mjs +48 -0
- package/dist/src/core/history-manager.mjs +107 -0
- package/dist/src/core/i18n.mjs +25 -0
- package/dist/src/core/models/action-model.mjs +72 -0
- package/dist/src/core/models/block-model.mjs +619 -0
- package/dist/src/core/models/extension-model.mjs +28 -0
- package/dist/src/core/models/file-action-model.mjs +24 -0
- package/dist/src/core/models/tool-model.mjs +80 -0
- package/dist/src/core/security/sanitizer.mjs +130 -0
- package/dist/src/core/selection-api.mjs +202 -0
- package/dist/src/core/tools.mjs +88 -0
- package/dist/src/core/ui/slider.mjs +81 -0
- package/dist/src/core/ui/toasts.mjs +55 -0
- package/dist/src/core/ui/virtual-selection.mjs +205 -0
- package/dist/src/entities/actions/convert-action.mjs +43 -0
- package/dist/src/entities/actions/create-action.mjs +39 -0
- package/dist/src/entities/actions/delete-action.mjs +19 -0
- package/dist/src/entities/actions/move-down-action.mjs +22 -0
- package/dist/src/entities/actions/move-up-action.mjs +22 -0
- package/dist/src/entities/blocks/code/index.mjs +144 -0
- package/dist/src/entities/blocks/code/languages.mjs +54 -0
- package/dist/src/entities/blocks/files/actions/DeleteFileAction.mjs +21 -0
- package/dist/src/entities/blocks/files/actions/DownloadFileAction.mjs +44 -0
- package/dist/src/entities/blocks/files/actions/EditFileAction.mjs +111 -0
- package/dist/src/entities/blocks/files/actions/MoveLeftFileAction.mjs +24 -0
- package/dist/src/entities/blocks/files/actions/MoveRightFileAction.mjs +24 -0
- package/dist/src/entities/blocks/files/index.mjs +424 -0
- package/dist/src/entities/blocks/gallery/index.mjs +141 -0
- package/dist/src/entities/blocks/header/H1.mjs +5 -0
- package/dist/src/entities/blocks/header/H2.mjs +16 -0
- package/dist/src/entities/blocks/header/H3.mjs +16 -0
- package/dist/src/entities/blocks/header/H4.mjs +16 -0
- package/dist/src/entities/blocks/header/H5.mjs +16 -0
- package/dist/src/entities/blocks/header/H6.mjs +16 -0
- package/dist/src/entities/blocks/header/index.mjs +46 -0
- package/dist/src/entities/blocks/list/index.mjs +51 -0
- package/dist/src/entities/blocks/list/ol.mjs +16 -0
- package/dist/src/entities/blocks/paragraph/index.mjs +46 -0
- package/dist/src/entities/extensions/delete-selected.mjs +27 -0
- package/dist/src/entities/extensions/redo.mjs +22 -0
- package/dist/src/entities/extensions/undo.mjs +22 -0
- package/dist/src/entities/tools/bold.mjs +16 -0
- package/dist/src/entities/tools/clear-formatting.mjs +20 -0
- package/dist/src/entities/tools/inline-code.mjs +19 -0
- package/dist/src/entities/tools/italic.mjs +16 -0
- package/dist/src/entities/tools/link.mjs +89 -0
- package/dist/src/entities/tools/marker.mjs +17 -0
- package/dist/src/entities/tools/subscript.mjs +17 -0
- package/dist/src/entities/tools/superscript.mjs +18 -0
- package/dist/src/icons/index.mjs +4 -0
- package/dist/src/locales/en.mjs +68 -0
- package/dist/src/locales/ru.mjs +68 -0
- package/dist/src/store/currentStore.mjs +8 -0
- package/dist/src/store/mainStore.mjs +4 -0
- package/dist/src/utils/ajax.mjs +35 -0
- package/dist/src/utils/common.mjs +26 -0
- package/dist/src/utils/icon.mjs +12 -0
- package/dist/src/utils/sanitizer.mjs +20 -0
- package/dist/src/views/extensions.mjs +18 -0
- package/dist/src/views/main.mjs +19 -0
- package/dist/src/views/tools.mjs +9 -0
- package/dist/store/currentStore.d.ts +15 -0
- package/dist/store/currentStore.d.ts.map +1 -0
- package/dist/store/mainStore.d.ts +14 -0
- package/dist/store/mainStore.d.ts.map +1 -0
- package/dist/styles/animations.css +1 -0
- package/dist/styles/core/ui/selection.css +1 -0
- package/dist/styles/core/ui/slider.css +1 -0
- package/dist/styles/entities/blocks/code.css +1 -0
- package/dist/styles/entities/blocks/files.css +1 -0
- package/dist/styles/entities/blocks/gallery.css +1 -0
- package/dist/styles/entities/blocks/list.css +1 -0
- package/dist/styles/entities/blocks/paragraph.css +1 -0
- package/dist/styles/entities/tools/inline-code.css +1 -0
- package/dist/styles/entities/tools/link.css +1 -0
- package/dist/styles/texditor.css +1 -0
- package/dist/styles/theme.css +42 -0
- package/dist/texditor.d.ts +68 -0
- package/dist/texditor.d.ts.map +1 -0
- package/dist/texditor.mjs +138 -0
- package/dist/types/core/base/base-model.d.ts +212 -0
- package/dist/types/core/base/base-model.d.ts.map +1 -0
- package/dist/types/core/base/event-manager.d.ts +42 -0
- package/dist/types/core/base/event-manager.d.ts.map +1 -0
- package/dist/types/core/base/index.d.ts +3 -0
- package/dist/types/core/base/index.d.ts.map +1 -0
- package/dist/types/core/block-manager.d.ts +223 -0
- package/dist/types/core/block-manager.d.ts.map +1 -0
- package/dist/types/core/commands.d.ts +93 -0
- package/dist/types/core/commands.d.ts.map +1 -0
- package/dist/types/core/config.d.ts +86 -0
- package/dist/types/core/config.d.ts.map +1 -0
- package/dist/types/core/events.d.ts +58 -0
- package/dist/types/core/events.d.ts.map +1 -0
- package/dist/types/core/extensions.d.ts +19 -0
- package/dist/types/core/extensions.d.ts.map +1 -0
- package/dist/types/core/history-manager.d.ts +72 -0
- package/dist/types/core/history-manager.d.ts.map +1 -0
- package/dist/types/core/http/index.d.ts +2 -0
- package/dist/types/core/http/index.d.ts.map +1 -0
- package/dist/types/core/http/response.d.ts +6 -0
- package/dist/types/core/http/response.d.ts.map +1 -0
- package/dist/types/core/i18n.d.ts +40 -0
- package/dist/types/core/i18n.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +15 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/core/models/action-model.d.ts +46 -0
- package/dist/types/core/models/action-model.d.ts.map +1 -0
- package/dist/types/core/models/block-model.d.ts +404 -0
- package/dist/types/core/models/block-model.d.ts.map +1 -0
- package/dist/types/core/models/extension-model.d.ts +41 -0
- package/dist/types/core/models/extension-model.d.ts.map +1 -0
- package/dist/types/core/models/file-action-model.d.ts +36 -0
- package/dist/types/core/models/file-action-model.d.ts.map +1 -0
- package/dist/types/core/models/index.d.ts +7 -0
- package/dist/types/core/models/index.d.ts.map +1 -0
- package/dist/types/core/models/tool-model.d.ts +54 -0
- package/dist/types/core/models/tool-model.d.ts.map +1 -0
- package/dist/types/core/sanitizer.d.ts +27 -0
- package/dist/types/core/sanitizer.d.ts.map +1 -0
- package/dist/types/core/selection-api.d.ts +116 -0
- package/dist/types/core/selection-api.d.ts.map +1 -0
- package/dist/types/core/tools.d.ts +35 -0
- package/dist/types/core/tools.d.ts.map +1 -0
- package/dist/types/core/ui/index.d.ts +4 -0
- package/dist/types/core/ui/index.d.ts.map +1 -0
- package/dist/types/core/ui/slider.d.ts +45 -0
- package/dist/types/core/ui/slider.d.ts.map +1 -0
- package/dist/types/core/ui/toasts.d.ts +58 -0
- package/dist/types/core/ui/toasts.d.ts.map +1 -0
- package/dist/types/core/ui/virtual-selection.d.ts +83 -0
- package/dist/types/core/ui/virtual-selection.d.ts.map +1 -0
- package/dist/types/entities/blocks/code.d.ts +4 -0
- package/dist/types/entities/blocks/code.d.ts.map +1 -0
- package/dist/types/entities/blocks/files.d.ts +170 -0
- package/dist/types/entities/blocks/files.d.ts.map +1 -0
- package/dist/types/entities/blocks/gallery.d.ts +40 -0
- package/dist/types/entities/blocks/gallery.d.ts.map +1 -0
- package/dist/types/entities/blocks/header.d.ts +4 -0
- package/dist/types/entities/blocks/header.d.ts.map +1 -0
- package/dist/types/entities/blocks/index.d.ts +7 -0
- package/dist/types/entities/blocks/index.d.ts.map +1 -0
- package/dist/types/entities/blocks/list.d.ts +4 -0
- package/dist/types/entities/blocks/list.d.ts.map +1 -0
- package/dist/types/entities/blocks/paragraph.d.ts +4 -0
- package/dist/types/entities/blocks/paragraph.d.ts.map +1 -0
- package/dist/types/entities/index.d.ts +2 -0
- package/dist/types/entities/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +5 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/texditor.d.ts +66 -0
- package/dist/types/texditor.d.ts.map +1 -0
- package/dist/types/utils/ajax.d.ts +31 -0
- package/dist/types/utils/ajax.d.ts.map +1 -0
- package/dist/types/utils/icon.d.ts +10 -0
- package/dist/types/utils/icon.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +3 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/utils/ajax.d.ts +9 -0
- package/dist/utils/ajax.d.ts.map +1 -0
- package/dist/utils/common.d.ts +28 -0
- package/dist/utils/common.d.ts.map +1 -0
- package/dist/utils/icon.d.ts +12 -0
- package/dist/utils/icon.d.ts.map +1 -0
- package/dist/utils/index.d.ts +5 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/sanitizer.d.ts +8 -0
- package/dist/utils/sanitizer.d.ts.map +1 -0
- package/dist/views/extensions.d.ts +3 -0
- package/dist/views/extensions.d.ts.map +1 -0
- package/dist/views/main.d.ts +3 -0
- package/dist/views/main.d.ts.map +1 -0
- package/dist/views/tools.d.ts +2 -0
- package/dist/views/tools.d.ts.map +1 -0
- package/package.json +75 -0
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import e from "../base/base-model.mjs";
|
|
2
|
+
//#region src/core/models/tool-model.ts
|
|
3
|
+
var t = class extends e {
|
|
4
|
+
static setup(e) {
|
|
5
|
+
return super.setup(e);
|
|
6
|
+
}
|
|
7
|
+
getBlockElement() {
|
|
8
|
+
return this.blockElement || null;
|
|
9
|
+
}
|
|
10
|
+
parentConfig() {
|
|
11
|
+
return {
|
|
12
|
+
__modelCode: "tool",
|
|
13
|
+
tagName: "div",
|
|
14
|
+
override: !0
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
getTagName() {
|
|
18
|
+
return this.getConfig("tagName", "");
|
|
19
|
+
}
|
|
20
|
+
formatAction(e) {
|
|
21
|
+
let t = this.getTagName(), { commands: n, events: r, selectionApi: i, tools: a } = this.editor;
|
|
22
|
+
if (i.applyState(), this.isOverride()) n.findTags().forEach((e) => {
|
|
23
|
+
let t = a.getModelByTagName(e.localName);
|
|
24
|
+
t && !t.isOverride() && n.removeFormat(t.getTagName());
|
|
25
|
+
});
|
|
26
|
+
else {
|
|
27
|
+
let e = n.findTags(), t = n.findTags(this.getTagName());
|
|
28
|
+
e.length > t.length && n.clearAllFormatting();
|
|
29
|
+
}
|
|
30
|
+
e(t, n, i), i.applyState();
|
|
31
|
+
let o = n.findTags(t, !0);
|
|
32
|
+
this.onFormat(o), r.change({
|
|
33
|
+
modelCode: this.getModelCode(),
|
|
34
|
+
type: "format",
|
|
35
|
+
name: this.getName(),
|
|
36
|
+
blockElement: this.getBlockElement()
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
format() {
|
|
40
|
+
this.formatAction((e, t) => {
|
|
41
|
+
t.format(e);
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
forcedFormat() {
|
|
45
|
+
this.formatAction((e, t) => {
|
|
46
|
+
t.createFormat(e);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
removeFormat() {
|
|
50
|
+
let { commands: e, events: t, selectionApi: n } = this.editor, r = this.getTagName();
|
|
51
|
+
n.applyState(), e.removeFormat(r), n.applyState(), t.change({
|
|
52
|
+
modelCode: this.getModelCode(),
|
|
53
|
+
type: "removeFormat",
|
|
54
|
+
name: this.getName(),
|
|
55
|
+
blockElement: this.getBlockElement()
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
isOverride() {
|
|
59
|
+
return this.getConfig("override", !0);
|
|
60
|
+
}
|
|
61
|
+
onFormat(e) {}
|
|
62
|
+
onClick(e) {
|
|
63
|
+
this.format();
|
|
64
|
+
}
|
|
65
|
+
isVisible() {
|
|
66
|
+
let e = this.getBlockElement();
|
|
67
|
+
if (!e) return !1;
|
|
68
|
+
let t = e.baseModel;
|
|
69
|
+
if (t) {
|
|
70
|
+
let e = t.getAvailableTools();
|
|
71
|
+
return e.length ? e.includes(this.getName()) : !0;
|
|
72
|
+
}
|
|
73
|
+
return !0;
|
|
74
|
+
}
|
|
75
|
+
__setBlockElement(e) {
|
|
76
|
+
this.blockElement = e;
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
//#endregion
|
|
80
|
+
export { t as default };
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { de as e, ie as t } from "../../../node_modules/snappykit/dist/snappykit.mjs";
|
|
2
|
+
//#region src/core/security/sanitizer.ts
|
|
3
|
+
var n = class n {
|
|
4
|
+
static {
|
|
5
|
+
this.REGEX_PROTOCOL = /^([A-Za-z0-9+\-.&;*\s]*?)(?::|&*0*58|&*x0*3a)/i;
|
|
6
|
+
}
|
|
7
|
+
static {
|
|
8
|
+
this.RELATIVE = "**";
|
|
9
|
+
}
|
|
10
|
+
static {
|
|
11
|
+
this.ALL = "*";
|
|
12
|
+
}
|
|
13
|
+
constructor(e = {}) {
|
|
14
|
+
this.currentElement = null, this.whitelistNodes = [], this.config = {
|
|
15
|
+
elements: e.elements ? e.elements : [],
|
|
16
|
+
attributes: e.attributes ? e.attributes : {},
|
|
17
|
+
allowComments: e.allowComments ? e.allowComments : !1,
|
|
18
|
+
protocols: e.protocols ? e.protocols : {},
|
|
19
|
+
addAttributes: e.addAttributes ? e.addAttributes : {},
|
|
20
|
+
dom: e.dom ? e.dom : document,
|
|
21
|
+
removeContents: e.removeContents,
|
|
22
|
+
transformers: e.transformers ? e.transformers : [],
|
|
23
|
+
removeAllContents: !1,
|
|
24
|
+
removeElementContents: {}
|
|
25
|
+
}, this.config.attributes && (this.config.attributes[n.ALL] = this.config.attributes[n.ALL] ? this.config.attributes[n.ALL] : []), this.allowedElements = {}, this.dom = this.config.dom;
|
|
26
|
+
for (let e = 0; e < this.config.elements.length; e++) this.allowedElements[this.config.elements[e]] = !0;
|
|
27
|
+
if (e.removeContents) if (Array.isArray(e.removeContents)) for (let t = 0; t < e.removeContents.length; t++) this.config.removeElementContents[e.removeContents[t]] = !0;
|
|
28
|
+
else this.config.removeAllContents = !0;
|
|
29
|
+
this.transformers = e.transformers ? e.transformers : [];
|
|
30
|
+
}
|
|
31
|
+
arrayIndex(e, t) {
|
|
32
|
+
for (let n = 0; n < t.length; n++) if (t[n] === e) return n;
|
|
33
|
+
return -1;
|
|
34
|
+
}
|
|
35
|
+
mergeArrays(...e) {
|
|
36
|
+
let t = [], n = {};
|
|
37
|
+
for (let r of e) if (!(!r || !r.length)) for (let e of r) n[e] || (n[e] = !0, t.push(e));
|
|
38
|
+
return t;
|
|
39
|
+
}
|
|
40
|
+
clean(e) {
|
|
41
|
+
let t;
|
|
42
|
+
switch (e.nodeType) {
|
|
43
|
+
case 1:
|
|
44
|
+
this.cleanElement(e);
|
|
45
|
+
break;
|
|
46
|
+
case 3:
|
|
47
|
+
case 5:
|
|
48
|
+
t = this.dom.createTextNode(e.textContent || ""), this.currentElement?.appendChild(t);
|
|
49
|
+
break;
|
|
50
|
+
case 8:
|
|
51
|
+
this.config.allowComments && (t = e.cloneNode(!1), this.currentElement?.appendChild(t));
|
|
52
|
+
break;
|
|
53
|
+
default:
|
|
54
|
+
console.warn("Unknown node type", e.nodeType);
|
|
55
|
+
break;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
cleanElement(e) {
|
|
59
|
+
let t = this.transformElement(e);
|
|
60
|
+
e = t.node;
|
|
61
|
+
let r = e.nodeName.toLowerCase(), i = this.currentElement;
|
|
62
|
+
if (this.allowedElements[r] || t.whitelist) {
|
|
63
|
+
this.currentElement = this.dom.createElement(e.nodeName), i?.appendChild(this.currentElement);
|
|
64
|
+
let a = this.mergeArrays(this.config.attributes?.[r], this.config.attributes?.[n.ALL], t.attrWhitelist);
|
|
65
|
+
for (let t = 0; t < a.length; t++) {
|
|
66
|
+
let i = a[t], o = e.attributes.getNamedItem(i);
|
|
67
|
+
if (o) {
|
|
68
|
+
let e = !0;
|
|
69
|
+
if (this.config.protocols?.[r]?.[i]) {
|
|
70
|
+
let t = this.config.protocols[r][i], a = o.value.toLowerCase().match(n.REGEX_PROTOCOL);
|
|
71
|
+
e = a ? t.indexOf(a[1]) !== -1 : t.indexOf(n.RELATIVE) !== -1;
|
|
72
|
+
}
|
|
73
|
+
if (e) {
|
|
74
|
+
let e = document.createAttribute(i);
|
|
75
|
+
e.value = o.value, this.currentElement.setAttributeNode(e);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
if (this.config.addAttributes?.[r]) for (let e in this.config.addAttributes[r]) {
|
|
80
|
+
let t = document.createAttribute(e);
|
|
81
|
+
t.value = this.config.addAttributes[r][e], this.currentElement.setAttributeNode(t);
|
|
82
|
+
}
|
|
83
|
+
} else if (this.arrayIndex(e, this.whitelistNodes) !== -1) {
|
|
84
|
+
for (this.currentElement = e.cloneNode(!0); this.currentElement.childNodes.length > 0;) this.currentElement.removeChild(this.currentElement.firstChild);
|
|
85
|
+
i?.appendChild(this.currentElement);
|
|
86
|
+
}
|
|
87
|
+
if (!this.config.removeAllContents && !this.config.removeElementContents[r]) for (let t = 0; t < e.childNodes.length; t++) this.clean(e.childNodes[t]);
|
|
88
|
+
this.currentElement.normalize && this.currentElement.normalize(), this.currentElement = i;
|
|
89
|
+
}
|
|
90
|
+
transformElement(e) {
|
|
91
|
+
let t = {
|
|
92
|
+
attrWhitelist: [],
|
|
93
|
+
node: e,
|
|
94
|
+
whitelist: !1
|
|
95
|
+
};
|
|
96
|
+
for (let n = 0; n < this.transformers.length; n++) {
|
|
97
|
+
let r = this.transformers[n]({
|
|
98
|
+
allowedElements: this.allowedElements,
|
|
99
|
+
config: this.config,
|
|
100
|
+
node: e,
|
|
101
|
+
nodeName: e.nodeName.toLowerCase(),
|
|
102
|
+
whitelistNodes: this.whitelistNodes,
|
|
103
|
+
dom: this.dom
|
|
104
|
+
});
|
|
105
|
+
if (r != null) {
|
|
106
|
+
if (typeof r != "object") throw Error("Transformer output must be an object or null");
|
|
107
|
+
if (r.whitelistNodes?.length) for (let e = 0; e < r.whitelistNodes.length; e++) this.arrayIndex(r.whitelistNodes[e], this.whitelistNodes) === -1 && this.whitelistNodes.push(r.whitelistNodes[e]);
|
|
108
|
+
t.whitelist = !!r.whitelist, r.attrWhitelist && (t.attrWhitelist = this.mergeArrays(t.attrWhitelist, r.attrWhitelist)), t.node = r.node ? r.node : t.node;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return t;
|
|
112
|
+
}
|
|
113
|
+
mergeTextNodesToString(e) {
|
|
114
|
+
return Array.from(e).map((e) => e.nodeType === Node.TEXT_NODE ? this.escapeHtml(e.textContent || "") : e.nodeType === Node.ELEMENT_NODE && e.outerHTML || "").join("");
|
|
115
|
+
}
|
|
116
|
+
escapeHtml(e) {
|
|
117
|
+
let n = t("div");
|
|
118
|
+
return n.textContent = e, n.innerHTML;
|
|
119
|
+
}
|
|
120
|
+
sanitize(n) {
|
|
121
|
+
let r;
|
|
122
|
+
r = typeof n == "string" ? t("div", (t) => e(t, n)) : n;
|
|
123
|
+
let i = this.dom.createDocumentFragment();
|
|
124
|
+
this.currentElement = i, this.whitelistNodes = [];
|
|
125
|
+
for (let e = 0; e < r.childNodes.length; e++) this.clean(r.childNodes[e]);
|
|
126
|
+
return i.normalize && i.normalize(), this.mergeTextNodesToString(i.childNodes);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
//#endregion
|
|
130
|
+
export { n as default };
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { F as e, M as t, N as n, ae as r, ie as i, se as a, w as o } from "../../node_modules/snappykit/dist/snappykit.mjs";
|
|
2
|
+
//#region src/core/selection-api.ts
|
|
3
|
+
var s = class {
|
|
4
|
+
constructor(e) {
|
|
5
|
+
this.state = {
|
|
6
|
+
position: {
|
|
7
|
+
start: 0,
|
|
8
|
+
end: 0
|
|
9
|
+
},
|
|
10
|
+
element: null
|
|
11
|
+
}, this.editor = e;
|
|
12
|
+
}
|
|
13
|
+
setState(e) {
|
|
14
|
+
this.state = e;
|
|
15
|
+
}
|
|
16
|
+
getState() {
|
|
17
|
+
return this.state;
|
|
18
|
+
}
|
|
19
|
+
clearState() {
|
|
20
|
+
this.setState({
|
|
21
|
+
element: null,
|
|
22
|
+
position: {
|
|
23
|
+
start: 0,
|
|
24
|
+
end: 0
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
applyState() {
|
|
29
|
+
let { element: e, position: t } = this.getState(), { start: n, end: r } = t;
|
|
30
|
+
e && this.select(n, r, e);
|
|
31
|
+
}
|
|
32
|
+
select(t, n, r, i = !1) {
|
|
33
|
+
let { element: a } = this.getState(), o = r || a || null;
|
|
34
|
+
if (!o) return;
|
|
35
|
+
let s = e(o), c = Math.max(0, Math.min(t, s)), l = Math.max(c, Math.min(n, s)), u = document.createRange(), d = this.getSelection();
|
|
36
|
+
if (!d) return;
|
|
37
|
+
let f = 0, p = null, m = null, h = 0, g = 0, _ = document.createTreeWalker(o, NodeFilter.SHOW_TEXT, { acceptNode: (e) => e.textContent?.length ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_REJECT }), v, y = [];
|
|
38
|
+
for (; v = _.nextNode();) y.push(v);
|
|
39
|
+
for (let t of y) {
|
|
40
|
+
let n = e(t);
|
|
41
|
+
if (!p && f + n > c && (p = t, h = c - f), !m && f + n >= l) {
|
|
42
|
+
m = t, g = l - f;
|
|
43
|
+
break;
|
|
44
|
+
}
|
|
45
|
+
f += n;
|
|
46
|
+
}
|
|
47
|
+
if (!p) {
|
|
48
|
+
let t = y[y.length - 1];
|
|
49
|
+
t && (p = t, h = e(t));
|
|
50
|
+
}
|
|
51
|
+
if (!m) {
|
|
52
|
+
let t = y[y.length - 1];
|
|
53
|
+
t && (m = t, g = e(t));
|
|
54
|
+
}
|
|
55
|
+
if (p && m) try {
|
|
56
|
+
u.setStart(p, Math.min(h, e(p))), u.setEnd(m, Math.min(g, e(m)));
|
|
57
|
+
} catch (e) {
|
|
58
|
+
console.warn("Error setting range:", e);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
else return;
|
|
62
|
+
r && i && r.scrollIntoView({
|
|
63
|
+
behavior: "smooth",
|
|
64
|
+
block: "center"
|
|
65
|
+
}), d.removeAllRanges(), d.addRange(u);
|
|
66
|
+
}
|
|
67
|
+
insert(e, r = !0, o = !0) {
|
|
68
|
+
let s = this.getSelection();
|
|
69
|
+
if (document.activeElement?.isContentEditable && s && s.rangeCount > 0) {
|
|
70
|
+
let s = this.getRange();
|
|
71
|
+
if (!s) return !1;
|
|
72
|
+
s.deleteContents();
|
|
73
|
+
let c = i("div", (t) => {
|
|
74
|
+
a(t, e);
|
|
75
|
+
});
|
|
76
|
+
return r ? t(c).reverse().forEach((e) => {
|
|
77
|
+
s.insertNode(e);
|
|
78
|
+
}) : s.insertNode(document.createTextNode(o ? n(c) : e)), !0;
|
|
79
|
+
}
|
|
80
|
+
return !1;
|
|
81
|
+
}
|
|
82
|
+
insertText(e, t = !0) {
|
|
83
|
+
return this.insert(e, !1, t);
|
|
84
|
+
}
|
|
85
|
+
splitContent(e) {
|
|
86
|
+
let t = this.getSelection();
|
|
87
|
+
if (!t || t.rangeCount === 0) return "";
|
|
88
|
+
let s = t.getRangeAt(0), c = e || this.editor.blockManager.getBlock();
|
|
89
|
+
if (!c) return "";
|
|
90
|
+
let l = i("div");
|
|
91
|
+
if (a(l, ""), s.startContainer.nodeType === Node.TEXT_NODE) {
|
|
92
|
+
let e = s.startContainer, t = e.parentNode, i = n(e), a = i.substring(0, s.startOffset), u = i.substring(s.startOffset);
|
|
93
|
+
if (e.textContent = a, t !== c) {
|
|
94
|
+
let n = e, i = [];
|
|
95
|
+
for (; n && n !== c && n.parentNode !== c;) i.push(n.parentNode), n = n.parentNode;
|
|
96
|
+
let a = r(u);
|
|
97
|
+
i.forEach((e) => {
|
|
98
|
+
let t = e.cloneNode(!1);
|
|
99
|
+
o(t, a), a = t;
|
|
100
|
+
}), o(l, a);
|
|
101
|
+
let s = t.nextSibling;
|
|
102
|
+
for (; s;) o(l, s.cloneNode(!0)), t.parentNode?.removeChild(s), s = t.nextSibling;
|
|
103
|
+
} else {
|
|
104
|
+
u && (l.textContent = u);
|
|
105
|
+
let t = e.nextSibling;
|
|
106
|
+
for (; t;) o(l, t.cloneNode(!0)), c.removeChild(t), t = e.nextSibling;
|
|
107
|
+
}
|
|
108
|
+
} else {
|
|
109
|
+
let e = [], t = s.startContainer.childNodes[s.startOffset];
|
|
110
|
+
for (; t;) e.push(t.cloneNode(!0)), s.startContainer.removeChild(t), t = s.startContainer.childNodes[s.startOffset];
|
|
111
|
+
e.forEach((e) => o(l, e));
|
|
112
|
+
}
|
|
113
|
+
return a(l).trim();
|
|
114
|
+
}
|
|
115
|
+
findTags(e, t = !0) {
|
|
116
|
+
let n = this.getSelection();
|
|
117
|
+
if (!n || n.rangeCount === 0) return [];
|
|
118
|
+
let r = n.getRangeAt(0), i = [];
|
|
119
|
+
if (!e.contains(r.commonAncestorContainer)) return [];
|
|
120
|
+
let a = (n) => {
|
|
121
|
+
let o = document.createRange();
|
|
122
|
+
if (o.selectNode(n), (r.compareBoundaryPoints(Range.START_TO_START, o) <= 0 && r.compareBoundaryPoints(Range.END_TO_END, o) >= 0 || r.intersectsNode(n)) && n !== e && i.push(n), t) for (let e of Array.from(n.children)) a(e);
|
|
123
|
+
};
|
|
124
|
+
return Array.from(e.children).forEach((e) => {
|
|
125
|
+
a(e);
|
|
126
|
+
}), i;
|
|
127
|
+
}
|
|
128
|
+
getSelection() {
|
|
129
|
+
return window.getSelection() || null;
|
|
130
|
+
}
|
|
131
|
+
getRange(e = 0) {
|
|
132
|
+
let t = this.getSelection();
|
|
133
|
+
return !t || t.rangeCount === 0 ? null : t.getRangeAt(e);
|
|
134
|
+
}
|
|
135
|
+
getAbsoluteOffset(e, t) {
|
|
136
|
+
if (e.nodeType === Node.TEXT_NODE) return t;
|
|
137
|
+
let n = 0;
|
|
138
|
+
for (let r = 0, i = Math.min(e.childNodes.length, t); r < i; r++) {
|
|
139
|
+
let t = e.childNodes[r];
|
|
140
|
+
this.searchNode(t, t, (e) => (e.nodeType === Node.TEXT_NODE && (n += e.data.length), !1));
|
|
141
|
+
}
|
|
142
|
+
return n;
|
|
143
|
+
}
|
|
144
|
+
searchNode(e, t, n, r) {
|
|
145
|
+
if (n(t)) return !0;
|
|
146
|
+
for (let e = 0, r = t.childNodes.length; e < r; e++) if (this.searchNode(t, t.childNodes[e], n, !0)) return !0;
|
|
147
|
+
if (!r) {
|
|
148
|
+
let r = t;
|
|
149
|
+
if (r) for (; r && r !== e;) {
|
|
150
|
+
let t = r.nextSibling;
|
|
151
|
+
for (; t;) {
|
|
152
|
+
if (this.searchNode(e, t, n, !0)) return !0;
|
|
153
|
+
t = t.nextSibling;
|
|
154
|
+
}
|
|
155
|
+
r = r.parentNode;
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
return !1;
|
|
159
|
+
}
|
|
160
|
+
getOffset(t) {
|
|
161
|
+
let n = this.getRange(), { element: r } = this.getState(), i = t || r || null;
|
|
162
|
+
if (!n || !i || n.startContainer.ownerDocument !== i.ownerDocument) return [-1, -1];
|
|
163
|
+
let a = e(i), o = document.createRange();
|
|
164
|
+
if (o.selectNodeContents(i), n.compareBoundaryPoints(Range.START_TO_START, o) >= 0 && n.compareBoundaryPoints(Range.END_TO_END, o) <= 0) {
|
|
165
|
+
if (n.startContainer === i && n.startOffset === 0 && n.endContainer === i && n.endOffset === a) return [0, a];
|
|
166
|
+
let e = document.createRange();
|
|
167
|
+
e.setStart(i, 0), e.setEnd(n.startContainer, n.startOffset);
|
|
168
|
+
let t = e.toString().length, r = document.createRange();
|
|
169
|
+
return r.setStart(i, 0), r.setEnd(n.endContainer, n.endOffset), [t, r.toString().length];
|
|
170
|
+
}
|
|
171
|
+
let s, c;
|
|
172
|
+
if (n.compareBoundaryPoints(Range.START_TO_START, o) < 0) s = 0;
|
|
173
|
+
else {
|
|
174
|
+
let e = document.createRange();
|
|
175
|
+
e.setStart(i, 0), e.setEnd(n.startContainer, n.startOffset), s = e.toString().length;
|
|
176
|
+
}
|
|
177
|
+
if (n.compareBoundaryPoints(Range.END_TO_END, o) > 0) c = a;
|
|
178
|
+
else {
|
|
179
|
+
let e = document.createRange();
|
|
180
|
+
e.setStart(i, 0), e.setEnd(n.endContainer, n.endOffset), c = e.toString().length;
|
|
181
|
+
}
|
|
182
|
+
return [s, c];
|
|
183
|
+
}
|
|
184
|
+
getBounds() {
|
|
185
|
+
let e = this.getRange();
|
|
186
|
+
return e ? e.getBoundingClientRect() : null;
|
|
187
|
+
}
|
|
188
|
+
getFirstLineBounds() {
|
|
189
|
+
let e = this.getRange();
|
|
190
|
+
if (!e) return null;
|
|
191
|
+
let t = document.createRange(), n = e.startContainer, r = e.startOffset;
|
|
192
|
+
t.setStart(n, r), t.setEnd(n, r);
|
|
193
|
+
let i = t.getBoundingClientRect();
|
|
194
|
+
if (i.width === 0 || i.height === 0) {
|
|
195
|
+
let t = e.getClientRects();
|
|
196
|
+
if (t.length > 0) return t[0];
|
|
197
|
+
}
|
|
198
|
+
return i;
|
|
199
|
+
}
|
|
200
|
+
};
|
|
201
|
+
//#endregion
|
|
202
|
+
export { s as default };
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { detectMobileOS as e, executeMethodIfExists as t, getCaretPosition as n } from "../utils/common.mjs";
|
|
2
|
+
import { Q as r, S as i, Te as a, b as o, g as s, m as c, n as l, oe as u, w as d, y as f } from "../../node_modules/snappykit/dist/snappykit.mjs";
|
|
3
|
+
import p from "../entities/tools/bold.mjs";
|
|
4
|
+
import m from "../entities/tools/clear-formatting.mjs";
|
|
5
|
+
import h from "../entities/tools/inline-code.mjs";
|
|
6
|
+
import g from "../entities/tools/italic.mjs";
|
|
7
|
+
import _ from "../entities/tools/link.mjs";
|
|
8
|
+
import v from "../entities/tools/marker.mjs";
|
|
9
|
+
import y from "../entities/tools/subscript.mjs";
|
|
10
|
+
import b from "../entities/tools/superscript.mjs";
|
|
11
|
+
import "../../entities/tools.mjs";
|
|
12
|
+
//#region src/core/tools.ts
|
|
13
|
+
var x = class {
|
|
14
|
+
constructor(e) {
|
|
15
|
+
this.tools = [], this.eventId = ".tool" + c(12), this.editor = e;
|
|
16
|
+
let t = this.editor.config.get("tools", []);
|
|
17
|
+
(t.length ? t : [
|
|
18
|
+
p,
|
|
19
|
+
g,
|
|
20
|
+
h,
|
|
21
|
+
_,
|
|
22
|
+
v,
|
|
23
|
+
y,
|
|
24
|
+
b,
|
|
25
|
+
m
|
|
26
|
+
]).forEach((e) => {
|
|
27
|
+
this.tools.push(new e(this.editor));
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
show() {
|
|
31
|
+
let { blockManager: r, selectionApi: i } = this.editor, o = this.editor.getRoot(), c = r.getBlock();
|
|
32
|
+
if (!o || !c) return;
|
|
33
|
+
let [l] = u(".tex-tools", o), [p] = u(".tex-tools-list", o), [m] = u(".tex-tools-content", o);
|
|
34
|
+
if (!l && !p && !m) return;
|
|
35
|
+
this.getTools().forEach((e) => {
|
|
36
|
+
t(e, "__setBlockElement", [c]);
|
|
37
|
+
let n = e.getElement();
|
|
38
|
+
d(p, n), e.isVisible() || n.remove(), t(e, "__onMount", [n]);
|
|
39
|
+
}), f(l, "tex-tools-fixed tex-animate-fadeIn");
|
|
40
|
+
let h = () => {
|
|
41
|
+
let t = i.getFirstLineBounds(), r = n(), a = e(), c = o.getBoundingClientRect();
|
|
42
|
+
if (t) {
|
|
43
|
+
let e = t.left, n;
|
|
44
|
+
t.left + l.offsetWidth > c.width + c.left && (e = t.left - l.offsetWidth), e < 10 && (e = c.left);
|
|
45
|
+
let i = t.top - +l.offsetHeight < 10;
|
|
46
|
+
n = r?.y && (i || a != "other" && r?.y > t.top) ? t.top + r.y - t.top + t.height / 2 : t.top - l.clientHeight - t.height / 2, s(l, {
|
|
47
|
+
top: n,
|
|
48
|
+
left: e
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
h();
|
|
53
|
+
let g = this.eventId;
|
|
54
|
+
a(window, "resize" + g, () => h()), a(window, "scroll" + g, () => h());
|
|
55
|
+
}
|
|
56
|
+
hide() {
|
|
57
|
+
let e = this.editor.getRoot();
|
|
58
|
+
e && i(".tex-tools", (e) => {
|
|
59
|
+
o(e, "tex-tools-fixed");
|
|
60
|
+
}, e);
|
|
61
|
+
}
|
|
62
|
+
syncHighlight() {
|
|
63
|
+
let { selectionApi: e } = this.editor, t = ".tex-tool", n = e.getState()?.element, r = this.editor.getRoot();
|
|
64
|
+
if (!r || (i(t, (e) => o(e, "active"), r), !n)) return;
|
|
65
|
+
let a = e.findTags(n);
|
|
66
|
+
a.length && i(t, (e) => {
|
|
67
|
+
e.baseModel && a.forEach((t) => {
|
|
68
|
+
e.baseModel.getTagName() === t.localName && !l(t?.textContent || "") && f(e, "active");
|
|
69
|
+
});
|
|
70
|
+
}, r);
|
|
71
|
+
}
|
|
72
|
+
getTools() {
|
|
73
|
+
return this.tools;
|
|
74
|
+
}
|
|
75
|
+
getModelByTagName(e) {
|
|
76
|
+
let t = null;
|
|
77
|
+
return this.getTools().forEach((n) => {
|
|
78
|
+
n.getTagName() === e && (t = n);
|
|
79
|
+
}), t;
|
|
80
|
+
}
|
|
81
|
+
destroy() {
|
|
82
|
+
this.tools.forEach((e) => e.destroy());
|
|
83
|
+
let e = this.eventId;
|
|
84
|
+
r(window, "resize" + e), r(window, "scroll" + e);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
//#endregion
|
|
88
|
+
export { x as default };
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { E as e, S as t, Z as n, b as r, g as i, ie as a, se as o, w as s, y as c } from "../../../node_modules/snappykit/dist/snappykit.mjs";
|
|
2
|
+
import { IconArrowLeft as l, IconArrowRight as u } from "../../icons/index.mjs";
|
|
3
|
+
import { renderIcon as d } from "../../utils/icon.mjs";
|
|
4
|
+
/* empty css */
|
|
5
|
+
//#region src/core/ui/slider.ts
|
|
6
|
+
var f = class {
|
|
7
|
+
constructor(t, n = {}) {
|
|
8
|
+
if (this.slides = [], this.currentIndex = 0, this.defaultOptions = { infinite: !0 }, !t) throw Error("Container not found");
|
|
9
|
+
this.container = t, this.options = {
|
|
10
|
+
...this.defaultOptions,
|
|
11
|
+
...n
|
|
12
|
+
}, this.slider = a("div"), e(this.container, this.slider), s(this.slider, this.container), c(this.slider, "tex-slider"), c(this.container, "tex-slider-container"), this.eachSlides((e) => {
|
|
13
|
+
c(e, "tex-slide"), this.slides.push(e);
|
|
14
|
+
});
|
|
15
|
+
let r = this.slides.length;
|
|
16
|
+
i(this.container, "width", `${r * 100}%`), this.slides.forEach((e) => {
|
|
17
|
+
i(e, {
|
|
18
|
+
width: `${100 / r}%`,
|
|
19
|
+
flex: `0 0 ${100 / r}%`
|
|
20
|
+
});
|
|
21
|
+
}), this.init();
|
|
22
|
+
}
|
|
23
|
+
eachSlides(e) {
|
|
24
|
+
t(":scope > *", (t, n) => {
|
|
25
|
+
e(t, n);
|
|
26
|
+
}, this.container);
|
|
27
|
+
}
|
|
28
|
+
init() {
|
|
29
|
+
this.createDots(), this.createButtons(), this.updateActiveDot(), this.updateSliderPosition();
|
|
30
|
+
}
|
|
31
|
+
createButtons() {
|
|
32
|
+
let e = {
|
|
33
|
+
width: 14,
|
|
34
|
+
height: 14
|
|
35
|
+
}, t = a("button", (t) => {
|
|
36
|
+
c(t, "tex-slider-btn tex-slider-prev"), o(t, d(l, e)), n(t, "click.sliderPrev", () => this.prev());
|
|
37
|
+
}), r = a("button", (t) => {
|
|
38
|
+
c(t, "tex-slider-btn tex-slider-next"), o(t, d(u, e)), n(t, "click.sliderNext", () => this.next());
|
|
39
|
+
});
|
|
40
|
+
s(this.slider, [t, r]);
|
|
41
|
+
}
|
|
42
|
+
createDots() {
|
|
43
|
+
let e = a("div", (e) => {
|
|
44
|
+
c(e, "tex-slider-dots");
|
|
45
|
+
});
|
|
46
|
+
s(this.slider, e), this.dotsContainer = e, o(this.dotsContainer, "");
|
|
47
|
+
for (let e = 0; e < this.slides.length; e++) {
|
|
48
|
+
let t = a("button", (t) => {
|
|
49
|
+
c(t, "tex-slider-dot"), t.setAttribute("aria-label", `Go to slide: ${e + 1}`), n(t, "click.sliderDot", () => this.goToSlide(e));
|
|
50
|
+
});
|
|
51
|
+
s(this.dotsContainer, t);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
updateActiveDot() {
|
|
55
|
+
t(".tex-slider-dot", (e, t) => {
|
|
56
|
+
t === this.currentIndex ? c(e, "active") : r(e, "active");
|
|
57
|
+
}, this.dotsContainer);
|
|
58
|
+
}
|
|
59
|
+
updateSliderPosition() {
|
|
60
|
+
this.container && i(this.container, "transform", `translateX(-${this.currentIndex * (100 / this.slides.length)}%)`);
|
|
61
|
+
}
|
|
62
|
+
goToSlide(e) {
|
|
63
|
+
let t = this.slides.length;
|
|
64
|
+
this.options.infinite ? (e < 0 && (e = t - 1), e >= t && (e = 0)) : (e < 0 && (e = 0), e >= t && (e = t - 1)), this.currentIndex = e, this.updateSliderPosition(), this.updateActiveDot(), this.options?.onChange && this.options?.onChange(e);
|
|
65
|
+
}
|
|
66
|
+
next() {
|
|
67
|
+
this.goToSlide(this.currentIndex + 1);
|
|
68
|
+
}
|
|
69
|
+
prev() {
|
|
70
|
+
this.goToSlide(this.currentIndex - 1);
|
|
71
|
+
}
|
|
72
|
+
destroy() {
|
|
73
|
+
this.eachSlides((e) => {
|
|
74
|
+
r(e, "tex-slide"), e.removeAttribute("style");
|
|
75
|
+
}), this.container.removeAttribute("style"), r(this.container, "tex-slider-container"), t(".tex-slider-dots, .tex-slider-btn", (e) => {
|
|
76
|
+
e.remove();
|
|
77
|
+
}, this.slider), e(this.slider, this.container), this.slider.remove();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
//#endregion
|
|
81
|
+
export { f as default };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { D as e, E as t, M as n, T as r, ie as i, se as a, w as o, x as s, y as c } from "../../../node_modules/snappykit/dist/snappykit.mjs";
|
|
2
|
+
//#region src/core/ui/toasts.ts
|
|
3
|
+
var l = class {
|
|
4
|
+
constructor(e, t = "toasts-container", n = 3e3, r = "prepend") {
|
|
5
|
+
this.toastsNode = null, this.activeToast = null, this.defaultParent = e || null, this.defaultClassName = t, this.defaultTimeout = n, this.defaultInsertType = r;
|
|
6
|
+
}
|
|
7
|
+
add(l, u = {}) {
|
|
8
|
+
let { code: d = "error", parent: f, insertType: p = this.defaultInsertType, className: m, timeout: h = this.defaultTimeout, scrollIntoView: g = !0, single: _ = !1 } = u;
|
|
9
|
+
if (_ && this.activeToast && (this.activeToast.remove(), this.activeToast = null), _ && this.toastsNode) {
|
|
10
|
+
let e = n(this.toastsNode);
|
|
11
|
+
e.length > 0 && e.forEach((e) => e.remove());
|
|
12
|
+
}
|
|
13
|
+
this.toastsNode ||= this.createToasts(m || this.defaultClassName);
|
|
14
|
+
let v = i("div", (e) => {
|
|
15
|
+
c(e, "tex-animate-fadeIn tex-message tex-message-" + d), a(e, l);
|
|
16
|
+
});
|
|
17
|
+
o(this.toastsNode, v), _ && (this.activeToast = v), setTimeout(() => {
|
|
18
|
+
v.remove(), _ && this.activeToast === v && (this.activeToast = null);
|
|
19
|
+
}, h);
|
|
20
|
+
let y = f || this.defaultParent || document.body;
|
|
21
|
+
switch (p) {
|
|
22
|
+
case "prepend":
|
|
23
|
+
r(y, this.toastsNode);
|
|
24
|
+
break;
|
|
25
|
+
case "append":
|
|
26
|
+
o(y, this.toastsNode);
|
|
27
|
+
break;
|
|
28
|
+
case "before":
|
|
29
|
+
t(y, this.toastsNode);
|
|
30
|
+
break;
|
|
31
|
+
case "after":
|
|
32
|
+
e(y, this.toastsNode);
|
|
33
|
+
break;
|
|
34
|
+
default: r(y, this.toastsNode);
|
|
35
|
+
}
|
|
36
|
+
g && this.toastsNode && this.toastsNode.scrollIntoView({
|
|
37
|
+
behavior: "smooth",
|
|
38
|
+
block: "center"
|
|
39
|
+
});
|
|
40
|
+
let b = new MutationObserver(() => {
|
|
41
|
+
this.toastsNode && n(this.toastsNode).length === 0 && (b.disconnect(), s(this.toastsNode), this.toastsNode = null, this.activeToast = null);
|
|
42
|
+
});
|
|
43
|
+
b.observe(this.toastsNode, { childList: !0 });
|
|
44
|
+
}
|
|
45
|
+
clear() {
|
|
46
|
+
this.toastsNode && (s(this.toastsNode), this.toastsNode = null, this.activeToast = null);
|
|
47
|
+
}
|
|
48
|
+
createToasts(e) {
|
|
49
|
+
return i("div", (t) => {
|
|
50
|
+
c(t, e);
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
//#endregion
|
|
55
|
+
export { l as default };
|