@novaprose/core 0.5.2 → 0.6.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 +51 -17
- package/THIRD_PARTY_NOTICES.md +50 -0
- package/dist/{advlist-FH3K3AAQ.js → advlist-K2U3VPH2.js} +3 -3
- package/dist/{autolink-IDJWAL2V.js → autolink-XWDTLY37.js} +2 -2
- package/dist/{autoresize-4ZEPQCHP.js → autoresize-UB3GOA6D.js} +2 -2
- package/dist/{autosave-WODRZ7L6.js → autosave-MWNRUNU3.js} +6 -3
- package/dist/autosave-MWNRUNU3.js.map +1 -0
- package/dist/{charmap-LWA7TL3K.js → charmap-ADLYOIB3.js} +6 -3
- package/dist/charmap-ADLYOIB3.js.map +1 -0
- package/dist/{chunk-PHRON5PL.js → chunk-435CRWKA.js} +70 -155
- package/dist/chunk-435CRWKA.js.map +1 -0
- package/dist/{chunk-2A3IYKPE.js → chunk-46RIM5KP.js} +934 -32
- package/dist/chunk-46RIM5KP.js.map +1 -0
- package/dist/{chunk-YZPJQB3I.js → chunk-7ON7PR5R.js} +106 -25
- package/dist/chunk-7ON7PR5R.js.map +1 -0
- package/dist/{chunk-6GWG2BLC.js → chunk-HPLT3XRZ.js} +1 -1
- package/dist/chunk-HPLT3XRZ.js.map +1 -0
- package/dist/chunk-NPKAIW34.js +239 -0
- package/dist/chunk-NPKAIW34.js.map +1 -0
- package/dist/{directionality-N62ZB7CF.js → directionality-XOHJFSL6.js} +7 -4
- package/dist/directionality-XOHJFSL6.js.map +1 -0
- package/dist/{emoticons-WQ3K4J6G.js → emoticons-TP4N4ZGY.js} +6 -3
- package/dist/emoticons-TP4N4ZGY.js.map +1 -0
- package/dist/index.cjs +1660 -308
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +334 -81
- package/dist/index.d.ts +334 -81
- package/dist/index.js +223 -34
- package/dist/index.js.map +1 -1
- package/dist/{insertdatetime-2RZ3UUQE.js → insertdatetime-T4SEMQWP.js} +6 -3
- package/dist/insertdatetime-T4SEMQWP.js.map +1 -0
- package/dist/{nonbreaking-L6GNDHVO.js → nonbreaking-HG5HV6AL.js} +6 -3
- package/dist/nonbreaking-HG5HV6AL.js.map +1 -0
- package/dist/{quickbars-TIRY3RH4.js → quickbars-4NU4SIPL.js} +7 -5
- package/dist/{quickbars-TIRY3RH4.js.map → quickbars-4NU4SIPL.js.map} +1 -1
- package/dist/{revisionhistory-GDTOULKS.js → revisionhistory-3YQPLPLM.js} +9 -6
- package/dist/revisionhistory-3YQPLPLM.js.map +1 -0
- package/dist/{visualblocks-V4CQ4XMF.js → visualblocks-RTAYJOGR.js} +6 -3
- package/dist/visualblocks-RTAYJOGR.js.map +1 -0
- package/package.json +3 -2
- package/src/style.css +106 -0
- package/dist/autosave-WODRZ7L6.js.map +0 -1
- package/dist/charmap-LWA7TL3K.js.map +0 -1
- package/dist/chunk-2A3IYKPE.js.map +0 -1
- package/dist/chunk-6GWG2BLC.js.map +0 -1
- package/dist/chunk-PHRON5PL.js.map +0 -1
- package/dist/chunk-YZPJQB3I.js.map +0 -1
- package/dist/directionality-N62ZB7CF.js.map +0 -1
- package/dist/emoticons-WQ3K4J6G.js.map +0 -1
- package/dist/insertdatetime-2RZ3UUQE.js.map +0 -1
- package/dist/nonbreaking-L6GNDHVO.js.map +0 -1
- package/dist/revisionhistory-GDTOULKS.js.map +0 -1
- package/dist/visualblocks-V4CQ4XMF.js.map +0 -1
- /package/dist/{advlist-FH3K3AAQ.js.map → advlist-K2U3VPH2.js.map} +0 -0
- /package/dist/{autolink-IDJWAL2V.js.map → autolink-XWDTLY37.js.map} +0 -0
- /package/dist/{autoresize-4ZEPQCHP.js.map → autoresize-UB3GOA6D.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -97,56 +97,6 @@ var init_plugins = __esm({
|
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
// src/ui/dom.ts
|
|
101
|
-
function h(tag, attrs = {}, ...children) {
|
|
102
|
-
const el = document.createElement(tag);
|
|
103
|
-
for (const [name, value] of Object.entries(attrs)) {
|
|
104
|
-
if (value === null || value === void 0 || value === false) continue;
|
|
105
|
-
if (typeof value === "function") {
|
|
106
|
-
el.addEventListener(name.replace(/^on/, "").toLowerCase(), value);
|
|
107
|
-
} else if (name === "className") {
|
|
108
|
-
el.className = String(value);
|
|
109
|
-
} else {
|
|
110
|
-
el.setAttribute(name, value === true ? "" : String(value));
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
for (const child of children.flat()) {
|
|
114
|
-
if (child === null || child === void 0 || child === false) continue;
|
|
115
|
-
el.append(child);
|
|
116
|
-
}
|
|
117
|
-
return el;
|
|
118
|
-
}
|
|
119
|
-
function icon(svg2) {
|
|
120
|
-
const span = document.createElement("span");
|
|
121
|
-
span.className = "nova-icon";
|
|
122
|
-
span.innerHTML = svg2;
|
|
123
|
-
return span;
|
|
124
|
-
}
|
|
125
|
-
function uniqueId(prefix = "nova") {
|
|
126
|
-
uid += 1;
|
|
127
|
-
return `${prefix}-${uid}`;
|
|
128
|
-
}
|
|
129
|
-
function formatShortcut(shortcut) {
|
|
130
|
-
const parts = shortcut.split("-");
|
|
131
|
-
const key3 = parts.pop();
|
|
132
|
-
const keyLabel = key3.length === 1 ? key3.toUpperCase() : key3;
|
|
133
|
-
if (isMac) {
|
|
134
|
-
const map2 = { Mod: "\u2318", Shift: "\u21E7", Alt: "\u2325", Ctrl: "\u2303" };
|
|
135
|
-
return parts.map((p) => map2[p] ?? p).join("") + keyLabel;
|
|
136
|
-
}
|
|
137
|
-
const map = { Mod: "Ctrl", Shift: "Shift", Alt: "Alt", Ctrl: "Ctrl" };
|
|
138
|
-
return [...parts.map((p) => map[p] ?? p), keyLabel].join("+");
|
|
139
|
-
}
|
|
140
|
-
var uid, isMac, FOCUSABLE;
|
|
141
|
-
var init_dom = __esm({
|
|
142
|
-
"src/ui/dom.ts"() {
|
|
143
|
-
"use strict";
|
|
144
|
-
uid = 0;
|
|
145
|
-
isMac = typeof navigator !== "undefined" && /Mac|iP(hone|[oa]d)/.test(navigator.platform);
|
|
146
|
-
FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
147
|
-
}
|
|
148
|
-
});
|
|
149
|
-
|
|
150
100
|
// src/ui/icons.ts
|
|
151
101
|
var svg, icons;
|
|
152
102
|
var init_icons = __esm({
|
|
@@ -154,153 +104,290 @@ var init_icons = __esm({
|
|
|
154
104
|
"use strict";
|
|
155
105
|
svg = (body) => `<svg viewBox="0 0 24 24" width="18" height="18" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${body}</svg>`;
|
|
156
106
|
icons = {
|
|
157
|
-
undo: svg(
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
107
|
+
undo: svg(
|
|
108
|
+
'<path d="M9 14 4 9l5-5" /><path d="M4 9h10.5a5.5 5.5 0 0 1 5.5 5.5a5.5 5.5 0 0 1-5.5 5.5H11" />'
|
|
109
|
+
),
|
|
110
|
+
redo: svg(
|
|
111
|
+
'<path d="m15 14 5-5-5-5" /><path d="M20 9H9.5A5.5 5.5 0 0 0 4 14.5A5.5 5.5 0 0 0 9.5 20H13" />'
|
|
112
|
+
),
|
|
113
|
+
bold: svg('<path d="M6 12h9a4 4 0 010 8H7a1 1 0 01-1-1V5a1 1 0 011-1h7a4 4 0 010 8" />'),
|
|
114
|
+
italic: svg(
|
|
115
|
+
'<line x1="19" x2="10" y1="4" y2="4" /><line x1="14" x2="5" y1="20" y2="20" /><line x1="15" x2="9" y1="4" y2="20" />'
|
|
116
|
+
),
|
|
117
|
+
underline: svg('<path d="M6 4v6a6 6 0 0 0 12 0V4" /><line x1="4" x2="20" y1="20" y2="20" />'),
|
|
162
118
|
strike: svg(
|
|
163
|
-
'<path d="
|
|
119
|
+
'<path d="M16 4H9a3 3 0 0 0-2.83 4" /><path d="M14 12a4 4 0 0 1 0 8H6" /><line x1="4" x2="20" y1="12" y2="12" />'
|
|
164
120
|
),
|
|
165
|
-
code: svg('<path d="
|
|
121
|
+
code: svg('<path d="m16 18 6-6-6-6" /><path d="m8 6-6 6 6 6" />'),
|
|
166
122
|
subscript: svg(
|
|
167
|
-
'<path d="m4
|
|
123
|
+
'<path d="m4 5 8 8" /><path d="m12 5-8 8" /><path d="M20 19h-4c0-1.5.44-2 1.5-2.5S20 15.33 20 14c0-.47-.17-.93-.48-1.29a2.11 2.11 0 0 0-2.62-.44c-.42.24-.74.62-.9 1.07" />'
|
|
168
124
|
),
|
|
169
125
|
superscript: svg(
|
|
170
|
-
'<path d="m4
|
|
126
|
+
'<path d="m4 19 8-8" /><path d="m12 19-8-8" /><path d="M20 12h-4c0-1.5.442-2 1.5-2.5S20 8.334 20 7.002c0-.472-.17-.93-.484-1.29a2.105 2.105 0 0 0-2.617-.436c-.42.239-.738.614-.899 1.06" />'
|
|
171
127
|
),
|
|
172
128
|
bulletList: svg(
|
|
173
|
-
'<
|
|
129
|
+
'<path d="M3 5h.01" /><path d="M3 12h.01" /><path d="M3 19h.01" /><path d="M8 5h13" /><path d="M8 12h13" /><path d="M8 19h13" />'
|
|
174
130
|
),
|
|
175
131
|
orderedList: svg(
|
|
176
|
-
'<path d="
|
|
132
|
+
'<path d="M11 5h10" /><path d="M11 12h10" /><path d="M11 19h10" /><path d="M4 4h1v5" /><path d="M4 9h2" /><path d="M6.5 20H3.4c0-1 2.6-1.925 2.6-3.5a1.5 1.5 0 0 0-2.6-1.02" />'
|
|
133
|
+
),
|
|
134
|
+
indent: svg(
|
|
135
|
+
'<path d="M21 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m3 8 4 4-4 4" />'
|
|
136
|
+
),
|
|
137
|
+
outdent: svg(
|
|
138
|
+
'<path d="M21 5H11" /><path d="M21 12H11" /><path d="M21 19H11" /><path d="m7 8-4 4 4 4" />'
|
|
177
139
|
),
|
|
178
|
-
indent: svg('<path d="M4 6h16M10 12h10M4 18h16"/><path d="m4 10 3 2-3 2"/>'),
|
|
179
|
-
outdent: svg('<path d="M4 6h16M10 12h10M4 18h16"/><path d="m7 10-3 2 3 2"/>'),
|
|
180
140
|
blockquote: svg(
|
|
181
|
-
'<path d="
|
|
141
|
+
'<path d="M17 5H3" /><path d="M21 12H8" /><path d="M21 19H8" /><path d="M3 12v7" />'
|
|
182
142
|
),
|
|
183
143
|
codeBlock: svg(
|
|
184
|
-
'<rect x="3" y="
|
|
144
|
+
'<path d="m10 9-3 3 3 3" /><path d="m14 15 3-3-3-3" /><rect x="3" y="3" width="18" height="18" rx="2" />'
|
|
185
145
|
),
|
|
186
|
-
alignLeft: svg('<path d="
|
|
187
|
-
alignCenter: svg('<path d="
|
|
188
|
-
alignRight: svg('<path d="
|
|
189
|
-
alignJustify: svg('<path d="
|
|
190
|
-
horizontalRule: svg('<path d="
|
|
146
|
+
alignLeft: svg('<path d="M21 5H3" /><path d="M15 12H3" /><path d="M17 19H3" />'),
|
|
147
|
+
alignCenter: svg('<path d="M21 5H3" /><path d="M17 12H7" /><path d="M19 19H5" />'),
|
|
148
|
+
alignRight: svg('<path d="M21 5H3" /><path d="M21 12H9" /><path d="M21 19H7" />'),
|
|
149
|
+
alignJustify: svg('<path d="M3 5h18" /><path d="M3 12h18" /><path d="M3 19h18" />'),
|
|
150
|
+
horizontalRule: svg('<path d="m16 16-4 4-4-4" /><path d="M3 12h18" /><path d="m8 8 4-4 4 4" />'),
|
|
191
151
|
link: svg(
|
|
192
|
-
'<path d="M10
|
|
152
|
+
'<path d="M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71" /><path d="M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71" />'
|
|
193
153
|
),
|
|
194
154
|
unlink: svg(
|
|
195
|
-
'<path d="
|
|
155
|
+
'<path d="m18.84 12.25 1.72-1.71h-.02a5.004 5.004 0 0 0-.12-7.07 5.006 5.006 0 0 0-6.95 0l-1.72 1.71" /><path d="m5.17 11.75-1.71 1.71a5.004 5.004 0 0 0 .12 7.07 5.006 5.006 0 0 0 6.95 0l1.71-1.71" /><line x1="8" x2="8" y1="2" y2="5" /><line x1="2" x2="5" y1="8" y2="8" /><line x1="16" x2="16" y1="19" y2="22" /><line x1="19" x2="22" y1="16" y2="16" />'
|
|
196
156
|
),
|
|
197
157
|
image: svg(
|
|
198
|
-
'<rect
|
|
158
|
+
'<rect width="18" height="18" x="3" y="3" rx="2" ry="2" /><circle cx="9" cy="9" r="2" /><path d="m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21" />'
|
|
159
|
+
),
|
|
160
|
+
clearFormatting: svg(
|
|
161
|
+
'<path d="M4 7V4h16v3" /><path d="M5 20h6" /><path d="M13 4 8 20" /><path d="m15 15 5 5" /><path d="m20 15-5 5" />'
|
|
199
162
|
),
|
|
200
|
-
clearFormatting: svg('<path d="M6 5h12M12 5l-3 14"/><path d="m15 15 5 5M20 15l-5 5"/>'),
|
|
201
|
-
// «T²» — меню дополнительного форматирования
|
|
202
163
|
formatMore: svg(
|
|
203
|
-
'<path d="
|
|
164
|
+
'<path d="M12 4v16" /><path d="M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2" /><path d="M9 20h6" />'
|
|
204
165
|
),
|
|
205
|
-
// Картинка: обтекание слева / по центру / справа — прямоугольник + строки текста
|
|
206
166
|
imageLeft: svg(
|
|
207
|
-
'<rect x="
|
|
167
|
+
'<rect width="9" height="6" x="6" y="14" rx="2" /><rect width="16" height="6" x="6" y="4" rx="2" /><path d="M2 2v20" />'
|
|
168
|
+
),
|
|
169
|
+
imageCenter: svg(
|
|
170
|
+
'<path d="M12 2v20" /><path d="M8 10H4a2 2 0 0 1-2-2V6c0-1.1.9-2 2-2h4" /><path d="M16 10h4a2 2 0 0 0 2-2V6a2 2 0 0 0-2-2h-4" /><path d="M8 20H7a2 2 0 0 1-2-2v-2c0-1.1.9-2 2-2h1" /><path d="M16 14h1a2 2 0 0 1 2 2v2a2 2 0 0 1-2 2h-1" />'
|
|
208
171
|
),
|
|
209
|
-
imageCenter: svg('<rect x="7" y="4" width="10" height="9" rx="1"/><path d="M3 17h18M6 20h12"/>'),
|
|
210
172
|
imageRight: svg(
|
|
211
|
-
'<rect x="
|
|
173
|
+
'<rect width="16" height="6" x="2" y="4" rx="2" /><rect width="9" height="6" x="9" y="14" rx="2" /><path d="M22 22V2" />'
|
|
174
|
+
),
|
|
175
|
+
resize: svg(
|
|
176
|
+
'<path d="M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7" /><path d="M14 15H9v-5" /><path d="M16 3h5v5" /><path d="M21 3 9 15" />'
|
|
212
177
|
),
|
|
213
|
-
resize: svg('<path d="M15 3h6v6M9 21H3v-6"/><path d="m21 3-7 7M3 21l7-7"/>'),
|
|
214
178
|
altText: svg(
|
|
215
|
-
'<rect
|
|
179
|
+
'<rect width="18" height="14" x="3" y="5" rx="2" ry="2" /><path d="M7 15h4M15 15h2M7 11h2M13 11h4" />'
|
|
180
|
+
),
|
|
181
|
+
trash: svg(
|
|
182
|
+
'<path d="M10 11v6" /><path d="M14 11v6" /><path d="M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6" /><path d="M3 6h18" /><path d="M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2" />'
|
|
216
183
|
),
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
184
|
+
paragraph: svg(
|
|
185
|
+
'<path d="M13 4v16" /><path d="M17 4v16" /><path d="M19 4H9.5a4.5 4.5 0 0 0 0 9H13" />'
|
|
186
|
+
),
|
|
187
|
+
h1: svg('<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="m17 12 3-2v8" />'),
|
|
220
188
|
h2: svg(
|
|
221
|
-
'<path d="M4
|
|
189
|
+
'<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="M21 18h-4c0-4 4-3 4-6 0-1.5-2-2.5-4-1" />'
|
|
190
|
+
),
|
|
191
|
+
h3: svg(
|
|
192
|
+
'<path d="M4 12h8" /><path d="M4 18V6" /><path d="M12 18V6" /><path d="M17.5 10.5c1.7-1 3.5 0 3.5 1.5a2 2 0 0 1-2 2" /><path d="M17 17.5c2 1.5 4 .3 4-1.5a2 2 0 0 0-2-2" />'
|
|
222
193
|
),
|
|
223
|
-
h3: svg('<path d="M4 6v12M12 6v12M4 12h8"/><path d="M16 7.5h4.5l-2.5 3.5a3 3 0 1 1-2.5 5"/>'),
|
|
224
|
-
// Планшет буфера обмена с буквой T — «вставить как текст»
|
|
225
194
|
pasteText: svg(
|
|
226
|
-
'<rect
|
|
195
|
+
'<rect width="8" height="4" x="8" y="2" rx="1" ry="1" /><path d="M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2" /><path d="M9 12v-1h6v1" /><path d="M11 17h2" /><path d="M12 11v6" />'
|
|
227
196
|
),
|
|
228
|
-
// ---------- таблицы ----------
|
|
229
197
|
table: svg(
|
|
230
|
-
'<
|
|
198
|
+
'<path d="M12 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" /><path d="M3 15h18" />'
|
|
199
|
+
),
|
|
200
|
+
rowBefore: svg(
|
|
201
|
+
'<path d="M12 2v6" /><path d="M18.464 3H19a2 2 0 012 2v14a2 2 0 01-2 2H5a2 2 0 01-2-2V5a2 2 0 012-2h.535" /><path d="M21 12H3" /><path d="M9 5h6" />'
|
|
202
|
+
),
|
|
203
|
+
rowAfter: svg(
|
|
204
|
+
'<path d="M12 22v-6" /><path d="M18.464 21H19a2 2 0 002-2V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h.535" /><path d="M21 12H3" /><path d="M9 19h6" />'
|
|
231
205
|
),
|
|
232
|
-
rowBefore: svg('<rect x="3" y="12" width="18" height="8" rx="1"/><path d="M12 3v6M9 6h6"/>'),
|
|
233
|
-
rowAfter: svg('<rect x="3" y="4" width="18" height="8" rx="1"/><path d="M12 15v6M9 18h6"/>'),
|
|
234
206
|
rowDelete: svg(
|
|
235
|
-
'<
|
|
207
|
+
'<path d="M16 5H3" /><path d="M11 12H3" /><path d="M16 19H3" /><path d="m15.5 9.5 5 5" /><path d="m20.5 9.5-5 5" />'
|
|
208
|
+
),
|
|
209
|
+
colBefore: svg(
|
|
210
|
+
'<path d="M12 3v18" /><path d="M3 5.536V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-.535" /><path d="M5 15V9" /><path d="M8 12H2" />'
|
|
211
|
+
),
|
|
212
|
+
colAfter: svg(
|
|
213
|
+
'<path d="M12 3v18" /><path d="M16 12h6" /><path d="M19 15V9" /><path d="M21 5.536V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h14a2 2 0 002-2v-.535" />'
|
|
236
214
|
),
|
|
237
|
-
colBefore: svg('<rect x="12" y="3" width="8" height="18" rx="1"/><path d="M3 12h6M6 9v6"/>'),
|
|
238
|
-
colAfter: svg('<rect x="4" y="3" width="8" height="18" rx="1"/><path d="M15 12h6M18 9v6"/>'),
|
|
239
215
|
colDelete: svg(
|
|
240
|
-
'<
|
|
216
|
+
'<g transform="rotate(90 12 12)"><path d="M16 5H3" /><path d="M11 12H3" /><path d="M16 19H3" /><path d="m15.5 9.5 5 5" /><path d="m20.5 9.5-5 5" /></g>'
|
|
241
217
|
),
|
|
242
218
|
merge: svg(
|
|
243
|
-
'<
|
|
219
|
+
'<path d="M12 21v-6" /><path d="M12 9V3" /><path d="M3 15h18" /><path d="M3 9h18" /><rect width="18" height="18" x="3" y="3" rx="2" />'
|
|
244
220
|
),
|
|
245
221
|
split: svg(
|
|
246
|
-
'<
|
|
247
|
-
),
|
|
248
|
-
rowHeader: svg(
|
|
249
|
-
'<rect x="3" y="4" width="18" height="16" rx="1.5"/><path d="M3 9.5h18"/><path d="M4 5h16v4H4z" fill="currentColor" opacity=".35" stroke="none"/>'
|
|
222
|
+
'<path d="M12 15V9" /><path d="M3 15h18" /><path d="M3 9h18" /><rect width="18" height="18" x="3" y="3" rx="2" />'
|
|
250
223
|
),
|
|
251
|
-
|
|
252
|
-
|
|
224
|
+
rowHeader: svg('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M3 9h18" />'),
|
|
225
|
+
colHeader: svg('<rect width="18" height="18" x="3" y="3" rx="2" /><path d="M9 3v18" />'),
|
|
226
|
+
sort: svg(
|
|
227
|
+
'<path d="m3 16 4 4 4-4" /><path d="M7 20V4" /><path d="M11 4h10" /><path d="M11 8h7" /><path d="M11 12h4" />'
|
|
253
228
|
),
|
|
254
|
-
sort: svg('<path d="M7 4v16M4 17l3 3 3-3"/><path d="M14 6h7M14 11h5M14 16h3"/>'),
|
|
255
229
|
tableProps: svg(
|
|
256
|
-
'<
|
|
230
|
+
'<path d="M15 3v18" /><rect width="18" height="18" x="3" y="3" rx="2" /><path d="M21 9H3" /><path d="M21 15H3" />'
|
|
257
231
|
),
|
|
258
232
|
cellProps: svg(
|
|
259
|
-
'<
|
|
233
|
+
'<path d="M10.6 21H5a2 2 0 01-2-2V5a2 2 0 012-2h14a2 2 0 012 2v5.6" /><path d="m14.305 19.53.923-.382" /><path d="M15 3v7.6" /><path d="m15.229 16.852-.924-.383" /><path d="m16.852 15.228-.383-.923" /><path d="m16.852 20.772-.383.924" /><path d="m19.148 15.228.383-.923" /><path d="m19.53 21.696-.382-.924" /><path d="m20.773 16.852.922-.383" /><path d="m20.773 19.148.922.383" /><path d="M9 3v18" /><circle cx="18" cy="18" r="3" />'
|
|
260
234
|
),
|
|
261
235
|
tableDelete: svg(
|
|
262
|
-
'<
|
|
236
|
+
'<path d="M12 3v17a1 1 0 0 1-1 1H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v6a1 1 0 0 1-1 1H3" /><path d="m16.5 16.5 5 5" /><path d="m16.5 21.5 5-5" />'
|
|
237
|
+
),
|
|
238
|
+
chevronUp: svg('<path d="m18 15-6-6-6 6" />'),
|
|
239
|
+
search: svg('<path d="m21 21-4.34-4.34" /><circle cx="11" cy="11" r="8" />'),
|
|
240
|
+
fullscreen: svg(
|
|
241
|
+
'<path d="M8 3H5a2 2 0 0 0-2 2v3" /><path d="M21 8V5a2 2 0 0 0-2-2h-3" /><path d="M3 16v3a2 2 0 0 0 2 2h3" /><path d="M16 21h3a2 2 0 0 0 2-2v-3" />'
|
|
242
|
+
),
|
|
243
|
+
fullscreenExit: svg(
|
|
244
|
+
'<path d="M8 3v3a2 2 0 0 1-2 2H3" /><path d="M21 8h-3a2 2 0 0 1-2-2V3" /><path d="M3 16h3a2 2 0 0 1 2 2v3" /><path d="M16 21v-3a2 2 0 0 1 2-2h3" />'
|
|
263
245
|
),
|
|
264
|
-
chevronUp: svg('<path d="m7 14 5-5 5 5"/>'),
|
|
265
|
-
search: svg('<circle cx="11" cy="11" r="6.5"/><path d="m20 20-4.2-4.2"/>'),
|
|
266
|
-
fullscreen: svg('<path d="M4 9V4h5M20 9V4h-5M4 15v5h5M20 15v5h-5"/>'),
|
|
267
|
-
fullscreenExit: svg('<path d="M9 4v5H4M15 4v5h5M9 20v-5H4M15 20v-5h5"/>'),
|
|
268
246
|
preview: svg(
|
|
269
|
-
'<path d="M2
|
|
247
|
+
'<path d="M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0" /><circle cx="12" cy="12" r="3" />'
|
|
270
248
|
),
|
|
271
|
-
sourceCode: svg('<path d="
|
|
249
|
+
sourceCode: svg('<path d="m18 16 4-4-4-4" /><path d="m6 8-4 4 4 4" /><path d="m14.5 4-5 16" />'),
|
|
272
250
|
help: svg(
|
|
273
|
-
'<circle cx="12" cy="12" r="
|
|
251
|
+
'<circle cx="12" cy="12" r="10" /><path d="M9 9.5a3 2.5 0 016 0c0 2-2 2-3 3.5" /><path d="M12 17h.01" />'
|
|
274
252
|
),
|
|
275
253
|
print: svg(
|
|
276
|
-
'<path d="
|
|
254
|
+
'<path d="M6 18H4a2 2 0 0 1-2-2v-5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v5a2 2 0 0 1-2 2h-2" /><path d="M6 9V3a1 1 0 0 1 1-1h10a1 1 0 0 1 1 1v6" /><rect x="6" y="14" width="12" height="8" rx="1" />'
|
|
277
255
|
),
|
|
278
|
-
check: svg('<path d="
|
|
279
|
-
close: svg('<path d="
|
|
280
|
-
chevronDown: svg('<path d="
|
|
256
|
+
check: svg('<path d="M20 6 9 17l-5-5" />'),
|
|
257
|
+
close: svg('<path d="M18 6 6 18" /><path d="m6 6 12 12" />'),
|
|
258
|
+
chevronDown: svg('<path d="m6 9 6 6 6-6" />'),
|
|
281
259
|
more: svg(
|
|
282
|
-
'<circle cx="
|
|
260
|
+
'<circle cx="12" cy="12" r="1" /><circle cx="19" cy="12" r="1" /><circle cx="5" cy="12" r="1" />'
|
|
261
|
+
),
|
|
262
|
+
textColor: svg('<path d="M4 20h16" /><path d="m6 16 6-12 6 12" /><path d="M8 12h8" />'),
|
|
263
|
+
highlight: svg(
|
|
264
|
+
'<path d="m9 11-6 6v3h9l3-3" /><path d="m22 12-4.6 4.6a2 2 0 0 1-2.8 0l-5.2-5.2a2 2 0 0 1 0-2.8L14 4" />'
|
|
283
265
|
),
|
|
284
|
-
// Буква «A» — цвет полоски под ней задаётся через currentColor у .nova-color-bar
|
|
285
|
-
textColor: svg('<path d="m6 16 6-12 6 12"/><path d="M8.5 11h7"/>'),
|
|
286
|
-
highlight: svg('<path d="m14 4 6 6-8 8H6v-6z"/><path d="m11 7 6 6"/>'),
|
|
287
266
|
lineHeight: svg(
|
|
288
|
-
'<path d="
|
|
267
|
+
'<path d="M15 14H9" /><path d="M21 21H3" /><path d="M21 3H3" /><path d="m8 16 3.453-7.648a.6.6 0 011.094.001L16 16" />'
|
|
289
268
|
),
|
|
290
269
|
upload: svg(
|
|
291
|
-
'<path d="M12
|
|
270
|
+
'<path d="M12 3v12" /><path d="m17 8-5-5-5 5" /><path d="M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4" />'
|
|
292
271
|
),
|
|
293
272
|
externalLink: svg(
|
|
294
|
-
'<path d="
|
|
273
|
+
'<path d="M21 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h6" /><path d="m21 3-9 9" /><path d="M15 3h6v6" />'
|
|
295
274
|
),
|
|
296
275
|
copy: svg(
|
|
297
|
-
'<rect
|
|
276
|
+
'<rect width="14" height="14" x="8" y="8" rx="2" ry="2" /><path d="M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2" />'
|
|
277
|
+
),
|
|
278
|
+
edit: svg(
|
|
279
|
+
'<path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" /><path d="m15 5 4 4" />'
|
|
280
|
+
),
|
|
281
|
+
resizeHandle: svg(
|
|
282
|
+
'<circle cx="12" cy="9" r="1" /><circle cx="19" cy="9" r="1" /><circle cx="5" cy="9" r="1" /><circle cx="12" cy="15" r="1" /><circle cx="19" cy="15" r="1" /><circle cx="5" cy="15" r="1" />'
|
|
283
|
+
),
|
|
284
|
+
browse: svg(
|
|
285
|
+
'<path d="m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2" />'
|
|
286
|
+
),
|
|
287
|
+
mergeTags: svg(
|
|
288
|
+
'<path d="M8 3H7a2 2 0 0 0-2 2v5a2 2 0 0 1-2 2 2 2 0 0 1 2 2v5c0 1.1.9 2 2 2h1" /><path d="M16 21h1a2 2 0 0 0 2-2v-5c0-1.1.9-2 2-2a2 2 0 0 1-2-2V5a2 2 0 0 0-2-2h-1" />'
|
|
289
|
+
),
|
|
290
|
+
resizeHandleBoth: svg('<path d="M19 13v6h-6" /><path d="M5 11V5h6" /><path d="m5 5 14 14" />'),
|
|
291
|
+
anchor: svg(
|
|
292
|
+
'<path d="M12 6v16" /><path d="m19 13 2-1a9 9 0 0 1-18 0l2 1" /><path d="M9 11h6" /><circle cx="12" cy="4" r="2" />'
|
|
293
|
+
),
|
|
294
|
+
save: svg(
|
|
295
|
+
'<path d="M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z" /><path d="M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7" /><path d="M7 3v4a1 1 0 0 0 1 1h7" />'
|
|
296
|
+
),
|
|
297
|
+
charmap: svg(
|
|
298
|
+
'<path d="M3 20h4.5a.5.5 0 0 0 .5-.5v-.282a.52.52 0 0 0-.247-.437 8 8 0 1 1 8.494-.001.52.52 0 0 0-.247.438v.282a.5.5 0 0 0 .5.5H21" />'
|
|
299
|
+
),
|
|
300
|
+
commentAdd: svg(
|
|
301
|
+
'<path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" /><path d="M12 8v6" /><path d="M9 11h6" />'
|
|
302
|
+
),
|
|
303
|
+
comments: svg(
|
|
304
|
+
'<path d="M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z" /><path d="M7 11h10" /><path d="M7 15h6" /><path d="M7 7h8" />'
|
|
305
|
+
),
|
|
306
|
+
emoji: svg(
|
|
307
|
+
'<path d="M15 10V9" /><path d="M16.472 15a6 6 0 01-8.943 0" /><path d="M9 10V9" /><circle cx="12" cy="12" r="10" />'
|
|
308
|
+
),
|
|
309
|
+
dateTime: svg(
|
|
310
|
+
'<path d="M16 2v3" /><path d="M17 15.5v1.7l1 .625" /><path d="M21 8.936V5a2 2 0 00-2-2H5a2 2 0 00-2 2v14a2 2 0 002 2h3.935" /><path d="M3 9h9.873" /><path d="M8 2v3" /><circle cx="17" cy="17" r="5" />'
|
|
311
|
+
),
|
|
312
|
+
media: svg(
|
|
313
|
+
'<rect x="3" y="3" width="18" height="18" rx="2" /><path d="M9 9.003a1 1 0 0 1 1.517-.859l4.997 2.997a1 1 0 0 1 0 1.718l-4.997 2.997A1 1 0 0 1 9 14.996z" />'
|
|
314
|
+
),
|
|
315
|
+
nonBreaking: svg('<path d="M22 17v1c0 .5-.5 1-1 1H3c-.5 0-1-.5-1-1v-1" />'),
|
|
316
|
+
pageBreak: svg(
|
|
317
|
+
'<path d="M5.42 9.42 8 12" /><circle cx="4" cy="8" r="2" /><path d="m14 6-8.58 8.58" /><circle cx="4" cy="16" r="2" /><path d="M10.8 14.8 14 18" /><path d="M16 12h-2" /><path d="M22 12h-2" />'
|
|
318
|
+
),
|
|
319
|
+
history: svg(
|
|
320
|
+
'<path d="M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8" /><path d="M3 3v5h5" /><path d="M12 7v5l4 2" />'
|
|
321
|
+
),
|
|
322
|
+
suggest: svg(
|
|
323
|
+
'<path d="M13 21h8" /><path d="M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z" />'
|
|
324
|
+
),
|
|
325
|
+
review: svg(
|
|
326
|
+
'<path d="M13 5h8" /><path d="M13 12h8" /><path d="M13 19h8" /><path d="m3 17 2 2 4-4" /><path d="m3 7 2 2 4-4" />'
|
|
298
327
|
),
|
|
299
|
-
|
|
328
|
+
visualBlocks: svg(
|
|
329
|
+
'<path d="M5 3a2 2 0 0 0-2 2" /><path d="M19 3a2 2 0 0 1 2 2" /><path d="M21 19a2 2 0 0 1-2 2" /><path d="M5 21a2 2 0 0 1-2-2" /><path d="M9 3h1" /><path d="M9 21h1" /><path d="M14 3h1" /><path d="M14 21h1" /><path d="M3 9v1" /><path d="M21 9v1" /><path d="M3 14v1" /><path d="M21 14v1" />'
|
|
330
|
+
),
|
|
331
|
+
ltr: svg(
|
|
332
|
+
'<path d="M10 3v11" /><path d="M10 9H7a1 1 0 0 1 0-6h8" /><path d="M14 3v11" /><path d="m18 14 4 4H2" /><path d="m22 18-4 4" />'
|
|
333
|
+
),
|
|
334
|
+
rtl: svg(
|
|
335
|
+
'<path d="M14 3v11" /><path d="M14 9h-3a3 3 0 0 1 0-6h9" /><path d="M18 3v11" /><path d="M22 18H2l4-4" /><path d="m6 22-4-4" />'
|
|
336
|
+
)
|
|
300
337
|
};
|
|
301
338
|
}
|
|
302
339
|
});
|
|
303
340
|
|
|
341
|
+
// src/ui/dom.ts
|
|
342
|
+
function h(tag, attrs = {}, ...children) {
|
|
343
|
+
const el = document.createElement(tag);
|
|
344
|
+
for (const [name, value] of Object.entries(attrs)) {
|
|
345
|
+
if (value === null || value === void 0 || value === false) continue;
|
|
346
|
+
if (typeof value === "function") {
|
|
347
|
+
el.addEventListener(name.replace(/^on/, "").toLowerCase(), value);
|
|
348
|
+
} else if (name === "className") {
|
|
349
|
+
el.className = String(value);
|
|
350
|
+
} else {
|
|
351
|
+
el.setAttribute(name, value === true ? "" : String(value));
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
for (const child of children.flat()) {
|
|
355
|
+
if (child === null || child === void 0 || child === false) continue;
|
|
356
|
+
el.append(child);
|
|
357
|
+
}
|
|
358
|
+
return el;
|
|
359
|
+
}
|
|
360
|
+
function icon(svg2) {
|
|
361
|
+
const span = document.createElement("span");
|
|
362
|
+
span.className = "nova-icon";
|
|
363
|
+
span.innerHTML = svg2;
|
|
364
|
+
return span;
|
|
365
|
+
}
|
|
366
|
+
function uniqueId(prefix = "nova") {
|
|
367
|
+
uid += 1;
|
|
368
|
+
return `${prefix}-${uid}`;
|
|
369
|
+
}
|
|
370
|
+
function formatShortcut(shortcut) {
|
|
371
|
+
const parts = shortcut.split("-");
|
|
372
|
+
const key3 = parts.pop();
|
|
373
|
+
const keyLabel = key3.length === 1 ? key3.toUpperCase() : key3;
|
|
374
|
+
if (isMac) {
|
|
375
|
+
const map2 = { Mod: "\u2318", Shift: "\u21E7", Alt: "\u2325", Ctrl: "\u2303" };
|
|
376
|
+
return parts.map((p) => map2[p] ?? p).join("") + keyLabel;
|
|
377
|
+
}
|
|
378
|
+
const map = { Mod: "Ctrl", Shift: "Shift", Alt: "Alt", Ctrl: "Ctrl" };
|
|
379
|
+
return [...parts.map((p) => map[p] ?? p), keyLabel].join("+");
|
|
380
|
+
}
|
|
381
|
+
var uid, isMac, FOCUSABLE;
|
|
382
|
+
var init_dom = __esm({
|
|
383
|
+
"src/ui/dom.ts"() {
|
|
384
|
+
"use strict";
|
|
385
|
+
uid = 0;
|
|
386
|
+
isMac = typeof navigator !== "undefined" && /Mac|iP(hone|[oa]d)/.test(navigator.platform);
|
|
387
|
+
FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
|
|
388
|
+
}
|
|
389
|
+
});
|
|
390
|
+
|
|
304
391
|
// src/ui/dialog.ts
|
|
305
392
|
function openDialog(options) {
|
|
306
393
|
const titleId = uniqueId("nova-dialog-title");
|
|
@@ -1123,6 +1210,48 @@ var init_comments_panel = __esm({
|
|
|
1123
1210
|
}
|
|
1124
1211
|
});
|
|
1125
1212
|
|
|
1213
|
+
// src/ui/file-picker.ts
|
|
1214
|
+
function attachFilePicker(editor, field, type, onPick) {
|
|
1215
|
+
const { filePicker: picker, filePickerTypes: types } = editor.options;
|
|
1216
|
+
if (!picker || types && !types.includes(type)) return;
|
|
1217
|
+
const { input } = field;
|
|
1218
|
+
const button = h(
|
|
1219
|
+
"button",
|
|
1220
|
+
{
|
|
1221
|
+
type: "button",
|
|
1222
|
+
className: "nova-btn nova-input-action",
|
|
1223
|
+
"aria-label": editor.ui.t("dialog.browse"),
|
|
1224
|
+
title: editor.ui.t("dialog.browse")
|
|
1225
|
+
},
|
|
1226
|
+
icon(icons.browse)
|
|
1227
|
+
);
|
|
1228
|
+
const group = h("div", { className: "nova-input-group" });
|
|
1229
|
+
input.replaceWith(group);
|
|
1230
|
+
group.append(input, button);
|
|
1231
|
+
button.addEventListener("click", async () => {
|
|
1232
|
+
button.disabled = true;
|
|
1233
|
+
try {
|
|
1234
|
+
const result = await picker({ type, value: input.value });
|
|
1235
|
+
if (!result?.url) return;
|
|
1236
|
+
input.value = result.url;
|
|
1237
|
+
input.removeAttribute("aria-invalid");
|
|
1238
|
+
onPick?.(result);
|
|
1239
|
+
} catch (error) {
|
|
1240
|
+
console.error("[nova] filePicker failed:", error);
|
|
1241
|
+
} finally {
|
|
1242
|
+
button.disabled = false;
|
|
1243
|
+
if (input.isConnected) input.focus();
|
|
1244
|
+
}
|
|
1245
|
+
});
|
|
1246
|
+
}
|
|
1247
|
+
var init_file_picker = __esm({
|
|
1248
|
+
"src/ui/file-picker.ts"() {
|
|
1249
|
+
"use strict";
|
|
1250
|
+
init_dom();
|
|
1251
|
+
init_icons();
|
|
1252
|
+
}
|
|
1253
|
+
});
|
|
1254
|
+
|
|
1126
1255
|
// src/url.ts
|
|
1127
1256
|
function protocolOf(url) {
|
|
1128
1257
|
const cleaned = url.replace(/[\u0000- \u007f-\u009f]/g, "");
|
|
@@ -1217,11 +1346,20 @@ function tableStyle(attrs) {
|
|
|
1217
1346
|
else if (attrs.align === "right") parts.push("margin-left: auto;");
|
|
1218
1347
|
return parts.join(" ");
|
|
1219
1348
|
}
|
|
1220
|
-
function buildTableNodes() {
|
|
1349
|
+
function buildTableNodes(allow) {
|
|
1221
1350
|
const specs = (0, import_prosemirror_tables.tableNodes)({
|
|
1222
1351
|
tableGroup: "block",
|
|
1223
1352
|
cellContent: "block+",
|
|
1224
1353
|
cellAttributes: {
|
|
1354
|
+
// Стиль ячейки из списка (tableCellClassList) — рамки, отступы задаёт CSS сайта.
|
|
1355
|
+
class: {
|
|
1356
|
+
default: null,
|
|
1357
|
+
getFromDOM: (dom) => readClass(dom, allow),
|
|
1358
|
+
setDOMAttr: (value, attrs) => {
|
|
1359
|
+
const cls = classAttr(value).class;
|
|
1360
|
+
if (cls) attrs.class = cls;
|
|
1361
|
+
}
|
|
1362
|
+
},
|
|
1225
1363
|
background: {
|
|
1226
1364
|
default: null,
|
|
1227
1365
|
// Фон заранее перенесён в data-атрибут (parser.ts → preprocessDOM); style — запасной путь.
|
|
@@ -1248,7 +1386,12 @@ function buildTableNodes() {
|
|
|
1248
1386
|
}
|
|
1249
1387
|
}
|
|
1250
1388
|
});
|
|
1251
|
-
specs.table.attrs = {
|
|
1389
|
+
specs.table.attrs = {
|
|
1390
|
+
width: { default: null },
|
|
1391
|
+
align: { default: null },
|
|
1392
|
+
// Стиль таблицы из списка (tableClassList): «с рамками», «раскладка без рамок»…
|
|
1393
|
+
class: { default: null }
|
|
1394
|
+
};
|
|
1252
1395
|
specs.table.parseDOM = [
|
|
1253
1396
|
{
|
|
1254
1397
|
tag: "table",
|
|
@@ -1257,13 +1400,13 @@ function buildTableNodes() {
|
|
|
1257
1400
|
const width = cssValue.length(el.style.width) ?? cssValue.length(`${el.getAttribute("width") ?? ""}px`);
|
|
1258
1401
|
const auto = (v) => v === "auto";
|
|
1259
1402
|
const align = el.getAttribute("align") === "center" || auto(el.style.marginLeft) && auto(el.style.marginRight) ? "center" : el.getAttribute("align") === "right" || auto(el.style.marginLeft) ? "right" : null;
|
|
1260
|
-
return { width, align };
|
|
1403
|
+
return { width, align, class: readClass(el, allow) };
|
|
1261
1404
|
}
|
|
1262
1405
|
}
|
|
1263
1406
|
];
|
|
1264
1407
|
specs.table.toDOM = (node) => {
|
|
1265
1408
|
const style = tableStyle(node.attrs);
|
|
1266
|
-
return ["table", style ? { style } : {}, ["tbody", 0]];
|
|
1409
|
+
return ["table", { ...classAttr(node.attrs.class), ...style ? { style } : {} }, ["tbody", 0]];
|
|
1267
1410
|
};
|
|
1268
1411
|
for (const name of ["table_cell", "table_header"]) {
|
|
1269
1412
|
const spec = specs[name];
|
|
@@ -1289,16 +1432,27 @@ function buildTableNodes() {
|
|
|
1289
1432
|
}
|
|
1290
1433
|
return specs;
|
|
1291
1434
|
}
|
|
1435
|
+
function readClass(dom, allow) {
|
|
1436
|
+
const kept = [...dom.classList].filter((c) => CLASS_TOKEN.test(c) && allow(c));
|
|
1437
|
+
return kept.length ? kept.join(" ") : null;
|
|
1438
|
+
}
|
|
1439
|
+
function classAttr(value) {
|
|
1440
|
+
if (typeof value !== "string") return {};
|
|
1441
|
+
const tokens = value.split(/\s+/).filter((c) => CLASS_TOKEN.test(c));
|
|
1442
|
+
return tokens.length ? { class: tokens.join(" ") } : {};
|
|
1443
|
+
}
|
|
1292
1444
|
function styleAttr(value) {
|
|
1293
1445
|
return value ? { value } : false;
|
|
1294
1446
|
}
|
|
1295
1447
|
function styleSpan(property, value) {
|
|
1296
1448
|
return value ? ["span", { style: `${property}: ${value};` }, 0] : ["span", 0];
|
|
1297
1449
|
}
|
|
1298
|
-
function createSchema(extensions = {}) {
|
|
1450
|
+
function createSchema(extensions = {}, classFilter) {
|
|
1299
1451
|
const extraNodes = Object.entries(extensions.nodes ?? {});
|
|
1300
1452
|
const extraMarks = Object.entries(extensions.marks ?? {});
|
|
1301
|
-
if (!extraNodes.length && !extraMarks.length) return schema;
|
|
1453
|
+
if (!extraNodes.length && !extraMarks.length && !classFilter) return schema;
|
|
1454
|
+
const baseNodes = classFilter ? buildNodes2(classFilter) : nodes;
|
|
1455
|
+
const baseMarks = classFilter ? buildMarks(classFilter) : marks;
|
|
1302
1456
|
for (const [name] of extraNodes) {
|
|
1303
1457
|
if (name in nodes) throw new Error(`[nova] node "${name}" already exists in the base schema`);
|
|
1304
1458
|
}
|
|
@@ -1306,11 +1460,11 @@ function createSchema(extensions = {}) {
|
|
|
1306
1460
|
if (name in marks) throw new Error(`[nova] mark "${name}" already exists in the base schema`);
|
|
1307
1461
|
}
|
|
1308
1462
|
return new import_prosemirror_model2.Schema({
|
|
1309
|
-
nodes: { ...
|
|
1310
|
-
marks: { ...
|
|
1463
|
+
nodes: { ...baseNodes, ...Object.fromEntries(extraNodes) },
|
|
1464
|
+
marks: { ...baseMarks, ...Object.fromEntries(extraMarks) }
|
|
1311
1465
|
});
|
|
1312
1466
|
}
|
|
1313
|
-
var import_prosemirror_model2, import_prosemirror_tables, ALIGNMENTS, COLOR_RE, LENGTH_RE, LINE_HEIGHT_RE, FONT_FAMILY_RE, cssValue, blockStyleSpec, BULLET_STYLES, ORDERED_STYLES, OL_TYPE, IMAGE_ALIGN_STYLES, CELL_VALIGN, MAX_SPAN, nodes, marks, schema;
|
|
1467
|
+
var import_prosemirror_model2, import_prosemirror_tables, ALIGNMENTS, COLOR_RE, LENGTH_RE, LINE_HEIGHT_RE, FONT_FAMILY_RE, cssValue, blockStyleSpec, BULLET_STYLES, ORDERED_STYLES, OL_TYPE, IMAGE_ALIGN_STYLES, CELL_VALIGN, MAX_SPAN, NO_CLASSES, CLASS_TOKEN, classSpec, buildNodes2, nodes, buildMarks, marks, schema;
|
|
1314
1468
|
var init_schema = __esm({
|
|
1315
1469
|
"src/schema.ts"() {
|
|
1316
1470
|
"use strict";
|
|
@@ -1359,32 +1513,61 @@ var init_schema = __esm({
|
|
|
1359
1513
|
};
|
|
1360
1514
|
CELL_VALIGN = ["top", "middle", "bottom"];
|
|
1361
1515
|
MAX_SPAN = 100;
|
|
1362
|
-
|
|
1516
|
+
NO_CLASSES = () => false;
|
|
1517
|
+
CLASS_TOKEN = /^-?[_a-zA-Z][\w-]*$/;
|
|
1518
|
+
classSpec = { class: { default: null } };
|
|
1519
|
+
buildNodes2 = (allow) => ({
|
|
1363
1520
|
doc: { content: "block+" },
|
|
1364
1521
|
paragraph: {
|
|
1365
1522
|
group: "block",
|
|
1366
1523
|
content: "inline*",
|
|
1367
|
-
attrs: { ...blockStyleSpec },
|
|
1368
|
-
parseDOM: [
|
|
1369
|
-
|
|
1524
|
+
attrs: { ...blockStyleSpec, ...classSpec },
|
|
1525
|
+
parseDOM: [
|
|
1526
|
+
{
|
|
1527
|
+
tag: "p",
|
|
1528
|
+
getAttrs: (dom) => ({
|
|
1529
|
+
...readBlockStyle(dom),
|
|
1530
|
+
class: readClass(dom, allow)
|
|
1531
|
+
})
|
|
1532
|
+
}
|
|
1533
|
+
],
|
|
1534
|
+
toDOM: (node) => [
|
|
1535
|
+
"p",
|
|
1536
|
+
{ ...classAttr(node.attrs.class), ...blockStyleAttrs(node.attrs) },
|
|
1537
|
+
0
|
|
1538
|
+
]
|
|
1370
1539
|
},
|
|
1371
1540
|
heading: {
|
|
1372
1541
|
group: "block",
|
|
1373
1542
|
content: "inline*",
|
|
1374
1543
|
defining: true,
|
|
1375
|
-
attrs: { level: { default: 1 }, ...blockStyleSpec },
|
|
1544
|
+
attrs: { level: { default: 1 }, ...blockStyleSpec, ...classSpec },
|
|
1376
1545
|
parseDOM: [1, 2, 3, 4, 5, 6].map((level) => ({
|
|
1377
1546
|
tag: `h${level}`,
|
|
1378
|
-
getAttrs: (dom) => ({
|
|
1547
|
+
getAttrs: (dom) => ({
|
|
1548
|
+
level,
|
|
1549
|
+
...readBlockStyle(dom),
|
|
1550
|
+
class: readClass(dom, allow)
|
|
1551
|
+
})
|
|
1379
1552
|
})),
|
|
1380
|
-
toDOM: (node) => [
|
|
1553
|
+
toDOM: (node) => [
|
|
1554
|
+
`h${node.attrs.level}`,
|
|
1555
|
+
{ ...classAttr(node.attrs.class), ...blockStyleAttrs(node.attrs) },
|
|
1556
|
+
0
|
|
1557
|
+
]
|
|
1381
1558
|
},
|
|
1382
1559
|
blockquote: {
|
|
1383
1560
|
group: "block",
|
|
1384
1561
|
content: "block+",
|
|
1385
1562
|
defining: true,
|
|
1386
|
-
|
|
1387
|
-
|
|
1563
|
+
attrs: { ...classSpec },
|
|
1564
|
+
parseDOM: [
|
|
1565
|
+
{
|
|
1566
|
+
tag: "blockquote",
|
|
1567
|
+
getAttrs: (dom) => ({ class: readClass(dom, allow) })
|
|
1568
|
+
}
|
|
1569
|
+
],
|
|
1570
|
+
toDOM: (node) => ["blockquote", classAttr(node.attrs.class), 0]
|
|
1388
1571
|
},
|
|
1389
1572
|
horizontal_rule: {
|
|
1390
1573
|
group: "block",
|
|
@@ -1426,7 +1609,11 @@ var init_schema = __esm({
|
|
|
1426
1609
|
})
|
|
1427
1610
|
}
|
|
1428
1611
|
],
|
|
1429
|
-
toDOM: (node) => [
|
|
1612
|
+
toDOM: (node) => [
|
|
1613
|
+
"ul",
|
|
1614
|
+
listStyleAttrs(node.attrs.listStyle, BULLET_STYLES),
|
|
1615
|
+
0
|
|
1616
|
+
]
|
|
1430
1617
|
},
|
|
1431
1618
|
ordered_list: {
|
|
1432
1619
|
group: "block",
|
|
@@ -1470,7 +1657,8 @@ var init_schema = __esm({
|
|
|
1470
1657
|
title: { default: null },
|
|
1471
1658
|
width: { default: null },
|
|
1472
1659
|
height: { default: null },
|
|
1473
|
-
align: { default: null }
|
|
1660
|
+
align: { default: null },
|
|
1661
|
+
...classSpec
|
|
1474
1662
|
},
|
|
1475
1663
|
parseDOM: [
|
|
1476
1664
|
{
|
|
@@ -1484,7 +1672,8 @@ var init_schema = __esm({
|
|
|
1484
1672
|
title: el.getAttribute("title"),
|
|
1485
1673
|
width: imageSize(el.getAttribute("width") ?? el.style.width),
|
|
1486
1674
|
height: imageSize(el.getAttribute("height") ?? el.style.height),
|
|
1487
|
-
align: readImageAlign(el)
|
|
1675
|
+
align: readImageAlign(el),
|
|
1676
|
+
class: readClass(el, allow)
|
|
1488
1677
|
};
|
|
1489
1678
|
}
|
|
1490
1679
|
}
|
|
@@ -1499,6 +1688,7 @@ var init_schema = __esm({
|
|
|
1499
1688
|
"img",
|
|
1500
1689
|
{
|
|
1501
1690
|
src,
|
|
1691
|
+
...classAttr(node.attrs.class),
|
|
1502
1692
|
...alt ? { alt } : {},
|
|
1503
1693
|
...title ? { title } : {},
|
|
1504
1694
|
...width ? { width: String(width) } : {},
|
|
@@ -1515,9 +1705,10 @@ var init_schema = __esm({
|
|
|
1515
1705
|
parseDOM: [{ tag: "br" }],
|
|
1516
1706
|
toDOM: () => ["br"]
|
|
1517
1707
|
},
|
|
1518
|
-
...buildTableNodes()
|
|
1519
|
-
};
|
|
1520
|
-
|
|
1708
|
+
...buildTableNodes(allow)
|
|
1709
|
+
});
|
|
1710
|
+
nodes = buildNodes2(NO_CLASSES);
|
|
1711
|
+
buildMarks = (allow) => ({
|
|
1521
1712
|
link: {
|
|
1522
1713
|
attrs: { href: {}, title: { default: null }, target: { default: null } },
|
|
1523
1714
|
inclusive: false,
|
|
@@ -1625,8 +1816,25 @@ var init_schema = __esm({
|
|
|
1625
1816
|
attrs: { value: {} },
|
|
1626
1817
|
parseDOM: [{ style: "font-size", getAttrs: (v) => styleAttr(cssValue.length(v)) }],
|
|
1627
1818
|
toDOM: (mark) => styleSpan("font-size", cssValue.length(mark.attrs.value))
|
|
1819
|
+
},
|
|
1820
|
+
/** <span class="…"> — инлайн-стиль из style_formats. Только разрешённые классы. */
|
|
1821
|
+
span_class: {
|
|
1822
|
+
attrs: { class: {} },
|
|
1823
|
+
parseDOM: [
|
|
1824
|
+
{
|
|
1825
|
+
tag: "span[class]",
|
|
1826
|
+
// Не «съедает» span: его style-атрибуты разбирают марки цвета и шрифта.
|
|
1827
|
+
consuming: false,
|
|
1828
|
+
getAttrs: (dom) => {
|
|
1829
|
+
const value = readClass(dom, allow);
|
|
1830
|
+
return value ? { class: value } : false;
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
],
|
|
1834
|
+
toDOM: (mark) => ["span", classAttr(mark.attrs.class), 0]
|
|
1628
1835
|
}
|
|
1629
|
-
};
|
|
1836
|
+
});
|
|
1837
|
+
marks = buildMarks(NO_CLASSES);
|
|
1630
1838
|
schema = new import_prosemirror_model2.Schema({ nodes, marks });
|
|
1631
1839
|
}
|
|
1632
1840
|
});
|
|
@@ -1641,13 +1849,14 @@ function insertText2(editor, text) {
|
|
|
1641
1849
|
dispatch(state.tr.insertText(text).scrollIntoView());
|
|
1642
1850
|
editor.focus();
|
|
1643
1851
|
}
|
|
1644
|
-
var ICON4,
|
|
1852
|
+
var ICON4, LABELS8, FORMATS, insertdatetime_default;
|
|
1645
1853
|
var init_insertdatetime = __esm({
|
|
1646
1854
|
"src/plugins/insertdatetime.ts"() {
|
|
1647
1855
|
"use strict";
|
|
1856
|
+
init_icons();
|
|
1648
1857
|
init_plugins();
|
|
1649
|
-
ICON4 =
|
|
1650
|
-
|
|
1858
|
+
ICON4 = icons.dateTime;
|
|
1859
|
+
LABELS8 = {
|
|
1651
1860
|
en: {
|
|
1652
1861
|
title: "Insert date/time",
|
|
1653
1862
|
date: "Date",
|
|
@@ -1674,7 +1883,7 @@ var init_insertdatetime = __esm({
|
|
|
1674
1883
|
toolbar: "insertdatetime",
|
|
1675
1884
|
setup(editor) {
|
|
1676
1885
|
const lang = editor.options.language ?? "en";
|
|
1677
|
-
const labels =
|
|
1886
|
+
const labels = LABELS8[lang.split("-")[0]] ?? LABELS8.en;
|
|
1678
1887
|
const now = () => editor.options.pluginOptions?.insertdatetime?.now?.() ?? /* @__PURE__ */ new Date();
|
|
1679
1888
|
const format = (kind) => new Intl.DateTimeFormat(lang, FORMATS[kind]).format(now());
|
|
1680
1889
|
editor.ui.registry.addMenuItem("insertdatetime", {
|
|
@@ -2046,8 +2255,8 @@ function dataImageSrcs(doc, type) {
|
|
|
2046
2255
|
return srcs;
|
|
2047
2256
|
}
|
|
2048
2257
|
function embeddedImageUploadPlugin(editor) {
|
|
2049
|
-
return new
|
|
2050
|
-
key: new
|
|
2258
|
+
return new import_prosemirror_state6.Plugin({
|
|
2259
|
+
key: new import_prosemirror_state6.PluginKey("nova-embedded-image-upload"),
|
|
2051
2260
|
appendTransaction(transactions, oldState, newState) {
|
|
2052
2261
|
if (!editor.options.uploadImage) return null;
|
|
2053
2262
|
const fromUser = transactions.some(
|
|
@@ -2064,8 +2273,8 @@ function embeddedImageUploadPlugin(editor) {
|
|
|
2064
2273
|
});
|
|
2065
2274
|
}
|
|
2066
2275
|
function imageDropPastePlugin(editor) {
|
|
2067
|
-
return new
|
|
2068
|
-
key: new
|
|
2276
|
+
return new import_prosemirror_state6.Plugin({
|
|
2277
|
+
key: new import_prosemirror_state6.PluginKey("nova-image-drop-paste"),
|
|
2069
2278
|
props: {
|
|
2070
2279
|
handlePaste(_view, event) {
|
|
2071
2280
|
if (!editor.isAllowed("image")) return false;
|
|
@@ -2105,6 +2314,9 @@ function openImageDialog(editor) {
|
|
|
2105
2314
|
);
|
|
2106
2315
|
const url = textField({ label: t("image.url"), type: "url", placeholder: "https://" });
|
|
2107
2316
|
const alt = textField({ label: t("image.alt"), hint: t("image.altHint") });
|
|
2317
|
+
attachFilePicker(editor, url, "image", (picked) => {
|
|
2318
|
+
if (picked.alt) alt.input.value = picked.alt;
|
|
2319
|
+
});
|
|
2108
2320
|
const body = h(
|
|
2109
2321
|
"div",
|
|
2110
2322
|
{ className: "nova-form" },
|
|
@@ -2151,7 +2363,7 @@ function openImageDialog(editor) {
|
|
|
2151
2363
|
}
|
|
2152
2364
|
function getSelectedImage(state) {
|
|
2153
2365
|
const { selection } = state;
|
|
2154
|
-
if (selection instanceof
|
|
2366
|
+
if (selection instanceof import_prosemirror_state6.NodeSelection && selection.node.type === nodesOf(state).image) {
|
|
2155
2367
|
return { node: selection.node, pos: selection.from };
|
|
2156
2368
|
}
|
|
2157
2369
|
return null;
|
|
@@ -2162,7 +2374,7 @@ function setImageAttrs(attrs) {
|
|
|
2162
2374
|
if (!image) return false;
|
|
2163
2375
|
if (dispatch) {
|
|
2164
2376
|
const tr = state.tr.setNodeMarkup(image.pos, void 0, { ...image.node.attrs, ...attrs });
|
|
2165
|
-
tr.setSelection(
|
|
2377
|
+
tr.setSelection(import_prosemirror_state6.NodeSelection.create(tr.doc, image.pos));
|
|
2166
2378
|
dispatch(tr);
|
|
2167
2379
|
}
|
|
2168
2380
|
return true;
|
|
@@ -2206,11 +2418,12 @@ function openImageAltDialog(editor) {
|
|
|
2206
2418
|
}
|
|
2207
2419
|
});
|
|
2208
2420
|
}
|
|
2209
|
-
var
|
|
2421
|
+
var import_prosemirror_state6, IMAGE_TYPES, DATA_IMAGE;
|
|
2210
2422
|
var init_image = __esm({
|
|
2211
2423
|
"src/image.ts"() {
|
|
2212
2424
|
"use strict";
|
|
2213
|
-
|
|
2425
|
+
init_file_picker();
|
|
2426
|
+
import_prosemirror_state6 = require("prosemirror-state");
|
|
2214
2427
|
init_commands();
|
|
2215
2428
|
init_commands();
|
|
2216
2429
|
init_dialog();
|
|
@@ -2286,6 +2499,10 @@ function openLinkDialog(editor) {
|
|
|
2286
2499
|
const text = textField({ label: t("link.text"), value: selectedText });
|
|
2287
2500
|
const title = textField({ label: t("link.tooltip"), value: existing?.title ?? "" });
|
|
2288
2501
|
const newTab = checkboxField(t("link.newTab"), existing?.target === "_blank");
|
|
2502
|
+
attachFilePicker(editor, url, "file", (picked) => {
|
|
2503
|
+
if (picked.text && !text.input.value.trim()) text.input.value = picked.text;
|
|
2504
|
+
if (picked.title) title.input.value = picked.title;
|
|
2505
|
+
});
|
|
2289
2506
|
const body = h(
|
|
2290
2507
|
"div",
|
|
2291
2508
|
{ className: "nova-form" },
|
|
@@ -2321,6 +2538,7 @@ function openLinkDialog(editor) {
|
|
|
2321
2538
|
var init_link = __esm({
|
|
2322
2539
|
"src/link.ts"() {
|
|
2323
2540
|
"use strict";
|
|
2541
|
+
init_file_picker();
|
|
2324
2542
|
init_commands();
|
|
2325
2543
|
init_commands();
|
|
2326
2544
|
init_dialog();
|
|
@@ -2353,7 +2571,7 @@ function insertTable(rows, cols, withHeader = true) {
|
|
|
2353
2571
|
if (n === node) tablePos = pos;
|
|
2354
2572
|
return tablePos < 0;
|
|
2355
2573
|
});
|
|
2356
|
-
if (tablePos >= 0) tr.setSelection(
|
|
2574
|
+
if (tablePos >= 0) tr.setSelection(import_prosemirror_state7.TextSelection.near(tr.doc.resolve(tablePos + 3)));
|
|
2357
2575
|
dispatch(tr.scrollIntoView());
|
|
2358
2576
|
}
|
|
2359
2577
|
return true;
|
|
@@ -2361,7 +2579,9 @@ function insertTable(rows, cols, withHeader = true) {
|
|
|
2361
2579
|
}
|
|
2362
2580
|
function tablePlugins() {
|
|
2363
2581
|
return [
|
|
2364
|
-
|
|
2582
|
+
// defaultCellMinWidth — минимум для столбцов без заданной ширины (по умолчанию 100px:
|
|
2583
|
+
// таблица из 5+ столбцов раньше времени вылезала за край узкого редактора).
|
|
2584
|
+
(0, import_prosemirror_tables2.columnResizing)({ cellMinWidth: 48, defaultCellMinWidth: 48, View: NovaTableView }),
|
|
2365
2585
|
(0, import_prosemirror_tables2.tableEditing)(),
|
|
2366
2586
|
(0, import_prosemirror_keymap3.keymap)({
|
|
2367
2587
|
Tab: nextCellOrNewRow,
|
|
@@ -2512,14 +2732,24 @@ function sortTable(direction, locale) {
|
|
|
2512
2732
|
}
|
|
2513
2733
|
function getTableProps(state) {
|
|
2514
2734
|
const found = (0, import_prosemirror_tables2.findTable)(state.selection.$from);
|
|
2515
|
-
return found ? {
|
|
2735
|
+
return found ? {
|
|
2736
|
+
width: found.node.attrs.width ?? null,
|
|
2737
|
+
align: found.node.attrs.align ?? null,
|
|
2738
|
+
class: found.node.attrs.class ?? null
|
|
2739
|
+
} : null;
|
|
2516
2740
|
}
|
|
2517
2741
|
function setTableProps(props) {
|
|
2518
2742
|
return (state, dispatch) => {
|
|
2519
2743
|
const found = (0, import_prosemirror_tables2.findTable)(state.selection.$from);
|
|
2520
2744
|
if (!found) return false;
|
|
2521
2745
|
if (props.width !== null && !cssValue.length(props.width)) return false;
|
|
2522
|
-
|
|
2746
|
+
const attrs = {
|
|
2747
|
+
...found.node.attrs,
|
|
2748
|
+
width: props.width,
|
|
2749
|
+
align: props.align
|
|
2750
|
+
};
|
|
2751
|
+
if (props.class !== void 0) attrs.class = classAttr(props.class).class ?? null;
|
|
2752
|
+
dispatch?.(state.tr.setNodeMarkup(found.pos, void 0, attrs));
|
|
2523
2753
|
return true;
|
|
2524
2754
|
};
|
|
2525
2755
|
}
|
|
@@ -2547,7 +2777,8 @@ function getCellProps(state) {
|
|
|
2547
2777
|
return {
|
|
2548
2778
|
valign: cell.node.attrs.valign ?? null,
|
|
2549
2779
|
header: cell.node.type === state.schema.nodes.table_header,
|
|
2550
|
-
width: widths?.[0] ?? null
|
|
2780
|
+
width: widths?.[0] ?? null,
|
|
2781
|
+
class: cell.node.attrs.class ?? null
|
|
2551
2782
|
};
|
|
2552
2783
|
}
|
|
2553
2784
|
function setCellProps(props) {
|
|
@@ -2562,7 +2793,8 @@ function setCellProps(props) {
|
|
|
2562
2793
|
const type = props.header === void 0 ? node.type : props.header ? nodes2.table_header : nodes2.table_cell;
|
|
2563
2794
|
const attrs = {
|
|
2564
2795
|
...node.attrs,
|
|
2565
|
-
...props.valign !== void 0 ? { valign: props.valign } : {}
|
|
2796
|
+
...props.valign !== void 0 ? { valign: props.valign } : {},
|
|
2797
|
+
...props.class !== void 0 ? { class: classAttr(props.class).class ?? null } : {}
|
|
2566
2798
|
};
|
|
2567
2799
|
tr.setNodeMarkup(pos, type, attrs);
|
|
2568
2800
|
}
|
|
@@ -2595,13 +2827,13 @@ function setCellProps(props) {
|
|
|
2595
2827
|
return true;
|
|
2596
2828
|
};
|
|
2597
2829
|
}
|
|
2598
|
-
var import_prosemirror_keymap3, import_prosemirror_model3,
|
|
2830
|
+
var import_prosemirror_keymap3, import_prosemirror_model3, import_prosemirror_state7, import_prosemirror_tables2, MAX_GRID, nextCellOrNewRow, tableCommands, NovaTableView;
|
|
2599
2831
|
var init_table = __esm({
|
|
2600
2832
|
"src/table.ts"() {
|
|
2601
2833
|
"use strict";
|
|
2602
2834
|
import_prosemirror_keymap3 = require("prosemirror-keymap");
|
|
2603
2835
|
import_prosemirror_model3 = require("prosemirror-model");
|
|
2604
|
-
|
|
2836
|
+
import_prosemirror_state7 = require("prosemirror-state");
|
|
2605
2837
|
import_prosemirror_tables2 = require("prosemirror-tables");
|
|
2606
2838
|
init_schema();
|
|
2607
2839
|
init_dom();
|
|
@@ -2650,6 +2882,9 @@ var init_table = __esm({
|
|
|
2650
2882
|
const align = node.attrs.align;
|
|
2651
2883
|
this.table.style.marginLeft = align ? "auto" : "";
|
|
2652
2884
|
this.table.style.marginRight = align === "center" ? "auto" : "";
|
|
2885
|
+
const cls = classAttr(node.attrs.class).class;
|
|
2886
|
+
if (cls) this.table.setAttribute("class", cls);
|
|
2887
|
+
else this.table.removeAttribute("class");
|
|
2653
2888
|
}
|
|
2654
2889
|
};
|
|
2655
2890
|
}
|
|
@@ -2666,7 +2901,7 @@ __export(quickbars_exports, {
|
|
|
2666
2901
|
});
|
|
2667
2902
|
function hasTextSelection(editor) {
|
|
2668
2903
|
const { selection } = editor.view.state;
|
|
2669
|
-
if (!(selection instanceof
|
|
2904
|
+
if (!(selection instanceof import_prosemirror_state8.TextSelection) || selection.empty) return false;
|
|
2670
2905
|
if (selection.$from.parent.type.spec.code) return false;
|
|
2671
2906
|
return editor.view.state.doc.textBetween(selection.from, selection.to).trim().length > 0;
|
|
2672
2907
|
}
|
|
@@ -2686,11 +2921,11 @@ function pickImage(editor) {
|
|
|
2686
2921
|
});
|
|
2687
2922
|
input.click();
|
|
2688
2923
|
}
|
|
2689
|
-
var
|
|
2924
|
+
var import_prosemirror_state8, DEFAULT_SELECTION, DEFAULT_INSERT, quickbars_default;
|
|
2690
2925
|
var init_quickbars = __esm({
|
|
2691
2926
|
"src/plugins/quickbars.ts"() {
|
|
2692
2927
|
"use strict";
|
|
2693
|
-
|
|
2928
|
+
import_prosemirror_state8 = require("prosemirror-state");
|
|
2694
2929
|
init_image();
|
|
2695
2930
|
init_link();
|
|
2696
2931
|
init_plugins();
|
|
@@ -2751,14 +2986,15 @@ var charmap_exports = {};
|
|
|
2751
2986
|
__export(charmap_exports, {
|
|
2752
2987
|
default: () => charmap_default
|
|
2753
2988
|
});
|
|
2754
|
-
var ICON5,
|
|
2989
|
+
var ICON5, LABELS9, SYMBOLS, charmap_default;
|
|
2755
2990
|
var init_charmap = __esm({
|
|
2756
2991
|
"src/plugins/charmap.ts"() {
|
|
2757
2992
|
"use strict";
|
|
2993
|
+
init_icons();
|
|
2758
2994
|
init_plugins();
|
|
2759
2995
|
init_shared();
|
|
2760
|
-
ICON5 =
|
|
2761
|
-
|
|
2996
|
+
ICON5 = icons.charmap;
|
|
2997
|
+
LABELS9 = {
|
|
2762
2998
|
en: {
|
|
2763
2999
|
title: "Special character",
|
|
2764
3000
|
search: "Search characters",
|
|
@@ -2913,7 +3149,7 @@ var init_charmap = __esm({
|
|
|
2913
3149
|
name: "charmap",
|
|
2914
3150
|
toolbar: "charmap",
|
|
2915
3151
|
setup(editor) {
|
|
2916
|
-
const labels = pickLabels(editor,
|
|
3152
|
+
const labels = pickLabels(editor, LABELS9);
|
|
2917
3153
|
const groups = SYMBOLS.map((items, i) => ({ title: labels.groups[i], items }));
|
|
2918
3154
|
const panel = (close) => symbolPanel({
|
|
2919
3155
|
groups,
|
|
@@ -2946,14 +3182,15 @@ var emoticons_exports = {};
|
|
|
2946
3182
|
__export(emoticons_exports, {
|
|
2947
3183
|
default: () => emoticons_default
|
|
2948
3184
|
});
|
|
2949
|
-
var ICON6,
|
|
3185
|
+
var ICON6, LABELS10, EMOJI, emoticons_default;
|
|
2950
3186
|
var init_emoticons = __esm({
|
|
2951
3187
|
"src/plugins/emoticons.ts"() {
|
|
2952
3188
|
"use strict";
|
|
3189
|
+
init_icons();
|
|
2953
3190
|
init_plugins();
|
|
2954
3191
|
init_shared();
|
|
2955
|
-
ICON6 =
|
|
2956
|
-
|
|
3192
|
+
ICON6 = icons.emoji;
|
|
3193
|
+
LABELS10 = {
|
|
2957
3194
|
en: {
|
|
2958
3195
|
title: "Emoji",
|
|
2959
3196
|
search: "Search emoji",
|
|
@@ -3111,7 +3348,7 @@ var init_emoticons = __esm({
|
|
|
3111
3348
|
name: "emoticons",
|
|
3112
3349
|
toolbar: "emoticons",
|
|
3113
3350
|
setup(editor) {
|
|
3114
|
-
const labels = pickLabels(editor,
|
|
3351
|
+
const labels = pickLabels(editor, LABELS10);
|
|
3115
3352
|
const groups = EMOJI.map((items, i) => ({ title: labels.groups[i], items }));
|
|
3116
3353
|
const all = EMOJI.flat();
|
|
3117
3354
|
const panel = (close) => symbolPanel({
|
|
@@ -3160,16 +3397,17 @@ var nonbreaking_exports = {};
|
|
|
3160
3397
|
__export(nonbreaking_exports, {
|
|
3161
3398
|
default: () => nonbreaking_default
|
|
3162
3399
|
});
|
|
3163
|
-
var import_prosemirror_keymap4, NBSP, ICON7,
|
|
3400
|
+
var import_prosemirror_keymap4, NBSP, ICON7, LABELS11, nonbreaking_default;
|
|
3164
3401
|
var init_nonbreaking = __esm({
|
|
3165
3402
|
"src/plugins/nonbreaking.ts"() {
|
|
3166
3403
|
"use strict";
|
|
3404
|
+
init_icons();
|
|
3167
3405
|
import_prosemirror_keymap4 = require("prosemirror-keymap");
|
|
3168
3406
|
init_plugins();
|
|
3169
3407
|
init_shared();
|
|
3170
3408
|
NBSP = String.fromCharCode(160);
|
|
3171
|
-
ICON7 =
|
|
3172
|
-
|
|
3409
|
+
ICON7 = icons.nonBreaking;
|
|
3410
|
+
LABELS11 = { en: { title: "Nonbreaking space" }, ru: { title: "\u041D\u0435\u0440\u0430\u0437\u0440\u044B\u0432\u043D\u044B\u0439 \u043F\u0440\u043E\u0431\u0435\u043B" } };
|
|
3173
3411
|
nonbreaking_default = definePlugin({
|
|
3174
3412
|
name: "nonbreaking",
|
|
3175
3413
|
toolbar: "nonbreaking",
|
|
@@ -3182,7 +3420,7 @@ var init_nonbreaking = __esm({
|
|
|
3182
3420
|
})
|
|
3183
3421
|
],
|
|
3184
3422
|
setup(editor) {
|
|
3185
|
-
const { title } = pickLabels(editor,
|
|
3423
|
+
const { title } = pickLabels(editor, LABELS11);
|
|
3186
3424
|
const spec = {
|
|
3187
3425
|
icon: ICON7,
|
|
3188
3426
|
tooltip: title,
|
|
@@ -3227,12 +3465,12 @@ function linkifyBefore(state, tr, end) {
|
|
|
3227
3465
|
tr.addMark(from, to, link.create({ href }));
|
|
3228
3466
|
return true;
|
|
3229
3467
|
}
|
|
3230
|
-
var import_prosemirror_inputrules,
|
|
3468
|
+
var import_prosemirror_inputrules, import_prosemirror_state9, URL_AT_END, SINGLE_URL, autolink_default;
|
|
3231
3469
|
var init_autolink = __esm({
|
|
3232
3470
|
"src/plugins/autolink.ts"() {
|
|
3233
3471
|
"use strict";
|
|
3234
3472
|
import_prosemirror_inputrules = require("prosemirror-inputrules");
|
|
3235
|
-
|
|
3473
|
+
import_prosemirror_state9 = require("prosemirror-state");
|
|
3236
3474
|
init_commands();
|
|
3237
3475
|
init_plugins();
|
|
3238
3476
|
init_url();
|
|
@@ -3253,7 +3491,7 @@ var init_autolink = __esm({
|
|
|
3253
3491
|
})
|
|
3254
3492
|
]
|
|
3255
3493
|
}),
|
|
3256
|
-
new
|
|
3494
|
+
new import_prosemirror_state9.Plugin({
|
|
3257
3495
|
/**
|
|
3258
3496
|
* Enter после адреса. Раскладка клавиш ядра обрабатывает Enter раньше плагинов, поэтому смотрим
|
|
3259
3497
|
* на результат: курсор в начале нового блока, а предыдущий блок заканчивается адресом.
|
|
@@ -3262,14 +3500,14 @@ var init_autolink = __esm({
|
|
|
3262
3500
|
if (!editor.isAllowed("link") || !transactions.some((tr2) => tr2.docChanged)) return null;
|
|
3263
3501
|
const { $from, empty } = state.selection;
|
|
3264
3502
|
if (!empty || $from.parentOffset !== 0 || $from.depth < 1) return null;
|
|
3265
|
-
const prev =
|
|
3503
|
+
const prev = import_prosemirror_state9.Selection.findFrom(state.doc.resolve($from.before()), -1, true);
|
|
3266
3504
|
if (!prev || !prev.empty || prev.$from.parentOffset !== prev.$from.parent.content.size)
|
|
3267
3505
|
return null;
|
|
3268
3506
|
const tr = state.tr;
|
|
3269
3507
|
return linkifyBefore(state, tr, prev.from) ? tr : null;
|
|
3270
3508
|
}
|
|
3271
3509
|
}),
|
|
3272
|
-
new
|
|
3510
|
+
new import_prosemirror_state9.Plugin({
|
|
3273
3511
|
props: {
|
|
3274
3512
|
handlePaste(view, event) {
|
|
3275
3513
|
const { state } = view;
|
|
@@ -3304,14 +3542,15 @@ function storage() {
|
|
|
3304
3542
|
return null;
|
|
3305
3543
|
}
|
|
3306
3544
|
}
|
|
3307
|
-
var ICON8,
|
|
3545
|
+
var ICON8, LABELS12, autosave_default;
|
|
3308
3546
|
var init_autosave = __esm({
|
|
3309
3547
|
"src/plugins/autosave.ts"() {
|
|
3310
3548
|
"use strict";
|
|
3549
|
+
init_icons();
|
|
3311
3550
|
init_plugins();
|
|
3312
3551
|
init_shared();
|
|
3313
|
-
ICON8 =
|
|
3314
|
-
|
|
3552
|
+
ICON8 = icons.save;
|
|
3553
|
+
LABELS12 = {
|
|
3315
3554
|
en: {
|
|
3316
3555
|
restore: "Restore last draft",
|
|
3317
3556
|
found: "An unsaved draft was found. Use \u201CRestore last draft\u201D to bring it back.",
|
|
@@ -3328,7 +3567,7 @@ var init_autosave = __esm({
|
|
|
3328
3567
|
toolbar: "restoredraft",
|
|
3329
3568
|
setup(editor) {
|
|
3330
3569
|
const options = editor.options.pluginOptions?.autosave ?? {};
|
|
3331
|
-
const labels = pickLabels(editor,
|
|
3570
|
+
const labels = pickLabels(editor, LABELS12);
|
|
3332
3571
|
const store = storage();
|
|
3333
3572
|
const key3 = options.key ?? `novaprose-draft:${typeof location === "undefined" ? "" : location.pathname}:${editor.options.element.id || "editor"}`;
|
|
3334
3573
|
const delay = options.delay ?? 1e3;
|
|
@@ -3427,19 +3666,20 @@ var visualblocks_exports = {};
|
|
|
3427
3666
|
__export(visualblocks_exports, {
|
|
3428
3667
|
default: () => visualblocks_default
|
|
3429
3668
|
});
|
|
3430
|
-
var ICON9,
|
|
3669
|
+
var ICON9, LABELS13, visualblocks_default;
|
|
3431
3670
|
var init_visualblocks = __esm({
|
|
3432
3671
|
"src/plugins/visualblocks.ts"() {
|
|
3433
3672
|
"use strict";
|
|
3673
|
+
init_icons();
|
|
3434
3674
|
init_plugins();
|
|
3435
3675
|
init_shared();
|
|
3436
|
-
ICON9 =
|
|
3437
|
-
|
|
3676
|
+
ICON9 = icons.visualBlocks;
|
|
3677
|
+
LABELS13 = { en: { title: "Show blocks" }, ru: { title: "\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0431\u043B\u043E\u043A\u0438" } };
|
|
3438
3678
|
visualblocks_default = definePlugin({
|
|
3439
3679
|
name: "visualblocks",
|
|
3440
3680
|
toolbar: "visualblocks",
|
|
3441
3681
|
setup(editor) {
|
|
3442
|
-
const { title } = pickLabels(editor,
|
|
3682
|
+
const { title } = pickLabels(editor, LABELS13);
|
|
3443
3683
|
const options = editor.options.pluginOptions?.visualblocks ?? {};
|
|
3444
3684
|
const isOn = () => editor.root.classList.contains("nova-visualblocks");
|
|
3445
3685
|
const toggle = () => {
|
|
@@ -3490,18 +3730,19 @@ function setDir(dir) {
|
|
|
3490
3730
|
return true;
|
|
3491
3731
|
};
|
|
3492
3732
|
}
|
|
3493
|
-
var ICONS,
|
|
3733
|
+
var ICONS, LABELS14, directionality_default;
|
|
3494
3734
|
var init_directionality = __esm({
|
|
3495
3735
|
"src/plugins/directionality.ts"() {
|
|
3496
3736
|
"use strict";
|
|
3737
|
+
init_icons();
|
|
3497
3738
|
init_commands();
|
|
3498
3739
|
init_plugins();
|
|
3499
3740
|
init_shared();
|
|
3500
3741
|
ICONS = {
|
|
3501
|
-
ltr:
|
|
3502
|
-
rtl:
|
|
3742
|
+
ltr: icons.ltr,
|
|
3743
|
+
rtl: icons.rtl
|
|
3503
3744
|
};
|
|
3504
|
-
|
|
3745
|
+
LABELS14 = {
|
|
3505
3746
|
en: { ltr: "Left to right", rtl: "Right to left" },
|
|
3506
3747
|
ru: { ltr: "\u0421\u043B\u0435\u0432\u0430 \u043D\u0430\u043F\u0440\u0430\u0432\u043E", rtl: "\u0421\u043F\u0440\u0430\u0432\u0430 \u043D\u0430\u043B\u0435\u0432\u043E" }
|
|
3507
3748
|
};
|
|
@@ -3509,7 +3750,7 @@ var init_directionality = __esm({
|
|
|
3509
3750
|
name: "directionality",
|
|
3510
3751
|
toolbar: "ltr rtl",
|
|
3511
3752
|
setup(editor) {
|
|
3512
|
-
const labels = pickLabels(editor,
|
|
3753
|
+
const labels = pickLabels(editor, LABELS14);
|
|
3513
3754
|
for (const dir of ["ltr", "rtl"]) {
|
|
3514
3755
|
const isActive = () => currentDir(editor) === dir;
|
|
3515
3756
|
const onAction = () => {
|
|
@@ -3563,7 +3804,7 @@ function applyStyle(editor, kind, style, fallback) {
|
|
|
3563
3804
|
);
|
|
3564
3805
|
editor.focus();
|
|
3565
3806
|
}
|
|
3566
|
-
var
|
|
3807
|
+
var LABELS15, advlist_default;
|
|
3567
3808
|
var init_advlist = __esm({
|
|
3568
3809
|
"src/plugins/advlist.ts"() {
|
|
3569
3810
|
"use strict";
|
|
@@ -3571,7 +3812,7 @@ var init_advlist = __esm({
|
|
|
3571
3812
|
init_plugins();
|
|
3572
3813
|
init_schema();
|
|
3573
3814
|
init_shared();
|
|
3574
|
-
|
|
3815
|
+
LABELS15 = {
|
|
3575
3816
|
en: {
|
|
3576
3817
|
disc: "Default",
|
|
3577
3818
|
circle: "Circle",
|
|
@@ -3598,7 +3839,7 @@ var init_advlist = __esm({
|
|
|
3598
3839
|
advlist_default = definePlugin({
|
|
3599
3840
|
name: "advlist",
|
|
3600
3841
|
setup(editor) {
|
|
3601
|
-
const labels = pickLabels(editor,
|
|
3842
|
+
const labels = pickLabels(editor, LABELS15);
|
|
3602
3843
|
const options = editor.options.pluginOptions?.advlist ?? {};
|
|
3603
3844
|
const lists = [
|
|
3604
3845
|
{
|
|
@@ -3638,6 +3879,576 @@ var init_advlist = __esm({
|
|
|
3638
3879
|
}
|
|
3639
3880
|
});
|
|
3640
3881
|
|
|
3882
|
+
// src/formats.ts
|
|
3883
|
+
function warnOnce(message) {
|
|
3884
|
+
if (warned.has(message)) return;
|
|
3885
|
+
warned.add(message);
|
|
3886
|
+
console.warn(`[nova] formats: ${message}`);
|
|
3887
|
+
}
|
|
3888
|
+
function classList(value) {
|
|
3889
|
+
if (Array.isArray(value)) return value.flatMap(classList);
|
|
3890
|
+
return typeof value === "string" ? value.split(/\s+/).filter(Boolean) : [];
|
|
3891
|
+
}
|
|
3892
|
+
function formatClasses(specs) {
|
|
3893
|
+
const out = [];
|
|
3894
|
+
for (const spec of specs) {
|
|
3895
|
+
out.push(...classList(spec.classes));
|
|
3896
|
+
if ("items" in spec && spec.items) out.push(...formatClasses(spec.items));
|
|
3897
|
+
}
|
|
3898
|
+
return out;
|
|
3899
|
+
}
|
|
3900
|
+
function blockStyles(spec) {
|
|
3901
|
+
const out = {};
|
|
3902
|
+
for (const [prop, value] of Object.entries(spec.styles ?? {})) {
|
|
3903
|
+
if (prop === "text-align" && ALIGNMENTS.includes(value))
|
|
3904
|
+
out.align = value;
|
|
3905
|
+
else if (prop === "line-height" && cssValue.lineHeight(value))
|
|
3906
|
+
out.lineHeight = cssValue.lineHeight(value);
|
|
3907
|
+
else warnOnce(`style "${prop}" is not supported on blocks`);
|
|
3908
|
+
}
|
|
3909
|
+
return out;
|
|
3910
|
+
}
|
|
3911
|
+
function inlineMarks(state, spec) {
|
|
3912
|
+
const marks2 = marksOf(state);
|
|
3913
|
+
const out = [];
|
|
3914
|
+
if (spec.inline && spec.inline !== "span") {
|
|
3915
|
+
const type = marks2[INLINE_MARKS[spec.inline]];
|
|
3916
|
+
if (type) out.push(type.create());
|
|
3917
|
+
}
|
|
3918
|
+
const classes = classList(spec.classes);
|
|
3919
|
+
if (classes.length && marks2.span_class)
|
|
3920
|
+
out.push(marks2.span_class.create({ class: classes.join(" ") }));
|
|
3921
|
+
for (const [prop, raw] of Object.entries(spec.styles ?? {})) {
|
|
3922
|
+
const style = INLINE_STYLES[prop];
|
|
3923
|
+
const value = style?.read(raw);
|
|
3924
|
+
const type = style ? marks2[style.mark] : void 0;
|
|
3925
|
+
if (type && value) out.push(type.create({ value }));
|
|
3926
|
+
else warnOnce(`style "${prop}: ${raw}" is not supported on text`);
|
|
3927
|
+
}
|
|
3928
|
+
return out;
|
|
3929
|
+
}
|
|
3930
|
+
function selectedNodes(state, tags) {
|
|
3931
|
+
const out = [];
|
|
3932
|
+
const matches = (node) => tags.some((tag) => BLOCK_TAGS[tag](node));
|
|
3933
|
+
const { selection } = state;
|
|
3934
|
+
if (selection instanceof import_prosemirror_state10.NodeSelection && matches(selection.node)) {
|
|
3935
|
+
return [{ node: selection.node, pos: selection.from }];
|
|
3936
|
+
}
|
|
3937
|
+
const { $from, from, to } = selection;
|
|
3938
|
+
for (let depth = $from.depth; depth > 0; depth--) {
|
|
3939
|
+
const node = $from.node(depth);
|
|
3940
|
+
if (matches(node)) out.push({ node, pos: $from.before(depth) });
|
|
3941
|
+
}
|
|
3942
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
3943
|
+
if (matches(node) && !out.some((o) => o.pos === pos)) out.push({ node, pos });
|
|
3944
|
+
});
|
|
3945
|
+
return out;
|
|
3946
|
+
}
|
|
3947
|
+
function textBlocks(state) {
|
|
3948
|
+
const out = [];
|
|
3949
|
+
const { from, to } = state.selection;
|
|
3950
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
3951
|
+
if (node.isTextblock) {
|
|
3952
|
+
out.push({ node, pos });
|
|
3953
|
+
return false;
|
|
3954
|
+
}
|
|
3955
|
+
return true;
|
|
3956
|
+
});
|
|
3957
|
+
return out;
|
|
3958
|
+
}
|
|
3959
|
+
function blockquoteAt(state) {
|
|
3960
|
+
const { $from } = state.selection;
|
|
3961
|
+
for (let depth = $from.depth; depth > 0; depth--) {
|
|
3962
|
+
const node = $from.node(depth);
|
|
3963
|
+
if (node.type.name === "blockquote") return { node, pos: $from.before(depth) };
|
|
3964
|
+
}
|
|
3965
|
+
return null;
|
|
3966
|
+
}
|
|
3967
|
+
function keepBlockStyle(attrs) {
|
|
3968
|
+
return {
|
|
3969
|
+
align: attrs.align ?? null,
|
|
3970
|
+
lineHeight: attrs.lineHeight ?? null,
|
|
3971
|
+
dir: attrs.dir ?? null
|
|
3972
|
+
};
|
|
3973
|
+
}
|
|
3974
|
+
function canApply(state, spec) {
|
|
3975
|
+
if (spec.selector) return selectedNodes(state, selectorTags(spec)).length > 0;
|
|
3976
|
+
return true;
|
|
3977
|
+
}
|
|
3978
|
+
function hasBlockStyles(node, spec) {
|
|
3979
|
+
if (node.type.name === "image") return true;
|
|
3980
|
+
return Object.entries(blockStyles(spec)).every(([key3, value]) => node.attrs[key3] === value);
|
|
3981
|
+
}
|
|
3982
|
+
function matchSpec(state, spec) {
|
|
3983
|
+
const classes = classList(spec.classes);
|
|
3984
|
+
if (spec.block) {
|
|
3985
|
+
if (spec.block === "blockquote") {
|
|
3986
|
+
const quote = blockquoteAt(state);
|
|
3987
|
+
return !!quote && hasClasses(quote.node.attrs.class, classes);
|
|
3988
|
+
}
|
|
3989
|
+
const node = state.selection.$from.parent;
|
|
3990
|
+
return BLOCK_TAGS[spec.block](node) && hasClasses(node.attrs.class, classes) && hasBlockStyles(node, spec);
|
|
3991
|
+
}
|
|
3992
|
+
if (spec.selector) {
|
|
3993
|
+
const nodes2 = selectedNodes(state, selectorTags(spec));
|
|
3994
|
+
return nodes2.length > 0 && nodes2.some(({ node }) => hasClasses(node.attrs.class, classes) && hasBlockStyles(node, spec));
|
|
3995
|
+
}
|
|
3996
|
+
if (spec.inline) {
|
|
3997
|
+
const wanted = inlineMarks(state, spec);
|
|
3998
|
+
if (!wanted.length) return false;
|
|
3999
|
+
const { $from, empty, from, to } = state.selection;
|
|
4000
|
+
if (empty) {
|
|
4001
|
+
const marks2 = state.storedMarks ?? $from.marks();
|
|
4002
|
+
return wanted.every((mark) => marks2.some((m) => markCovers(m, mark)));
|
|
4003
|
+
}
|
|
4004
|
+
let found = false;
|
|
4005
|
+
let all = true;
|
|
4006
|
+
state.doc.nodesBetween(from, to, (node) => {
|
|
4007
|
+
if (!node.isText) return;
|
|
4008
|
+
found = true;
|
|
4009
|
+
if (!wanted.every((mark) => node.marks.some((m) => markCovers(m, mark)))) all = false;
|
|
4010
|
+
});
|
|
4011
|
+
return found && all;
|
|
4012
|
+
}
|
|
4013
|
+
return false;
|
|
4014
|
+
}
|
|
4015
|
+
function markCovers(m, mark) {
|
|
4016
|
+
if (m.type !== mark.type) return false;
|
|
4017
|
+
if (mark.type.name === "span_class")
|
|
4018
|
+
return hasClasses(m.attrs.class, classList(mark.attrs.class));
|
|
4019
|
+
return mark.attrs.value === void 0 || m.attrs.value === mark.attrs.value;
|
|
4020
|
+
}
|
|
4021
|
+
function applySpec(state, tr, spec) {
|
|
4022
|
+
const classes = classList(spec.classes);
|
|
4023
|
+
const nodes2 = nodesOf(state);
|
|
4024
|
+
if (spec.block === "blockquote") {
|
|
4025
|
+
const quote = blockquoteAt(state);
|
|
4026
|
+
if (quote) {
|
|
4027
|
+
tr.setNodeMarkup(quote.pos, void 0, {
|
|
4028
|
+
...quote.node.attrs,
|
|
4029
|
+
class: withClasses(quote.node.attrs.class, classes)
|
|
4030
|
+
});
|
|
4031
|
+
return true;
|
|
4032
|
+
}
|
|
4033
|
+
return (0, import_prosemirror_commands2.wrapIn)(nodes2.blockquote, { class: withClasses(null, classes) })(
|
|
4034
|
+
state,
|
|
4035
|
+
(wrapped) => wrapped.steps.forEach((step) => tr.step(step))
|
|
4036
|
+
);
|
|
4037
|
+
}
|
|
4038
|
+
if (spec.block === "pre") {
|
|
4039
|
+
for (const { node, pos } of textBlocks(state)) {
|
|
4040
|
+
if (node.type !== nodes2.code_block)
|
|
4041
|
+
tr.setNodeMarkup(pos, nodes2.code_block, { language: null });
|
|
4042
|
+
}
|
|
4043
|
+
return true;
|
|
4044
|
+
}
|
|
4045
|
+
if (spec.block) {
|
|
4046
|
+
const level = spec.block === "p" ? 0 : Number(spec.block.slice(1));
|
|
4047
|
+
const type = level ? nodes2.heading : nodes2.paragraph;
|
|
4048
|
+
const styles = blockStyles(spec);
|
|
4049
|
+
for (const { node, pos } of textBlocks(state)) {
|
|
4050
|
+
if (node.type === nodes2.code_block && node.textContent.includes("\n")) continue;
|
|
4051
|
+
const sameType = node.type === type && (!level || node.attrs.level === level);
|
|
4052
|
+
tr.setNodeMarkup(pos, type, {
|
|
4053
|
+
...keepBlockStyle(node.attrs),
|
|
4054
|
+
...level ? { level } : {},
|
|
4055
|
+
...styles,
|
|
4056
|
+
class: withClasses(sameType ? node.attrs.class : null, classes)
|
|
4057
|
+
});
|
|
4058
|
+
}
|
|
4059
|
+
return true;
|
|
4060
|
+
}
|
|
4061
|
+
if (spec.selector) {
|
|
4062
|
+
const styles = blockStyles(spec);
|
|
4063
|
+
const targets = selectedNodes(state, selectorTags(spec));
|
|
4064
|
+
if (!targets.length) return false;
|
|
4065
|
+
for (const { node, pos } of targets) {
|
|
4066
|
+
const extra = node.type.name === "image" ? {} : styles;
|
|
4067
|
+
tr.setNodeMarkup(pos, void 0, {
|
|
4068
|
+
...node.attrs,
|
|
4069
|
+
...extra,
|
|
4070
|
+
class: withClasses(node.attrs.class, classes)
|
|
4071
|
+
});
|
|
4072
|
+
}
|
|
4073
|
+
if (state.selection instanceof import_prosemirror_state10.NodeSelection)
|
|
4074
|
+
tr.setSelection(import_prosemirror_state10.NodeSelection.create(tr.doc, state.selection.from));
|
|
4075
|
+
return true;
|
|
4076
|
+
}
|
|
4077
|
+
if (spec.inline) {
|
|
4078
|
+
const marks2 = inlineMarks(state, spec);
|
|
4079
|
+
if (!marks2.length) return false;
|
|
4080
|
+
const { empty, ranges } = state.selection;
|
|
4081
|
+
if (empty) {
|
|
4082
|
+
let stored = state.storedMarks ?? state.selection.$from.marks();
|
|
4083
|
+
for (const mark of marks2) stored = mark.addToSet(stored);
|
|
4084
|
+
tr.setStoredMarks(stored);
|
|
4085
|
+
return true;
|
|
4086
|
+
}
|
|
4087
|
+
for (const { $from, $to } of ranges) {
|
|
4088
|
+
for (const mark of marks2) tr.addMark($from.pos, $to.pos, mark);
|
|
4089
|
+
}
|
|
4090
|
+
return true;
|
|
4091
|
+
}
|
|
4092
|
+
return false;
|
|
4093
|
+
}
|
|
4094
|
+
function removeSpec(state, tr, spec) {
|
|
4095
|
+
const classes = classList(spec.classes);
|
|
4096
|
+
const nodes2 = nodesOf(state);
|
|
4097
|
+
if (spec.block === "blockquote") {
|
|
4098
|
+
const quote = blockquoteAt(state);
|
|
4099
|
+
if (!quote) return;
|
|
4100
|
+
const rest = withoutClasses(quote.node.attrs.class, classes);
|
|
4101
|
+
if (classes.length && rest !== null) {
|
|
4102
|
+
tr.setNodeMarkup(quote.pos, void 0, { ...quote.node.attrs, class: rest });
|
|
4103
|
+
return;
|
|
4104
|
+
}
|
|
4105
|
+
(0, import_prosemirror_commands2.lift)(state, (lifted) => lifted.steps.forEach((step) => tr.step(step)));
|
|
4106
|
+
return;
|
|
4107
|
+
}
|
|
4108
|
+
if (spec.block) {
|
|
4109
|
+
for (const { node, pos } of textBlocks(state)) {
|
|
4110
|
+
if (!BLOCK_TAGS[spec.block](node)) continue;
|
|
4111
|
+
tr.setNodeMarkup(pos, nodes2.paragraph, {
|
|
4112
|
+
...keepBlockStyle(node.attrs),
|
|
4113
|
+
class: spec.block === "p" ? withoutClasses(node.attrs.class, classes) : null
|
|
4114
|
+
});
|
|
4115
|
+
}
|
|
4116
|
+
return;
|
|
4117
|
+
}
|
|
4118
|
+
if (spec.selector) {
|
|
4119
|
+
const styles = blockStyles(spec);
|
|
4120
|
+
for (const { node, pos } of selectedNodes(state, selectorTags(spec))) {
|
|
4121
|
+
const reset = {};
|
|
4122
|
+
if (node.type.name !== "image") {
|
|
4123
|
+
if ("align" in styles && node.attrs.align === styles.align) reset.align = null;
|
|
4124
|
+
if ("lineHeight" in styles && node.attrs.lineHeight === styles.lineHeight)
|
|
4125
|
+
reset.lineHeight = null;
|
|
4126
|
+
}
|
|
4127
|
+
tr.setNodeMarkup(pos, void 0, {
|
|
4128
|
+
...node.attrs,
|
|
4129
|
+
...reset,
|
|
4130
|
+
class: withoutClasses(node.attrs.class, classes)
|
|
4131
|
+
});
|
|
4132
|
+
}
|
|
4133
|
+
if (state.selection instanceof import_prosemirror_state10.NodeSelection)
|
|
4134
|
+
tr.setSelection(import_prosemirror_state10.NodeSelection.create(tr.doc, state.selection.from));
|
|
4135
|
+
return;
|
|
4136
|
+
}
|
|
4137
|
+
if (spec.inline) {
|
|
4138
|
+
const marks2 = inlineMarks(state, spec);
|
|
4139
|
+
const { empty, from, to, $from } = state.selection;
|
|
4140
|
+
if (empty) {
|
|
4141
|
+
const stored = (state.storedMarks ?? $from.marks()).filter(
|
|
4142
|
+
(m) => !marks2.some((mark) => markCovers(m, mark))
|
|
4143
|
+
);
|
|
4144
|
+
tr.setStoredMarks(stored);
|
|
4145
|
+
return;
|
|
4146
|
+
}
|
|
4147
|
+
for (const mark of marks2) {
|
|
4148
|
+
if (mark.type.name !== "span_class") {
|
|
4149
|
+
tr.removeMark(from, to, mark.type);
|
|
4150
|
+
continue;
|
|
4151
|
+
}
|
|
4152
|
+
state.doc.nodesBetween(from, to, (node, pos) => {
|
|
4153
|
+
if (!node.isText) return;
|
|
4154
|
+
const current = node.marks.find((m) => m.type === mark.type);
|
|
4155
|
+
if (!current) return;
|
|
4156
|
+
const start = Math.max(pos, from);
|
|
4157
|
+
const end = Math.min(pos + node.nodeSize, to);
|
|
4158
|
+
tr.removeMark(start, end, mark.type);
|
|
4159
|
+
const rest = withoutClasses(current.attrs.class, classList(mark.attrs.class));
|
|
4160
|
+
if (rest) tr.addMark(start, end, mark.type.create({ class: rest }));
|
|
4161
|
+
});
|
|
4162
|
+
}
|
|
4163
|
+
}
|
|
4164
|
+
}
|
|
4165
|
+
var import_prosemirror_state10, import_prosemirror_commands2, INLINE_MARKS, INLINE_STYLES, BLOCK_TAGS, warned, hasClasses, withClasses, withoutClasses, selectorTags, Formatter;
|
|
4166
|
+
var init_formats = __esm({
|
|
4167
|
+
"src/formats.ts"() {
|
|
4168
|
+
"use strict";
|
|
4169
|
+
import_prosemirror_state10 = require("prosemirror-state");
|
|
4170
|
+
import_prosemirror_commands2 = require("prosemirror-commands");
|
|
4171
|
+
init_commands();
|
|
4172
|
+
init_schema();
|
|
4173
|
+
INLINE_MARKS = {
|
|
4174
|
+
strong: "bold",
|
|
4175
|
+
b: "bold",
|
|
4176
|
+
em: "italic",
|
|
4177
|
+
i: "italic",
|
|
4178
|
+
u: "underline",
|
|
4179
|
+
s: "strike",
|
|
4180
|
+
strike: "strike",
|
|
4181
|
+
del: "strike",
|
|
4182
|
+
code: "code",
|
|
4183
|
+
sub: "subscript",
|
|
4184
|
+
sup: "superscript"
|
|
4185
|
+
};
|
|
4186
|
+
INLINE_STYLES = {
|
|
4187
|
+
color: { mark: "color", read: cssValue.color },
|
|
4188
|
+
"background-color": { mark: "background", read: cssValue.color },
|
|
4189
|
+
"font-family": { mark: "font_family", read: cssValue.fontFamily },
|
|
4190
|
+
"font-size": { mark: "font_size", read: cssValue.length }
|
|
4191
|
+
};
|
|
4192
|
+
BLOCK_TAGS = {
|
|
4193
|
+
p: (n) => n.type.name === "paragraph",
|
|
4194
|
+
h1: (n) => n.type.name === "heading" && n.attrs.level === 1,
|
|
4195
|
+
h2: (n) => n.type.name === "heading" && n.attrs.level === 2,
|
|
4196
|
+
h3: (n) => n.type.name === "heading" && n.attrs.level === 3,
|
|
4197
|
+
h4: (n) => n.type.name === "heading" && n.attrs.level === 4,
|
|
4198
|
+
h5: (n) => n.type.name === "heading" && n.attrs.level === 5,
|
|
4199
|
+
h6: (n) => n.type.name === "heading" && n.attrs.level === 6,
|
|
4200
|
+
blockquote: (n) => n.type.name === "blockquote",
|
|
4201
|
+
pre: (n) => n.type.name === "code_block",
|
|
4202
|
+
img: (n) => n.type.name === "image"
|
|
4203
|
+
};
|
|
4204
|
+
warned = /* @__PURE__ */ new Set();
|
|
4205
|
+
hasClasses = (value, wanted) => {
|
|
4206
|
+
const have = classList(value);
|
|
4207
|
+
return wanted.every((c) => have.includes(c));
|
|
4208
|
+
};
|
|
4209
|
+
withClasses = (value, add) => {
|
|
4210
|
+
const merged = [.../* @__PURE__ */ new Set([...classList(value), ...add])];
|
|
4211
|
+
return merged.length ? merged.join(" ") : null;
|
|
4212
|
+
};
|
|
4213
|
+
withoutClasses = (value, drop) => {
|
|
4214
|
+
const rest = classList(value).filter((c) => !drop.includes(c));
|
|
4215
|
+
return rest.length ? rest.join(" ") : null;
|
|
4216
|
+
};
|
|
4217
|
+
selectorTags = (spec) => (spec.selector ?? "").split(",").map((s) => s.trim().toLowerCase()).filter((tag) => {
|
|
4218
|
+
if (BLOCK_TAGS[tag]) return true;
|
|
4219
|
+
warnOnce(`selector "${tag}" is not supported`);
|
|
4220
|
+
return false;
|
|
4221
|
+
});
|
|
4222
|
+
Formatter = class {
|
|
4223
|
+
constructor(editor, allowedClasses) {
|
|
4224
|
+
this.editor = editor;
|
|
4225
|
+
this.allowedClasses = allowedClasses;
|
|
4226
|
+
}
|
|
4227
|
+
editor;
|
|
4228
|
+
allowedClasses;
|
|
4229
|
+
registry = /* @__PURE__ */ new Map();
|
|
4230
|
+
/** Зарегистрировать именованный формат (одно описание или несколько вариантов). */
|
|
4231
|
+
register(name, spec) {
|
|
4232
|
+
const specs = Array.isArray(spec) ? spec : [spec];
|
|
4233
|
+
this.registry.set(name, specs);
|
|
4234
|
+
formatClasses(specs).forEach((c) => this.allowedClasses.add(c));
|
|
4235
|
+
}
|
|
4236
|
+
unregister(name) {
|
|
4237
|
+
this.registry.delete(name);
|
|
4238
|
+
}
|
|
4239
|
+
has(name) {
|
|
4240
|
+
return this.registry.has(name);
|
|
4241
|
+
}
|
|
4242
|
+
get(name) {
|
|
4243
|
+
return this.registry.get(name);
|
|
4244
|
+
}
|
|
4245
|
+
resolve(format) {
|
|
4246
|
+
if (typeof format !== "string") return [format];
|
|
4247
|
+
const specs = this.registry.get(format);
|
|
4248
|
+
if (!specs) warnOnce(`unknown format "${format}"`);
|
|
4249
|
+
return specs ?? [];
|
|
4250
|
+
}
|
|
4251
|
+
/** Можно ли применить формат к выделению (для selector — есть ли подходящие элементы). */
|
|
4252
|
+
canApply(format) {
|
|
4253
|
+
if (!this.editor.isEditable()) return false;
|
|
4254
|
+
const state = this.editor.view.state;
|
|
4255
|
+
return this.resolve(format).some((spec) => canApply(state, spec));
|
|
4256
|
+
}
|
|
4257
|
+
/** Подходит ли выделение под формат. */
|
|
4258
|
+
match(format) {
|
|
4259
|
+
const state = this.editor.view.state;
|
|
4260
|
+
return this.resolve(format).some((spec) => matchSpec(state, spec));
|
|
4261
|
+
}
|
|
4262
|
+
apply(format) {
|
|
4263
|
+
if (!this.editor.isEditable()) return false;
|
|
4264
|
+
const specs = this.resolve(format);
|
|
4265
|
+
if (!specs.length) return false;
|
|
4266
|
+
const spec = specs.find((s) => canApply(this.editor.view.state, s)) ?? specs[0];
|
|
4267
|
+
return this.run((state, tr) => applySpec(state, tr, spec));
|
|
4268
|
+
}
|
|
4269
|
+
remove(format) {
|
|
4270
|
+
if (!this.editor.isEditable()) return false;
|
|
4271
|
+
const specs = this.resolve(format);
|
|
4272
|
+
if (!specs.length) return false;
|
|
4273
|
+
return this.run((state, tr) => specs.forEach((spec) => removeSpec(state, tr, spec)));
|
|
4274
|
+
}
|
|
4275
|
+
toggle(format) {
|
|
4276
|
+
return this.match(format) ? this.remove(format) : this.apply(format);
|
|
4277
|
+
}
|
|
4278
|
+
run(fn) {
|
|
4279
|
+
const { view } = this.editor;
|
|
4280
|
+
const tr = view.state.tr;
|
|
4281
|
+
const result = fn(view.state, tr);
|
|
4282
|
+
if (result === false) return false;
|
|
4283
|
+
if (tr.docChanged || tr.storedMarksSet) view.dispatch(tr.scrollIntoView());
|
|
4284
|
+
view.focus();
|
|
4285
|
+
return true;
|
|
4286
|
+
}
|
|
4287
|
+
};
|
|
4288
|
+
}
|
|
4289
|
+
});
|
|
4290
|
+
|
|
4291
|
+
// src/content-css.ts
|
|
4292
|
+
function splitTopLevel(css) {
|
|
4293
|
+
const items = [];
|
|
4294
|
+
let i = 0;
|
|
4295
|
+
let start = 0;
|
|
4296
|
+
let depth = 0;
|
|
4297
|
+
let prelude = "";
|
|
4298
|
+
while (i < css.length) {
|
|
4299
|
+
const ch = css[i];
|
|
4300
|
+
if (ch === "/" && css[i + 1] === "*") {
|
|
4301
|
+
const end = css.indexOf("*/", i + 2);
|
|
4302
|
+
const cut = end === -1 ? css.length : end + 2;
|
|
4303
|
+
if (depth === 0) {
|
|
4304
|
+
css = css.slice(0, i) + css.slice(cut);
|
|
4305
|
+
continue;
|
|
4306
|
+
}
|
|
4307
|
+
i = cut;
|
|
4308
|
+
continue;
|
|
4309
|
+
}
|
|
4310
|
+
if (ch === '"' || ch === "'") {
|
|
4311
|
+
i++;
|
|
4312
|
+
while (i < css.length && css[i] !== ch) i += css[i] === "\\" ? 2 : 1;
|
|
4313
|
+
i++;
|
|
4314
|
+
continue;
|
|
4315
|
+
}
|
|
4316
|
+
if (ch === "{") {
|
|
4317
|
+
if (depth === 0) {
|
|
4318
|
+
prelude = css.slice(start, i).trim();
|
|
4319
|
+
start = i + 1;
|
|
4320
|
+
}
|
|
4321
|
+
depth++;
|
|
4322
|
+
} else if (ch === "}") {
|
|
4323
|
+
depth--;
|
|
4324
|
+
if (depth === 0) {
|
|
4325
|
+
items.push({ prelude, body: css.slice(start, i) });
|
|
4326
|
+
start = i + 1;
|
|
4327
|
+
}
|
|
4328
|
+
if (depth < 0) depth = 0;
|
|
4329
|
+
} else if (ch === ";" && depth === 0) {
|
|
4330
|
+
const statement = css.slice(start, i).trim();
|
|
4331
|
+
if (statement) items.push({ prelude: statement, body: null });
|
|
4332
|
+
start = i + 1;
|
|
4333
|
+
}
|
|
4334
|
+
i++;
|
|
4335
|
+
}
|
|
4336
|
+
return items;
|
|
4337
|
+
}
|
|
4338
|
+
function splitSelectors(list) {
|
|
4339
|
+
const parts = [];
|
|
4340
|
+
let depth = 0;
|
|
4341
|
+
let quote = "";
|
|
4342
|
+
let start = 0;
|
|
4343
|
+
for (let i = 0; i < list.length; i++) {
|
|
4344
|
+
const ch = list[i];
|
|
4345
|
+
if (quote) {
|
|
4346
|
+
if (ch === "\\") i++;
|
|
4347
|
+
else if (ch === quote) quote = "";
|
|
4348
|
+
} else if (ch === '"' || ch === "'") quote = ch;
|
|
4349
|
+
else if (ch === "(" || ch === "[") depth++;
|
|
4350
|
+
else if (ch === ")" || ch === "]") depth--;
|
|
4351
|
+
else if (ch === "," && depth === 0) {
|
|
4352
|
+
parts.push(list.slice(start, i));
|
|
4353
|
+
start = i + 1;
|
|
4354
|
+
}
|
|
4355
|
+
}
|
|
4356
|
+
parts.push(list.slice(start));
|
|
4357
|
+
return parts.map((s) => s.trim()).filter(Boolean);
|
|
4358
|
+
}
|
|
4359
|
+
function scopeSelector(selector, scope) {
|
|
4360
|
+
let rest = selector;
|
|
4361
|
+
let root = false;
|
|
4362
|
+
for (; ; ) {
|
|
4363
|
+
const m = rest.match(/^(html|body|:root)(?![\w-])\s*/i);
|
|
4364
|
+
if (!m) break;
|
|
4365
|
+
root = true;
|
|
4366
|
+
rest = rest.slice(m[0].length);
|
|
4367
|
+
}
|
|
4368
|
+
if (!root) return `${scope} ${selector}`;
|
|
4369
|
+
if (/^[.#[:]/.test(rest)) {
|
|
4370
|
+
const end = rest.search(/[\s>+~]/);
|
|
4371
|
+
return end === -1 ? `${scope}${rest}` : `${scope}${rest.slice(0, end)} ${rest.slice(end).trim()}`;
|
|
4372
|
+
}
|
|
4373
|
+
return rest ? `${scope} ${rest}` : scope;
|
|
4374
|
+
}
|
|
4375
|
+
function scopeCss(css, scope) {
|
|
4376
|
+
const out = [];
|
|
4377
|
+
for (const { prelude, body } of splitTopLevel(css)) {
|
|
4378
|
+
if (body === null) {
|
|
4379
|
+
if (/^@layer\b/i.test(prelude)) out.push(`${prelude};`);
|
|
4380
|
+
continue;
|
|
4381
|
+
}
|
|
4382
|
+
if (GLOBAL_AT_RULES.test(prelude)) out.push(`${prelude}{${body}}`);
|
|
4383
|
+
else if (GROUP_AT_RULES.test(prelude)) out.push(`${prelude}{${scopeCss(body, scope)}}`);
|
|
4384
|
+
else if (prelude.startsWith("@"))
|
|
4385
|
+
continue;
|
|
4386
|
+
else {
|
|
4387
|
+
const selectors = splitSelectors(prelude).map((s) => scopeSelector(s, scope));
|
|
4388
|
+
if (selectors.length) out.push(`${selectors.join(", ")}{${body}}`);
|
|
4389
|
+
}
|
|
4390
|
+
}
|
|
4391
|
+
return out.join("\n");
|
|
4392
|
+
}
|
|
4393
|
+
function absolutizeUrls(css, base) {
|
|
4394
|
+
return css.replace(/url\(\s*(['"]?)([^'")]+)\1\s*\)/gi, (match, quote, url) => {
|
|
4395
|
+
if (/^(data:|https?:|\/\/|#)/i.test(url)) return match;
|
|
4396
|
+
try {
|
|
4397
|
+
return `url(${quote}${new URL(url, base).href}${quote})`;
|
|
4398
|
+
} catch {
|
|
4399
|
+
return match;
|
|
4400
|
+
}
|
|
4401
|
+
});
|
|
4402
|
+
}
|
|
4403
|
+
async function loadCss(url, depth = 0) {
|
|
4404
|
+
const base = new URL(url, document.baseURI).href;
|
|
4405
|
+
const response = await fetch(base);
|
|
4406
|
+
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
4407
|
+
let css = absolutizeUrls(await response.text(), base);
|
|
4408
|
+
if (depth >= 3) return css.replace(IMPORT, "");
|
|
4409
|
+
const imports = [...css.matchAll(IMPORT)];
|
|
4410
|
+
for (const m of imports) {
|
|
4411
|
+
const media = m[3].trim();
|
|
4412
|
+
let inner = "";
|
|
4413
|
+
try {
|
|
4414
|
+
inner = await loadCss(new URL(m[2], base).href, depth + 1);
|
|
4415
|
+
} catch (error) {
|
|
4416
|
+
console.warn(`[nova] contentCss: could not load ${m[2]}`, error);
|
|
4417
|
+
}
|
|
4418
|
+
css = css.replace(m[0], media ? `@media ${media}{${inner}}` : inner);
|
|
4419
|
+
}
|
|
4420
|
+
return css;
|
|
4421
|
+
}
|
|
4422
|
+
function attachCss(host, css) {
|
|
4423
|
+
const root = host.getRootNode();
|
|
4424
|
+
const canAdopt = "adoptedStyleSheets" in root && typeof CSSStyleSheet !== "undefined" && "replaceSync" in CSSStyleSheet.prototype;
|
|
4425
|
+
if (canAdopt) {
|
|
4426
|
+
try {
|
|
4427
|
+
const sheet = new CSSStyleSheet();
|
|
4428
|
+
sheet.replaceSync(css);
|
|
4429
|
+
root.adoptedStyleSheets = [...root.adoptedStyleSheets, sheet];
|
|
4430
|
+
return () => {
|
|
4431
|
+
root.adoptedStyleSheets = root.adoptedStyleSheets.filter((s) => s !== sheet);
|
|
4432
|
+
};
|
|
4433
|
+
} catch {
|
|
4434
|
+
}
|
|
4435
|
+
}
|
|
4436
|
+
const style = document.createElement("style");
|
|
4437
|
+
style.setAttribute("data-nova-content-css", "");
|
|
4438
|
+
style.textContent = css;
|
|
4439
|
+
host.prepend(style);
|
|
4440
|
+
return () => style.remove();
|
|
4441
|
+
}
|
|
4442
|
+
var GLOBAL_AT_RULES, GROUP_AT_RULES, IMPORT;
|
|
4443
|
+
var init_content_css = __esm({
|
|
4444
|
+
"src/content-css.ts"() {
|
|
4445
|
+
"use strict";
|
|
4446
|
+
GLOBAL_AT_RULES = /^@(font-face|(-webkit-)?keyframes|property|counter-style|page|font-feature-values|font-palette-values)\b/i;
|
|
4447
|
+
GROUP_AT_RULES = /^@(media|supports|container|layer|document|scope)\b/i;
|
|
4448
|
+
IMPORT = /@import\s+(?:url\(\s*)?(['"]?)([^'")\s;]+)\1\s*\)?([^;]*);/gi;
|
|
4449
|
+
}
|
|
4450
|
+
});
|
|
4451
|
+
|
|
3641
4452
|
// src/i18n/en.ts
|
|
3642
4453
|
var en;
|
|
3643
4454
|
var init_en = __esm({
|
|
@@ -3676,6 +4487,11 @@ var init_en = __esm({
|
|
|
3676
4487
|
more: "More",
|
|
3677
4488
|
moreFormats: "More formatting",
|
|
3678
4489
|
blocks: "Text style",
|
|
4490
|
+
styles: "Formats",
|
|
4491
|
+
"styles.headings": "Headings",
|
|
4492
|
+
"styles.inline": "Inline",
|
|
4493
|
+
"styles.blocks": "Blocks",
|
|
4494
|
+
"styles.align": "Align",
|
|
3679
4495
|
paragraph: "Paragraph",
|
|
3680
4496
|
h1: "Heading 1",
|
|
3681
4497
|
h2: "Heading 2",
|
|
@@ -3729,6 +4545,8 @@ var init_en = __esm({
|
|
|
3729
4545
|
"image.sizeOriginal": "Original size",
|
|
3730
4546
|
"image.delete": "Remove image",
|
|
3731
4547
|
"status.words": "{count} words",
|
|
4548
|
+
"status.resize": "Resize editor",
|
|
4549
|
+
"dialog.browse": "Browse",
|
|
3732
4550
|
pasteAsText: "Paste as text",
|
|
3733
4551
|
"menu.label": "Menu",
|
|
3734
4552
|
"menu.file": "File",
|
|
@@ -3790,6 +4608,8 @@ var init_en = __esm({
|
|
|
3790
4608
|
"table.sortAsc": "Sort A \u2192 Z, 1 \u2192 9",
|
|
3791
4609
|
"table.sortDesc": "Sort Z \u2192 A, 9 \u2192 1",
|
|
3792
4610
|
"table.props": "Table properties",
|
|
4611
|
+
"table.style": "Style",
|
|
4612
|
+
"table.styleDefault": "Default",
|
|
3793
4613
|
"table.width": "Width",
|
|
3794
4614
|
"table.widthHint": "For example 100% or 600px. Leave empty to fit the content.",
|
|
3795
4615
|
"table.invalidWidth": "Enter a width such as 100% or 600px",
|
|
@@ -3852,6 +4672,11 @@ var init_ru = __esm({
|
|
|
3852
4672
|
more: "\u0415\u0449\u0451",
|
|
3853
4673
|
moreFormats: "\u0415\u0449\u0451 \u0444\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435",
|
|
3854
4674
|
blocks: "\u0421\u0442\u0438\u043B\u044C \u0442\u0435\u043A\u0441\u0442\u0430",
|
|
4675
|
+
styles: "\u0424\u043E\u0440\u043C\u0430\u0442\u044B",
|
|
4676
|
+
"styles.headings": "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043A\u0438",
|
|
4677
|
+
"styles.inline": "\u0422\u0435\u043A\u0441\u0442",
|
|
4678
|
+
"styles.blocks": "\u0411\u043B\u043E\u043A\u0438",
|
|
4679
|
+
"styles.align": "\u0412\u044B\u0440\u0430\u0432\u043D\u0438\u0432\u0430\u043D\u0438\u0435",
|
|
3855
4680
|
paragraph: "\u041E\u0431\u044B\u0447\u043D\u044B\u0439 \u0442\u0435\u043A\u0441\u0442",
|
|
3856
4681
|
h1: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 1",
|
|
3857
4682
|
h2: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 2",
|
|
@@ -3905,6 +4730,8 @@ var init_ru = __esm({
|
|
|
3905
4730
|
"image.sizeOriginal": "\u0418\u0441\u0445\u043E\u0434\u043D\u044B\u0439 \u0440\u0430\u0437\u043C\u0435\u0440",
|
|
3906
4731
|
"image.delete": "\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435",
|
|
3907
4732
|
"status.words": "\u0421\u043B\u043E\u0432: {count}",
|
|
4733
|
+
"status.resize": "\u0418\u0437\u043C\u0435\u043D\u0438\u0442\u044C \u0440\u0430\u0437\u043C\u0435\u0440 \u0440\u0435\u0434\u0430\u043A\u0442\u043E\u0440\u0430",
|
|
4734
|
+
"dialog.browse": "\u041E\u0431\u0437\u043E\u0440",
|
|
3908
4735
|
pasteAsText: "\u0412\u0441\u0442\u0430\u0432\u043B\u044F\u0442\u044C \u043A\u0430\u043A \u0442\u0435\u043A\u0441\u0442",
|
|
3909
4736
|
"menu.label": "\u041C\u0435\u043D\u044E",
|
|
3910
4737
|
"menu.file": "\u0424\u0430\u0439\u043B",
|
|
@@ -3966,6 +4793,8 @@ var init_ru = __esm({
|
|
|
3966
4793
|
"table.sortAsc": "\u0421\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0410 \u2192 \u042F, 1 \u2192 9",
|
|
3967
4794
|
"table.sortDesc": "\u0421\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u042F \u2192 \u0410, 9 \u2192 1",
|
|
3968
4795
|
"table.props": "\u0421\u0432\u043E\u0439\u0441\u0442\u0432\u0430 \u0442\u0430\u0431\u043B\u0438\u0446\u044B",
|
|
4796
|
+
"table.style": "\u0421\u0442\u0438\u043B\u044C",
|
|
4797
|
+
"table.styleDefault": "\u041E\u0431\u044B\u0447\u043D\u044B\u0439",
|
|
3969
4798
|
"table.width": "\u0428\u0438\u0440\u0438\u043D\u0430",
|
|
3970
4799
|
"table.widthHint": "\u041D\u0430\u043F\u0440\u0438\u043C\u0435\u0440, 100% \u0438\u043B\u0438 600px. \u041F\u0443\u0441\u0442\u043E \u2014 \u043F\u043E \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u043C\u043E\u043C\u0443.",
|
|
3971
4800
|
"table.invalidWidth": "\u0423\u043A\u0430\u0436\u0438\u0442\u0435 \u0448\u0438\u0440\u0438\u043D\u0443, \u043D\u0430\u043F\u0440\u0438\u043C\u0435\u0440 100% \u0438\u043B\u0438 600px",
|
|
@@ -4078,18 +4907,18 @@ function buildKeymap(resolve = (name) => commands[name]) {
|
|
|
4078
4907
|
"Shift-Tab": commands.outdent
|
|
4079
4908
|
};
|
|
4080
4909
|
if (!mac) keys["Mod-y"] = byName(resolve, "redo");
|
|
4081
|
-
return [(0, import_prosemirror_keymap5.keymap)(keys), (0, import_prosemirror_keymap5.keymap)(
|
|
4910
|
+
return [(0, import_prosemirror_keymap5.keymap)(keys), (0, import_prosemirror_keymap5.keymap)(import_prosemirror_commands3.baseKeymap)];
|
|
4082
4911
|
}
|
|
4083
|
-
var
|
|
4912
|
+
var import_prosemirror_commands3, import_prosemirror_keymap5, import_prosemirror_schema_list2, mac, insertHardBreak, byName;
|
|
4084
4913
|
var init_keymap = __esm({
|
|
4085
4914
|
"src/keymap.ts"() {
|
|
4086
4915
|
"use strict";
|
|
4087
|
-
|
|
4916
|
+
import_prosemirror_commands3 = require("prosemirror-commands");
|
|
4088
4917
|
import_prosemirror_keymap5 = require("prosemirror-keymap");
|
|
4089
4918
|
import_prosemirror_schema_list2 = require("prosemirror-schema-list");
|
|
4090
4919
|
init_commands();
|
|
4091
4920
|
mac = typeof navigator !== "undefined" && /Mac|iP(hone|[oa]d)/.test(navigator.platform);
|
|
4092
|
-
insertHardBreak = (0,
|
|
4921
|
+
insertHardBreak = (0, import_prosemirror_commands3.chainCommands)(import_prosemirror_commands3.exitCode, (state, dispatch) => {
|
|
4093
4922
|
dispatch?.(state.tr.replaceSelectionWith(nodesOf(state).hard_break.create()).scrollIntoView());
|
|
4094
4923
|
return true;
|
|
4095
4924
|
});
|
|
@@ -4132,6 +4961,8 @@ function cleanPastedHTML(html, styles = "clean") {
|
|
|
4132
4961
|
removeBreaksBetweenBlocks(root);
|
|
4133
4962
|
normalizeEmptyParagraphs(root);
|
|
4134
4963
|
wrapCellContent(root);
|
|
4964
|
+
if (source !== "web")
|
|
4965
|
+
root.querySelectorAll("[class]").forEach((el) => el.removeAttribute("class"));
|
|
4135
4966
|
return root.innerHTML;
|
|
4136
4967
|
}
|
|
4137
4968
|
function parseDeclarations(css) {
|
|
@@ -4653,7 +5484,7 @@ function htmlToPlainText(html) {
|
|
|
4653
5484
|
}
|
|
4654
5485
|
function pastePlugin(editor) {
|
|
4655
5486
|
let reentrant = false;
|
|
4656
|
-
return new
|
|
5487
|
+
return new import_prosemirror_state11.Plugin({
|
|
4657
5488
|
key,
|
|
4658
5489
|
props: {
|
|
4659
5490
|
/**
|
|
@@ -4712,15 +5543,15 @@ function pastePlugin(editor) {
|
|
|
4712
5543
|
}
|
|
4713
5544
|
});
|
|
4714
5545
|
}
|
|
4715
|
-
var import_prosemirror_model4,
|
|
5546
|
+
var import_prosemirror_model4, import_prosemirror_state11, key;
|
|
4716
5547
|
var init_paste = __esm({
|
|
4717
5548
|
"src/paste.ts"() {
|
|
4718
5549
|
"use strict";
|
|
4719
5550
|
import_prosemirror_model4 = require("prosemirror-model");
|
|
4720
|
-
|
|
5551
|
+
import_prosemirror_state11 = require("prosemirror-state");
|
|
4721
5552
|
init_paste_office();
|
|
4722
5553
|
init_paste_rtf();
|
|
4723
|
-
key = new
|
|
5554
|
+
key = new import_prosemirror_state11.PluginKey("nova-paste");
|
|
4724
5555
|
}
|
|
4725
5556
|
});
|
|
4726
5557
|
|
|
@@ -4750,12 +5581,21 @@ var init_parser = __esm({
|
|
|
4750
5581
|
init_schema();
|
|
4751
5582
|
CELL_BG_ATTR = "data-nova-cell-bg";
|
|
4752
5583
|
NovaDOMParser = class extends import_prosemirror_model5.DOMParser {
|
|
4753
|
-
|
|
5584
|
+
atomSelector;
|
|
5585
|
+
prepare(dom) {
|
|
4754
5586
|
preprocessDOM(dom);
|
|
5587
|
+
this.atomSelector ??= Object.values(this.schema.nodes).filter((type) => type.spec.ignoreStyles).flatMap((type) => (type.spec.parseDOM ?? []).map((rule) => rule.tag)).filter((tag) => !!tag).join(", ");
|
|
5588
|
+
if (!this.atomSelector || !("querySelectorAll" in dom)) return;
|
|
5589
|
+
dom.querySelectorAll(this.atomSelector).forEach((el) => {
|
|
5590
|
+
el.removeAttribute("style");
|
|
5591
|
+
});
|
|
5592
|
+
}
|
|
5593
|
+
parse(dom, options) {
|
|
5594
|
+
this.prepare(dom);
|
|
4755
5595
|
return super.parse(dom, options);
|
|
4756
5596
|
}
|
|
4757
5597
|
parseSlice(dom, options) {
|
|
4758
|
-
|
|
5598
|
+
this.prepare(dom);
|
|
4759
5599
|
return super.parseSlice(dom, options);
|
|
4760
5600
|
}
|
|
4761
5601
|
};
|
|
@@ -4768,12 +5608,18 @@ var init_parser = __esm({
|
|
|
4768
5608
|
function createMenu(entries, onDone, label) {
|
|
4769
5609
|
const items = [];
|
|
4770
5610
|
const menu = h("div", { className: "nova-menu", role: "menu", "aria-label": label });
|
|
4771
|
-
const hasChecks = entries.some(
|
|
5611
|
+
const hasChecks = entries.some(
|
|
5612
|
+
(e) => (e.type === void 0 || e.type === "item") && e.active !== void 0
|
|
5613
|
+
);
|
|
4772
5614
|
for (const entry of entries) {
|
|
4773
5615
|
if (entry.type === "separator") {
|
|
4774
5616
|
menu.append(h("div", { className: "nova-menu-sep", role: "separator" }));
|
|
4775
5617
|
continue;
|
|
4776
5618
|
}
|
|
5619
|
+
if (entry.type === "heading") {
|
|
5620
|
+
menu.append(h("div", { className: "nova-menu-heading", role: "presentation" }, entry.label));
|
|
5621
|
+
continue;
|
|
5622
|
+
}
|
|
4777
5623
|
const labelEl = h("span", { className: "nova-menu-label" }, entry.label);
|
|
4778
5624
|
if (entry.labelStyle) labelEl.setAttribute("style", entry.labelStyle);
|
|
4779
5625
|
const button = h(
|
|
@@ -5073,7 +5919,7 @@ function registerMenuItems(editor) {
|
|
|
5073
5919
|
text: t("selectAll"),
|
|
5074
5920
|
shortcut: "Mod-a",
|
|
5075
5921
|
onAction: (e) => {
|
|
5076
|
-
e.view.dispatch(e.view.state.tr.setSelection(new
|
|
5922
|
+
e.view.dispatch(e.view.state.tr.setSelection(new import_prosemirror_state12.AllSelection(e.view.state.doc)));
|
|
5077
5923
|
e.focus();
|
|
5078
5924
|
}
|
|
5079
5925
|
});
|
|
@@ -5090,12 +5936,12 @@ function registerMenuItems(editor) {
|
|
|
5090
5936
|
onAction: (e) => openInsertTableDialog(e)
|
|
5091
5937
|
});
|
|
5092
5938
|
}
|
|
5093
|
-
var import_prosemirror_model6,
|
|
5939
|
+
var import_prosemirror_model6, import_prosemirror_state12, PRINT_CSS;
|
|
5094
5940
|
var init_menu_items = __esm({
|
|
5095
5941
|
"src/ui/menu-items.ts"() {
|
|
5096
5942
|
"use strict";
|
|
5097
5943
|
import_prosemirror_model6 = require("prosemirror-model");
|
|
5098
|
-
|
|
5944
|
+
import_prosemirror_state12 = require("prosemirror-state");
|
|
5099
5945
|
init_table();
|
|
5100
5946
|
init_dialog();
|
|
5101
5947
|
init_dom();
|
|
@@ -5164,7 +6010,7 @@ function flattenTable(fragment) {
|
|
|
5164
6010
|
return out;
|
|
5165
6011
|
}
|
|
5166
6012
|
function contentRulesPlugin(rules) {
|
|
5167
|
-
return new
|
|
6013
|
+
return new import_prosemirror_state13.Plugin({
|
|
5168
6014
|
key: key2,
|
|
5169
6015
|
appendTransaction(transactions, oldState, newState) {
|
|
5170
6016
|
if (!transactions.some((tr2) => tr2.docChanged)) return null;
|
|
@@ -5195,12 +6041,12 @@ function contentRulesPlugin(rules) {
|
|
|
5195
6041
|
}
|
|
5196
6042
|
});
|
|
5197
6043
|
}
|
|
5198
|
-
var import_prosemirror_model7,
|
|
6044
|
+
var import_prosemirror_model7, import_prosemirror_state13, ALIASES, KNOWN_TAGS, KNOWN_STYLES, REQUIREMENTS, ContentRules, key2;
|
|
5199
6045
|
var init_content_rules = __esm({
|
|
5200
6046
|
"src/content-rules.ts"() {
|
|
5201
6047
|
"use strict";
|
|
5202
6048
|
import_prosemirror_model7 = require("prosemirror-model");
|
|
5203
|
-
|
|
6049
|
+
import_prosemirror_state13 = require("prosemirror-state");
|
|
5204
6050
|
ALIASES = {
|
|
5205
6051
|
b: "strong",
|
|
5206
6052
|
i: "em",
|
|
@@ -5460,7 +6306,7 @@ var init_content_rules = __esm({
|
|
|
5460
6306
|
return doc.type.createAndFill(null, content.size ? content : schema2.nodes.paragraph.create());
|
|
5461
6307
|
}
|
|
5462
6308
|
};
|
|
5463
|
-
key2 = new
|
|
6309
|
+
key2 = new import_prosemirror_state13.PluginKey("nova-content-rules");
|
|
5464
6310
|
}
|
|
5465
6311
|
});
|
|
5466
6312
|
|
|
@@ -5498,7 +6344,7 @@ function indexFrom(matches, pos) {
|
|
|
5498
6344
|
return i < 0 ? 0 : i;
|
|
5499
6345
|
}
|
|
5500
6346
|
function searchPlugin() {
|
|
5501
|
-
return new
|
|
6347
|
+
return new import_prosemirror_state14.Plugin({
|
|
5502
6348
|
key: searchKey,
|
|
5503
6349
|
state: {
|
|
5504
6350
|
init: () => EMPTY,
|
|
@@ -5545,7 +6391,7 @@ function setSearch(options) {
|
|
|
5545
6391
|
};
|
|
5546
6392
|
}
|
|
5547
6393
|
function gotoMatch(tr, match, index) {
|
|
5548
|
-
return tr.setMeta(searchKey, { type: "goto", index }).setSelection(
|
|
6394
|
+
return tr.setMeta(searchKey, { type: "goto", index }).setSelection(import_prosemirror_state14.TextSelection.create(tr.doc, match.from, match.to)).scrollIntoView();
|
|
5549
6395
|
}
|
|
5550
6396
|
function findNext(dir = 1) {
|
|
5551
6397
|
return (state, dispatch) => {
|
|
@@ -5568,7 +6414,7 @@ function replaceCurrent(replacement) {
|
|
|
5568
6414
|
if (replacement) tr.replaceWith(match.from, match.to, state.schema.text(replacement, marks2));
|
|
5569
6415
|
else tr.delete(match.from, match.to);
|
|
5570
6416
|
const after = tr.mapping.map(match.to);
|
|
5571
|
-
dispatch(tr.setSelection(
|
|
6417
|
+
dispatch(tr.setSelection(import_prosemirror_state14.TextSelection.create(tr.doc, after)).scrollIntoView());
|
|
5572
6418
|
}
|
|
5573
6419
|
return true;
|
|
5574
6420
|
};
|
|
@@ -5590,15 +6436,15 @@ function replaceAll(replacement) {
|
|
|
5590
6436
|
return true;
|
|
5591
6437
|
};
|
|
5592
6438
|
}
|
|
5593
|
-
var
|
|
6439
|
+
var import_prosemirror_state14, import_prosemirror_view3, MAX_MATCHES, LEAF, searchKey, EMPTY, clearSearch;
|
|
5594
6440
|
var init_search = __esm({
|
|
5595
6441
|
"src/search.ts"() {
|
|
5596
6442
|
"use strict";
|
|
5597
|
-
|
|
6443
|
+
import_prosemirror_state14 = require("prosemirror-state");
|
|
5598
6444
|
import_prosemirror_view3 = require("prosemirror-view");
|
|
5599
6445
|
MAX_MATCHES = 1e4;
|
|
5600
6446
|
LEAF = "\uFFFC";
|
|
5601
|
-
searchKey = new
|
|
6447
|
+
searchKey = new import_prosemirror_state14.PluginKey("nova-search");
|
|
5602
6448
|
EMPTY = {
|
|
5603
6449
|
query: "",
|
|
5604
6450
|
caseSensitive: false,
|
|
@@ -5998,7 +6844,7 @@ function renderSpec(spec) {
|
|
|
5998
6844
|
for (const [name, value] of Object.entries(first)) {
|
|
5999
6845
|
if (value === null || value === void 0) continue;
|
|
6000
6846
|
const attrName = name.includes(" ") ? name.split(" ")[1] : name;
|
|
6001
|
-
if (!
|
|
6847
|
+
if (!ATTR_RE2.test(attrName)) continue;
|
|
6002
6848
|
const safe = safeAttr(attrName, String(value));
|
|
6003
6849
|
if (safe === null) continue;
|
|
6004
6850
|
attrs += ` ${attrName}="${escapeAttr(safe)}"`;
|
|
@@ -6034,7 +6880,7 @@ function renderSpec(spec) {
|
|
|
6034
6880
|
const close = `</${tag}>`;
|
|
6035
6881
|
return { open: open + before, close: after + close, hole, html: open + before + after + close };
|
|
6036
6882
|
}
|
|
6037
|
-
var VOID_ELEMENTS, NBSP2, TAG_RE, FORBIDDEN_TAGS, LINK_ATTRS, RESOURCE_ATTRS, UNSAFE_CSS, reported,
|
|
6883
|
+
var VOID_ELEMENTS, NBSP2, TAG_RE, FORBIDDEN_TAGS, LINK_ATTRS, RESOURCE_ATTRS, UNSAFE_CSS, reported, ATTR_RE2, HTMLSerializer;
|
|
6038
6884
|
var init_serializer = __esm({
|
|
6039
6885
|
"src/serializer.ts"() {
|
|
6040
6886
|
"use strict";
|
|
@@ -6074,7 +6920,7 @@ var init_serializer = __esm({
|
|
|
6074
6920
|
RESOURCE_ATTRS = /* @__PURE__ */ new Set(["src", "poster", "data", "background"]);
|
|
6075
6921
|
UNSAFE_CSS = /url\s*\(|expression\s*\(|javascript:|@import|behavior\s*:|-moz-binding/i;
|
|
6076
6922
|
reported = /* @__PURE__ */ new Set();
|
|
6077
|
-
|
|
6923
|
+
ATTR_RE2 = /^[a-z_:][a-z0-9_.:-]*$/i;
|
|
6078
6924
|
HTMLSerializer = class {
|
|
6079
6925
|
cache = /* @__PURE__ */ new Map();
|
|
6080
6926
|
serializeFragment(fragment) {
|
|
@@ -6408,6 +7254,15 @@ function registerTableUi(editor) {
|
|
|
6408
7254
|
items: "tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells | tablerowheader tablecolheader tablecellbackground | advtablesort tablecellprops tableprops | tabledelete"
|
|
6409
7255
|
});
|
|
6410
7256
|
}
|
|
7257
|
+
function classSelect(editor, list, current) {
|
|
7258
|
+
if (!list?.length) return null;
|
|
7259
|
+
const { t } = editor.ui;
|
|
7260
|
+
const options = [{ value: "", label: t("table.styleDefault") }];
|
|
7261
|
+
for (const o of list) if (o.value) options.push({ value: o.value, label: o.title });
|
|
7262
|
+
if (current && !options.some((o) => o.value === current))
|
|
7263
|
+
options.push({ value: current, label: current });
|
|
7264
|
+
return selectField({ label: t("table.style"), value: current ?? "", options });
|
|
7265
|
+
}
|
|
6411
7266
|
function openTableProps(editor) {
|
|
6412
7267
|
const { t } = editor.ui;
|
|
6413
7268
|
const current = getTableProps(editor.view.state);
|
|
@@ -6426,15 +7281,17 @@ function openTableProps(editor) {
|
|
|
6426
7281
|
{ value: "right", label: t("table.alignRight") }
|
|
6427
7282
|
]
|
|
6428
7283
|
});
|
|
7284
|
+
const styles = classSelect(editor, editor.options.tableClassList, current.class ?? null);
|
|
6429
7285
|
editor.ui.openDialog({
|
|
6430
7286
|
title: t("table.props"),
|
|
6431
|
-
body: h("div", { className: "nova-form" }, width.el, align.el),
|
|
7287
|
+
body: h("div", { className: "nova-form" }, styles?.el ?? null, width.el, align.el),
|
|
6432
7288
|
submitLabel: t("dialog.save"),
|
|
6433
7289
|
onSubmit: () => {
|
|
6434
7290
|
const raw = width.input.value.trim().replace(/^(\d+(\.\d+)?)$/, "$1px");
|
|
6435
7291
|
const props = {
|
|
6436
7292
|
width: raw || null,
|
|
6437
|
-
align: align.select.value || null
|
|
7293
|
+
align: align.select.value || null,
|
|
7294
|
+
...styles ? { class: styles.select.value || null } : {}
|
|
6438
7295
|
};
|
|
6439
7296
|
return editor.exec(setTableProps(props)) || t("table.invalidWidth");
|
|
6440
7297
|
}
|
|
@@ -6467,9 +7324,10 @@ function openCellProps(editor) {
|
|
|
6467
7324
|
hint: t("table.colWidthHint"),
|
|
6468
7325
|
value: current.width ? String(current.width) : ""
|
|
6469
7326
|
});
|
|
7327
|
+
const styles = classSelect(editor, editor.options.tableCellClassList, current.class ?? null);
|
|
6470
7328
|
editor.ui.openDialog({
|
|
6471
7329
|
title: t("table.cellProps"),
|
|
6472
|
-
body: h("div", { className: "nova-form" }, valign.el, type.el, width.el),
|
|
7330
|
+
body: h("div", { className: "nova-form" }, styles?.el ?? null, valign.el, type.el, width.el),
|
|
6473
7331
|
submitLabel: t("dialog.save"),
|
|
6474
7332
|
onSubmit: () => {
|
|
6475
7333
|
const rawWidth = width.input.value.trim();
|
|
@@ -6480,7 +7338,8 @@ function openCellProps(editor) {
|
|
|
6480
7338
|
setCellProps({
|
|
6481
7339
|
valign: valign.select.value || null,
|
|
6482
7340
|
header: type.select.value === "th",
|
|
6483
|
-
width: px
|
|
7341
|
+
width: px,
|
|
7342
|
+
...styles ? { class: styles.select.value || null } : {}
|
|
6484
7343
|
})
|
|
6485
7344
|
);
|
|
6486
7345
|
return true;
|
|
@@ -6615,20 +7474,133 @@ function registerBuiltins(editor) {
|
|
|
6615
7474
|
onAction: (e) => e.exec(currentBlock() === command ? "paragraph" : command)
|
|
6616
7475
|
});
|
|
6617
7476
|
}
|
|
7477
|
+
const BLOCK_COMMANDS = {
|
|
7478
|
+
p: "paragraph",
|
|
7479
|
+
h1: "h1",
|
|
7480
|
+
h2: "h2",
|
|
7481
|
+
h3: "h3",
|
|
7482
|
+
h4: "h4",
|
|
7483
|
+
h5: "h5",
|
|
7484
|
+
h6: "h6",
|
|
7485
|
+
pre: "codeBlock"
|
|
7486
|
+
};
|
|
7487
|
+
const blockList = () => {
|
|
7488
|
+
const custom = editor.options.blockFormats;
|
|
7489
|
+
if (!custom?.length) return blockItems;
|
|
7490
|
+
return custom.flatMap(({ label, block }) => {
|
|
7491
|
+
const command = BLOCK_COMMANDS[block];
|
|
7492
|
+
const item = blockItems.find((i) => i.command === command);
|
|
7493
|
+
return item ? [{ ...item, label }] : [];
|
|
7494
|
+
});
|
|
7495
|
+
};
|
|
6618
7496
|
registry2.addMenuButton("blocks", {
|
|
6619
7497
|
tooltip: t("blocks"),
|
|
6620
|
-
label: () => t(currentBlock()),
|
|
7498
|
+
label: () => blockList().find((i) => i.command === currentBlock())?.label ?? t(currentBlock()),
|
|
6621
7499
|
minChars: 11,
|
|
6622
|
-
isEnabled: (e) =>
|
|
6623
|
-
items: (e) =>
|
|
7500
|
+
isEnabled: (e) => blockList().some(({ command }) => e.can(command)),
|
|
7501
|
+
items: (e) => blockList().filter(({ command }) => e.isAllowed(command)).map(({ command, style, label }) => ({
|
|
6624
7502
|
id: command,
|
|
6625
|
-
label: t(command),
|
|
7503
|
+
label: label ?? t(command),
|
|
6626
7504
|
labelStyle: style,
|
|
6627
7505
|
...SHORTCUTS2[command] ? { shortcut: SHORTCUTS2[command] } : {},
|
|
6628
7506
|
active: currentBlock() === command,
|
|
6629
7507
|
onSelect: () => e.exec(command)
|
|
6630
7508
|
}))
|
|
6631
7509
|
});
|
|
7510
|
+
const ALIGN_SELECTOR = "p,h1,h2,h3,h4,h5,h6";
|
|
7511
|
+
const defaultStyleFormats = () => [
|
|
7512
|
+
{
|
|
7513
|
+
title: t("styles.headings"),
|
|
7514
|
+
items: [1, 2, 3, 4, 5, 6].map((level) => ({
|
|
7515
|
+
title: t(`h${level}`),
|
|
7516
|
+
block: `h${level}`
|
|
7517
|
+
}))
|
|
7518
|
+
},
|
|
7519
|
+
{
|
|
7520
|
+
title: t("styles.inline"),
|
|
7521
|
+
items: [
|
|
7522
|
+
{ title: t("bold"), inline: "strong" },
|
|
7523
|
+
{ title: t("italic"), inline: "em" },
|
|
7524
|
+
{ title: t("underline"), inline: "u" },
|
|
7525
|
+
{ title: t("strike"), inline: "s" },
|
|
7526
|
+
{ title: t("superscript"), inline: "sup" },
|
|
7527
|
+
{ title: t("subscript"), inline: "sub" },
|
|
7528
|
+
{ title: t("code"), inline: "code" }
|
|
7529
|
+
]
|
|
7530
|
+
},
|
|
7531
|
+
{
|
|
7532
|
+
title: t("styles.blocks"),
|
|
7533
|
+
items: [
|
|
7534
|
+
{ title: t("paragraph"), block: "p" },
|
|
7535
|
+
{ title: t("blockquote"), block: "blockquote" },
|
|
7536
|
+
{ title: t("codeBlock"), block: "pre" }
|
|
7537
|
+
]
|
|
7538
|
+
},
|
|
7539
|
+
{
|
|
7540
|
+
title: t("styles.align"),
|
|
7541
|
+
items: ["left", "center", "right", "justify"].map((align) => ({
|
|
7542
|
+
title: t(
|
|
7543
|
+
`align${align === "justify" ? "Justify" : align[0].toUpperCase() + align.slice(1)}`
|
|
7544
|
+
),
|
|
7545
|
+
selector: ALIGN_SELECTOR,
|
|
7546
|
+
styles: { "text-align": align }
|
|
7547
|
+
}))
|
|
7548
|
+
}
|
|
7549
|
+
];
|
|
7550
|
+
const formatOf = (item) => item.format ?? item;
|
|
7551
|
+
const previewStyle = (item) => {
|
|
7552
|
+
const spec = item.format ? editor.formatter.get(item.format)?.[0] : item;
|
|
7553
|
+
const parts = [];
|
|
7554
|
+
const block = spec?.block;
|
|
7555
|
+
if (block && /^h[1-6]$/.test(block)) parts.push("font-weight: 700");
|
|
7556
|
+
if (spec?.inline === "strong" || spec?.inline === "b") parts.push("font-weight: 700");
|
|
7557
|
+
if (spec?.inline === "em" || spec?.inline === "i") parts.push("font-style: italic");
|
|
7558
|
+
if (spec?.inline === "u") parts.push("text-decoration: underline");
|
|
7559
|
+
if (spec?.inline === "s" || spec?.inline === "strike" || spec?.inline === "del")
|
|
7560
|
+
parts.push("text-decoration: line-through");
|
|
7561
|
+
if (spec?.inline === "code" || block === "pre")
|
|
7562
|
+
parts.push("font-family: ui-monospace, monospace");
|
|
7563
|
+
for (const prop of ["color", "background-color", "font-family"]) {
|
|
7564
|
+
const value = spec?.styles?.[prop];
|
|
7565
|
+
if (value && /^[#\w\s,'"().%-]+$/.test(value)) parts.push(`${prop}: ${value}`);
|
|
7566
|
+
}
|
|
7567
|
+
return parts.join("; ");
|
|
7568
|
+
};
|
|
7569
|
+
const flatStyles = (items) => items.flatMap((item) => item.items ? flatStyles(item.items) : [item]);
|
|
7570
|
+
const styleFormats = () => {
|
|
7571
|
+
const custom = editor.options.styleFormats;
|
|
7572
|
+
if (!custom) return defaultStyleFormats();
|
|
7573
|
+
return editor.options.styleFormatsMerge ? [...defaultStyleFormats(), ...custom] : custom;
|
|
7574
|
+
};
|
|
7575
|
+
registry2.addMenuButton("styles", {
|
|
7576
|
+
tooltip: t("styles"),
|
|
7577
|
+
minChars: 10,
|
|
7578
|
+
label: (e) => flatStyles(styleFormats()).find((item) => e.formatter.match(formatOf(item)))?.title ?? t("styles"),
|
|
7579
|
+
items: (e) => {
|
|
7580
|
+
const entries = [];
|
|
7581
|
+
const add = (items, prefix) => {
|
|
7582
|
+
items.forEach((item, index) => {
|
|
7583
|
+
if (item.items) {
|
|
7584
|
+
if (entries.length) entries.push({ type: "separator" });
|
|
7585
|
+
entries.push({ type: "heading", label: item.title });
|
|
7586
|
+
add(item.items, `${prefix}${index}-`);
|
|
7587
|
+
return;
|
|
7588
|
+
}
|
|
7589
|
+
entries.push({
|
|
7590
|
+
id: `style-${prefix}${index}`,
|
|
7591
|
+
label: item.title,
|
|
7592
|
+
labelStyle: previewStyle(item),
|
|
7593
|
+
active: e.formatter.match(formatOf(item)),
|
|
7594
|
+
// Формат по селектору без подходящих элементов (картинка не выделена) — неактивен.
|
|
7595
|
+
disabled: !e.formatter.canApply(formatOf(item)),
|
|
7596
|
+
onSelect: () => e.formatter.toggle(formatOf(item))
|
|
7597
|
+
});
|
|
7598
|
+
});
|
|
7599
|
+
};
|
|
7600
|
+
add(styleFormats(), "");
|
|
7601
|
+
return entries;
|
|
7602
|
+
}
|
|
7603
|
+
});
|
|
6632
7604
|
const families = editor.options.fontFamilies ?? defaultFontFamilies;
|
|
6633
7605
|
registry2.addMenuButton("fontfamily", {
|
|
6634
7606
|
tooltip: t("fontFamily"),
|
|
@@ -7027,8 +7999,8 @@ var init_popover = __esm({
|
|
|
7027
7999
|
|
|
7028
8000
|
// src/ui/link-bubble.ts
|
|
7029
8001
|
function linkBubblePlugin(editor) {
|
|
7030
|
-
return new
|
|
7031
|
-
key: new
|
|
8002
|
+
return new import_prosemirror_state15.Plugin({
|
|
8003
|
+
key: new import_prosemirror_state15.PluginKey("nova-link-bubble"),
|
|
7032
8004
|
view(view) {
|
|
7033
8005
|
const { t } = editor.ui;
|
|
7034
8006
|
const anchor = h("a", {
|
|
@@ -7109,11 +8081,11 @@ function linkBubblePlugin(editor) {
|
|
|
7109
8081
|
}
|
|
7110
8082
|
});
|
|
7111
8083
|
}
|
|
7112
|
-
var
|
|
8084
|
+
var import_prosemirror_state15;
|
|
7113
8085
|
var init_link_bubble = __esm({
|
|
7114
8086
|
"src/ui/link-bubble.ts"() {
|
|
7115
8087
|
"use strict";
|
|
7116
|
-
|
|
8088
|
+
import_prosemirror_state15 = require("prosemirror-state");
|
|
7117
8089
|
init_commands();
|
|
7118
8090
|
init_link();
|
|
7119
8091
|
init_commands();
|
|
@@ -7438,8 +8410,8 @@ var init_toolbar = __esm({
|
|
|
7438
8410
|
|
|
7439
8411
|
// src/ui/context-toolbar.ts
|
|
7440
8412
|
function contextToolbarPlugin(editor) {
|
|
7441
|
-
return new
|
|
7442
|
-
key: new
|
|
8413
|
+
return new import_prosemirror_state16.Plugin({
|
|
8414
|
+
key: new import_prosemirror_state16.PluginKey("nova-context-toolbar"),
|
|
7443
8415
|
view(view) {
|
|
7444
8416
|
const container = h("div", {
|
|
7445
8417
|
className: "nova-bubble nova-context-toolbar",
|
|
@@ -7475,7 +8447,7 @@ function contextToolbarPlugin(editor) {
|
|
|
7475
8447
|
};
|
|
7476
8448
|
const anchorRect = (spec) => {
|
|
7477
8449
|
const { selection } = view.state;
|
|
7478
|
-
if ((spec.position ?? "node") === "node" && selection instanceof
|
|
8450
|
+
if ((spec.position ?? "node") === "node" && selection instanceof import_prosemirror_state16.NodeSelection) {
|
|
7479
8451
|
const dom = view.nodeDOM(selection.from);
|
|
7480
8452
|
return dom?.getBoundingClientRect() ?? null;
|
|
7481
8453
|
}
|
|
@@ -7571,11 +8543,11 @@ function focusContextToolbar(editor) {
|
|
|
7571
8543
|
button?.focus();
|
|
7572
8544
|
return !!button;
|
|
7573
8545
|
}
|
|
7574
|
-
var
|
|
8546
|
+
var import_prosemirror_state16;
|
|
7575
8547
|
var init_context_toolbar = __esm({
|
|
7576
8548
|
"src/ui/context-toolbar.ts"() {
|
|
7577
8549
|
"use strict";
|
|
7578
|
-
|
|
8550
|
+
import_prosemirror_state16 = require("prosemirror-state");
|
|
7579
8551
|
init_dom();
|
|
7580
8552
|
init_popover();
|
|
7581
8553
|
init_toolbar();
|
|
@@ -7583,11 +8555,11 @@ var init_context_toolbar = __esm({
|
|
|
7583
8555
|
});
|
|
7584
8556
|
|
|
7585
8557
|
// src/ui/image-view.ts
|
|
7586
|
-
var
|
|
8558
|
+
var import_prosemirror_state17, MIN_WIDTH, ImageView;
|
|
7587
8559
|
var init_image_view = __esm({
|
|
7588
8560
|
"src/ui/image-view.ts"() {
|
|
7589
8561
|
"use strict";
|
|
7590
|
-
|
|
8562
|
+
import_prosemirror_state17 = require("prosemirror-state");
|
|
7591
8563
|
init_schema();
|
|
7592
8564
|
init_url();
|
|
7593
8565
|
MIN_WIDTH = 24;
|
|
@@ -7624,6 +8596,7 @@ var init_image_view = __esm({
|
|
|
7624
8596
|
if (this.img.getAttribute("src") !== safeSrc) this.img.setAttribute("src", safeSrc);
|
|
7625
8597
|
this.setAttr("alt", alt);
|
|
7626
8598
|
this.setAttr("title", title);
|
|
8599
|
+
this.setAttr("class", classAttr(this.node.attrs.class).class ?? null);
|
|
7627
8600
|
const w = imageSize(width);
|
|
7628
8601
|
const h2 = imageSize(height);
|
|
7629
8602
|
this.img.style.width = w ? `${w}px` : "";
|
|
@@ -7689,7 +8662,7 @@ var init_image_view = __esm({
|
|
|
7689
8662
|
width,
|
|
7690
8663
|
height: Math.round(width * ratio)
|
|
7691
8664
|
});
|
|
7692
|
-
tr.setSelection(
|
|
8665
|
+
tr.setSelection(import_prosemirror_state17.NodeSelection.create(tr.doc, pos));
|
|
7693
8666
|
this.view.dispatch(tr);
|
|
7694
8667
|
};
|
|
7695
8668
|
handle.addEventListener("pointermove", onMove);
|
|
@@ -7821,8 +8794,8 @@ function autocompleterPlugin(editor) {
|
|
|
7821
8794
|
renderItems(view);
|
|
7822
8795
|
});
|
|
7823
8796
|
};
|
|
7824
|
-
return new
|
|
7825
|
-
key: new
|
|
8797
|
+
return new import_prosemirror_state18.Plugin({
|
|
8798
|
+
key: new import_prosemirror_state18.PluginKey("nova-autocompleter"),
|
|
7826
8799
|
view(view) {
|
|
7827
8800
|
list = h("div", {
|
|
7828
8801
|
className: "nova-popover nova-ac",
|
|
@@ -7869,11 +8842,11 @@ function autocompleterPlugin(editor) {
|
|
|
7869
8842
|
}
|
|
7870
8843
|
});
|
|
7871
8844
|
}
|
|
7872
|
-
var
|
|
8845
|
+
var import_prosemirror_state18, MAX_QUERY;
|
|
7873
8846
|
var init_autocompleter = __esm({
|
|
7874
8847
|
"src/ui/autocompleter.ts"() {
|
|
7875
8848
|
"use strict";
|
|
7876
|
-
|
|
8849
|
+
import_prosemirror_state18 = require("prosemirror-state");
|
|
7877
8850
|
init_dom();
|
|
7878
8851
|
init_popover();
|
|
7879
8852
|
MAX_QUERY = 30;
|
|
@@ -8326,6 +9299,8 @@ function createStatusbar(editor, host) {
|
|
|
8326
9299
|
const path = h("div", { className: "nova-path", "aria-hidden": "true" });
|
|
8327
9300
|
const words = h("div", { className: "nova-wordcount", "aria-live": "off" });
|
|
8328
9301
|
host.append(path, words);
|
|
9302
|
+
const resize = editor.options.resize;
|
|
9303
|
+
const removeHandle = resize ? createResizeHandle(editor, host, resize === "both") : null;
|
|
8329
9304
|
let timer = null;
|
|
8330
9305
|
const updateWords = () => {
|
|
8331
9306
|
const doc = editor.view.state.doc;
|
|
@@ -8359,15 +9334,76 @@ function createStatusbar(editor, host) {
|
|
|
8359
9334
|
update,
|
|
8360
9335
|
destroy: () => {
|
|
8361
9336
|
if (timer) clearTimeout(timer);
|
|
9337
|
+
removeHandle?.();
|
|
8362
9338
|
host.replaceChildren();
|
|
8363
9339
|
}
|
|
8364
9340
|
};
|
|
8365
9341
|
}
|
|
8366
|
-
|
|
9342
|
+
function createResizeHandle(editor, host, both) {
|
|
9343
|
+
const root = editor.root;
|
|
9344
|
+
const handle = h("div", {
|
|
9345
|
+
className: "nova-resize-handle",
|
|
9346
|
+
role: "separator",
|
|
9347
|
+
tabIndex: 0,
|
|
9348
|
+
"aria-orientation": "horizontal",
|
|
9349
|
+
"aria-label": editor.ui.t("status.resize")
|
|
9350
|
+
});
|
|
9351
|
+
handle.append(icon(both ? icons.resizeHandleBoth : icons.resizeHandle));
|
|
9352
|
+
root.dataset.resize = both ? "both" : "vertical";
|
|
9353
|
+
host.append(handle);
|
|
9354
|
+
const setSize = (height, width) => {
|
|
9355
|
+
root.style.boxSizing = "border-box";
|
|
9356
|
+
root.style.height = `${Math.max(MIN_HEIGHT, Math.round(height))}px`;
|
|
9357
|
+
if (both && width !== void 0) {
|
|
9358
|
+
const max = root.parentElement?.clientWidth || Infinity;
|
|
9359
|
+
root.style.width = `${Math.min(max, Math.max(MIN_WIDTH2, Math.round(width)))}px`;
|
|
9360
|
+
}
|
|
9361
|
+
handle.setAttribute("aria-valuenow", String(root.offsetHeight));
|
|
9362
|
+
};
|
|
9363
|
+
let start = null;
|
|
9364
|
+
const onDown = (event) => {
|
|
9365
|
+
if (editor.isDisabled()) return;
|
|
9366
|
+
event.preventDefault();
|
|
9367
|
+
handle.setPointerCapture(event.pointerId);
|
|
9368
|
+
start = {
|
|
9369
|
+
x: event.clientX,
|
|
9370
|
+
y: event.clientY,
|
|
9371
|
+
height: root.offsetHeight,
|
|
9372
|
+
width: root.offsetWidth
|
|
9373
|
+
};
|
|
9374
|
+
};
|
|
9375
|
+
const onMove = (event) => {
|
|
9376
|
+
if (!start) return;
|
|
9377
|
+
setSize(start.height + event.clientY - start.y, start.width + event.clientX - start.x);
|
|
9378
|
+
};
|
|
9379
|
+
const onUp = (event) => {
|
|
9380
|
+
if (!start) return;
|
|
9381
|
+
start = null;
|
|
9382
|
+
if (handle.hasPointerCapture(event.pointerId)) handle.releasePointerCapture(event.pointerId);
|
|
9383
|
+
};
|
|
9384
|
+
const onKey = (event) => {
|
|
9385
|
+
const dy = event.key === "ArrowDown" ? KEY_STEP : event.key === "ArrowUp" ? -KEY_STEP : 0;
|
|
9386
|
+
const dx = both ? event.key === "ArrowRight" ? KEY_STEP : event.key === "ArrowLeft" ? -KEY_STEP : 0 : 0;
|
|
9387
|
+
if (!dx && !dy) return;
|
|
9388
|
+
event.preventDefault();
|
|
9389
|
+
setSize(root.offsetHeight + dy, root.offsetWidth + dx);
|
|
9390
|
+
};
|
|
9391
|
+
handle.addEventListener("pointerdown", onDown);
|
|
9392
|
+
handle.addEventListener("pointermove", onMove);
|
|
9393
|
+
handle.addEventListener("pointerup", onUp);
|
|
9394
|
+
handle.addEventListener("pointercancel", onUp);
|
|
9395
|
+
handle.addEventListener("keydown", onKey);
|
|
9396
|
+
return () => {
|
|
9397
|
+
handle.remove();
|
|
9398
|
+
delete root.dataset.resize;
|
|
9399
|
+
};
|
|
9400
|
+
}
|
|
9401
|
+
var TAGS, MARK_TAGS, MIN_HEIGHT, MIN_WIDTH2, KEY_STEP;
|
|
8367
9402
|
var init_statusbar = __esm({
|
|
8368
9403
|
"src/ui/statusbar.ts"() {
|
|
8369
9404
|
"use strict";
|
|
8370
9405
|
init_dom();
|
|
9406
|
+
init_icons();
|
|
8371
9407
|
TAGS = {
|
|
8372
9408
|
paragraph: () => "p",
|
|
8373
9409
|
heading: (n) => `h${n.attrs.level}`,
|
|
@@ -8391,6 +9427,9 @@ var init_statusbar = __esm({
|
|
|
8391
9427
|
subscript: "sub",
|
|
8392
9428
|
superscript: "sup"
|
|
8393
9429
|
};
|
|
9430
|
+
MIN_HEIGHT = 100;
|
|
9431
|
+
MIN_WIDTH2 = 200;
|
|
9432
|
+
KEY_STEP = 20;
|
|
8394
9433
|
}
|
|
8395
9434
|
});
|
|
8396
9435
|
|
|
@@ -8409,16 +9448,18 @@ function parseContent(schema2, content) {
|
|
|
8409
9448
|
function createEditor(options) {
|
|
8410
9449
|
return new Editor(options);
|
|
8411
9450
|
}
|
|
8412
|
-
var import_prosemirror_dropcursor, import_prosemirror_gapcursor, import_prosemirror_history2, import_prosemirror_keymap6, import_prosemirror_model9,
|
|
9451
|
+
var import_prosemirror_dropcursor, import_prosemirror_gapcursor, import_prosemirror_history2, import_prosemirror_keymap6, import_prosemirror_model9, import_prosemirror_state19, import_prosemirror_view4, htmlSerializer, INSERT_BLOCK_TAGS, contentScopeId, Editor;
|
|
8413
9452
|
var init_editor = __esm({
|
|
8414
9453
|
"src/editor.ts"() {
|
|
8415
9454
|
"use strict";
|
|
9455
|
+
init_formats();
|
|
9456
|
+
init_content_css();
|
|
8416
9457
|
import_prosemirror_dropcursor = require("prosemirror-dropcursor");
|
|
8417
9458
|
import_prosemirror_gapcursor = require("prosemirror-gapcursor");
|
|
8418
9459
|
import_prosemirror_history2 = require("prosemirror-history");
|
|
8419
9460
|
import_prosemirror_keymap6 = require("prosemirror-keymap");
|
|
8420
9461
|
import_prosemirror_model9 = require("prosemirror-model");
|
|
8421
|
-
|
|
9462
|
+
import_prosemirror_state19 = require("prosemirror-state");
|
|
8422
9463
|
import_prosemirror_view4 = require("prosemirror-view");
|
|
8423
9464
|
init_commands();
|
|
8424
9465
|
init_i18n();
|
|
@@ -8448,6 +9489,10 @@ var init_editor = __esm({
|
|
|
8448
9489
|
init_statusbar();
|
|
8449
9490
|
init_toolbar();
|
|
8450
9491
|
htmlSerializer = new HTMLSerializer();
|
|
9492
|
+
INSERT_BLOCK_TAGS = new Set(
|
|
9493
|
+
"P H1 H2 H3 H4 H5 H6 UL OL TABLE BLOCKQUOTE PRE HR DIV FIGURE".split(" ")
|
|
9494
|
+
);
|
|
9495
|
+
contentScopeId = 0;
|
|
8451
9496
|
Editor = class {
|
|
8452
9497
|
view;
|
|
8453
9498
|
root;
|
|
@@ -8468,10 +9513,13 @@ var init_editor = __esm({
|
|
|
8468
9513
|
contentRules;
|
|
8469
9514
|
/** Схема документа этого редактора: базовая + узлы и марки синхронных плагинов. */
|
|
8470
9515
|
schema;
|
|
9516
|
+
/** Форматы: register / apply / remove / toggle / match. */
|
|
9517
|
+
formatter;
|
|
8471
9518
|
statusbar;
|
|
8472
9519
|
searchBar;
|
|
8473
9520
|
destroyed = false;
|
|
8474
9521
|
editable;
|
|
9522
|
+
disabled;
|
|
8475
9523
|
pasteAsText;
|
|
8476
9524
|
constructor(options) {
|
|
8477
9525
|
this.options = options;
|
|
@@ -8538,10 +9586,24 @@ var init_editor = __esm({
|
|
|
8538
9586
|
const pluginPm = syncPlugins.flatMap((plugin) => this.collectPmPlugins(plugin));
|
|
8539
9587
|
const hasRules = options.validElements !== void 0 || options.invalidElements !== void 0 || options.validStyles !== void 0;
|
|
8540
9588
|
this.contentRules = hasRules ? new ContentRules(options) : null;
|
|
8541
|
-
|
|
9589
|
+
const allowedClasses = /* @__PURE__ */ new Set([
|
|
9590
|
+
...formatClasses(Object.values(options.formats ?? {}).flat()),
|
|
9591
|
+
...formatClasses(options.styleFormats ?? []),
|
|
9592
|
+
...Array.isArray(options.validClasses) ? options.validClasses : [],
|
|
9593
|
+
...[...options.tableClassList ?? [], ...options.tableCellClassList ?? []].flatMap(
|
|
9594
|
+
(o) => o.value.split(/\s+/).filter(Boolean)
|
|
9595
|
+
)
|
|
9596
|
+
]);
|
|
9597
|
+
this.schema = this.buildSchema(
|
|
9598
|
+
syncPlugins,
|
|
9599
|
+
options.validClasses === true ? () => true : (name) => allowedClasses.has(name)
|
|
9600
|
+
);
|
|
9601
|
+
this.formatter = new Formatter(this, allowedClasses);
|
|
9602
|
+
for (const [name, spec] of Object.entries(options.formats ?? {}))
|
|
9603
|
+
this.formatter.register(name, spec);
|
|
8542
9604
|
syncPlugins.forEach((plugin) => this.registerCommands(plugin));
|
|
8543
9605
|
const initialDoc = parseContent(this.schema, options.content ?? "");
|
|
8544
|
-
const state =
|
|
9606
|
+
const state = import_prosemirror_state19.EditorState.create({
|
|
8545
9607
|
doc: this.contentRules ? this.contentRules.normalizeDoc(initialDoc) : initialDoc,
|
|
8546
9608
|
plugins: [
|
|
8547
9609
|
// Первым: при открытом списке Enter/Tab/стрелки принадлежат автокомплитеру, а не раскладке клавиш.
|
|
@@ -8566,11 +9628,12 @@ var init_editor = __esm({
|
|
|
8566
9628
|
]
|
|
8567
9629
|
});
|
|
8568
9630
|
this.editable = options.editable ?? true;
|
|
9631
|
+
this.disabled = options.disabled ?? false;
|
|
8569
9632
|
this.pasteAsText = options.pasteAsText ?? false;
|
|
8570
9633
|
const handleTransaction = this.handleTransaction.bind(this);
|
|
8571
9634
|
this.view = new import_prosemirror_view4.EditorView(contentHost, {
|
|
8572
9635
|
state,
|
|
8573
|
-
editable: () => this.
|
|
9636
|
+
editable: () => this.isEditable(),
|
|
8574
9637
|
attributes: {
|
|
8575
9638
|
class: "nova-prosemirror",
|
|
8576
9639
|
role: "textbox",
|
|
@@ -8595,6 +9658,7 @@ var init_editor = __esm({
|
|
|
8595
9658
|
}
|
|
8596
9659
|
});
|
|
8597
9660
|
this.root.classList.toggle("nova-readonly", !this.editable);
|
|
9661
|
+
this.applyDisabled();
|
|
8598
9662
|
registerBuiltins(this);
|
|
8599
9663
|
registerMenuItems(this);
|
|
8600
9664
|
if (options.slashCommands !== false) registerSlashCommands(this, options.slashCommands ?? []);
|
|
@@ -8619,7 +9683,40 @@ var init_editor = __esm({
|
|
|
8619
9683
|
if (!this.statusbar) statusbarHost.remove();
|
|
8620
9684
|
if (options.onChange) this.on("change", options.onChange);
|
|
8621
9685
|
this.updatePlaceholder();
|
|
8622
|
-
|
|
9686
|
+
const contentCss = this.applyContentStyles();
|
|
9687
|
+
this.ready = Promise.all([
|
|
9688
|
+
resolved.loaders.length ? this.loadLazyPlugins(resolved.loaders) : void 0,
|
|
9689
|
+
contentCss
|
|
9690
|
+
]).then(() => void 0);
|
|
9691
|
+
}
|
|
9692
|
+
/** contentStyle сразу, contentCss — по мере загрузки. Каждый редактор — своя область. */
|
|
9693
|
+
applyContentStyles() {
|
|
9694
|
+
const { contentStyle, contentCss } = this.options;
|
|
9695
|
+
const files = contentCss === void 0 ? [] : Array.isArray(contentCss) ? contentCss : [contentCss];
|
|
9696
|
+
if (!contentStyle && !files.length) return void 0;
|
|
9697
|
+
const id = `nova-cs-${++contentScopeId}`;
|
|
9698
|
+
this.root.classList.add(id);
|
|
9699
|
+
const scope = `.nova-editor.${id} .nova-prosemirror`;
|
|
9700
|
+
const sheets = files.map(() => "");
|
|
9701
|
+
let detach = null;
|
|
9702
|
+
const apply = () => {
|
|
9703
|
+
if (this.destroyed) return;
|
|
9704
|
+
detach?.();
|
|
9705
|
+
detach = attachCss(this.root, scopeCss([...sheets, contentStyle ?? ""].join("\n"), scope));
|
|
9706
|
+
};
|
|
9707
|
+
this.cleanups.push(() => detach?.());
|
|
9708
|
+
apply();
|
|
9709
|
+
if (!files.length) return void 0;
|
|
9710
|
+
return Promise.all(
|
|
9711
|
+
files.map(
|
|
9712
|
+
(url, index) => loadCss(url).then(
|
|
9713
|
+
(css) => {
|
|
9714
|
+
sheets[index] = css;
|
|
9715
|
+
},
|
|
9716
|
+
(error) => console.warn(`[nova] contentCss: could not load ${url}`, error)
|
|
9717
|
+
)
|
|
9718
|
+
)
|
|
9719
|
+
).then(apply);
|
|
8623
9720
|
}
|
|
8624
9721
|
// ---------- плагины ----------
|
|
8625
9722
|
/** Разрешён ли контрол/команда/тег по ограничениям контента (без ограничений — всегда да). */
|
|
@@ -8633,11 +9730,12 @@ var init_editor = __esm({
|
|
|
8633
9730
|
* Схема с узлами и марками плагинов. Конфликт имён — ошибка конфигурации: сообщаем и работаем
|
|
8634
9731
|
* на базовой схеме, чтобы редактор всё равно открылся.
|
|
8635
9732
|
*/
|
|
8636
|
-
buildSchema(plugins) {
|
|
9733
|
+
buildSchema(plugins, classFilter) {
|
|
8637
9734
|
const nodes2 = {};
|
|
8638
9735
|
const marks2 = {};
|
|
8639
9736
|
for (const plugin of plugins) {
|
|
8640
|
-
|
|
9737
|
+
const pluginNodes = typeof plugin.nodes === "function" ? plugin.nodes(this) : plugin.nodes;
|
|
9738
|
+
for (const [name, spec] of Object.entries(pluginNodes ?? {})) {
|
|
8641
9739
|
if (name in nodes2) reportPluginError(`Node "${name}" is defined by several plugins`);
|
|
8642
9740
|
else nodes2[name] = spec;
|
|
8643
9741
|
}
|
|
@@ -8647,10 +9745,10 @@ var init_editor = __esm({
|
|
|
8647
9745
|
}
|
|
8648
9746
|
}
|
|
8649
9747
|
try {
|
|
8650
|
-
return createSchema({ nodes: nodes2, marks: marks2 });
|
|
9748
|
+
return createSchema({ nodes: nodes2, marks: marks2 }, classFilter);
|
|
8651
9749
|
} catch (error) {
|
|
8652
9750
|
reportPluginError("Failed to build the document schema from plugins", error);
|
|
8653
|
-
return createSchema();
|
|
9751
|
+
return createSchema({}, classFilter);
|
|
8654
9752
|
}
|
|
8655
9753
|
}
|
|
8656
9754
|
collectPmPlugins(plugin) {
|
|
@@ -8764,6 +9862,39 @@ var init_editor = __esm({
|
|
|
8764
9862
|
if (!addToHistory) tr.setMeta("addToHistory", false);
|
|
8765
9863
|
this.view.dispatch(tr);
|
|
8766
9864
|
}
|
|
9865
|
+
/**
|
|
9866
|
+
* Вставить HTML в позицию курсора (как insertContent в TinyMCE). HTML разбирается схемой
|
|
9867
|
+
* редактора — как вставка: без скриптов, опасных ссылок и лишних тегов.
|
|
9868
|
+
* Блоки (абзацы, таблицы) встают отдельными блоками. Таблица, вставляемая при курсоре
|
|
9869
|
+
* внутри таблицы, встаёт после неё (а не заменяет её ячейки).
|
|
9870
|
+
*/
|
|
9871
|
+
insertContent(html) {
|
|
9872
|
+
if (!this.isEditable()) return false;
|
|
9873
|
+
const template = document.createElement("template");
|
|
9874
|
+
template.innerHTML = html;
|
|
9875
|
+
const container = document.createElement("div");
|
|
9876
|
+
container.append(template.content);
|
|
9877
|
+
const parser = parserFor(this.schema);
|
|
9878
|
+
const hasBlocks = [...container.children].some((el) => INSERT_BLOCK_TAGS.has(el.tagName));
|
|
9879
|
+
const { state } = this.view;
|
|
9880
|
+
const slice = hasBlocks ? new import_prosemirror_model9.Slice(parser.parse(container).content, 0, 0) : parser.parseSlice(container);
|
|
9881
|
+
let hasTable = false;
|
|
9882
|
+
slice.content.descendants((node) => {
|
|
9883
|
+
if (node.type.spec.tableRole === "table") hasTable = true;
|
|
9884
|
+
return !hasTable;
|
|
9885
|
+
});
|
|
9886
|
+
const { $from } = state.selection;
|
|
9887
|
+
let tableDepth = 0;
|
|
9888
|
+
for (let depth = 1; depth <= $from.depth; depth++) {
|
|
9889
|
+
if ($from.node(depth).type.spec.tableRole === "table") {
|
|
9890
|
+
tableDepth = depth;
|
|
9891
|
+
break;
|
|
9892
|
+
}
|
|
9893
|
+
}
|
|
9894
|
+
const tr = hasTable && tableDepth ? state.tr.insert($from.after(tableDepth), slice.content) : state.tr.replaceSelection(slice);
|
|
9895
|
+
this.view.dispatch(tr.scrollIntoView());
|
|
9896
|
+
return true;
|
|
9897
|
+
}
|
|
8767
9898
|
isEmpty() {
|
|
8768
9899
|
return this.view.dom.classList.contains("nova-empty");
|
|
8769
9900
|
}
|
|
@@ -8812,8 +9943,32 @@ var init_editor = __esm({
|
|
|
8812
9943
|
closeSearch() {
|
|
8813
9944
|
this.searchBar.close();
|
|
8814
9945
|
}
|
|
9946
|
+
/** Можно ли сейчас править текст: не «только чтение» и не отключён. */
|
|
8815
9947
|
isEditable() {
|
|
8816
|
-
return this.editable;
|
|
9948
|
+
return this.editable && !this.disabled;
|
|
9949
|
+
}
|
|
9950
|
+
isDisabled() {
|
|
9951
|
+
return this.disabled;
|
|
9952
|
+
}
|
|
9953
|
+
/** Отключить или включить редактор (как disabled у поля формы). */
|
|
9954
|
+
setDisabled(value) {
|
|
9955
|
+
if (this.disabled === value) return;
|
|
9956
|
+
this.disabled = value;
|
|
9957
|
+
this.view.setProps({});
|
|
9958
|
+
this.applyDisabled();
|
|
9959
|
+
if (value) {
|
|
9960
|
+
this.ui.closePopover();
|
|
9961
|
+
this.view.dom.blur();
|
|
9962
|
+
}
|
|
9963
|
+
this.toolbar?.update();
|
|
9964
|
+
this.emit("editableChange");
|
|
9965
|
+
}
|
|
9966
|
+
applyDisabled() {
|
|
9967
|
+
this.root.classList.toggle("nova-disabled", this.disabled);
|
|
9968
|
+
if (this.disabled) this.root.setAttribute("aria-disabled", "true");
|
|
9969
|
+
else this.root.removeAttribute("aria-disabled");
|
|
9970
|
+
if (this.disabled) this.view.dom.setAttribute("tabindex", "-1");
|
|
9971
|
+
else this.view.dom.removeAttribute("tabindex");
|
|
8817
9972
|
}
|
|
8818
9973
|
setEditable(value) {
|
|
8819
9974
|
if (this.editable === value) return;
|
|
@@ -9016,7 +10171,7 @@ function toDoc(editor, content) {
|
|
|
9016
10171
|
return parseContent(editor.schema, html);
|
|
9017
10172
|
}
|
|
9018
10173
|
function openHistory(editor, options) {
|
|
9019
|
-
const labels = pickLabels(editor,
|
|
10174
|
+
const labels = pickLabels(editor, LABELS16);
|
|
9020
10175
|
const lang = editor.options.language ?? "en";
|
|
9021
10176
|
const dateFormat = new Intl.DateTimeFormat(lang, { dateStyle: "medium", timeStyle: "short" });
|
|
9022
10177
|
const titleId = uniqueId("nova-history-title");
|
|
@@ -9081,7 +10236,7 @@ function openHistory(editor, options) {
|
|
|
9081
10236
|
};
|
|
9082
10237
|
const showDoc = (doc) => {
|
|
9083
10238
|
selectedDoc = doc;
|
|
9084
|
-
const state =
|
|
10239
|
+
const state = import_prosemirror_state20.EditorState.create({ doc });
|
|
9085
10240
|
const decorations = decorationsFor(doc);
|
|
9086
10241
|
if (preview) {
|
|
9087
10242
|
preview.setProps({ state, decorations: () => decorations });
|
|
@@ -9233,13 +10388,14 @@ function openHistory(editor, options) {
|
|
|
9233
10388
|
});
|
|
9234
10389
|
return { close, element: view };
|
|
9235
10390
|
}
|
|
9236
|
-
var import_prosemirror_model10, import_prosemirror_history3,
|
|
10391
|
+
var import_prosemirror_model10, import_prosemirror_history3, import_prosemirror_state20, import_prosemirror_view5, LABELS16, ICON10, serializer, revisionhistory_default;
|
|
9237
10392
|
var init_revisionhistory = __esm({
|
|
9238
10393
|
"src/plugins/revisionhistory.ts"() {
|
|
9239
10394
|
"use strict";
|
|
10395
|
+
init_icons();
|
|
9240
10396
|
import_prosemirror_model10 = require("prosemirror-model");
|
|
9241
10397
|
import_prosemirror_history3 = require("prosemirror-history");
|
|
9242
|
-
|
|
10398
|
+
import_prosemirror_state20 = require("prosemirror-state");
|
|
9243
10399
|
import_prosemirror_view5 = require("prosemirror-view");
|
|
9244
10400
|
init_editor();
|
|
9245
10401
|
init_plugins();
|
|
@@ -9247,7 +10403,7 @@ var init_revisionhistory = __esm({
|
|
|
9247
10403
|
init_dom();
|
|
9248
10404
|
init_history_diff();
|
|
9249
10405
|
init_shared();
|
|
9250
|
-
|
|
10406
|
+
LABELS16 = {
|
|
9251
10407
|
en: {
|
|
9252
10408
|
button: "Version history",
|
|
9253
10409
|
title: "Version history",
|
|
@@ -9285,7 +10441,7 @@ var init_revisionhistory = __esm({
|
|
|
9285
10441
|
versions: "\u0412\u0435\u0440\u0441\u0438\u0438"
|
|
9286
10442
|
}
|
|
9287
10443
|
};
|
|
9288
|
-
ICON10 =
|
|
10444
|
+
ICON10 = icons.history;
|
|
9289
10445
|
serializer = new HTMLSerializer();
|
|
9290
10446
|
revisionhistory_default = definePlugin({
|
|
9291
10447
|
name: "revisionhistory",
|
|
@@ -9296,7 +10452,7 @@ var init_revisionhistory = __esm({
|
|
|
9296
10452
|
console.warn("[nova] revisionhistory: set pluginOptions.revisionhistory.list and .load");
|
|
9297
10453
|
return;
|
|
9298
10454
|
}
|
|
9299
|
-
const labels = pickLabels(editor,
|
|
10455
|
+
const labels = pickLabels(editor, LABELS16);
|
|
9300
10456
|
let current = null;
|
|
9301
10457
|
const open = () => {
|
|
9302
10458
|
if (current?.element.isConnected) return;
|
|
@@ -9325,6 +10481,7 @@ __export(index_exports, {
|
|
|
9325
10481
|
DEFAULT_MENUBAR: () => DEFAULT_MENUBAR,
|
|
9326
10482
|
DEFAULT_MENUS: () => DEFAULT_MENUS,
|
|
9327
10483
|
Editor: () => Editor,
|
|
10484
|
+
Formatter: () => Formatter,
|
|
9328
10485
|
HTMLSerializer: () => HTMLSerializer,
|
|
9329
10486
|
KNOWN_STYLES: () => KNOWN_STYLES,
|
|
9330
10487
|
KNOWN_TAGS: () => KNOWN_TAGS,
|
|
@@ -9417,12 +10574,13 @@ module.exports = __toCommonJS(index_exports);
|
|
|
9417
10574
|
init_plugins();
|
|
9418
10575
|
|
|
9419
10576
|
// src/plugins/anchor.ts
|
|
10577
|
+
init_icons();
|
|
9420
10578
|
var import_prosemirror_state = require("prosemirror-state");
|
|
9421
10579
|
init_plugins();
|
|
9422
10580
|
init_dialog();
|
|
9423
10581
|
init_dom();
|
|
9424
10582
|
init_shared();
|
|
9425
|
-
var ICON =
|
|
10583
|
+
var ICON = icons.anchor;
|
|
9426
10584
|
var LABELS = {
|
|
9427
10585
|
en: {
|
|
9428
10586
|
title: "Anchor",
|
|
@@ -9511,6 +10669,7 @@ var anchor_default = definePlugin({
|
|
|
9511
10669
|
});
|
|
9512
10670
|
|
|
9513
10671
|
// src/plugins/comments.ts
|
|
10672
|
+
init_icons();
|
|
9514
10673
|
var import_prosemirror_state2 = require("prosemirror-state");
|
|
9515
10674
|
var import_prosemirror_view = require("prosemirror-view");
|
|
9516
10675
|
var import_prosemirror_keymap = require("prosemirror-keymap");
|
|
@@ -9527,8 +10686,8 @@ var LABELS2 = {
|
|
|
9527
10686
|
var MENTION_ID_RE = /^[\w.@:+-]{1,128}$/;
|
|
9528
10687
|
var MAX_NAME = 80;
|
|
9529
10688
|
var cleanName = (value) => value.replace(/^@/, "").trim().slice(0, MAX_NAME);
|
|
9530
|
-
async function findMentionUsers(
|
|
9531
|
-
const result = await
|
|
10689
|
+
async function findMentionUsers(fetch2, query, max = 8) {
|
|
10690
|
+
const result = await fetch2(query);
|
|
9532
10691
|
if (!Array.isArray(result)) return [];
|
|
9533
10692
|
return result.filter((u) => u && typeof u.id === "string" && MENTION_ID_RE.test(u.id) && u.name).slice(0, max).map((u) => ({
|
|
9534
10693
|
id: u.id,
|
|
@@ -9673,8 +10832,8 @@ var LABELS3 = {
|
|
|
9673
10832
|
count: "\u041A\u043E\u043C\u043C\u0435\u043D\u0442\u0430\u0440\u0438\u0435\u0432: {count}"
|
|
9674
10833
|
}
|
|
9675
10834
|
};
|
|
9676
|
-
var ICON_ADD =
|
|
9677
|
-
var ICON_SHOW =
|
|
10835
|
+
var ICON_ADD = icons.commentAdd;
|
|
10836
|
+
var ICON_SHOW = icons.comments;
|
|
9678
10837
|
var SHORTCUT = "Mod-Alt-m";
|
|
9679
10838
|
var commentsKey = new import_prosemirror_state2.PluginKey("nova-comments");
|
|
9680
10839
|
var controllers = /* @__PURE__ */ new WeakMap();
|
|
@@ -9991,9 +11150,193 @@ var comments_default = definePlugin({
|
|
|
9991
11150
|
}
|
|
9992
11151
|
});
|
|
9993
11152
|
|
|
11153
|
+
// src/plugins/mergetags.ts
|
|
11154
|
+
var import_prosemirror_state3 = require("prosemirror-state");
|
|
11155
|
+
init_plugins();
|
|
11156
|
+
init_icons();
|
|
11157
|
+
init_shared();
|
|
11158
|
+
var LABELS4 = {
|
|
11159
|
+
en: {
|
|
11160
|
+
insert: "Insert variable",
|
|
11161
|
+
search: "Variables",
|
|
11162
|
+
empty: "No variables found",
|
|
11163
|
+
unknown: "Unknown variable"
|
|
11164
|
+
},
|
|
11165
|
+
ru: {
|
|
11166
|
+
insert: "\u0412\u0441\u0442\u0430\u0432\u0438\u0442\u044C \u043F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u0443\u044E",
|
|
11167
|
+
search: "\u041F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u044B\u0435",
|
|
11168
|
+
empty: "\u041F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u044B\u0435 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u044B",
|
|
11169
|
+
unknown: "\u041D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u0430\u044F \u043F\u0435\u0440\u0435\u043C\u0435\u043D\u043D\u0430\u044F"
|
|
11170
|
+
}
|
|
11171
|
+
};
|
|
11172
|
+
var KEY_RE = /^[\w.:-]{1,100}$/;
|
|
11173
|
+
var ATTR_RE = /^data-[a-z0-9-]{1,40}$/;
|
|
11174
|
+
function optionsOf(editor) {
|
|
11175
|
+
return editor.options.pluginOptions?.mergetags ?? {};
|
|
11176
|
+
}
|
|
11177
|
+
function attributeOf(editor) {
|
|
11178
|
+
const attribute = optionsOf(editor).attribute ?? "data-mergetag";
|
|
11179
|
+
if (ATTR_RE.test(attribute)) return attribute;
|
|
11180
|
+
console.warn(
|
|
11181
|
+
`[nova] mergetags: attribute "${attribute}" must look like data-name; using data-mergetag`
|
|
11182
|
+
);
|
|
11183
|
+
return "data-mergetag";
|
|
11184
|
+
}
|
|
11185
|
+
var isGroup = (entry) => Array.isArray(entry.items);
|
|
11186
|
+
function flatList(editor) {
|
|
11187
|
+
return (optionsOf(editor).list ?? []).flatMap(
|
|
11188
|
+
(entry) => isGroup(entry) ? entry.items : [entry]
|
|
11189
|
+
);
|
|
11190
|
+
}
|
|
11191
|
+
function labelFor(editor, key3) {
|
|
11192
|
+
return flatList(editor).find((tag) => tag.key === key3)?.label;
|
|
11193
|
+
}
|
|
11194
|
+
function buildNodes(editor) {
|
|
11195
|
+
const attribute = attributeOf(editor);
|
|
11196
|
+
return {
|
|
11197
|
+
mergetag: {
|
|
11198
|
+
group: "inline",
|
|
11199
|
+
inline: true,
|
|
11200
|
+
atom: true,
|
|
11201
|
+
selectable: true,
|
|
11202
|
+
draggable: true,
|
|
11203
|
+
// Свой style «фишки» (цвет, фон, жирность) — оформление, а не формат текста вокруг.
|
|
11204
|
+
ignoreStyles: true,
|
|
11205
|
+
attrs: { key: {}, label: { default: "" } },
|
|
11206
|
+
parseDOM: [
|
|
11207
|
+
{
|
|
11208
|
+
tag: `span[${attribute}]`,
|
|
11209
|
+
// Выше марок и стилей: переменная — целый узел, а не span с форматированием.
|
|
11210
|
+
priority: 60,
|
|
11211
|
+
getAttrs: (dom) => {
|
|
11212
|
+
const el = dom;
|
|
11213
|
+
const key3 = el.getAttribute(attribute) ?? "";
|
|
11214
|
+
if (!KEY_RE.test(key3)) return false;
|
|
11215
|
+
return { key: key3, label: labelFor(editor, key3) ?? el.textContent?.trim() ?? key3 };
|
|
11216
|
+
}
|
|
11217
|
+
}
|
|
11218
|
+
],
|
|
11219
|
+
// Документ мог прийти из JSON — ключ проверяем и на выходе.
|
|
11220
|
+
toDOM: (node) => {
|
|
11221
|
+
const key3 = KEY_RE.test(node.attrs.key) ? node.attrs.key : "";
|
|
11222
|
+
const label = node.attrs.label || key3;
|
|
11223
|
+
return ["span", { [attribute]: key3, contenteditable: "false" }, label];
|
|
11224
|
+
}
|
|
11225
|
+
}
|
|
11226
|
+
};
|
|
11227
|
+
}
|
|
11228
|
+
var MergeTagView = class {
|
|
11229
|
+
constructor(node, editor, unknownTitle) {
|
|
11230
|
+
this.node = node;
|
|
11231
|
+
this.editor = editor;
|
|
11232
|
+
this.unknownTitle = unknownTitle;
|
|
11233
|
+
this.dom = document.createElement("span");
|
|
11234
|
+
this.dom.className = "nova-mergetag";
|
|
11235
|
+
this.dom.contentEditable = "false";
|
|
11236
|
+
this.render();
|
|
11237
|
+
}
|
|
11238
|
+
node;
|
|
11239
|
+
editor;
|
|
11240
|
+
unknownTitle;
|
|
11241
|
+
dom;
|
|
11242
|
+
render() {
|
|
11243
|
+
const key3 = this.node.attrs.key;
|
|
11244
|
+
const known = labelFor(this.editor, key3);
|
|
11245
|
+
this.dom.textContent = known ?? (this.node.attrs.label || key3);
|
|
11246
|
+
this.dom.dataset.key = key3;
|
|
11247
|
+
const list = optionsOf(this.editor).list;
|
|
11248
|
+
const unknown = !!list?.length && known === void 0;
|
|
11249
|
+
this.dom.classList.toggle("is-unknown", unknown);
|
|
11250
|
+
this.dom.title = unknown ? `${this.unknownTitle}: ${key3}` : key3;
|
|
11251
|
+
}
|
|
11252
|
+
update(node) {
|
|
11253
|
+
if (node.type !== this.node.type) return false;
|
|
11254
|
+
this.node = node;
|
|
11255
|
+
this.render();
|
|
11256
|
+
return true;
|
|
11257
|
+
}
|
|
11258
|
+
selectNode() {
|
|
11259
|
+
this.dom.classList.add("is-selected");
|
|
11260
|
+
}
|
|
11261
|
+
deselectNode() {
|
|
11262
|
+
this.dom.classList.remove("is-selected");
|
|
11263
|
+
}
|
|
11264
|
+
stopEvent() {
|
|
11265
|
+
return false;
|
|
11266
|
+
}
|
|
11267
|
+
ignoreMutation() {
|
|
11268
|
+
return true;
|
|
11269
|
+
}
|
|
11270
|
+
};
|
|
11271
|
+
function insertTag(editor, tag, range) {
|
|
11272
|
+
const { state, dispatch } = editor.view;
|
|
11273
|
+
const node = editor.schema.nodes.mergetag.create({ key: tag.key, label: tag.label });
|
|
11274
|
+
const tr = range ? state.tr.replaceWith(range.from, range.to, node) : state.tr.replaceSelectionWith(node, false);
|
|
11275
|
+
dispatch(tr.scrollIntoView());
|
|
11276
|
+
editor.focus();
|
|
11277
|
+
}
|
|
11278
|
+
var mergetags_default = definePlugin({
|
|
11279
|
+
name: "mergetags",
|
|
11280
|
+
toolbar: "mergetags",
|
|
11281
|
+
nodes: buildNodes,
|
|
11282
|
+
prosemirrorPlugins: (editor) => {
|
|
11283
|
+
const labels = pickLabels(editor, LABELS4);
|
|
11284
|
+
return [
|
|
11285
|
+
new import_prosemirror_state3.Plugin({
|
|
11286
|
+
props: {
|
|
11287
|
+
nodeViews: {
|
|
11288
|
+
mergetag: (node, _view) => new MergeTagView(node, editor, labels.unknown)
|
|
11289
|
+
}
|
|
11290
|
+
}
|
|
11291
|
+
})
|
|
11292
|
+
];
|
|
11293
|
+
},
|
|
11294
|
+
setup(editor) {
|
|
11295
|
+
const labels = pickLabels(editor, LABELS4);
|
|
11296
|
+
editor.ui.registry.addMenuButton("mergetags", {
|
|
11297
|
+
icon: icons.mergeTags,
|
|
11298
|
+
tooltip: labels.insert,
|
|
11299
|
+
isEnabled: (e) => e.isEditable() && flatList(e).length > 0,
|
|
11300
|
+
items: (e) => {
|
|
11301
|
+
const entries = [];
|
|
11302
|
+
const item = (tag, id) => ({
|
|
11303
|
+
id,
|
|
11304
|
+
label: tag.label,
|
|
11305
|
+
onSelect: () => insertTag(e, tag)
|
|
11306
|
+
});
|
|
11307
|
+
(optionsOf(e).list ?? []).forEach((entry, index) => {
|
|
11308
|
+
if (isGroup(entry)) {
|
|
11309
|
+
if (entries.length) entries.push({ type: "separator" });
|
|
11310
|
+
entries.push({ type: "heading", label: entry.title });
|
|
11311
|
+
entry.items.forEach((tag, i) => entries.push(item(tag, `mergetag-${index}-${i}`)));
|
|
11312
|
+
} else {
|
|
11313
|
+
entries.push(item(entry, `mergetag-${index}`));
|
|
11314
|
+
}
|
|
11315
|
+
});
|
|
11316
|
+
return entries;
|
|
11317
|
+
}
|
|
11318
|
+
});
|
|
11319
|
+
editor.ui.registry.addAutocompleter("mergetags", {
|
|
11320
|
+
trigger: "{{",
|
|
11321
|
+
label: labels.search,
|
|
11322
|
+
emptyText: labels.empty,
|
|
11323
|
+
maxResults: 12,
|
|
11324
|
+
fetch: (query, e) => {
|
|
11325
|
+
const q = query.toLowerCase();
|
|
11326
|
+
return flatList(e).filter((tag) => tag.label.toLowerCase().includes(q) || tag.key.toLowerCase().includes(q)).map((tag) => ({ value: tag.key, label: tag.label, detail: tag.key }));
|
|
11327
|
+
},
|
|
11328
|
+
onSelect: (item, range, e) => {
|
|
11329
|
+
const tag = flatList(e).find((t) => t.key === item.value);
|
|
11330
|
+
if (tag) insertTag(e, tag, range);
|
|
11331
|
+
}
|
|
11332
|
+
});
|
|
11333
|
+
}
|
|
11334
|
+
});
|
|
11335
|
+
|
|
9994
11336
|
// src/plugins/suggestions.ts
|
|
11337
|
+
init_icons();
|
|
9995
11338
|
var import_prosemirror_model = require("prosemirror-model");
|
|
9996
|
-
var
|
|
11339
|
+
var import_prosemirror_state4 = require("prosemirror-state");
|
|
9997
11340
|
var import_prosemirror_transform = require("prosemirror-transform");
|
|
9998
11341
|
var import_prosemirror_view2 = require("prosemirror-view");
|
|
9999
11342
|
var import_prosemirror_keymap2 = require("prosemirror-keymap");
|
|
@@ -10001,7 +11344,7 @@ init_plugins();
|
|
|
10001
11344
|
init_shared();
|
|
10002
11345
|
var ID_RE2 = /^[A-Za-z0-9_-]{1,64}$/;
|
|
10003
11346
|
var USER_ID_RE = /^[\w.@:+-]{1,128}$/;
|
|
10004
|
-
var
|
|
11347
|
+
var LABELS5 = {
|
|
10005
11348
|
en: {
|
|
10006
11349
|
toggle: "Suggest edits",
|
|
10007
11350
|
review: "Review suggestions",
|
|
@@ -10033,11 +11376,11 @@ var LABELS4 = {
|
|
|
10033
11376
|
none: "\u041F\u0440\u0430\u0432\u043E\u043A \u043D\u0435\u0442"
|
|
10034
11377
|
}
|
|
10035
11378
|
};
|
|
10036
|
-
var ICON_TOGGLE =
|
|
10037
|
-
var ICON_REVIEW =
|
|
10038
|
-
var ICON_ACCEPT =
|
|
10039
|
-
var ICON_REJECT =
|
|
10040
|
-
var suggestionsKey = new
|
|
11379
|
+
var ICON_TOGGLE = icons.suggest;
|
|
11380
|
+
var ICON_REVIEW = icons.review;
|
|
11381
|
+
var ICON_ACCEPT = icons.check;
|
|
11382
|
+
var ICON_REJECT = icons.close;
|
|
11383
|
+
var suggestionsKey = new import_prosemirror_state4.PluginKey("nova-suggestions");
|
|
10041
11384
|
var OWN = "nova-suggestions-own";
|
|
10042
11385
|
var PALETTE2 = ["#1a7f37", "#8250df", "#bf3989", "#0969da", "#bc4c00", "#1b7c83"];
|
|
10043
11386
|
function colorFor2(key3) {
|
|
@@ -10186,14 +11529,14 @@ function suggestTransaction(tr, state, author) {
|
|
|
10186
11529
|
toOut = (pos) => outMap.map(prev(inverse.map(pos, -1)), 1);
|
|
10187
11530
|
});
|
|
10188
11531
|
if (forwardDeleteEnd !== null) {
|
|
10189
|
-
out.setSelection(
|
|
11532
|
+
out.setSelection(import_prosemirror_state4.TextSelection.create(out.doc, forwardDeleteEnd));
|
|
10190
11533
|
} else if (insertEnd !== null && tr.selection.empty) {
|
|
10191
|
-
out.setSelection(
|
|
11534
|
+
out.setSelection(import_prosemirror_state4.TextSelection.create(out.doc, insertEnd));
|
|
10192
11535
|
} else {
|
|
10193
11536
|
const anchor = toOut(tr.selection.anchor);
|
|
10194
11537
|
const head = toOut(tr.selection.head);
|
|
10195
11538
|
try {
|
|
10196
|
-
out.setSelection(
|
|
11539
|
+
out.setSelection(import_prosemirror_state4.TextSelection.create(out.doc, anchor, head));
|
|
10197
11540
|
} catch {
|
|
10198
11541
|
}
|
|
10199
11542
|
}
|
|
@@ -10272,7 +11615,7 @@ var suggestions_default = definePlugin({
|
|
|
10272
11615
|
const options = editor.options.pluginOptions?.suggestions ?? {};
|
|
10273
11616
|
let cache = null;
|
|
10274
11617
|
return [
|
|
10275
|
-
new
|
|
11618
|
+
new import_prosemirror_state4.Plugin({
|
|
10276
11619
|
key: suggestionsKey,
|
|
10277
11620
|
state: {
|
|
10278
11621
|
init: () => ({ enabled: !!(options.enabled || options.force) }),
|
|
@@ -10286,7 +11629,7 @@ var suggestions_default = definePlugin({
|
|
|
10286
11629
|
attributes: (state) => suggestionsKey.getState(state)?.enabled ? { class: "nova-suggesting" } : {},
|
|
10287
11630
|
decorations(state) {
|
|
10288
11631
|
if (cache?.doc === state.doc) return cache.set;
|
|
10289
|
-
const labels = pickLabels(editor,
|
|
11632
|
+
const labels = pickLabels(editor, LABELS5);
|
|
10290
11633
|
const time = new Intl.DateTimeFormat(editor.options.language ?? "en", {
|
|
10291
11634
|
dateStyle: "medium",
|
|
10292
11635
|
timeStyle: "short"
|
|
@@ -10322,7 +11665,7 @@ var suggestions_default = definePlugin({
|
|
|
10322
11665
|
transformTransaction(tr, state, editor) {
|
|
10323
11666
|
if (!isSuggesting(state)) return tr;
|
|
10324
11667
|
const options = editor.options.pluginOptions?.suggestions ?? {};
|
|
10325
|
-
const labels = pickLabels(editor,
|
|
11668
|
+
const labels = pickLabels(editor, LABELS5);
|
|
10326
11669
|
const author = {
|
|
10327
11670
|
id: USER_ID_RE.test(options.author?.id ?? "") ? options.author.id : "guest",
|
|
10328
11671
|
name: String(options.author?.name || labels.guest).slice(0, 80)
|
|
@@ -10331,7 +11674,7 @@ var suggestions_default = definePlugin({
|
|
|
10331
11674
|
},
|
|
10332
11675
|
setup(editor) {
|
|
10333
11676
|
const options = editor.options.pluginOptions?.suggestions ?? {};
|
|
10334
|
-
const labels = pickLabels(editor,
|
|
11677
|
+
const labels = pickLabels(editor, LABELS5);
|
|
10335
11678
|
const canReview = options.canReview !== false;
|
|
10336
11679
|
const dispatch = (tr) => editor.view.dispatch(tr);
|
|
10337
11680
|
const current = () => suggestionAt(editor.view.state);
|
|
@@ -10350,7 +11693,7 @@ var suggestions_default = definePlugin({
|
|
|
10350
11693
|
return;
|
|
10351
11694
|
}
|
|
10352
11695
|
dispatch(
|
|
10353
|
-
state.tr.setSelection(
|
|
11696
|
+
state.tr.setSelection(import_prosemirror_state4.TextSelection.create(state.doc, target.from)).scrollIntoView()
|
|
10354
11697
|
);
|
|
10355
11698
|
editor.focus();
|
|
10356
11699
|
};
|
|
@@ -10418,7 +11761,9 @@ var suggestions_default = definePlugin({
|
|
|
10418
11761
|
});
|
|
10419
11762
|
|
|
10420
11763
|
// src/plugins/media.ts
|
|
10421
|
-
|
|
11764
|
+
init_icons();
|
|
11765
|
+
init_file_picker();
|
|
11766
|
+
var import_prosemirror_state5 = require("prosemirror-state");
|
|
10422
11767
|
init_plugins();
|
|
10423
11768
|
init_schema();
|
|
10424
11769
|
init_dialog();
|
|
@@ -10437,8 +11782,8 @@ function parseMediaUrl(url) {
|
|
|
10437
11782
|
if (VIDEO_FILE.test(value)) return { kind: "video", src: value };
|
|
10438
11783
|
return null;
|
|
10439
11784
|
}
|
|
10440
|
-
var ICON2 =
|
|
10441
|
-
var
|
|
11785
|
+
var ICON2 = icons.media;
|
|
11786
|
+
var LABELS6 = {
|
|
10442
11787
|
en: {
|
|
10443
11788
|
title: "Video",
|
|
10444
11789
|
url: "Video URL",
|
|
@@ -10539,7 +11884,7 @@ var media_default = definePlugin({
|
|
|
10539
11884
|
}
|
|
10540
11885
|
},
|
|
10541
11886
|
prosemirrorPlugins: () => [
|
|
10542
|
-
new
|
|
11887
|
+
new import_prosemirror_state5.Plugin({
|
|
10543
11888
|
props: {
|
|
10544
11889
|
nodeViews: {
|
|
10545
11890
|
// В редакторе плеер закрыт прозрачным слоем: клик выделяет блок, а не запускает видео.
|
|
@@ -10558,10 +11903,10 @@ var media_default = definePlugin({
|
|
|
10558
11903
|
})
|
|
10559
11904
|
],
|
|
10560
11905
|
setup(editor) {
|
|
10561
|
-
const labels = pickLabels(editor,
|
|
11906
|
+
const labels = pickLabels(editor, LABELS6);
|
|
10562
11907
|
const selected = () => {
|
|
10563
11908
|
const { selection } = editor.view.state;
|
|
10564
|
-
return selection instanceof
|
|
11909
|
+
return selection instanceof import_prosemirror_state5.NodeSelection && selection.node.type.name === "media" ? selection : null;
|
|
10565
11910
|
};
|
|
10566
11911
|
const open = () => {
|
|
10567
11912
|
const current = selected();
|
|
@@ -10576,6 +11921,9 @@ var media_default = definePlugin({
|
|
|
10576
11921
|
label: labels.name,
|
|
10577
11922
|
value: current?.node.attrs.title ?? ""
|
|
10578
11923
|
});
|
|
11924
|
+
attachFilePicker(editor, url, "media", (picked) => {
|
|
11925
|
+
if (picked.title) title.input.value = picked.title;
|
|
11926
|
+
});
|
|
10579
11927
|
editor.ui.openDialog({
|
|
10580
11928
|
title: labels.title,
|
|
10581
11929
|
body: h("div", { className: "nova-form" }, url.el, title.el),
|
|
@@ -10608,10 +11956,11 @@ var media_default = definePlugin({
|
|
|
10608
11956
|
});
|
|
10609
11957
|
|
|
10610
11958
|
// src/plugins/pagebreak.ts
|
|
11959
|
+
init_icons();
|
|
10611
11960
|
init_plugins();
|
|
10612
11961
|
init_shared();
|
|
10613
|
-
var ICON3 =
|
|
10614
|
-
var
|
|
11962
|
+
var ICON3 = icons.pageBreak;
|
|
11963
|
+
var LABELS7 = { en: { title: "Page break" }, ru: { title: "\u0420\u0430\u0437\u0440\u044B\u0432 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B" } };
|
|
10615
11964
|
var pagebreak_default = definePlugin({
|
|
10616
11965
|
name: "pagebreak",
|
|
10617
11966
|
toolbar: "pagebreak",
|
|
@@ -10636,7 +11985,7 @@ var pagebreak_default = definePlugin({
|
|
|
10636
11985
|
}
|
|
10637
11986
|
},
|
|
10638
11987
|
setup(editor) {
|
|
10639
|
-
const { title } = pickLabels(editor,
|
|
11988
|
+
const { title } = pickLabels(editor, LABELS7);
|
|
10640
11989
|
const insert = () => {
|
|
10641
11990
|
const { state, dispatch } = editor.view;
|
|
10642
11991
|
const type = editor.schema.nodes.pagebreak;
|
|
@@ -10668,6 +12017,7 @@ registerPlugin("pagebreak", pagebreak_default);
|
|
|
10668
12017
|
registerPlugin("media", media_default);
|
|
10669
12018
|
registerPlugin("comments", comments_default);
|
|
10670
12019
|
registerPlugin("mentions", mentions_default);
|
|
12020
|
+
registerPlugin("mergetags", mergetags_default);
|
|
10671
12021
|
registerPlugin("suggestions", suggestions_default);
|
|
10672
12022
|
registerPlugin("directionality", () => Promise.resolve().then(() => (init_directionality(), directionality_exports)));
|
|
10673
12023
|
registerPlugin("advlist", () => Promise.resolve().then(() => (init_advlist(), advlist_exports)));
|
|
@@ -10676,6 +12026,7 @@ registerPlugin("revisionhistory", () => Promise.resolve().then(() => (init_revis
|
|
|
10676
12026
|
// src/index.ts
|
|
10677
12027
|
init_editor();
|
|
10678
12028
|
init_menubar();
|
|
12029
|
+
init_formats();
|
|
10679
12030
|
init_menu_items();
|
|
10680
12031
|
init_schema();
|
|
10681
12032
|
init_parser();
|
|
@@ -10706,6 +12057,7 @@ init_serializer();
|
|
|
10706
12057
|
DEFAULT_MENUBAR,
|
|
10707
12058
|
DEFAULT_MENUS,
|
|
10708
12059
|
Editor,
|
|
12060
|
+
Formatter,
|
|
10709
12061
|
HTMLSerializer,
|
|
10710
12062
|
KNOWN_STYLES,
|
|
10711
12063
|
KNOWN_TAGS,
|