@rg-dev/tinymce-helpers 1.0.14 → 1.0.16
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 +2 -4
- package/index.mjs +11 -14
- 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'> & 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
|
}
|
package/index.mjs
CHANGED
|
@@ -63,7 +63,7 @@ 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
|
|
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}';
|
|
67
67
|
|
|
68
68
|
// src/client/custom-components/tinymce-helpers.ts
|
|
69
69
|
import { isNonEmptyString } from "@rg-dev/stdlib/lib/common-env";
|
|
@@ -120,7 +120,7 @@ function resolvePatch(defaults, patch) {
|
|
|
120
120
|
} else {
|
|
121
121
|
resolved = patch;
|
|
122
122
|
}
|
|
123
|
-
const _b = resolved || {}, { target, setup, selector } = _b, safe = __objRest(_b, ["target", "setup", "selector"]);
|
|
123
|
+
const _b = resolved || {}, { target, setup, selector, content_css } = _b, safe = __objRest(_b, ["target", "setup", "selector", "content_css"]);
|
|
124
124
|
return safe;
|
|
125
125
|
}
|
|
126
126
|
var ListBuilder = class {
|
|
@@ -210,21 +210,13 @@ var MenuBuilder = class {
|
|
|
210
210
|
return this;
|
|
211
211
|
}
|
|
212
212
|
/** Edit one menu's items with the same builder API as toolbar/contextmenu. */
|
|
213
|
-
|
|
213
|
+
patchMenu(key, patch) {
|
|
214
214
|
const menu = this.menus[key];
|
|
215
215
|
if (!menu) {
|
|
216
216
|
console.error(`MenuBuilder.items: menu "${key}" does not exist`);
|
|
217
|
-
return
|
|
217
|
+
return;
|
|
218
218
|
}
|
|
219
219
|
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
220
|
}
|
|
229
221
|
/** Empty menus are dropped so TinyMCE never sees a menu with no items. */
|
|
230
222
|
toObject() {
|
|
@@ -470,6 +462,7 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
470
462
|
quickbars_selection_toolbar: "bold italic | quicklink blockquote quickimage quicktable",
|
|
471
463
|
noneditable_class: "mceNonEditable",
|
|
472
464
|
toolbar_mode: "sliding",
|
|
465
|
+
content_css: "",
|
|
473
466
|
browser_spellcheck: true,
|
|
474
467
|
menu: {
|
|
475
468
|
file: {
|
|
@@ -598,8 +591,12 @@ var tinymceHelpers = class _tinymceHelpers {
|
|
|
598
591
|
if (opts.dir) {
|
|
599
592
|
this.toggleTextDirection(opts.dir);
|
|
600
593
|
}
|
|
601
|
-
|
|
602
|
-
|
|
594
|
+
if (typeof content == "string") {
|
|
595
|
+
this._editor.setContent(content);
|
|
596
|
+
this._editor.undoManager.clear();
|
|
597
|
+
} else {
|
|
598
|
+
console.error("setContent()", "content not a string");
|
|
599
|
+
}
|
|
603
600
|
}
|
|
604
601
|
getCustomStyles() {
|
|
605
602
|
const sheets = this._editor.getDoc().styleSheets;
|