@rg-dev/tinymce-helpers 1.0.15 → 1.0.17
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/index.d.mts +4 -4
- package/index.mjs +145 -36
- package/package.json +1 -1
package/index.d.mts
CHANGED
|
@@ -24,7 +24,7 @@ type RawEditorOptionsExtended = RawEditorOptions & {
|
|
|
24
24
|
quickbars_selection_toolbar?: string;
|
|
25
25
|
image_advtab: boolean;
|
|
26
26
|
};
|
|
27
|
-
type EditorOpts = Omit<RemoveIndexSignature<RawEditorOptionsExtended>, 'setup' | 'target' | 'selector'> & Record<string, unknown>;
|
|
27
|
+
type EditorOpts = Omit<RemoveIndexSignature<RawEditorOptionsExtended>, 'setup' | 'target' | 'selector' | 'content_css' | 'toolbar_mode'> & Record<string, unknown>;
|
|
28
28
|
/** A partial patch object, or a function that derives one from the defaults. */
|
|
29
29
|
type TinyMCEPatch = Partial<EditorOpts> | ((defaults: EditorOpts) => Partial<EditorOpts> | void);
|
|
30
30
|
declare class ListBuilder {
|
|
@@ -58,9 +58,7 @@ declare class MenuBuilder {
|
|
|
58
58
|
addMenu(key: string, config: MenuEntry): this;
|
|
59
59
|
removeMenu(key: string): this;
|
|
60
60
|
/** Edit one menu's items with the same builder API as toolbar/contextmenu. */
|
|
61
|
-
|
|
62
|
-
/** Remove items from one menu, or from every menu if `key` is omitted. */
|
|
63
|
-
removeItem(names: string | string[], key?: string): this;
|
|
61
|
+
patchMenu(key: string, patch: ListPatch): void;
|
|
64
62
|
/** Empty menus are dropped so TinyMCE never sees a menu with no items. */
|
|
65
63
|
toObject(): MenuConfig;
|
|
66
64
|
}
|
|
@@ -96,6 +94,8 @@ declare class tinymceHelpers {
|
|
|
96
94
|
private constructor();
|
|
97
95
|
static initMce(el: HTMLElement, customOpts?: MyTinymceOpts): Promise<tinymceHelpers>;
|
|
98
96
|
addImg(src: string): void;
|
|
97
|
+
private _arrowCleanup?;
|
|
98
|
+
private createToolbarArrows;
|
|
99
99
|
_initMce(el: HTMLElement, customOpts?: MyTinymceOpts): Promise<this>;
|
|
100
100
|
private setContextMenu;
|
|
101
101
|
toggleReadOnly(lock?: 'yes' | 'no'): void;
|
package/index.mjs
CHANGED
|
@@ -63,18 +63,31 @@ import "tinymce/plugins/preview";
|
|
|
63
63
|
import "tinymce/plugins/insertdatetime";
|
|
64
64
|
|
|
65
65
|
// src/client/custom-components/mce.css?raw
|
|
66
|
-
var mce_default = ':where(.mce-content-body) {\n --editor-text: #000;\n --editor-link: #000;\n --editor-border: #d6d6d6c9;\n --editor-table-header-text: #6e6e6e;\n --editor-table-row-even: #fafafa;\n --editor-hr: #bbb;\n}\n\n\nli::marker {\n color: var(--editor-link) !important;\n}\n\n::-webkit-scrollbar {\n width: 10px;\n}\n\n::-webkit-scrollbar-track {\n background: var(--editor-table-row-even);\n}\n\n::-webkit-scrollbar-thumb {\n background: var(--editor-link);\n border-radius: 35px;\n}\n\n @media print {\n .mce-content-body {\n --editor-text: #000;\n --editor-link: #000;\n --editor-border: #d6d6d6c9;\n --editor-table-header-text: #000;\n --editor-table-row-even: #fafafa;\n --editor-hr: #000;\n }\n\n .mce-content-body table tr:nth-child(even) {\n background: var(--editor-table-row-even) !important;\n -webkit-print-color-adjust: exact;\n print-color-adjust: exact;\n }\n\n \n .mce-content-body blockquote {\n border-inline-start: none !important;\n background: #f9f9f9 !important;\n\n color: #000 !important;\n -webkit-print-color-adjust: exact !important;\n print-color-adjust: exact !important;\n }\n\n \n\n .mce-content-body td[data-mce-selected]::after,\n .mce-content-body th[data-mce-selected]::after {\n display: none !important;\n}\n}\n\n img {\n padding-block: 7px;\n max-width: 100%;\n }\n\n\n\n .mce-content-body blockquote {\n display: flow-root;\n padding: 15px;\n border-radius: 8px;\n margin: 0px !important;\n margin-block: 20px !important;\n overflow: hidden;\n border: none !important;\n background: var(--editor-table-row-even);\n color: var(--editor-text);\n}\n\n\n\n.mce-content-body blockquote p {\n margin: 0;\n}\n\n* {\n border: 0;\n padding: 0;\n margin: 0;\n background: 0 0;\n color: inherit;\n box-sizing: border-box;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n font-weight: 400;\n}\n\n:focus {\n outline: 0;\n}\n\na {\n text-decoration: none;\n cursor: pointer;\n}\n\nb,\nb *,\nstrong,\nstrong * {\n font-weight: 700;\n}\n\nol,\nul {\n list-style: none;\n}\n\npre {\n font: inherit;\n}\n\nbutton,\ninput,\ninput:not([type]),\ninput[type="button"],\ninput[type="color"],\ninput[type="date"],\ninput[type="datetime-local"],\ninput[type="datetime"],\ninput[type="email"],\ninput[type="month"],\ninput[type="number"],\ninput[type="password"],\ninput[type="reset"],\ninput[type="search"],\ninput[type="submit"],\ninput[type="tel"],\ninput[type="text"],\ninput[type="time"],\ninput[type="url"],\ninput[type="week"],\nselect,\ntextarea {\n font: inherit;\n}\n\n.mce-container textarea {\n display: inline-block !important;\n} \n\n\n.my-custom-styles{\n direction: ltr;\n }\n\n.mce-content-body {\n font-size: 22px;\n font-family: Rubik, Helvetica, Arial, sans-serif;\n padding: 0 25px 25px;\n color: var(--editor-text);\n}\n\n.mce-content-body table {\n width: 100%;\n table-layout: fixed;\n}\n\n\n\n.mce-content-body table td,\n.mce-content-body table th {\n overflow-wrap: anywhere;\n word-break: break-word;\n white-space: normal;\n}\n\n\n.mce-content-body h1 {\n font-size: 34px;\n line-height: 1.4em;\n margin: 25px 0 15px;\n}\n\n.mce-content-body h2 {\n font-size: 30px;\n line-height: 1.4em;\n margin: 25px 0 15px;\n}\n\n.mce-content-body h3 {\n font-size: 26px;\n line-height: 1.4em;\n margin: 25px 0 15px;\n}\n\n.mce-content-body h4 {\n font-size: 22px;\n line-height: 1.4em;\n margin: 25px 0 15px;\n}\n\n.mce-content-body h5 {\n font-size: 18px;\n line-height: 1.4em;\n margin: 25px 0 15px;\n}\n\n.mce-content-body h6 {\n font-size: 14px;\n line-height: 1.4em;\n margin: 25px 0 15px;\n}\n\n.mce-content-body p {\n margin: 25px 0;\n}\n\n.mce-content-body pre {\n font-family: monospace;\n}\n\n.mce-content-body ol,\n.mce-content-body ul {\n margin-left: 15px;\n list-style-position: outside;\n margin-bottom: 20px;\n}\n\n.mce-content-body ol li,\n.mce-content-body ul li {\n margin-left: 10px;\n margin-bottom: 10px;\n color: var(--editor-text);\n}\n\n.mce-content-body ul {\n list-style-type: disc;\n}\n\n.mce-content-body ol {\n list-style-type: decimal;\n}\n\n.mce-content-body a[href] {\n color: var(--editor-link);\n text-decoration: underline;\n}\n\n.mce-content-body table caption,\n.mce-content-body table td,\n.mce-content-body table th {\n padding: 15px 7px;\n font: inherit;\n}\n\n.mce-content-body table td,\n.mce-content-body table th {\n border: 1px solid var(--editor-border) !important;\n border-collapse: collapse;\n}\n\n.mce-content-body table th {\n font-weight: 400;\n color: var(--editor-table-header-text);\n background-position: 100% 100%;\n background-size: 2px 10px;\n background-repeat: no-repeat;\n}\n\n.mce-content-body table {\n width: 100%;\n border-spacing: 0;\n border-collapse: separate;\n \n}\n\n.mce-content-body table tr:nth-child(even) {\n background: var(--editor-table-row-even);\n}\n\n.mce-content-body hr {\n border-top: 2px solid var(--editor-hr);\n}';
|
|
66
|
+
var mce_default = ':where(.mce-content-body) {\n --editor-text: #000;\n --editor-link: #000;\n --editor-border: #d6d6d6c9;\n --editor-table-header-text: #6e6e6e;\n --editor-table-row-even: #fafafa;\n --editor-hr: #bbb;\n}\n\n\n\nli::marker {\n color: var(--editor-link) !important;\n}\n\n::-webkit-scrollbar {\n width: 10px;\n}\n\n::-webkit-scrollbar-track {\n background: var(--editor-table-row-even);\n}\n\n::-webkit-scrollbar-thumb {\n background: var(--editor-link);\n border-radius: 35px;\n}\n\n @media print {\n .mce-content-body {\n --editor-text: #000;\n --editor-link: #000;\n --editor-border: #d6d6d6c9;\n --editor-table-header-text: #000;\n --editor-table-row-even: #fafafa;\n --editor-hr: #000;\n }\n\n .mce-content-body table tr:nth-child(even) {\n background: var(--editor-table-row-even) !important;\n -webkit-print-color-adjust: exact;\n print-color-adjust: exact;\n }\n\n \n .mce-content-body blockquote {\n border-inline-start: none !important;\n background: #f9f9f9 !important;\n\n color: #000 !important;\n -webkit-print-color-adjust: exact !important;\n print-color-adjust: exact !important;\n }\n\n \n\n .mce-content-body td[data-mce-selected]::after,\n .mce-content-body th[data-mce-selected]::after {\n display: none !important;\n}\n}\n\n img {\n padding-block: 7px;\n max-width: 100%;\n }\n\n\n\n .mce-content-body blockquote {\n display: flow-root;\n padding: 15px;\n border-radius: 8px;\n margin: 0px !important;\n margin-block: 20px !important;\n overflow: hidden;\n border: none !important;\n background: var(--editor-table-row-even);\n color: var(--editor-text);\n}\n\n\n\n.mce-content-body blockquote p {\n margin: 0;\n}\n\n* {\n border: 0;\n padding: 0;\n margin: 0;\n background: 0 0;\n color: inherit;\n box-sizing: border-box;\n background-repeat: no-repeat;\n background-position: 50% 50%;\n font-weight: 400;\n}\n\n:focus {\n outline: 0;\n}\n\na {\n text-decoration: none;\n cursor: pointer;\n}\n\nb,\nb *,\nstrong,\nstrong * {\n font-weight: 700;\n}\n\nol,\nul {\n list-style: none;\n}\n\npre {\n font: inherit;\n}\n\nbutton,\ninput,\ninput:not([type]),\ninput[type="button"],\ninput[type="color"],\ninput[type="date"],\ninput[type="datetime-local"],\ninput[type="datetime"],\ninput[type="email"],\ninput[type="month"],\ninput[type="number"],\ninput[type="password"],\ninput[type="reset"],\ninput[type="search"],\ninput[type="submit"],\ninput[type="tel"],\ninput[type="text"],\ninput[type="time"],\ninput[type="url"],\ninput[type="week"],\nselect,\ntextarea {\n font: inherit;\n}\n\n.mce-container textarea {\n display: inline-block !important;\n} \n\n\n.my-custom-styles{\n direction: ltr;\n }\n\n.mce-content-body {\n font-size: 22px;\n font-family: Rubik, Helvetica, Arial, sans-serif;\n padding: 0 25px 25px;\n color: var(--editor-text);\n}\n\n.mce-content-body table {\n width: 100%;\n table-layout: fixed;\n}\n\n\n\n.mce-content-body table td,\n.mce-content-body table th {\n overflow-wrap: anywhere;\n word-break: break-word;\n white-space: normal;\n}\n\n\n.mce-content-body h1 {\n font-size: 34px;\n line-height: 1.4em;\n margin: 25px 0 15px;\n}\n\n.mce-content-body h2 {\n font-size: 30px;\n line-height: 1.4em;\n margin: 25px 0 15px;\n}\n\n.mce-content-body h3 {\n font-size: 26px;\n line-height: 1.4em;\n margin: 25px 0 15px;\n}\n\n.mce-content-body h4 {\n font-size: 22px;\n line-height: 1.4em;\n margin: 25px 0 15px;\n}\n\n.mce-content-body h5 {\n font-size: 18px;\n line-height: 1.4em;\n margin: 25px 0 15px;\n}\n\n.mce-content-body h6 {\n font-size: 14px;\n line-height: 1.4em;\n margin: 25px 0 15px;\n}\n\n.mce-content-body p {\n margin: 25px 0;\n}\n\n.mce-content-body pre {\n font-family: monospace;\n}\n\n.mce-content-body ol,\n.mce-content-body ul {\n margin-left: 15px;\n list-style-position: outside;\n margin-bottom: 20px;\n}\n\n.mce-content-body ol li,\n.mce-content-body ul li {\n margin-left: 10px;\n margin-bottom: 10px;\n color: var(--editor-text);\n}\n\n.mce-content-body ul {\n list-style-type: disc;\n}\n\n.mce-content-body ol {\n list-style-type: decimal;\n}\n\n.mce-content-body a[href] {\n color: var(--editor-link);\n text-decoration: underline;\n}\n\n.mce-content-body table caption,\n.mce-content-body table td,\n.mce-content-body table th {\n padding: 15px 7px;\n font: inherit;\n}\n\n.mce-content-body table td,\n.mce-content-body table th {\n border: 1px solid var(--editor-border) !important;\n border-collapse: collapse;\n}\n\n.mce-content-body table th {\n font-weight: 400;\n color: var(--editor-table-header-text);\n background-position: 100% 100%;\n background-size: 2px 10px;\n background-repeat: no-repeat;\n}\n\n.mce-content-body table {\n width: 100%;\n border-spacing: 0;\n border-collapse: separate;\n \n}\n\n.mce-content-body table tr:nth-child(even) {\n background: var(--editor-table-row-even);\n}\n\n.mce-content-body hr {\n border-top: 2px solid var(--editor-hr);\n}';
|
|
67
|
+
|
|
68
|
+
// src/client/custom-components/arrows.css?raw
|
|
69
|
+
var arrows_default = "\n\n.tox .tox-editor-header .tox-toolbar-arrow.visible {\n opacity: 1;\n pointer-events: auto;\n}\n\n/* ---------- toolbar scroll arrows ---------- */\n.tox .tox-editor-header .tox-toolbar-arrow {\n position: absolute !important;\n bottom: 0 !important;\n z-index: 5;\n\n height: 100%;\n \n width: 20px !important;\n border-radius: 5px !important;\n\n box-sizing: border-box !important;\n\n\n display: flex;\n align-items: center;\n margin: 0 !important;\n padding: 0;\n border: 0;\n border-radius: 0;\n cursor: pointer;\n font-weight: bold !important;\n color: var(--editor-text,white); /* arrow icon color */\n\n margin-block: 1px !important;\n background: rgba(0, 0, 0, 0.08); /* transparent dark background */\n opacity: 0;\n pointer-events: none;\n transition: opacity 0.15s ease-in-out, background 0.2s ease-in-out;\n}\n\n.tox-toolbar--scrolling{\n margin-inline: 20px !important;\n}\n\n@media screen and (max-width:660px) {\n \n .tox-toolbar--scrolling{\n margin-inline: 0px !important;\n}\n}\n\n.tox .tox-editor-header .tox-toolbar-arrow.visible {\n opacity: 1;\n pointer-events: auto;\n}\n\n.tox .tox-editor-header .tox-toolbar-arrow:hover {\n background: rgba(0, 0, 0, 0.3);\n}\n\n.tox .tox-editor-header .tox-toolbar-arrow.left {\n left: 0 !important;\n right: auto !important;\n justify-content: flex-start;\n padding-left: 4px;\n}\n\n.tox .tox-editor-header .tox-toolbar-arrow.right {\n right: 0 !important;\n left: auto !important;\n justify-content: flex-end;\n padding-right: 4px;\n}\n";
|
|
67
70
|
|
|
68
71
|
// src/client/custom-components/tinymce-helpers.ts
|
|
69
72
|
import { isNonEmptyString } from "@rg-dev/stdlib/lib/common-env";
|
|
70
73
|
async function defaultSkin() {
|
|
71
74
|
const contentSkin = `default`;
|
|
72
75
|
const shellSkin = "oxide";
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
injectCss(
|
|
77
|
+
"tinymce-toolbar-arrows-css",
|
|
78
|
+
`${arrows_default}
|
|
79
|
+
${`
|
|
80
|
+
.tox-toolbar-arrow{
|
|
81
|
+
--editor-text: black !important;
|
|
82
|
+
}`}`
|
|
83
|
+
);
|
|
84
|
+
await Promise.all(
|
|
85
|
+
[
|
|
86
|
+
import("tinymce/skins/ui/oxide/content.js"),
|
|
87
|
+
import("tinymce/skins/content/default/content.js"),
|
|
88
|
+
import("tinymce/skins/ui/oxide/skin.js")
|
|
89
|
+
]
|
|
90
|
+
);
|
|
78
91
|
return {
|
|
79
92
|
css: tinymce.Resource.get(`content/${contentSkin}/content.css`) + tinymce.Resource.get(`ui/${shellSkin}/content.css`),
|
|
80
93
|
skin: shellSkin
|
|
@@ -90,6 +103,14 @@ async function darkSkin() {
|
|
|
90
103
|
import("tinymce/skins/ui/oxide-dark/skin.js")
|
|
91
104
|
]
|
|
92
105
|
);
|
|
106
|
+
injectCss(
|
|
107
|
+
"tinymce-toolbar-arrows-css",
|
|
108
|
+
`${arrows_default}
|
|
109
|
+
${`
|
|
110
|
+
.tox-toolbar-arrow{
|
|
111
|
+
--editor-text: white !important;
|
|
112
|
+
}`}`
|
|
113
|
+
);
|
|
93
114
|
return {
|
|
94
115
|
css: tinymce.Resource.get(`content/${contentSkin}/content.css`) + tinymce.Resource.get(`ui/${shellSkin}/content.css`) + `
|
|
95
116
|
.mce-content-body {
|
|
@@ -120,7 +141,7 @@ function resolvePatch(defaults, patch) {
|
|
|
120
141
|
} else {
|
|
121
142
|
resolved = patch;
|
|
122
143
|
}
|
|
123
|
-
const _b = resolved || {}, { target, setup, selector } = _b, safe = __objRest(_b, ["target", "setup", "selector"]);
|
|
144
|
+
const _b = resolved || {}, { target, setup, selector, content_css, toolbar_mode } = _b, safe = __objRest(_b, ["target", "setup", "selector", "content_css", "toolbar_mode"]);
|
|
124
145
|
return safe;
|
|
125
146
|
}
|
|
126
147
|
var ListBuilder = class {
|
|
@@ -210,21 +231,13 @@ var MenuBuilder = class {
|
|
|
210
231
|
return this;
|
|
211
232
|
}
|
|
212
233
|
/** Edit one menu's items with the same builder API as toolbar/contextmenu. */
|
|
213
|
-
|
|
234
|
+
patchMenu(key, patch) {
|
|
214
235
|
const menu = this.menus[key];
|
|
215
236
|
if (!menu) {
|
|
216
237
|
console.error(`MenuBuilder.items: menu "${key}" does not exist`);
|
|
217
|
-
return
|
|
238
|
+
return;
|
|
218
239
|
}
|
|
219
240
|
menu.items = applyListPatch(menu.items, patch);
|
|
220
|
-
return this;
|
|
221
|
-
}
|
|
222
|
-
/** Remove items from one menu, or from every menu if `key` is omitted. */
|
|
223
|
-
removeItem(names, key) {
|
|
224
|
-
const list = Array.isArray(names) ? names : [names];
|
|
225
|
-
const keys = key ? [key] : Object.keys(this.menus);
|
|
226
|
-
for (const k of keys) this.items(k, (t) => t.remove(...list));
|
|
227
|
-
return this;
|
|
228
241
|
}
|
|
229
242
|
/** Empty menus are dropped so TinyMCE never sees a menu with no items. */
|
|
230
243
|
toObject() {
|
|
@@ -245,6 +258,7 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
245
258
|
__publicField(this, "_editor");
|
|
246
259
|
__publicField(this, "_lockButton");
|
|
247
260
|
__publicField(this, "originalContextMenu");
|
|
261
|
+
__publicField(this, "_arrowCleanup");
|
|
248
262
|
}
|
|
249
263
|
static async initMce(el, customOpts = Object()) {
|
|
250
264
|
return await new _tinymceHelpers()._initMce(el, customOpts);
|
|
@@ -252,6 +266,82 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
252
266
|
addImg(src) {
|
|
253
267
|
this.editor.insertContent(`<img src="${src}" alt="">`);
|
|
254
268
|
}
|
|
269
|
+
createToolbarArrows() {
|
|
270
|
+
const container = this._editor.getContainer();
|
|
271
|
+
const header = container == null ? void 0 : container.querySelector(".tox-editor-header");
|
|
272
|
+
if (!header) {
|
|
273
|
+
console.error("header not found");
|
|
274
|
+
return;
|
|
275
|
+
}
|
|
276
|
+
if (getComputedStyle(header).position === "static") {
|
|
277
|
+
header.style.position = "relative";
|
|
278
|
+
}
|
|
279
|
+
const getScroller = () => {
|
|
280
|
+
var _a;
|
|
281
|
+
return (_a = Array.from(header.querySelectorAll("*")).find(
|
|
282
|
+
(el) => {
|
|
283
|
+
if (el.classList.contains("tox-toolbar-arrow")) return false;
|
|
284
|
+
const ox = getComputedStyle(el).overflowX;
|
|
285
|
+
return ox !== "visible" && el.scrollWidth > el.clientWidth + 1;
|
|
286
|
+
}
|
|
287
|
+
)) != null ? _a : null;
|
|
288
|
+
};
|
|
289
|
+
const hideBars = () => {
|
|
290
|
+
header.querySelectorAll("*").forEach(
|
|
291
|
+
(el) => {
|
|
292
|
+
if (el.classList.contains("tox-toolbar-arrow")) return;
|
|
293
|
+
if (getComputedStyle(el).overflowX !== "visible") {
|
|
294
|
+
el.style.setProperty("scrollbar-width", "none", "important");
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
);
|
|
298
|
+
};
|
|
299
|
+
const make = (dir) => {
|
|
300
|
+
const b = document.createElement("button");
|
|
301
|
+
try {
|
|
302
|
+
b.style.height = getComputedStyle(container.querySelector(".tox-toolbar--scrolling")).height;
|
|
303
|
+
} catch (e) {
|
|
304
|
+
}
|
|
305
|
+
b.type = "button";
|
|
306
|
+
b.className = `tox-toolbar-arrow ${dir}`;
|
|
307
|
+
b.setAttribute("aria-label", `Scroll toolbar ${dir}`);
|
|
308
|
+
b.innerHTML = `<svg width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="4" stroke-linecap="round" stroke-linejoin="round"><path d="${dir === "left" ? "M15 5l-7 7 7 7" : "M9 5l7 7-7 7"}"/></svg>`;
|
|
309
|
+
b.addEventListener("mousedown", (e) => e.preventDefault());
|
|
310
|
+
b.addEventListener(
|
|
311
|
+
"click",
|
|
312
|
+
() => {
|
|
313
|
+
const bar = getScroller();
|
|
314
|
+
bar == null ? void 0 : bar.scrollBy({ left: (dir === "left" ? -1 : 1) * bar.clientWidth * 0.6, behavior: "smooth" });
|
|
315
|
+
}
|
|
316
|
+
);
|
|
317
|
+
header.appendChild(b);
|
|
318
|
+
return b;
|
|
319
|
+
};
|
|
320
|
+
const left = make("left");
|
|
321
|
+
const right = make("right");
|
|
322
|
+
const update = () => {
|
|
323
|
+
hideBars();
|
|
324
|
+
const bar = getScroller();
|
|
325
|
+
left.classList.toggle("visible", !!bar && bar.scrollLeft > 1);
|
|
326
|
+
right.classList.toggle("visible", !!bar && bar.scrollLeft + bar.clientWidth < bar.scrollWidth - 1);
|
|
327
|
+
};
|
|
328
|
+
header.addEventListener("scroll", update, { capture: true, passive: true });
|
|
329
|
+
const ro = new ResizeObserver(update);
|
|
330
|
+
ro.observe(header);
|
|
331
|
+
requestAnimationFrame(() => {
|
|
332
|
+
update();
|
|
333
|
+
requestAnimationFrame(update);
|
|
334
|
+
});
|
|
335
|
+
this._arrowCleanup = () => {
|
|
336
|
+
try {
|
|
337
|
+
header.removeEventListener("scroll", update, true);
|
|
338
|
+
ro.disconnect();
|
|
339
|
+
left.remove();
|
|
340
|
+
right.remove();
|
|
341
|
+
} catch (e) {
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
}
|
|
255
345
|
async _initMce(el, customOpts = Object()) {
|
|
256
346
|
var _a, _b;
|
|
257
347
|
if (!(el instanceof HTMLElement)) {
|
|
@@ -264,13 +354,16 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
264
354
|
setup(editor) {
|
|
265
355
|
var _a2;
|
|
266
356
|
editor.ui.registry.addIcon("lock-icon", `<svg viewBox="0 0 24 24" width="24" height="24" fill="currentColor" aria-hidden="true"><path d="M12 17a2 2 0 1 0 0-4 2 2 0 0 0 0 4zm6-9h-1V6a5 5 0 0 0-10 0v2H6a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V10a2 2 0 0 0-2-2zM9 6a3 3 0 0 1 6 0v2H9V6zm9 14H6V10h12v10z"/></svg>`);
|
|
267
|
-
editor.ui.registry.addButton(
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
357
|
+
editor.ui.registry.addButton(
|
|
358
|
+
"lockContent",
|
|
359
|
+
{
|
|
360
|
+
tooltip: "Lock editing",
|
|
361
|
+
icon: "lock-icon",
|
|
362
|
+
onAction: () => {
|
|
363
|
+
that.toggleReadOnly("yes");
|
|
364
|
+
}
|
|
272
365
|
}
|
|
273
|
-
|
|
366
|
+
);
|
|
274
367
|
editor.on("keydown", (e) => {
|
|
275
368
|
if (e.key !== "Enter" || !e.shiftKey) {
|
|
276
369
|
return;
|
|
@@ -336,17 +429,20 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
336
429
|
that.toggleReadOnly();
|
|
337
430
|
}
|
|
338
431
|
});
|
|
339
|
-
editor.ui.registry.addMenuItem(
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
selectedImage
|
|
346
|
-
selectedImage.
|
|
432
|
+
editor.ui.registry.addMenuItem(
|
|
433
|
+
"reset-style-button-img",
|
|
434
|
+
{
|
|
435
|
+
text: "Reset Image Style",
|
|
436
|
+
icon: "resize",
|
|
437
|
+
onAction: () => {
|
|
438
|
+
const selectedImage = editor.selection.getNode();
|
|
439
|
+
if (selectedImage.nodeName === "IMG") {
|
|
440
|
+
selectedImage.style.width = "unset";
|
|
441
|
+
selectedImage.style.height = "unset";
|
|
442
|
+
}
|
|
347
443
|
}
|
|
348
444
|
}
|
|
349
|
-
|
|
445
|
+
);
|
|
350
446
|
editor.ui.registry.addMenuItem("clearTextStyle", {
|
|
351
447
|
text: "Clear formatting",
|
|
352
448
|
icon: "removeformat",
|
|
@@ -460,7 +556,6 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
460
556
|
body_class: "my-custom-styles",
|
|
461
557
|
target: el,
|
|
462
558
|
toolbar: "myBlockquote lockContent | undo redo | increaseFontSize decreaseFontSize bold italic underline strikethrough | fontfamily fontsize | ltr rtl alignleft aligncenter alignright alignjustify | outdent indent | numlist bullist | forecolor backcolor removeformat | charmap emoticons | fullscreen preview print | image media link anchor codesample",
|
|
463
|
-
toolbar_sticky: true,
|
|
464
559
|
promotion: false,
|
|
465
560
|
image_advtab: true,
|
|
466
561
|
license_key: "gpl",
|
|
@@ -469,7 +564,9 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
469
564
|
image_caption: true,
|
|
470
565
|
quickbars_selection_toolbar: "bold italic | quicklink blockquote quickimage quicktable",
|
|
471
566
|
noneditable_class: "mceNonEditable",
|
|
472
|
-
toolbar_mode: "
|
|
567
|
+
toolbar_mode: "scrolling",
|
|
568
|
+
toolbar_sticky: false,
|
|
569
|
+
content_css: "",
|
|
473
570
|
browser_spellcheck: true,
|
|
474
571
|
menu: {
|
|
475
572
|
file: {
|
|
@@ -564,6 +661,7 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
564
661
|
this.toggleTextDirection(customOpts.direction);
|
|
565
662
|
}
|
|
566
663
|
this.createLockButton();
|
|
664
|
+
this.createToolbarArrows();
|
|
567
665
|
return this;
|
|
568
666
|
}
|
|
569
667
|
setContextMenu(enabled) {
|
|
@@ -679,11 +777,22 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
679
777
|
return this._editor;
|
|
680
778
|
}
|
|
681
779
|
destroy() {
|
|
682
|
-
var _a;
|
|
683
|
-
(_a = this.
|
|
780
|
+
var _a, _b;
|
|
781
|
+
(_a = this._arrowCleanup) == null ? void 0 : _a.call(this);
|
|
782
|
+
(_b = this._lockButton) == null ? void 0 : _b.remove();
|
|
684
783
|
this._editor.destroy();
|
|
685
784
|
}
|
|
686
785
|
};
|
|
786
|
+
function injectCss(id, css) {
|
|
787
|
+
let style = document.getElementById(id);
|
|
788
|
+
if (!style) {
|
|
789
|
+
style = document.createElement("style");
|
|
790
|
+
style.id = id;
|
|
791
|
+
document.head.appendChild(style);
|
|
792
|
+
}
|
|
793
|
+
style.textContent = css;
|
|
794
|
+
return style;
|
|
795
|
+
}
|
|
687
796
|
export {
|
|
688
797
|
tinymceHelpers
|
|
689
798
|
};
|