@rg-dev/tinymce-helpers 1.0.16 → 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 +3 -1
- package/index.mjs +142 -26
- 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' | 'content_css'> & 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 {
|
|
@@ -94,6 +94,8 @@ declare class tinymceHelpers {
|
|
|
94
94
|
private constructor();
|
|
95
95
|
static initMce(el: HTMLElement, customOpts?: MyTinymceOpts): Promise<tinymceHelpers>;
|
|
96
96
|
addImg(src: string): void;
|
|
97
|
+
private _arrowCleanup?;
|
|
98
|
+
private createToolbarArrows;
|
|
97
99
|
_initMce(el: HTMLElement, customOpts?: MyTinymceOpts): Promise<this>;
|
|
98
100
|
private setContextMenu;
|
|
99
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, content_css } = _b, safe = __objRest(_b, ["target", "setup", "selector", "content_css"]);
|
|
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 {
|
|
@@ -237,6 +258,7 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
237
258
|
__publicField(this, "_editor");
|
|
238
259
|
__publicField(this, "_lockButton");
|
|
239
260
|
__publicField(this, "originalContextMenu");
|
|
261
|
+
__publicField(this, "_arrowCleanup");
|
|
240
262
|
}
|
|
241
263
|
static async initMce(el, customOpts = Object()) {
|
|
242
264
|
return await new _tinymceHelpers()._initMce(el, customOpts);
|
|
@@ -244,6 +266,82 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
244
266
|
addImg(src) {
|
|
245
267
|
this.editor.insertContent(`<img src="${src}" alt="">`);
|
|
246
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
|
+
}
|
|
247
345
|
async _initMce(el, customOpts = Object()) {
|
|
248
346
|
var _a, _b;
|
|
249
347
|
if (!(el instanceof HTMLElement)) {
|
|
@@ -256,13 +354,16 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
256
354
|
setup(editor) {
|
|
257
355
|
var _a2;
|
|
258
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>`);
|
|
259
|
-
editor.ui.registry.addButton(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
357
|
+
editor.ui.registry.addButton(
|
|
358
|
+
"lockContent",
|
|
359
|
+
{
|
|
360
|
+
tooltip: "Lock editing",
|
|
361
|
+
icon: "lock-icon",
|
|
362
|
+
onAction: () => {
|
|
363
|
+
that.toggleReadOnly("yes");
|
|
364
|
+
}
|
|
264
365
|
}
|
|
265
|
-
|
|
366
|
+
);
|
|
266
367
|
editor.on("keydown", (e) => {
|
|
267
368
|
if (e.key !== "Enter" || !e.shiftKey) {
|
|
268
369
|
return;
|
|
@@ -328,17 +429,20 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
328
429
|
that.toggleReadOnly();
|
|
329
430
|
}
|
|
330
431
|
});
|
|
331
|
-
editor.ui.registry.addMenuItem(
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
selectedImage
|
|
338
|
-
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
|
+
}
|
|
339
443
|
}
|
|
340
444
|
}
|
|
341
|
-
|
|
445
|
+
);
|
|
342
446
|
editor.ui.registry.addMenuItem("clearTextStyle", {
|
|
343
447
|
text: "Clear formatting",
|
|
344
448
|
icon: "removeformat",
|
|
@@ -452,7 +556,6 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
452
556
|
body_class: "my-custom-styles",
|
|
453
557
|
target: el,
|
|
454
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",
|
|
455
|
-
toolbar_sticky: true,
|
|
456
559
|
promotion: false,
|
|
457
560
|
image_advtab: true,
|
|
458
561
|
license_key: "gpl",
|
|
@@ -461,7 +564,8 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
461
564
|
image_caption: true,
|
|
462
565
|
quickbars_selection_toolbar: "bold italic | quicklink blockquote quickimage quicktable",
|
|
463
566
|
noneditable_class: "mceNonEditable",
|
|
464
|
-
toolbar_mode: "
|
|
567
|
+
toolbar_mode: "scrolling",
|
|
568
|
+
toolbar_sticky: false,
|
|
465
569
|
content_css: "",
|
|
466
570
|
browser_spellcheck: true,
|
|
467
571
|
menu: {
|
|
@@ -557,6 +661,7 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
557
661
|
this.toggleTextDirection(customOpts.direction);
|
|
558
662
|
}
|
|
559
663
|
this.createLockButton();
|
|
664
|
+
this.createToolbarArrows();
|
|
560
665
|
return this;
|
|
561
666
|
}
|
|
562
667
|
setContextMenu(enabled) {
|
|
@@ -672,11 +777,22 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
672
777
|
return this._editor;
|
|
673
778
|
}
|
|
674
779
|
destroy() {
|
|
675
|
-
var _a;
|
|
676
|
-
(_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();
|
|
677
783
|
this._editor.destroy();
|
|
678
784
|
}
|
|
679
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
|
+
}
|
|
680
796
|
export {
|
|
681
797
|
tinymceHelpers
|
|
682
798
|
};
|