@richscripts/richtexteditor 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +360 -0
- package/admin/index.d.ts +100 -0
- package/admin/index.js +94 -0
- package/angular/component.ts +284 -0
- package/angular/index.d.ts +80 -0
- package/angular/index.ts +24 -0
- package/headless/index.d.ts +65 -0
- package/headless/index.js +272 -0
- package/index.d.ts +1412 -0
- package/integrations/shared.d.ts +138 -0
- package/integrations/shared.js +5182 -0
- package/package.json +130 -0
- package/react/index.d.ts +104 -0
- package/react/index.js +310 -0
- package/richtexteditor/CHANGELOG.md +1876 -0
- package/richtexteditor/all_plugins.js +31125 -0
- package/richtexteditor/all_plugins.min.js +78 -0
- package/richtexteditor/lang/rte-lang-af.js +193 -0
- package/richtexteditor/lang/rte-lang-ar.js +193 -0
- package/richtexteditor/lang/rte-lang-bg.js +193 -0
- package/richtexteditor/lang/rte-lang-bn.js +193 -0
- package/richtexteditor/lang/rte-lang-bs.js +193 -0
- package/richtexteditor/lang/rte-lang-ca.js +193 -0
- package/richtexteditor/lang/rte-lang-cs.js +193 -0
- package/richtexteditor/lang/rte-lang-cy.js +193 -0
- package/richtexteditor/lang/rte-lang-da.js +193 -0
- package/richtexteditor/lang/rte-lang-de.js +193 -0
- package/richtexteditor/lang/rte-lang-el.js +193 -0
- package/richtexteditor/lang/rte-lang-en.js +6 -0
- package/richtexteditor/lang/rte-lang-es.js +193 -0
- package/richtexteditor/lang/rte-lang-et.js +193 -0
- package/richtexteditor/lang/rte-lang-fa.js +193 -0
- package/richtexteditor/lang/rte-lang-fi.js +193 -0
- package/richtexteditor/lang/rte-lang-fil.js +193 -0
- package/richtexteditor/lang/rte-lang-fj.js +193 -0
- package/richtexteditor/lang/rte-lang-fr.js +193 -0
- package/richtexteditor/lang/rte-lang-ga.js +193 -0
- package/richtexteditor/lang/rte-lang-gu.js +193 -0
- package/richtexteditor/lang/rte-lang-he.js +193 -0
- package/richtexteditor/lang/rte-lang-hi.js +193 -0
- package/richtexteditor/lang/rte-lang-hr.js +193 -0
- package/richtexteditor/lang/rte-lang-ht.js +193 -0
- package/richtexteditor/lang/rte-lang-hu.js +193 -0
- package/richtexteditor/lang/rte-lang-id.js +193 -0
- package/richtexteditor/lang/rte-lang-is.js +193 -0
- package/richtexteditor/lang/rte-lang-it.js +193 -0
- package/richtexteditor/lang/rte-lang-ja.js +193 -0
- package/richtexteditor/lang/rte-lang-kn.js +193 -0
- package/richtexteditor/lang/rte-lang-ko.js +193 -0
- package/richtexteditor/lang/rte-lang-lt.js +193 -0
- package/richtexteditor/lang/rte-lang-lv.js +193 -0
- package/richtexteditor/lang/rte-lang-mg.js +193 -0
- package/richtexteditor/lang/rte-lang-mi.js +193 -0
- package/richtexteditor/lang/rte-lang-ml.js +193 -0
- package/richtexteditor/lang/rte-lang-mr.js +193 -0
- package/richtexteditor/lang/rte-lang-ms.js +193 -0
- package/richtexteditor/lang/rte-lang-mt.js +193 -0
- package/richtexteditor/lang/rte-lang-mww.js +193 -0
- package/richtexteditor/lang/rte-lang-nb.js +193 -0
- package/richtexteditor/lang/rte-lang-nl.js +193 -0
- package/richtexteditor/lang/rte-lang-otq.js +193 -0
- package/richtexteditor/lang/rte-lang-pa.js +193 -0
- package/richtexteditor/lang/rte-lang-pl.js +193 -0
- package/richtexteditor/lang/rte-lang-pt-pt.js +193 -0
- package/richtexteditor/lang/rte-lang-pt.js +193 -0
- package/richtexteditor/lang/rte-lang-ro.js +193 -0
- package/richtexteditor/lang/rte-lang-ru.js +193 -0
- package/richtexteditor/lang/rte-lang-sk.js +193 -0
- package/richtexteditor/lang/rte-lang-sl.js +193 -0
- package/richtexteditor/lang/rte-lang-sm.js +193 -0
- package/richtexteditor/lang/rte-lang-sr-Cyrl.js +193 -0
- package/richtexteditor/lang/rte-lang-sr-Latn.js +193 -0
- package/richtexteditor/lang/rte-lang-sv.js +193 -0
- package/richtexteditor/lang/rte-lang-sw.js +193 -0
- package/richtexteditor/lang/rte-lang-ta.js +193 -0
- package/richtexteditor/lang/rte-lang-te.js +193 -0
- package/richtexteditor/lang/rte-lang-th.js +193 -0
- package/richtexteditor/lang/rte-lang-tlh-Latn.js +193 -0
- package/richtexteditor/lang/rte-lang-tlh-Piqd.js +193 -0
- package/richtexteditor/lang/rte-lang-to.js +193 -0
- package/richtexteditor/lang/rte-lang-tr.js +193 -0
- package/richtexteditor/lang/rte-lang-ty.js +193 -0
- package/richtexteditor/lang/rte-lang-uk.js +193 -0
- package/richtexteditor/lang/rte-lang-ur.js +193 -0
- package/richtexteditor/lang/rte-lang-vi.js +193 -0
- package/richtexteditor/lang/rte-lang-yua.js +193 -0
- package/richtexteditor/lang/rte-lang-zh-Hans.js +193 -0
- package/richtexteditor/lang/rte-lang-zh-Hant.js +193 -0
- package/richtexteditor/lang/rte-lang.js +1 -0
- package/richtexteditor/plugins/-combine-plugin.txt +2 -0
- package/richtexteditor/plugins/-combine-plugins.bat +20 -0
- package/richtexteditor/plugins/a11yenhance.js +90 -0
- package/richtexteditor/plugins/accessibilitychecker.js +579 -0
- package/richtexteditor/plugins/aitoolkit.css +15830 -0
- package/richtexteditor/plugins/aitoolkit.js +19171 -0
- package/richtexteditor/plugins/all_plugins.js +31125 -0
- package/richtexteditor/plugins/all_plugins.min.js +78 -0
- package/richtexteditor/plugins/autoembed.js +174 -0
- package/richtexteditor/plugins/blocktypes.js +175 -0
- package/richtexteditor/plugins/bookmarkcard.js +226 -0
- package/richtexteditor/plugins/charlimit.js +195 -0
- package/richtexteditor/plugins/comments.js +672 -0
- package/richtexteditor/plugins/contentminimap.js +369 -0
- package/richtexteditor/plugins/crdt-engine.js +8905 -0
- package/richtexteditor/plugins/crdt-engine.min.js +5 -0
- package/richtexteditor/plugins/dialoga11y.js +174 -0
- package/richtexteditor/plugins/dictation.js +268 -0
- package/richtexteditor/plugins/documentimport.js +369 -0
- package/richtexteditor/plugins/documentoutline.js +341 -0
- package/richtexteditor/plugins/emailtoolkit.js +165 -0
- package/richtexteditor/plugins/emojiautocomplete.js +241 -0
- package/richtexteditor/plugins/foldheadings.js +181 -0
- package/richtexteditor/plugins/ghostcomplete.js +297 -0
- package/richtexteditor/plugins/html2pdf.js +158 -0
- package/richtexteditor/plugins/imageeditor.js +159 -0
- package/richtexteditor/plugins/insertcode.js +319 -0
- package/richtexteditor/plugins/insertemoji.js +229 -0
- package/richtexteditor/plugins/insertgallery.js +362 -0
- package/richtexteditor/plugins/inserttemplate.js +261 -0
- package/richtexteditor/plugins/localdraft.js +213 -0
- package/richtexteditor/plugins/markdownexport.js +110 -0
- package/richtexteditor/plugins/mathdialog.js +153 -0
- package/richtexteditor/plugins/mentionplugin.js +534 -0
- package/richtexteditor/plugins/mermaiddiagram.js +294 -0
- package/richtexteditor/plugins/readabilitystats.js +148 -0
- package/richtexteditor/plugins/readaloud.js +243 -0
- package/richtexteditor/plugins/restrictedediting.js +208 -0
- package/richtexteditor/plugins/revisionhistory.js +670 -0
- package/richtexteditor/plugins/samples/insertcode_v1.js +76 -0
- package/richtexteditor/plugins/slashcommand.js +705 -0
- package/richtexteditor/plugins/smartchips.js +250 -0
- package/richtexteditor/plugins/spellcheck.js +181 -0
- package/richtexteditor/plugins/todolist.js +137 -0
- package/richtexteditor/plugins/trackedchanges.js +658 -0
- package/richtexteditor/plugins/tui.image-editor/fabric.min.js +8 -0
- package/richtexteditor/plugins/tui.image-editor/note.txt +5 -0
- package/richtexteditor/plugins/tui.image-editor/svg/icon-a.svg +235 -0
- package/richtexteditor/plugins/tui.image-editor/svg/icon-b.svg +224 -0
- package/richtexteditor/plugins/tui.image-editor/svg/icon-c.svg +224 -0
- package/richtexteditor/plugins/tui.image-editor/svg/icon-d.svg +224 -0
- package/richtexteditor/plugins/tui.image-editor/tui-code-snippet.min.js +7 -0
- package/richtexteditor/plugins/tui.image-editor/tui-color-picker.min.css +6 -0
- package/richtexteditor/plugins/tui.image-editor/tui-color-picker.min.js +7 -0
- package/richtexteditor/plugins/tui.image-editor/tui-image-editor.min.css +7 -0
- package/richtexteditor/plugins/tui.image-editor/tui-image-editor.min.js +15 -0
- package/richtexteditor/plugins/typewriter.js +203 -0
- package/richtexteditor/plugins/wordexport.js +0 -0
- package/richtexteditor/plugins/yjscollab.js +693 -0
- package/richtexteditor/plugins/zz_richtextbox_dialog_style.js +335 -0
- package/richtexteditor/rte-config.js +933 -0
- package/richtexteditor/rte.js +943 -0
- package/richtexteditor/rte_mobile.css +234 -0
- package/richtexteditor/rte_theme_default.css +4819 -0
- package/richtexteditor/runtime/colorpicker_more_ns.htm +2613 -0
- package/richtexteditor/runtime/help.htm +162 -0
- package/richtexteditor/runtime/images/1x1.gif +0 -0
- package/richtexteditor/runtime/images/cpie_Color.cur +0 -0
- package/richtexteditor/runtime/images/cpie_GradientPositionDark.gif +0 -0
- package/richtexteditor/runtime/images/cpie_GradientPositionLight.gif +0 -0
- package/richtexteditor/runtime/images/cpie_VerticalPosition.gif +0 -0
- package/richtexteditor/runtime/images/cpie_WebSafe.gif +0 -0
- package/richtexteditor/runtime/images/cpie_gradients.png +0 -0
- package/richtexteditor/runtime/images/cpns_Color.cur +0 -0
- package/richtexteditor/runtime/images/cpns_ColorSpace1.png +0 -0
- package/richtexteditor/runtime/images/cpns_ColorSpace2.png +0 -0
- package/richtexteditor/runtime/images/cpns_GradientPositionDark.gif +0 -0
- package/richtexteditor/runtime/images/cpns_GradientPositionLight.gif +0 -0
- package/richtexteditor/runtime/images/cpns_Vertical1.png +0 -0
- package/richtexteditor/runtime/images/cpns_Vertical2.png +0 -0
- package/richtexteditor/runtime/images/cpns_VerticalPosition.gif +0 -0
- package/richtexteditor/runtime/images/cpns_WebSafe.gif +0 -0
- package/richtexteditor/runtime/images/cpns_gradients.png +0 -0
- package/richtexteditor/runtime/images/cpns_hue2.png +0 -0
- package/richtexteditor/runtime/images/formbn.gif +0 -0
- package/richtexteditor/runtime/images/multiclavier.gif +0 -0
- package/richtexteditor/runtime/richtexteditor_content.css +362 -0
- package/richtexteditor/runtime/richtexteditor_preview.css +302 -0
- package/richtexteditor/runtime/richtexteditor_preview.js +1 -0
- package/server/index.d.ts +21 -0
- package/server/index.js +23 -0
- package/svelte/index.d.ts +19 -0
- package/svelte/index.js +59 -0
- package/vue/index.d.ts +94 -0
- package/vue/index.js +291 -0
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
if (!window.RTE_DefaultConfig) window.RTE_DefaultConfig = {};
|
|
2
|
+
|
|
3
|
+
RTE_DefaultConfig.plugin_contentminimap = RTE_Plugin_ContentMinimap;
|
|
4
|
+
|
|
5
|
+
function RTE_Plugin_ContentMinimap() {
|
|
6
|
+
var obj = this;
|
|
7
|
+
var config;
|
|
8
|
+
var editor;
|
|
9
|
+
var shell = null;
|
|
10
|
+
var panel = null;
|
|
11
|
+
var preview = null;
|
|
12
|
+
var viewport = null;
|
|
13
|
+
var empty = null;
|
|
14
|
+
var refreshTimer = 0;
|
|
15
|
+
var dragState = null;
|
|
16
|
+
|
|
17
|
+
obj.PluginName = "ContentMinimap";
|
|
18
|
+
|
|
19
|
+
obj.InitConfig = function (argconfig) {
|
|
20
|
+
config = argconfig;
|
|
21
|
+
if (config.contentMinimapEnabled === false) return;
|
|
22
|
+
|
|
23
|
+
if (typeof config.contentMinimapAutoOpen !== "boolean") config.contentMinimapAutoOpen = false;
|
|
24
|
+
if (typeof config.contentMinimapWidth !== "number") config.contentMinimapWidth = 168;
|
|
25
|
+
if (typeof config.contentMinimapScale !== "number") config.contentMinimapScale = 0.14;
|
|
26
|
+
config.contentMinimapTitle = config.contentMinimapTitle || "Minimap";
|
|
27
|
+
config.contentMinimapHint = config.contentMinimapHint || "Keep your place in long documents and jump by clicking the miniature preview.";
|
|
28
|
+
config.contentMinimapEmptyText = config.contentMinimapEmptyText || "Start typing to build the document preview.";
|
|
29
|
+
|
|
30
|
+
appendToolbarCommand("toolbar_default", "#{contentminimap}");
|
|
31
|
+
appendToolbarCommand("toolbar_full", "#{contentminimap}");
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
obj.InitEditor = function (argeditor) {
|
|
35
|
+
editor = argeditor;
|
|
36
|
+
if (config.contentMinimapEnabled === false) return;
|
|
37
|
+
|
|
38
|
+
editor.contentMinimap = {
|
|
39
|
+
close: function () { closePanel(); },
|
|
40
|
+
isOpen: function () { return !!(shell && shell.classList.contains("is-open")); },
|
|
41
|
+
open: function () { openPanel(); },
|
|
42
|
+
refresh: function () { renderSnapshot(); syncViewport(); },
|
|
43
|
+
toggle: function () { togglePanel(); }
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
injectStyles();
|
|
47
|
+
|
|
48
|
+
editor.toolbarFactoryMap = editor.toolbarFactoryMap || {};
|
|
49
|
+
editor.toolbarFactoryMap["contentminimap"] = function (cmd) {
|
|
50
|
+
return editor.createToolbarButton(cmd);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
editor.attachEvent("exec_command_contentminimap", function (state) {
|
|
54
|
+
state.returnValue = true;
|
|
55
|
+
state.stopBubble = true;
|
|
56
|
+
togglePanel();
|
|
57
|
+
});
|
|
58
|
+
editor.attachEvent("change", function () {
|
|
59
|
+
scheduleRefresh();
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
ensureShell();
|
|
63
|
+
bindScroll();
|
|
64
|
+
bindResize();
|
|
65
|
+
renderSnapshot();
|
|
66
|
+
syncViewport();
|
|
67
|
+
if (config.contentMinimapAutoOpen) openPanel();
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
function appendToolbarCommand(toolbar, item) {
|
|
71
|
+
if (!config[toolbar]) return;
|
|
72
|
+
if (config[toolbar].indexOf(item) !== -1) return;
|
|
73
|
+
config[toolbar] = config[toolbar] + item;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function injectStyles() {
|
|
77
|
+
var hostDoc = config.container.ownerDocument;
|
|
78
|
+
if (hostDoc.getElementById("rte-content-minimap-style")) return;
|
|
79
|
+
var style = hostDoc.createElement("style");
|
|
80
|
+
style.id = "rte-content-minimap-style";
|
|
81
|
+
style.innerHTML = [
|
|
82
|
+
".rte-content-minimap-shell{display:flex;align-items:stretch;gap:10px;}",
|
|
83
|
+
".rte-content-minimap-shell>.rte-content-minimap-host{flex:1 1 auto;min-width:0;}",
|
|
84
|
+
".rte-content-minimap-panel{display:none;flex:0 0 var(--rte-content-minimap-width,168px);min-width:148px;max-width:220px;border:1px solid rgba(148,163,184,.22);border-radius:16px;background:linear-gradient(180deg,rgba(255,255,255,.98),rgba(248,251,255,.96));box-shadow:0 18px 42px rgba(29,78,216,.12),0 2px 8px rgba(15,23,42,.06);overflow:hidden;color:#172033;font-family:Aptos,'Segoe UI',sans-serif;}",
|
|
85
|
+
".rte-content-minimap-shell.is-open>.rte-content-minimap-panel{display:flex;flex-direction:column;}",
|
|
86
|
+
".rte-content-minimap-header{padding:12px 12px 9px 14px;border-bottom:1px solid rgba(148,163,184,.16);background:rgba(255,255,255,.72);}",
|
|
87
|
+
".rte-content-minimap-kicker{font-size:10px;line-height:1.3;letter-spacing:.08em;text-transform:uppercase;color:#52657e;font-weight:850;}",
|
|
88
|
+
".rte-content-minimap-title{margin-top:3px;font-size:15px;line-height:1.2;font-weight:850;color:#172033;}",
|
|
89
|
+
".rte-content-minimap-copy{margin-top:5px;font-size:12px;line-height:1.42;color:#52657e;}",
|
|
90
|
+
".rte-content-minimap-toolbar{display:flex;align-items:center;justify-content:space-between;padding:8px 10px 8px 14px;border-bottom:1px solid rgba(148,163,184,.16);gap:8px;background:rgba(255,255,255,.52);}",
|
|
91
|
+
".rte-content-minimap-meta{min-width:0;font-size:12px;font-weight:750;color:#52657e;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}",
|
|
92
|
+
".rte-content-minimap-close{appearance:none;border:1px solid rgba(100,116,139,.18);background:#fff;color:#315277;cursor:pointer;font-size:12px;font-weight:750;padding:6px 9px;border-radius:999px;line-height:1;}",
|
|
93
|
+
".rte-content-minimap-close:hover,.rte-content-minimap-close:focus-visible{background:#eef4ff;color:#0f3f9f;border-color:rgba(37,99,235,.28);}",
|
|
94
|
+
".rte-content-minimap-body{padding:6px;overflow:auto;min-height:140px;max-height:520px;scrollbar-width:thin;}",
|
|
95
|
+
".rte-content-minimap-canvas{position:relative;border-radius:14px;background:#fff;border:1px solid rgba(148,163,184,.18);overflow:hidden;min-height:120px;box-shadow:inset 0 0 0 1px rgba(255,255,255,.7);}",
|
|
96
|
+
".rte-content-minimap-preview{position:relative;transform-origin:top left;pointer-events:none;color:#172033;background:#fff;}",
|
|
97
|
+
".rte-content-minimap-preview>*{max-width:100%;}",
|
|
98
|
+
".rte-content-minimap-preview img,.rte-content-minimap-preview table,.rte-content-minimap-preview iframe,.rte-content-minimap-preview video{max-width:100% !important;}",
|
|
99
|
+
".rte-content-minimap-preview [contenteditable]{pointer-events:none;}",
|
|
100
|
+
".rte-content-minimap-viewport{position:absolute;left:0;right:0;border:1px solid rgba(37,99,235,.62);background:linear-gradient(180deg,rgba(37,99,235,.18) 0%,rgba(14,165,233,.12) 100%);box-shadow:inset 0 0 0 1px rgba(255,255,255,.48),0 8px 18px rgba(37,99,235,.16);border-radius:10px;cursor:grab;}",
|
|
101
|
+
".rte-content-minimap-viewport.is-dragging{cursor:grabbing;}",
|
|
102
|
+
".rte-content-minimap-empty{position:absolute;inset:auto 8px 8px 8px;padding:10px;border-radius:12px;background:rgba(255,255,255,.94);color:#52657e;font-size:12px;font-weight:700;line-height:1.45;border:1px dashed rgba(148,163,184,.32);}",
|
|
103
|
+
"@media (max-width: 1100px){.rte-content-minimap-shell{display:block;}.rte-content-minimap-panel{margin-top:12px;max-width:none;width:100%;}.rte-content-minimap-body{max-height:280px;}}"
|
|
104
|
+
].join("");
|
|
105
|
+
hostDoc.head.appendChild(style);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function ensureShell() {
|
|
109
|
+
if (shell) return shell;
|
|
110
|
+
var container = config.container;
|
|
111
|
+
var hostDoc = container.ownerDocument;
|
|
112
|
+
shell = hostDoc.createElement("div");
|
|
113
|
+
shell.className = "rte-content-minimap-shell";
|
|
114
|
+
|
|
115
|
+
var host = hostDoc.createElement("div");
|
|
116
|
+
host.className = "rte-content-minimap-host";
|
|
117
|
+
|
|
118
|
+
var parent = container.parentNode;
|
|
119
|
+
parent.insertBefore(shell, container);
|
|
120
|
+
shell.appendChild(host);
|
|
121
|
+
host.appendChild(container);
|
|
122
|
+
|
|
123
|
+
panel = hostDoc.createElement("aside");
|
|
124
|
+
panel.className = "rte-content-minimap-panel";
|
|
125
|
+
panel.style.setProperty("--rte-content-minimap-width", String(Math.max(148, config.contentMinimapWidth || 168)) + "px");
|
|
126
|
+
panel.setAttribute("aria-label", config.contentMinimapTitle);
|
|
127
|
+
panel.setAttribute("role", "complementary");
|
|
128
|
+
|
|
129
|
+
var header = hostDoc.createElement("div");
|
|
130
|
+
header.className = "rte-content-minimap-header";
|
|
131
|
+
var kicker = hostDoc.createElement("div");
|
|
132
|
+
kicker.className = "rte-content-minimap-kicker";
|
|
133
|
+
kicker.innerText = "Document";
|
|
134
|
+
var title = hostDoc.createElement("div");
|
|
135
|
+
title.className = "rte-content-minimap-title";
|
|
136
|
+
title.innerText = config.contentMinimapTitle;
|
|
137
|
+
var copy = hostDoc.createElement("div");
|
|
138
|
+
copy.className = "rte-content-minimap-copy";
|
|
139
|
+
copy.innerText = config.contentMinimapHint;
|
|
140
|
+
header.appendChild(kicker);
|
|
141
|
+
header.appendChild(title);
|
|
142
|
+
header.appendChild(copy);
|
|
143
|
+
|
|
144
|
+
var toolbar = hostDoc.createElement("div");
|
|
145
|
+
toolbar.className = "rte-content-minimap-toolbar";
|
|
146
|
+
var meta = hostDoc.createElement("div");
|
|
147
|
+
meta.className = "rte-content-minimap-meta";
|
|
148
|
+
meta.setAttribute("data-rte-content-minimap-meta", "1");
|
|
149
|
+
var close = hostDoc.createElement("button");
|
|
150
|
+
close.type = "button";
|
|
151
|
+
close.className = "rte-content-minimap-close";
|
|
152
|
+
close.innerText = "Hide";
|
|
153
|
+
close.setAttribute("aria-label", "Hide content minimap");
|
|
154
|
+
close.onclick = function () { closePanel(); };
|
|
155
|
+
toolbar.appendChild(meta);
|
|
156
|
+
toolbar.appendChild(close);
|
|
157
|
+
|
|
158
|
+
var body = hostDoc.createElement("div");
|
|
159
|
+
body.className = "rte-content-minimap-body";
|
|
160
|
+
var canvas = hostDoc.createElement("div");
|
|
161
|
+
canvas.className = "rte-content-minimap-canvas";
|
|
162
|
+
canvas.addEventListener("click", handleCanvasClick, false);
|
|
163
|
+
|
|
164
|
+
preview = hostDoc.createElement("div");
|
|
165
|
+
preview.className = "rte-content-minimap-preview";
|
|
166
|
+
|
|
167
|
+
viewport = hostDoc.createElement("div");
|
|
168
|
+
viewport.className = "rte-content-minimap-viewport";
|
|
169
|
+
viewport.setAttribute("role", "presentation");
|
|
170
|
+
viewport.addEventListener("mousedown", beginViewportDrag, false);
|
|
171
|
+
|
|
172
|
+
empty = hostDoc.createElement("div");
|
|
173
|
+
empty.className = "rte-content-minimap-empty";
|
|
174
|
+
empty.innerText = config.contentMinimapEmptyText;
|
|
175
|
+
|
|
176
|
+
canvas.appendChild(preview);
|
|
177
|
+
canvas.appendChild(viewport);
|
|
178
|
+
canvas.appendChild(empty);
|
|
179
|
+
body.appendChild(canvas);
|
|
180
|
+
|
|
181
|
+
panel.appendChild(header);
|
|
182
|
+
panel.appendChild(toolbar);
|
|
183
|
+
panel.appendChild(body);
|
|
184
|
+
shell.appendChild(panel);
|
|
185
|
+
return shell;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
function bindScroll() {
|
|
189
|
+
var doc = editor.getDocument ? editor.getDocument() : null;
|
|
190
|
+
if (!doc || doc.__rteContentMinimapBound) return;
|
|
191
|
+
doc.__rteContentMinimapBound = true;
|
|
192
|
+
doc.addEventListener("scroll", function () {
|
|
193
|
+
syncViewport();
|
|
194
|
+
}, true);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
function bindResize() {
|
|
198
|
+
var hostWindow = config.container.ownerDocument.defaultView;
|
|
199
|
+
if (!hostWindow || hostWindow.__rteContentMinimapBound) return;
|
|
200
|
+
hostWindow.__rteContentMinimapBound = true;
|
|
201
|
+
hostWindow.addEventListener("resize", function () {
|
|
202
|
+
scheduleRefresh();
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
function togglePanel() {
|
|
207
|
+
if (shell && shell.classList.contains("is-open")) closePanel();
|
|
208
|
+
else openPanel();
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
function openPanel() {
|
|
212
|
+
ensureShell();
|
|
213
|
+
shell.classList.add("is-open");
|
|
214
|
+
renderSnapshot();
|
|
215
|
+
syncViewport();
|
|
216
|
+
notifyResize();
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
function closePanel() {
|
|
220
|
+
if (!shell) return;
|
|
221
|
+
shell.classList.remove("is-open");
|
|
222
|
+
notifyResize();
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Opening / closing the minimap changes the editor's available width.
|
|
226
|
+
// Editors that size their toolbar / editable on a width recompute (responsive
|
|
227
|
+
// wrap, sticky-toolbar geometry) need a nudge to re-lay-out for the new width;
|
|
228
|
+
// a resize notification is a harmless no-op when the editor is already fluid.
|
|
229
|
+
function notifyResize() {
|
|
230
|
+
var fire = function () {
|
|
231
|
+
try { if (editor && typeof editor.fireEvent === "function") editor.fireEvent("resize"); } catch (e) {}
|
|
232
|
+
try { if (editor && typeof editor.updateLayout === "function") editor.updateLayout(); } catch (e) {}
|
|
233
|
+
try {
|
|
234
|
+
var hostDoc = config.container.ownerDocument;
|
|
235
|
+
var win = hostDoc.defaultView || window;
|
|
236
|
+
win.dispatchEvent(new win.Event("resize"));
|
|
237
|
+
} catch (e) {}
|
|
238
|
+
};
|
|
239
|
+
fire();
|
|
240
|
+
var raf = (typeof requestAnimationFrame === "function") ? requestAnimationFrame : function (f) { return setTimeout(f, 16); };
|
|
241
|
+
raf(fire);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
function scheduleRefresh() {
|
|
245
|
+
clearTimeout(refreshTimer);
|
|
246
|
+
refreshTimer = setTimeout(function () {
|
|
247
|
+
renderSnapshot();
|
|
248
|
+
syncViewport();
|
|
249
|
+
}, 80);
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
function getEditable() {
|
|
253
|
+
return editor.getEditable ? editor.getEditable() : null;
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function getScrollElement() {
|
|
257
|
+
var doc = editor.getDocument ? editor.getDocument() : null;
|
|
258
|
+
if (!doc) return null;
|
|
259
|
+
return doc.scrollingElement || doc.documentElement || doc.body || getEditable();
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function getScale() {
|
|
263
|
+
var scale = config.contentMinimapScale || 0.14;
|
|
264
|
+
if (scale < 0.06) scale = 0.06;
|
|
265
|
+
if (scale > 0.22) scale = 0.22;
|
|
266
|
+
return scale;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function renderSnapshot() {
|
|
270
|
+
ensureShell();
|
|
271
|
+
var editable = getEditable();
|
|
272
|
+
if (!editable || !preview) return;
|
|
273
|
+
|
|
274
|
+
var html = editable.innerHTML || "";
|
|
275
|
+
preview.innerHTML = html;
|
|
276
|
+
|
|
277
|
+
var scale = getScale();
|
|
278
|
+
var sourceWidth = Math.max(editable.scrollWidth || editable.clientWidth || 600, 320);
|
|
279
|
+
var sourceHeight = Math.max(editable.scrollHeight || editable.clientHeight || 0, 0);
|
|
280
|
+
var targetWidth = Math.max(120, Math.round(sourceWidth * scale));
|
|
281
|
+
var targetHeight = Math.max(120, Math.round(sourceHeight * scale));
|
|
282
|
+
|
|
283
|
+
preview.style.width = sourceWidth + "px";
|
|
284
|
+
preview.style.transform = "scale(" + scale + ")";
|
|
285
|
+
preview.parentNode.style.height = targetHeight + "px";
|
|
286
|
+
preview.parentNode.style.width = targetWidth + "px";
|
|
287
|
+
|
|
288
|
+
empty.style.display = html.replace(/<[^>]+>/g, "").replace(/\s+/g, "") ? "none" : "block";
|
|
289
|
+
|
|
290
|
+
var meta = panel.querySelector("[data-rte-content-minimap-meta]");
|
|
291
|
+
if (meta) meta.innerText = Math.max(1, Math.round(sourceHeight / Math.max(editable.clientHeight || 1, 1))) + " screens";
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
function syncViewport() {
|
|
295
|
+
if (!viewport || !preview) return;
|
|
296
|
+
var editable = getEditable();
|
|
297
|
+
var scrollEl = getScrollElement();
|
|
298
|
+
if (!editable || !scrollEl) return;
|
|
299
|
+
|
|
300
|
+
var scale = getScale();
|
|
301
|
+
var sourceHeight = Math.max(editable.scrollHeight || scrollEl.scrollHeight || editable.clientHeight || 1, 1);
|
|
302
|
+
var scrollHeight = Math.max(scrollEl.scrollHeight || sourceHeight, sourceHeight);
|
|
303
|
+
var clientHeight = Math.max(scrollEl.clientHeight || editable.clientHeight || 1, 1);
|
|
304
|
+
var maxScroll = Math.max(0, scrollHeight - clientHeight);
|
|
305
|
+
var scaledHeight = Math.max(120, Math.round(sourceHeight * scale));
|
|
306
|
+
var viewportHeight = Math.max(18, Math.round(clientHeight * scale));
|
|
307
|
+
if (viewportHeight > scaledHeight) viewportHeight = scaledHeight;
|
|
308
|
+
var top = maxScroll ? Math.round((scrollEl.scrollTop / maxScroll) * Math.max(0, scaledHeight - viewportHeight)) : 0;
|
|
309
|
+
|
|
310
|
+
viewport.style.height = viewportHeight + "px";
|
|
311
|
+
viewport.style.top = top + "px";
|
|
312
|
+
viewport.style.display = scaledHeight > 0 ? "block" : "none";
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function handleCanvasClick(evt) {
|
|
316
|
+
if (evt.target === viewport) return;
|
|
317
|
+
jumpToPreviewOffset(evt.clientY);
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
function beginViewportDrag(evt) {
|
|
321
|
+
evt.preventDefault();
|
|
322
|
+
dragState = {
|
|
323
|
+
startY: evt.clientY,
|
|
324
|
+
startTop: parseFloat(viewport.style.top || "0") || 0
|
|
325
|
+
};
|
|
326
|
+
viewport.classList.add("is-dragging");
|
|
327
|
+
var hostDoc = config.container.ownerDocument;
|
|
328
|
+
hostDoc.addEventListener("mousemove", handleViewportDrag, true);
|
|
329
|
+
hostDoc.addEventListener("mouseup", endViewportDrag, true);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
function handleViewportDrag(evt) {
|
|
333
|
+
if (!dragState) return;
|
|
334
|
+
evt.preventDefault();
|
|
335
|
+
var delta = evt.clientY - dragState.startY;
|
|
336
|
+
jumpToScaledOffset(dragState.startTop + delta);
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
function endViewportDrag() {
|
|
340
|
+
if (!dragState) return;
|
|
341
|
+
dragState = null;
|
|
342
|
+
viewport.classList.remove("is-dragging");
|
|
343
|
+
var hostDoc = config.container.ownerDocument;
|
|
344
|
+
hostDoc.removeEventListener("mousemove", handleViewportDrag, true);
|
|
345
|
+
hostDoc.removeEventListener("mouseup", endViewportDrag, true);
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
function jumpToPreviewOffset(clientY) {
|
|
349
|
+
var rect = preview.parentNode.getBoundingClientRect();
|
|
350
|
+
var offset = clientY - rect.top - ((parseFloat(viewport.style.height || "0") || 0) / 2);
|
|
351
|
+
jumpToScaledOffset(offset);
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
function jumpToScaledOffset(offset) {
|
|
355
|
+
var editable = getEditable();
|
|
356
|
+
var scrollEl = getScrollElement();
|
|
357
|
+
if (!editable || !scrollEl || !preview) return;
|
|
358
|
+
|
|
359
|
+
var scale = getScale();
|
|
360
|
+
var sourceHeight = Math.max(editable.scrollHeight || scrollEl.scrollHeight || editable.clientHeight || 1, 1);
|
|
361
|
+
var scaledHeight = Math.max(120, Math.round(sourceHeight * scale));
|
|
362
|
+
var viewportHeight = Math.max(18, parseFloat(viewport.style.height || "0") || 18);
|
|
363
|
+
var maxTop = Math.max(0, scaledHeight - viewportHeight);
|
|
364
|
+
var nextTop = Math.max(0, Math.min(maxTop, offset));
|
|
365
|
+
var maxScroll = Math.max(0, (scrollEl.scrollHeight || sourceHeight) - (scrollEl.clientHeight || editable.clientHeight || 1));
|
|
366
|
+
scrollEl.scrollTop = maxTop ? Math.round((nextTop / maxTop) * maxScroll) : 0;
|
|
367
|
+
syncViewport();
|
|
368
|
+
}
|
|
369
|
+
}
|