@novaprose/core 0.5.3 → 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.
Files changed (47) hide show
  1. package/README.md +51 -17
  2. package/dist/{advlist-FH3K3AAQ.js → advlist-K2U3VPH2.js} +3 -3
  3. package/dist/{autolink-IDJWAL2V.js → autolink-XWDTLY37.js} +2 -2
  4. package/dist/{autoresize-4ZEPQCHP.js → autoresize-UB3GOA6D.js} +2 -2
  5. package/dist/{autosave-DH7SO4UQ.js → autosave-MWNRUNU3.js} +3 -3
  6. package/dist/{charmap-F7EVJ56K.js → charmap-ADLYOIB3.js} +3 -3
  7. package/dist/{chunk-6AL2IS6V.js → chunk-435CRWKA.js} +69 -8
  8. package/dist/chunk-435CRWKA.js.map +1 -0
  9. package/dist/{chunk-55LD2TT2.js → chunk-46RIM5KP.js} +932 -32
  10. package/dist/chunk-46RIM5KP.js.map +1 -0
  11. package/dist/{chunk-YZPJQB3I.js → chunk-7ON7PR5R.js} +106 -25
  12. package/dist/chunk-7ON7PR5R.js.map +1 -0
  13. package/dist/{chunk-6GWG2BLC.js → chunk-HPLT3XRZ.js} +1 -1
  14. package/dist/chunk-HPLT3XRZ.js.map +1 -0
  15. package/dist/{chunk-MOO4PJGI.js → chunk-NPKAIW34.js} +11 -1
  16. package/dist/{chunk-MOO4PJGI.js.map → chunk-NPKAIW34.js.map} +1 -1
  17. package/dist/{directionality-MF5HDXH3.js → directionality-XOHJFSL6.js} +3 -3
  18. package/dist/{emoticons-SONBUCFV.js → emoticons-TP4N4ZGY.js} +3 -3
  19. package/dist/index.cjs +1424 -162
  20. package/dist/index.cjs.map +1 -1
  21. package/dist/index.d.cts +248 -11
  22. package/dist/index.d.ts +248 -11
  23. package/dist/index.js +212 -25
  24. package/dist/index.js.map +1 -1
  25. package/dist/{insertdatetime-X2T4ZY6R.js → insertdatetime-T4SEMQWP.js} +3 -3
  26. package/dist/{nonbreaking-PP4KIJSR.js → nonbreaking-HG5HV6AL.js} +3 -3
  27. package/dist/{quickbars-3WKHLKAR.js → quickbars-4NU4SIPL.js} +5 -5
  28. package/dist/{revisionhistory-FYRVDGRA.js → revisionhistory-3YQPLPLM.js} +6 -6
  29. package/dist/{visualblocks-NPTMWFXD.js → visualblocks-RTAYJOGR.js} +3 -3
  30. package/package.json +1 -1
  31. package/src/style.css +106 -0
  32. package/dist/chunk-55LD2TT2.js.map +0 -1
  33. package/dist/chunk-6AL2IS6V.js.map +0 -1
  34. package/dist/chunk-6GWG2BLC.js.map +0 -1
  35. package/dist/chunk-YZPJQB3I.js.map +0 -1
  36. /package/dist/{advlist-FH3K3AAQ.js.map → advlist-K2U3VPH2.js.map} +0 -0
  37. /package/dist/{autolink-IDJWAL2V.js.map → autolink-XWDTLY37.js.map} +0 -0
  38. /package/dist/{autoresize-4ZEPQCHP.js.map → autoresize-UB3GOA6D.js.map} +0 -0
  39. /package/dist/{autosave-DH7SO4UQ.js.map → autosave-MWNRUNU3.js.map} +0 -0
  40. /package/dist/{charmap-F7EVJ56K.js.map → charmap-ADLYOIB3.js.map} +0 -0
  41. /package/dist/{directionality-MF5HDXH3.js.map → directionality-XOHJFSL6.js.map} +0 -0
  42. /package/dist/{emoticons-SONBUCFV.js.map → emoticons-TP4N4ZGY.js.map} +0 -0
  43. /package/dist/{insertdatetime-X2T4ZY6R.js.map → insertdatetime-T4SEMQWP.js.map} +0 -0
  44. /package/dist/{nonbreaking-PP4KIJSR.js.map → nonbreaking-HG5HV6AL.js.map} +0 -0
  45. /package/dist/{quickbars-3WKHLKAR.js.map → quickbars-4NU4SIPL.js.map} +0 -0
  46. /package/dist/{revisionhistory-FYRVDGRA.js.map → revisionhistory-3YQPLPLM.js.map} +0 -0
  47. /package/dist/{visualblocks-NPTMWFXD.js.map → visualblocks-RTAYJOGR.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -278,6 +278,16 @@ var init_icons = __esm({
278
278
  edit: svg(
279
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
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" />'),
281
291
  anchor: svg(
282
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" />'
283
293
  ),
@@ -1200,6 +1210,48 @@ var init_comments_panel = __esm({
1200
1210
  }
1201
1211
  });
1202
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
+
1203
1255
  // src/url.ts
1204
1256
  function protocolOf(url) {
1205
1257
  const cleaned = url.replace(/[\u0000- \u007f-\u009f]/g, "");
@@ -1294,11 +1346,20 @@ function tableStyle(attrs) {
1294
1346
  else if (attrs.align === "right") parts.push("margin-left: auto;");
1295
1347
  return parts.join(" ");
1296
1348
  }
1297
- function buildTableNodes() {
1349
+ function buildTableNodes(allow) {
1298
1350
  const specs = (0, import_prosemirror_tables.tableNodes)({
1299
1351
  tableGroup: "block",
1300
1352
  cellContent: "block+",
1301
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
+ },
1302
1363
  background: {
1303
1364
  default: null,
1304
1365
  // Фон заранее перенесён в data-атрибут (parser.ts → preprocessDOM); style — запасной путь.
@@ -1325,7 +1386,12 @@ function buildTableNodes() {
1325
1386
  }
1326
1387
  }
1327
1388
  });
1328
- specs.table.attrs = { width: { default: null }, align: { default: null } };
1389
+ specs.table.attrs = {
1390
+ width: { default: null },
1391
+ align: { default: null },
1392
+ // Стиль таблицы из списка (tableClassList): «с рамками», «раскладка без рамок»…
1393
+ class: { default: null }
1394
+ };
1329
1395
  specs.table.parseDOM = [
1330
1396
  {
1331
1397
  tag: "table",
@@ -1334,13 +1400,13 @@ function buildTableNodes() {
1334
1400
  const width = cssValue.length(el.style.width) ?? cssValue.length(`${el.getAttribute("width") ?? ""}px`);
1335
1401
  const auto = (v) => v === "auto";
1336
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;
1337
- return { width, align };
1403
+ return { width, align, class: readClass(el, allow) };
1338
1404
  }
1339
1405
  }
1340
1406
  ];
1341
1407
  specs.table.toDOM = (node) => {
1342
1408
  const style = tableStyle(node.attrs);
1343
- return ["table", style ? { style } : {}, ["tbody", 0]];
1409
+ return ["table", { ...classAttr(node.attrs.class), ...style ? { style } : {} }, ["tbody", 0]];
1344
1410
  };
1345
1411
  for (const name of ["table_cell", "table_header"]) {
1346
1412
  const spec = specs[name];
@@ -1366,16 +1432,27 @@ function buildTableNodes() {
1366
1432
  }
1367
1433
  return specs;
1368
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
+ }
1369
1444
  function styleAttr(value) {
1370
1445
  return value ? { value } : false;
1371
1446
  }
1372
1447
  function styleSpan(property, value) {
1373
1448
  return value ? ["span", { style: `${property}: ${value};` }, 0] : ["span", 0];
1374
1449
  }
1375
- function createSchema(extensions = {}) {
1450
+ function createSchema(extensions = {}, classFilter) {
1376
1451
  const extraNodes = Object.entries(extensions.nodes ?? {});
1377
1452
  const extraMarks = Object.entries(extensions.marks ?? {});
1378
- 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;
1379
1456
  for (const [name] of extraNodes) {
1380
1457
  if (name in nodes) throw new Error(`[nova] node "${name}" already exists in the base schema`);
1381
1458
  }
@@ -1383,11 +1460,11 @@ function createSchema(extensions = {}) {
1383
1460
  if (name in marks) throw new Error(`[nova] mark "${name}" already exists in the base schema`);
1384
1461
  }
1385
1462
  return new import_prosemirror_model2.Schema({
1386
- nodes: { ...nodes, ...Object.fromEntries(extraNodes) },
1387
- marks: { ...marks, ...Object.fromEntries(extraMarks) }
1463
+ nodes: { ...baseNodes, ...Object.fromEntries(extraNodes) },
1464
+ marks: { ...baseMarks, ...Object.fromEntries(extraMarks) }
1388
1465
  });
1389
1466
  }
1390
- 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;
1391
1468
  var init_schema = __esm({
1392
1469
  "src/schema.ts"() {
1393
1470
  "use strict";
@@ -1436,32 +1513,61 @@ var init_schema = __esm({
1436
1513
  };
1437
1514
  CELL_VALIGN = ["top", "middle", "bottom"];
1438
1515
  MAX_SPAN = 100;
1439
- nodes = {
1516
+ NO_CLASSES = () => false;
1517
+ CLASS_TOKEN = /^-?[_a-zA-Z][\w-]*$/;
1518
+ classSpec = { class: { default: null } };
1519
+ buildNodes2 = (allow) => ({
1440
1520
  doc: { content: "block+" },
1441
1521
  paragraph: {
1442
1522
  group: "block",
1443
1523
  content: "inline*",
1444
- attrs: { ...blockStyleSpec },
1445
- parseDOM: [{ tag: "p", getAttrs: (dom) => readBlockStyle(dom) }],
1446
- toDOM: (node) => ["p", blockStyleAttrs(node.attrs), 0]
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
+ ]
1447
1539
  },
1448
1540
  heading: {
1449
1541
  group: "block",
1450
1542
  content: "inline*",
1451
1543
  defining: true,
1452
- attrs: { level: { default: 1 }, ...blockStyleSpec },
1544
+ attrs: { level: { default: 1 }, ...blockStyleSpec, ...classSpec },
1453
1545
  parseDOM: [1, 2, 3, 4, 5, 6].map((level) => ({
1454
1546
  tag: `h${level}`,
1455
- getAttrs: (dom) => ({ level, ...readBlockStyle(dom) })
1547
+ getAttrs: (dom) => ({
1548
+ level,
1549
+ ...readBlockStyle(dom),
1550
+ class: readClass(dom, allow)
1551
+ })
1456
1552
  })),
1457
- toDOM: (node) => [`h${node.attrs.level}`, blockStyleAttrs(node.attrs), 0]
1553
+ toDOM: (node) => [
1554
+ `h${node.attrs.level}`,
1555
+ { ...classAttr(node.attrs.class), ...blockStyleAttrs(node.attrs) },
1556
+ 0
1557
+ ]
1458
1558
  },
1459
1559
  blockquote: {
1460
1560
  group: "block",
1461
1561
  content: "block+",
1462
1562
  defining: true,
1463
- parseDOM: [{ tag: "blockquote" }],
1464
- toDOM: () => ["blockquote", 0]
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]
1465
1571
  },
1466
1572
  horizontal_rule: {
1467
1573
  group: "block",
@@ -1503,7 +1609,11 @@ var init_schema = __esm({
1503
1609
  })
1504
1610
  }
1505
1611
  ],
1506
- toDOM: (node) => ["ul", listStyleAttrs(node.attrs.listStyle, BULLET_STYLES), 0]
1612
+ toDOM: (node) => [
1613
+ "ul",
1614
+ listStyleAttrs(node.attrs.listStyle, BULLET_STYLES),
1615
+ 0
1616
+ ]
1507
1617
  },
1508
1618
  ordered_list: {
1509
1619
  group: "block",
@@ -1547,7 +1657,8 @@ var init_schema = __esm({
1547
1657
  title: { default: null },
1548
1658
  width: { default: null },
1549
1659
  height: { default: null },
1550
- align: { default: null }
1660
+ align: { default: null },
1661
+ ...classSpec
1551
1662
  },
1552
1663
  parseDOM: [
1553
1664
  {
@@ -1561,7 +1672,8 @@ var init_schema = __esm({
1561
1672
  title: el.getAttribute("title"),
1562
1673
  width: imageSize(el.getAttribute("width") ?? el.style.width),
1563
1674
  height: imageSize(el.getAttribute("height") ?? el.style.height),
1564
- align: readImageAlign(el)
1675
+ align: readImageAlign(el),
1676
+ class: readClass(el, allow)
1565
1677
  };
1566
1678
  }
1567
1679
  }
@@ -1576,6 +1688,7 @@ var init_schema = __esm({
1576
1688
  "img",
1577
1689
  {
1578
1690
  src,
1691
+ ...classAttr(node.attrs.class),
1579
1692
  ...alt ? { alt } : {},
1580
1693
  ...title ? { title } : {},
1581
1694
  ...width ? { width: String(width) } : {},
@@ -1592,9 +1705,10 @@ var init_schema = __esm({
1592
1705
  parseDOM: [{ tag: "br" }],
1593
1706
  toDOM: () => ["br"]
1594
1707
  },
1595
- ...buildTableNodes()
1596
- };
1597
- marks = {
1708
+ ...buildTableNodes(allow)
1709
+ });
1710
+ nodes = buildNodes2(NO_CLASSES);
1711
+ buildMarks = (allow) => ({
1598
1712
  link: {
1599
1713
  attrs: { href: {}, title: { default: null }, target: { default: null } },
1600
1714
  inclusive: false,
@@ -1702,8 +1816,25 @@ var init_schema = __esm({
1702
1816
  attrs: { value: {} },
1703
1817
  parseDOM: [{ style: "font-size", getAttrs: (v) => styleAttr(cssValue.length(v)) }],
1704
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]
1705
1835
  }
1706
- };
1836
+ });
1837
+ marks = buildMarks(NO_CLASSES);
1707
1838
  schema = new import_prosemirror_model2.Schema({ nodes, marks });
1708
1839
  }
1709
1840
  });
@@ -1718,14 +1849,14 @@ function insertText2(editor, text) {
1718
1849
  dispatch(state.tr.insertText(text).scrollIntoView());
1719
1850
  editor.focus();
1720
1851
  }
1721
- var ICON4, LABELS7, FORMATS, insertdatetime_default;
1852
+ var ICON4, LABELS8, FORMATS, insertdatetime_default;
1722
1853
  var init_insertdatetime = __esm({
1723
1854
  "src/plugins/insertdatetime.ts"() {
1724
1855
  "use strict";
1725
1856
  init_icons();
1726
1857
  init_plugins();
1727
1858
  ICON4 = icons.dateTime;
1728
- LABELS7 = {
1859
+ LABELS8 = {
1729
1860
  en: {
1730
1861
  title: "Insert date/time",
1731
1862
  date: "Date",
@@ -1752,7 +1883,7 @@ var init_insertdatetime = __esm({
1752
1883
  toolbar: "insertdatetime",
1753
1884
  setup(editor) {
1754
1885
  const lang = editor.options.language ?? "en";
1755
- const labels = LABELS7[lang.split("-")[0]] ?? LABELS7.en;
1886
+ const labels = LABELS8[lang.split("-")[0]] ?? LABELS8.en;
1756
1887
  const now = () => editor.options.pluginOptions?.insertdatetime?.now?.() ?? /* @__PURE__ */ new Date();
1757
1888
  const format = (kind) => new Intl.DateTimeFormat(lang, FORMATS[kind]).format(now());
1758
1889
  editor.ui.registry.addMenuItem("insertdatetime", {
@@ -2124,8 +2255,8 @@ function dataImageSrcs(doc, type) {
2124
2255
  return srcs;
2125
2256
  }
2126
2257
  function embeddedImageUploadPlugin(editor) {
2127
- return new import_prosemirror_state5.Plugin({
2128
- key: new import_prosemirror_state5.PluginKey("nova-embedded-image-upload"),
2258
+ return new import_prosemirror_state6.Plugin({
2259
+ key: new import_prosemirror_state6.PluginKey("nova-embedded-image-upload"),
2129
2260
  appendTransaction(transactions, oldState, newState) {
2130
2261
  if (!editor.options.uploadImage) return null;
2131
2262
  const fromUser = transactions.some(
@@ -2142,8 +2273,8 @@ function embeddedImageUploadPlugin(editor) {
2142
2273
  });
2143
2274
  }
2144
2275
  function imageDropPastePlugin(editor) {
2145
- return new import_prosemirror_state5.Plugin({
2146
- key: new import_prosemirror_state5.PluginKey("nova-image-drop-paste"),
2276
+ return new import_prosemirror_state6.Plugin({
2277
+ key: new import_prosemirror_state6.PluginKey("nova-image-drop-paste"),
2147
2278
  props: {
2148
2279
  handlePaste(_view, event) {
2149
2280
  if (!editor.isAllowed("image")) return false;
@@ -2183,6 +2314,9 @@ function openImageDialog(editor) {
2183
2314
  );
2184
2315
  const url = textField({ label: t("image.url"), type: "url", placeholder: "https://" });
2185
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
+ });
2186
2320
  const body = h(
2187
2321
  "div",
2188
2322
  { className: "nova-form" },
@@ -2229,7 +2363,7 @@ function openImageDialog(editor) {
2229
2363
  }
2230
2364
  function getSelectedImage(state) {
2231
2365
  const { selection } = state;
2232
- if (selection instanceof import_prosemirror_state5.NodeSelection && selection.node.type === nodesOf(state).image) {
2366
+ if (selection instanceof import_prosemirror_state6.NodeSelection && selection.node.type === nodesOf(state).image) {
2233
2367
  return { node: selection.node, pos: selection.from };
2234
2368
  }
2235
2369
  return null;
@@ -2240,7 +2374,7 @@ function setImageAttrs(attrs) {
2240
2374
  if (!image) return false;
2241
2375
  if (dispatch) {
2242
2376
  const tr = state.tr.setNodeMarkup(image.pos, void 0, { ...image.node.attrs, ...attrs });
2243
- tr.setSelection(import_prosemirror_state5.NodeSelection.create(tr.doc, image.pos));
2377
+ tr.setSelection(import_prosemirror_state6.NodeSelection.create(tr.doc, image.pos));
2244
2378
  dispatch(tr);
2245
2379
  }
2246
2380
  return true;
@@ -2284,11 +2418,12 @@ function openImageAltDialog(editor) {
2284
2418
  }
2285
2419
  });
2286
2420
  }
2287
- var import_prosemirror_state5, IMAGE_TYPES, DATA_IMAGE;
2421
+ var import_prosemirror_state6, IMAGE_TYPES, DATA_IMAGE;
2288
2422
  var init_image = __esm({
2289
2423
  "src/image.ts"() {
2290
2424
  "use strict";
2291
- import_prosemirror_state5 = require("prosemirror-state");
2425
+ init_file_picker();
2426
+ import_prosemirror_state6 = require("prosemirror-state");
2292
2427
  init_commands();
2293
2428
  init_commands();
2294
2429
  init_dialog();
@@ -2364,6 +2499,10 @@ function openLinkDialog(editor) {
2364
2499
  const text = textField({ label: t("link.text"), value: selectedText });
2365
2500
  const title = textField({ label: t("link.tooltip"), value: existing?.title ?? "" });
2366
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
+ });
2367
2506
  const body = h(
2368
2507
  "div",
2369
2508
  { className: "nova-form" },
@@ -2399,6 +2538,7 @@ function openLinkDialog(editor) {
2399
2538
  var init_link = __esm({
2400
2539
  "src/link.ts"() {
2401
2540
  "use strict";
2541
+ init_file_picker();
2402
2542
  init_commands();
2403
2543
  init_commands();
2404
2544
  init_dialog();
@@ -2431,7 +2571,7 @@ function insertTable(rows, cols, withHeader = true) {
2431
2571
  if (n === node) tablePos = pos;
2432
2572
  return tablePos < 0;
2433
2573
  });
2434
- if (tablePos >= 0) tr.setSelection(import_prosemirror_state6.TextSelection.near(tr.doc.resolve(tablePos + 3)));
2574
+ if (tablePos >= 0) tr.setSelection(import_prosemirror_state7.TextSelection.near(tr.doc.resolve(tablePos + 3)));
2435
2575
  dispatch(tr.scrollIntoView());
2436
2576
  }
2437
2577
  return true;
@@ -2439,7 +2579,9 @@ function insertTable(rows, cols, withHeader = true) {
2439
2579
  }
2440
2580
  function tablePlugins() {
2441
2581
  return [
2442
- (0, import_prosemirror_tables2.columnResizing)({ cellMinWidth: 48, View: NovaTableView }),
2582
+ // defaultCellMinWidth — минимум для столбцов без заданной ширины (по умолчанию 100px:
2583
+ // таблица из 5+ столбцов раньше времени вылезала за край узкого редактора).
2584
+ (0, import_prosemirror_tables2.columnResizing)({ cellMinWidth: 48, defaultCellMinWidth: 48, View: NovaTableView }),
2443
2585
  (0, import_prosemirror_tables2.tableEditing)(),
2444
2586
  (0, import_prosemirror_keymap3.keymap)({
2445
2587
  Tab: nextCellOrNewRow,
@@ -2590,14 +2732,24 @@ function sortTable(direction, locale) {
2590
2732
  }
2591
2733
  function getTableProps(state) {
2592
2734
  const found = (0, import_prosemirror_tables2.findTable)(state.selection.$from);
2593
- return found ? { width: found.node.attrs.width ?? null, align: found.node.attrs.align ?? null } : null;
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;
2594
2740
  }
2595
2741
  function setTableProps(props) {
2596
2742
  return (state, dispatch) => {
2597
2743
  const found = (0, import_prosemirror_tables2.findTable)(state.selection.$from);
2598
2744
  if (!found) return false;
2599
2745
  if (props.width !== null && !cssValue.length(props.width)) return false;
2600
- dispatch?.(state.tr.setNodeMarkup(found.pos, void 0, { ...found.node.attrs, ...props }));
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));
2601
2753
  return true;
2602
2754
  };
2603
2755
  }
@@ -2625,7 +2777,8 @@ function getCellProps(state) {
2625
2777
  return {
2626
2778
  valign: cell.node.attrs.valign ?? null,
2627
2779
  header: cell.node.type === state.schema.nodes.table_header,
2628
- width: widths?.[0] ?? null
2780
+ width: widths?.[0] ?? null,
2781
+ class: cell.node.attrs.class ?? null
2629
2782
  };
2630
2783
  }
2631
2784
  function setCellProps(props) {
@@ -2640,7 +2793,8 @@ function setCellProps(props) {
2640
2793
  const type = props.header === void 0 ? node.type : props.header ? nodes2.table_header : nodes2.table_cell;
2641
2794
  const attrs = {
2642
2795
  ...node.attrs,
2643
- ...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 } : {}
2644
2798
  };
2645
2799
  tr.setNodeMarkup(pos, type, attrs);
2646
2800
  }
@@ -2673,13 +2827,13 @@ function setCellProps(props) {
2673
2827
  return true;
2674
2828
  };
2675
2829
  }
2676
- var import_prosemirror_keymap3, import_prosemirror_model3, import_prosemirror_state6, import_prosemirror_tables2, MAX_GRID, nextCellOrNewRow, tableCommands, NovaTableView;
2830
+ var import_prosemirror_keymap3, import_prosemirror_model3, import_prosemirror_state7, import_prosemirror_tables2, MAX_GRID, nextCellOrNewRow, tableCommands, NovaTableView;
2677
2831
  var init_table = __esm({
2678
2832
  "src/table.ts"() {
2679
2833
  "use strict";
2680
2834
  import_prosemirror_keymap3 = require("prosemirror-keymap");
2681
2835
  import_prosemirror_model3 = require("prosemirror-model");
2682
- import_prosemirror_state6 = require("prosemirror-state");
2836
+ import_prosemirror_state7 = require("prosemirror-state");
2683
2837
  import_prosemirror_tables2 = require("prosemirror-tables");
2684
2838
  init_schema();
2685
2839
  init_dom();
@@ -2728,6 +2882,9 @@ var init_table = __esm({
2728
2882
  const align = node.attrs.align;
2729
2883
  this.table.style.marginLeft = align ? "auto" : "";
2730
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");
2731
2888
  }
2732
2889
  };
2733
2890
  }
@@ -2744,7 +2901,7 @@ __export(quickbars_exports, {
2744
2901
  });
2745
2902
  function hasTextSelection(editor) {
2746
2903
  const { selection } = editor.view.state;
2747
- if (!(selection instanceof import_prosemirror_state7.TextSelection) || selection.empty) return false;
2904
+ if (!(selection instanceof import_prosemirror_state8.TextSelection) || selection.empty) return false;
2748
2905
  if (selection.$from.parent.type.spec.code) return false;
2749
2906
  return editor.view.state.doc.textBetween(selection.from, selection.to).trim().length > 0;
2750
2907
  }
@@ -2764,11 +2921,11 @@ function pickImage(editor) {
2764
2921
  });
2765
2922
  input.click();
2766
2923
  }
2767
- var import_prosemirror_state7, DEFAULT_SELECTION, DEFAULT_INSERT, quickbars_default;
2924
+ var import_prosemirror_state8, DEFAULT_SELECTION, DEFAULT_INSERT, quickbars_default;
2768
2925
  var init_quickbars = __esm({
2769
2926
  "src/plugins/quickbars.ts"() {
2770
2927
  "use strict";
2771
- import_prosemirror_state7 = require("prosemirror-state");
2928
+ import_prosemirror_state8 = require("prosemirror-state");
2772
2929
  init_image();
2773
2930
  init_link();
2774
2931
  init_plugins();
@@ -2829,7 +2986,7 @@ var charmap_exports = {};
2829
2986
  __export(charmap_exports, {
2830
2987
  default: () => charmap_default
2831
2988
  });
2832
- var ICON5, LABELS8, SYMBOLS, charmap_default;
2989
+ var ICON5, LABELS9, SYMBOLS, charmap_default;
2833
2990
  var init_charmap = __esm({
2834
2991
  "src/plugins/charmap.ts"() {
2835
2992
  "use strict";
@@ -2837,7 +2994,7 @@ var init_charmap = __esm({
2837
2994
  init_plugins();
2838
2995
  init_shared();
2839
2996
  ICON5 = icons.charmap;
2840
- LABELS8 = {
2997
+ LABELS9 = {
2841
2998
  en: {
2842
2999
  title: "Special character",
2843
3000
  search: "Search characters",
@@ -2992,7 +3149,7 @@ var init_charmap = __esm({
2992
3149
  name: "charmap",
2993
3150
  toolbar: "charmap",
2994
3151
  setup(editor) {
2995
- const labels = pickLabels(editor, LABELS8);
3152
+ const labels = pickLabels(editor, LABELS9);
2996
3153
  const groups = SYMBOLS.map((items, i) => ({ title: labels.groups[i], items }));
2997
3154
  const panel = (close) => symbolPanel({
2998
3155
  groups,
@@ -3025,7 +3182,7 @@ var emoticons_exports = {};
3025
3182
  __export(emoticons_exports, {
3026
3183
  default: () => emoticons_default
3027
3184
  });
3028
- var ICON6, LABELS9, EMOJI, emoticons_default;
3185
+ var ICON6, LABELS10, EMOJI, emoticons_default;
3029
3186
  var init_emoticons = __esm({
3030
3187
  "src/plugins/emoticons.ts"() {
3031
3188
  "use strict";
@@ -3033,7 +3190,7 @@ var init_emoticons = __esm({
3033
3190
  init_plugins();
3034
3191
  init_shared();
3035
3192
  ICON6 = icons.emoji;
3036
- LABELS9 = {
3193
+ LABELS10 = {
3037
3194
  en: {
3038
3195
  title: "Emoji",
3039
3196
  search: "Search emoji",
@@ -3191,7 +3348,7 @@ var init_emoticons = __esm({
3191
3348
  name: "emoticons",
3192
3349
  toolbar: "emoticons",
3193
3350
  setup(editor) {
3194
- const labels = pickLabels(editor, LABELS9);
3351
+ const labels = pickLabels(editor, LABELS10);
3195
3352
  const groups = EMOJI.map((items, i) => ({ title: labels.groups[i], items }));
3196
3353
  const all = EMOJI.flat();
3197
3354
  const panel = (close) => symbolPanel({
@@ -3240,7 +3397,7 @@ var nonbreaking_exports = {};
3240
3397
  __export(nonbreaking_exports, {
3241
3398
  default: () => nonbreaking_default
3242
3399
  });
3243
- var import_prosemirror_keymap4, NBSP, ICON7, LABELS10, nonbreaking_default;
3400
+ var import_prosemirror_keymap4, NBSP, ICON7, LABELS11, nonbreaking_default;
3244
3401
  var init_nonbreaking = __esm({
3245
3402
  "src/plugins/nonbreaking.ts"() {
3246
3403
  "use strict";
@@ -3250,7 +3407,7 @@ var init_nonbreaking = __esm({
3250
3407
  init_shared();
3251
3408
  NBSP = String.fromCharCode(160);
3252
3409
  ICON7 = icons.nonBreaking;
3253
- LABELS10 = { en: { title: "Nonbreaking space" }, ru: { title: "\u041D\u0435\u0440\u0430\u0437\u0440\u044B\u0432\u043D\u044B\u0439 \u043F\u0440\u043E\u0431\u0435\u043B" } };
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" } };
3254
3411
  nonbreaking_default = definePlugin({
3255
3412
  name: "nonbreaking",
3256
3413
  toolbar: "nonbreaking",
@@ -3263,7 +3420,7 @@ var init_nonbreaking = __esm({
3263
3420
  })
3264
3421
  ],
3265
3422
  setup(editor) {
3266
- const { title } = pickLabels(editor, LABELS10);
3423
+ const { title } = pickLabels(editor, LABELS11);
3267
3424
  const spec = {
3268
3425
  icon: ICON7,
3269
3426
  tooltip: title,
@@ -3308,12 +3465,12 @@ function linkifyBefore(state, tr, end) {
3308
3465
  tr.addMark(from, to, link.create({ href }));
3309
3466
  return true;
3310
3467
  }
3311
- var import_prosemirror_inputrules, import_prosemirror_state8, URL_AT_END, SINGLE_URL, autolink_default;
3468
+ var import_prosemirror_inputrules, import_prosemirror_state9, URL_AT_END, SINGLE_URL, autolink_default;
3312
3469
  var init_autolink = __esm({
3313
3470
  "src/plugins/autolink.ts"() {
3314
3471
  "use strict";
3315
3472
  import_prosemirror_inputrules = require("prosemirror-inputrules");
3316
- import_prosemirror_state8 = require("prosemirror-state");
3473
+ import_prosemirror_state9 = require("prosemirror-state");
3317
3474
  init_commands();
3318
3475
  init_plugins();
3319
3476
  init_url();
@@ -3334,7 +3491,7 @@ var init_autolink = __esm({
3334
3491
  })
3335
3492
  ]
3336
3493
  }),
3337
- new import_prosemirror_state8.Plugin({
3494
+ new import_prosemirror_state9.Plugin({
3338
3495
  /**
3339
3496
  * Enter после адреса. Раскладка клавиш ядра обрабатывает Enter раньше плагинов, поэтому смотрим
3340
3497
  * на результат: курсор в начале нового блока, а предыдущий блок заканчивается адресом.
@@ -3343,14 +3500,14 @@ var init_autolink = __esm({
3343
3500
  if (!editor.isAllowed("link") || !transactions.some((tr2) => tr2.docChanged)) return null;
3344
3501
  const { $from, empty } = state.selection;
3345
3502
  if (!empty || $from.parentOffset !== 0 || $from.depth < 1) return null;
3346
- const prev = import_prosemirror_state8.Selection.findFrom(state.doc.resolve($from.before()), -1, true);
3503
+ const prev = import_prosemirror_state9.Selection.findFrom(state.doc.resolve($from.before()), -1, true);
3347
3504
  if (!prev || !prev.empty || prev.$from.parentOffset !== prev.$from.parent.content.size)
3348
3505
  return null;
3349
3506
  const tr = state.tr;
3350
3507
  return linkifyBefore(state, tr, prev.from) ? tr : null;
3351
3508
  }
3352
3509
  }),
3353
- new import_prosemirror_state8.Plugin({
3510
+ new import_prosemirror_state9.Plugin({
3354
3511
  props: {
3355
3512
  handlePaste(view, event) {
3356
3513
  const { state } = view;
@@ -3385,7 +3542,7 @@ function storage() {
3385
3542
  return null;
3386
3543
  }
3387
3544
  }
3388
- var ICON8, LABELS11, autosave_default;
3545
+ var ICON8, LABELS12, autosave_default;
3389
3546
  var init_autosave = __esm({
3390
3547
  "src/plugins/autosave.ts"() {
3391
3548
  "use strict";
@@ -3393,7 +3550,7 @@ var init_autosave = __esm({
3393
3550
  init_plugins();
3394
3551
  init_shared();
3395
3552
  ICON8 = icons.save;
3396
- LABELS11 = {
3553
+ LABELS12 = {
3397
3554
  en: {
3398
3555
  restore: "Restore last draft",
3399
3556
  found: "An unsaved draft was found. Use \u201CRestore last draft\u201D to bring it back.",
@@ -3410,7 +3567,7 @@ var init_autosave = __esm({
3410
3567
  toolbar: "restoredraft",
3411
3568
  setup(editor) {
3412
3569
  const options = editor.options.pluginOptions?.autosave ?? {};
3413
- const labels = pickLabels(editor, LABELS11);
3570
+ const labels = pickLabels(editor, LABELS12);
3414
3571
  const store = storage();
3415
3572
  const key3 = options.key ?? `novaprose-draft:${typeof location === "undefined" ? "" : location.pathname}:${editor.options.element.id || "editor"}`;
3416
3573
  const delay = options.delay ?? 1e3;
@@ -3509,7 +3666,7 @@ var visualblocks_exports = {};
3509
3666
  __export(visualblocks_exports, {
3510
3667
  default: () => visualblocks_default
3511
3668
  });
3512
- var ICON9, LABELS12, visualblocks_default;
3669
+ var ICON9, LABELS13, visualblocks_default;
3513
3670
  var init_visualblocks = __esm({
3514
3671
  "src/plugins/visualblocks.ts"() {
3515
3672
  "use strict";
@@ -3517,12 +3674,12 @@ var init_visualblocks = __esm({
3517
3674
  init_plugins();
3518
3675
  init_shared();
3519
3676
  ICON9 = icons.visualBlocks;
3520
- LABELS12 = { en: { title: "Show blocks" }, ru: { title: "\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0431\u043B\u043E\u043A\u0438" } };
3677
+ LABELS13 = { en: { title: "Show blocks" }, ru: { title: "\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C \u0431\u043B\u043E\u043A\u0438" } };
3521
3678
  visualblocks_default = definePlugin({
3522
3679
  name: "visualblocks",
3523
3680
  toolbar: "visualblocks",
3524
3681
  setup(editor) {
3525
- const { title } = pickLabels(editor, LABELS12);
3682
+ const { title } = pickLabels(editor, LABELS13);
3526
3683
  const options = editor.options.pluginOptions?.visualblocks ?? {};
3527
3684
  const isOn = () => editor.root.classList.contains("nova-visualblocks");
3528
3685
  const toggle = () => {
@@ -3573,7 +3730,7 @@ function setDir(dir) {
3573
3730
  return true;
3574
3731
  };
3575
3732
  }
3576
- var ICONS, LABELS13, directionality_default;
3733
+ var ICONS, LABELS14, directionality_default;
3577
3734
  var init_directionality = __esm({
3578
3735
  "src/plugins/directionality.ts"() {
3579
3736
  "use strict";
@@ -3585,7 +3742,7 @@ var init_directionality = __esm({
3585
3742
  ltr: icons.ltr,
3586
3743
  rtl: icons.rtl
3587
3744
  };
3588
- LABELS13 = {
3745
+ LABELS14 = {
3589
3746
  en: { ltr: "Left to right", rtl: "Right to left" },
3590
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" }
3591
3748
  };
@@ -3593,7 +3750,7 @@ var init_directionality = __esm({
3593
3750
  name: "directionality",
3594
3751
  toolbar: "ltr rtl",
3595
3752
  setup(editor) {
3596
- const labels = pickLabels(editor, LABELS13);
3753
+ const labels = pickLabels(editor, LABELS14);
3597
3754
  for (const dir of ["ltr", "rtl"]) {
3598
3755
  const isActive = () => currentDir(editor) === dir;
3599
3756
  const onAction = () => {
@@ -3647,7 +3804,7 @@ function applyStyle(editor, kind, style, fallback) {
3647
3804
  );
3648
3805
  editor.focus();
3649
3806
  }
3650
- var LABELS14, advlist_default;
3807
+ var LABELS15, advlist_default;
3651
3808
  var init_advlist = __esm({
3652
3809
  "src/plugins/advlist.ts"() {
3653
3810
  "use strict";
@@ -3655,7 +3812,7 @@ var init_advlist = __esm({
3655
3812
  init_plugins();
3656
3813
  init_schema();
3657
3814
  init_shared();
3658
- LABELS14 = {
3815
+ LABELS15 = {
3659
3816
  en: {
3660
3817
  disc: "Default",
3661
3818
  circle: "Circle",
@@ -3682,7 +3839,7 @@ var init_advlist = __esm({
3682
3839
  advlist_default = definePlugin({
3683
3840
  name: "advlist",
3684
3841
  setup(editor) {
3685
- const labels = pickLabels(editor, LABELS14);
3842
+ const labels = pickLabels(editor, LABELS15);
3686
3843
  const options = editor.options.pluginOptions?.advlist ?? {};
3687
3844
  const lists = [
3688
3845
  {
@@ -3722,6 +3879,576 @@ var init_advlist = __esm({
3722
3879
  }
3723
3880
  });
3724
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
+
3725
4452
  // src/i18n/en.ts
3726
4453
  var en;
3727
4454
  var init_en = __esm({
@@ -3760,6 +4487,11 @@ var init_en = __esm({
3760
4487
  more: "More",
3761
4488
  moreFormats: "More formatting",
3762
4489
  blocks: "Text style",
4490
+ styles: "Formats",
4491
+ "styles.headings": "Headings",
4492
+ "styles.inline": "Inline",
4493
+ "styles.blocks": "Blocks",
4494
+ "styles.align": "Align",
3763
4495
  paragraph: "Paragraph",
3764
4496
  h1: "Heading 1",
3765
4497
  h2: "Heading 2",
@@ -3813,6 +4545,8 @@ var init_en = __esm({
3813
4545
  "image.sizeOriginal": "Original size",
3814
4546
  "image.delete": "Remove image",
3815
4547
  "status.words": "{count} words",
4548
+ "status.resize": "Resize editor",
4549
+ "dialog.browse": "Browse",
3816
4550
  pasteAsText: "Paste as text",
3817
4551
  "menu.label": "Menu",
3818
4552
  "menu.file": "File",
@@ -3874,6 +4608,8 @@ var init_en = __esm({
3874
4608
  "table.sortAsc": "Sort A \u2192 Z, 1 \u2192 9",
3875
4609
  "table.sortDesc": "Sort Z \u2192 A, 9 \u2192 1",
3876
4610
  "table.props": "Table properties",
4611
+ "table.style": "Style",
4612
+ "table.styleDefault": "Default",
3877
4613
  "table.width": "Width",
3878
4614
  "table.widthHint": "For example 100% or 600px. Leave empty to fit the content.",
3879
4615
  "table.invalidWidth": "Enter a width such as 100% or 600px",
@@ -3936,6 +4672,11 @@ var init_ru = __esm({
3936
4672
  more: "\u0415\u0449\u0451",
3937
4673
  moreFormats: "\u0415\u0449\u0451 \u0444\u043E\u0440\u043C\u0430\u0442\u0438\u0440\u043E\u0432\u0430\u043D\u0438\u0435",
3938
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",
3939
4680
  paragraph: "\u041E\u0431\u044B\u0447\u043D\u044B\u0439 \u0442\u0435\u043A\u0441\u0442",
3940
4681
  h1: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 1",
3941
4682
  h2: "\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043E\u043A 2",
@@ -3989,6 +4730,8 @@ var init_ru = __esm({
3989
4730
  "image.sizeOriginal": "\u0418\u0441\u0445\u043E\u0434\u043D\u044B\u0439 \u0440\u0430\u0437\u043C\u0435\u0440",
3990
4731
  "image.delete": "\u0423\u0434\u0430\u043B\u0438\u0442\u044C \u0438\u0437\u043E\u0431\u0440\u0430\u0436\u0435\u043D\u0438\u0435",
3991
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",
3992
4735
  pasteAsText: "\u0412\u0441\u0442\u0430\u0432\u043B\u044F\u0442\u044C \u043A\u0430\u043A \u0442\u0435\u043A\u0441\u0442",
3993
4736
  "menu.label": "\u041C\u0435\u043D\u044E",
3994
4737
  "menu.file": "\u0424\u0430\u0439\u043B",
@@ -4050,6 +4793,8 @@ var init_ru = __esm({
4050
4793
  "table.sortAsc": "\u0421\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u0410 \u2192 \u042F, 1 \u2192 9",
4051
4794
  "table.sortDesc": "\u0421\u043E\u0440\u0442\u0438\u0440\u043E\u0432\u0430\u0442\u044C \u042F \u2192 \u0410, 9 \u2192 1",
4052
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",
4053
4798
  "table.width": "\u0428\u0438\u0440\u0438\u043D\u0430",
4054
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.",
4055
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",
@@ -4162,18 +4907,18 @@ function buildKeymap(resolve = (name) => commands[name]) {
4162
4907
  "Shift-Tab": commands.outdent
4163
4908
  };
4164
4909
  if (!mac) keys["Mod-y"] = byName(resolve, "redo");
4165
- return [(0, import_prosemirror_keymap5.keymap)(keys), (0, import_prosemirror_keymap5.keymap)(import_prosemirror_commands2.baseKeymap)];
4910
+ return [(0, import_prosemirror_keymap5.keymap)(keys), (0, import_prosemirror_keymap5.keymap)(import_prosemirror_commands3.baseKeymap)];
4166
4911
  }
4167
- var import_prosemirror_commands2, import_prosemirror_keymap5, import_prosemirror_schema_list2, mac, insertHardBreak, byName;
4912
+ var import_prosemirror_commands3, import_prosemirror_keymap5, import_prosemirror_schema_list2, mac, insertHardBreak, byName;
4168
4913
  var init_keymap = __esm({
4169
4914
  "src/keymap.ts"() {
4170
4915
  "use strict";
4171
- import_prosemirror_commands2 = require("prosemirror-commands");
4916
+ import_prosemirror_commands3 = require("prosemirror-commands");
4172
4917
  import_prosemirror_keymap5 = require("prosemirror-keymap");
4173
4918
  import_prosemirror_schema_list2 = require("prosemirror-schema-list");
4174
4919
  init_commands();
4175
4920
  mac = typeof navigator !== "undefined" && /Mac|iP(hone|[oa]d)/.test(navigator.platform);
4176
- insertHardBreak = (0, import_prosemirror_commands2.chainCommands)(import_prosemirror_commands2.exitCode, (state, dispatch) => {
4921
+ insertHardBreak = (0, import_prosemirror_commands3.chainCommands)(import_prosemirror_commands3.exitCode, (state, dispatch) => {
4177
4922
  dispatch?.(state.tr.replaceSelectionWith(nodesOf(state).hard_break.create()).scrollIntoView());
4178
4923
  return true;
4179
4924
  });
@@ -4216,6 +4961,8 @@ function cleanPastedHTML(html, styles = "clean") {
4216
4961
  removeBreaksBetweenBlocks(root);
4217
4962
  normalizeEmptyParagraphs(root);
4218
4963
  wrapCellContent(root);
4964
+ if (source !== "web")
4965
+ root.querySelectorAll("[class]").forEach((el) => el.removeAttribute("class"));
4219
4966
  return root.innerHTML;
4220
4967
  }
4221
4968
  function parseDeclarations(css) {
@@ -4737,7 +5484,7 @@ function htmlToPlainText(html) {
4737
5484
  }
4738
5485
  function pastePlugin(editor) {
4739
5486
  let reentrant = false;
4740
- return new import_prosemirror_state9.Plugin({
5487
+ return new import_prosemirror_state11.Plugin({
4741
5488
  key,
4742
5489
  props: {
4743
5490
  /**
@@ -4796,15 +5543,15 @@ function pastePlugin(editor) {
4796
5543
  }
4797
5544
  });
4798
5545
  }
4799
- var import_prosemirror_model4, import_prosemirror_state9, key;
5546
+ var import_prosemirror_model4, import_prosemirror_state11, key;
4800
5547
  var init_paste = __esm({
4801
5548
  "src/paste.ts"() {
4802
5549
  "use strict";
4803
5550
  import_prosemirror_model4 = require("prosemirror-model");
4804
- import_prosemirror_state9 = require("prosemirror-state");
5551
+ import_prosemirror_state11 = require("prosemirror-state");
4805
5552
  init_paste_office();
4806
5553
  init_paste_rtf();
4807
- key = new import_prosemirror_state9.PluginKey("nova-paste");
5554
+ key = new import_prosemirror_state11.PluginKey("nova-paste");
4808
5555
  }
4809
5556
  });
4810
5557
 
@@ -4834,12 +5581,21 @@ var init_parser = __esm({
4834
5581
  init_schema();
4835
5582
  CELL_BG_ATTR = "data-nova-cell-bg";
4836
5583
  NovaDOMParser = class extends import_prosemirror_model5.DOMParser {
4837
- parse(dom, options) {
5584
+ atomSelector;
5585
+ prepare(dom) {
4838
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);
4839
5595
  return super.parse(dom, options);
4840
5596
  }
4841
5597
  parseSlice(dom, options) {
4842
- preprocessDOM(dom);
5598
+ this.prepare(dom);
4843
5599
  return super.parseSlice(dom, options);
4844
5600
  }
4845
5601
  };
@@ -4852,12 +5608,18 @@ var init_parser = __esm({
4852
5608
  function createMenu(entries, onDone, label) {
4853
5609
  const items = [];
4854
5610
  const menu = h("div", { className: "nova-menu", role: "menu", "aria-label": label });
4855
- const hasChecks = entries.some((e) => e.type !== "separator" && e.active !== void 0);
5611
+ const hasChecks = entries.some(
5612
+ (e) => (e.type === void 0 || e.type === "item") && e.active !== void 0
5613
+ );
4856
5614
  for (const entry of entries) {
4857
5615
  if (entry.type === "separator") {
4858
5616
  menu.append(h("div", { className: "nova-menu-sep", role: "separator" }));
4859
5617
  continue;
4860
5618
  }
5619
+ if (entry.type === "heading") {
5620
+ menu.append(h("div", { className: "nova-menu-heading", role: "presentation" }, entry.label));
5621
+ continue;
5622
+ }
4861
5623
  const labelEl = h("span", { className: "nova-menu-label" }, entry.label);
4862
5624
  if (entry.labelStyle) labelEl.setAttribute("style", entry.labelStyle);
4863
5625
  const button = h(
@@ -5157,7 +5919,7 @@ function registerMenuItems(editor) {
5157
5919
  text: t("selectAll"),
5158
5920
  shortcut: "Mod-a",
5159
5921
  onAction: (e) => {
5160
- e.view.dispatch(e.view.state.tr.setSelection(new import_prosemirror_state10.AllSelection(e.view.state.doc)));
5922
+ e.view.dispatch(e.view.state.tr.setSelection(new import_prosemirror_state12.AllSelection(e.view.state.doc)));
5161
5923
  e.focus();
5162
5924
  }
5163
5925
  });
@@ -5174,12 +5936,12 @@ function registerMenuItems(editor) {
5174
5936
  onAction: (e) => openInsertTableDialog(e)
5175
5937
  });
5176
5938
  }
5177
- var import_prosemirror_model6, import_prosemirror_state10, PRINT_CSS;
5939
+ var import_prosemirror_model6, import_prosemirror_state12, PRINT_CSS;
5178
5940
  var init_menu_items = __esm({
5179
5941
  "src/ui/menu-items.ts"() {
5180
5942
  "use strict";
5181
5943
  import_prosemirror_model6 = require("prosemirror-model");
5182
- import_prosemirror_state10 = require("prosemirror-state");
5944
+ import_prosemirror_state12 = require("prosemirror-state");
5183
5945
  init_table();
5184
5946
  init_dialog();
5185
5947
  init_dom();
@@ -5248,7 +6010,7 @@ function flattenTable(fragment) {
5248
6010
  return out;
5249
6011
  }
5250
6012
  function contentRulesPlugin(rules) {
5251
- return new import_prosemirror_state11.Plugin({
6013
+ return new import_prosemirror_state13.Plugin({
5252
6014
  key: key2,
5253
6015
  appendTransaction(transactions, oldState, newState) {
5254
6016
  if (!transactions.some((tr2) => tr2.docChanged)) return null;
@@ -5279,12 +6041,12 @@ function contentRulesPlugin(rules) {
5279
6041
  }
5280
6042
  });
5281
6043
  }
5282
- var import_prosemirror_model7, import_prosemirror_state11, ALIASES, KNOWN_TAGS, KNOWN_STYLES, REQUIREMENTS, ContentRules, key2;
6044
+ var import_prosemirror_model7, import_prosemirror_state13, ALIASES, KNOWN_TAGS, KNOWN_STYLES, REQUIREMENTS, ContentRules, key2;
5283
6045
  var init_content_rules = __esm({
5284
6046
  "src/content-rules.ts"() {
5285
6047
  "use strict";
5286
6048
  import_prosemirror_model7 = require("prosemirror-model");
5287
- import_prosemirror_state11 = require("prosemirror-state");
6049
+ import_prosemirror_state13 = require("prosemirror-state");
5288
6050
  ALIASES = {
5289
6051
  b: "strong",
5290
6052
  i: "em",
@@ -5544,7 +6306,7 @@ var init_content_rules = __esm({
5544
6306
  return doc.type.createAndFill(null, content.size ? content : schema2.nodes.paragraph.create());
5545
6307
  }
5546
6308
  };
5547
- key2 = new import_prosemirror_state11.PluginKey("nova-content-rules");
6309
+ key2 = new import_prosemirror_state13.PluginKey("nova-content-rules");
5548
6310
  }
5549
6311
  });
5550
6312
 
@@ -5582,7 +6344,7 @@ function indexFrom(matches, pos) {
5582
6344
  return i < 0 ? 0 : i;
5583
6345
  }
5584
6346
  function searchPlugin() {
5585
- return new import_prosemirror_state12.Plugin({
6347
+ return new import_prosemirror_state14.Plugin({
5586
6348
  key: searchKey,
5587
6349
  state: {
5588
6350
  init: () => EMPTY,
@@ -5629,7 +6391,7 @@ function setSearch(options) {
5629
6391
  };
5630
6392
  }
5631
6393
  function gotoMatch(tr, match, index) {
5632
- return tr.setMeta(searchKey, { type: "goto", index }).setSelection(import_prosemirror_state12.TextSelection.create(tr.doc, match.from, match.to)).scrollIntoView();
6394
+ return tr.setMeta(searchKey, { type: "goto", index }).setSelection(import_prosemirror_state14.TextSelection.create(tr.doc, match.from, match.to)).scrollIntoView();
5633
6395
  }
5634
6396
  function findNext(dir = 1) {
5635
6397
  return (state, dispatch) => {
@@ -5652,7 +6414,7 @@ function replaceCurrent(replacement) {
5652
6414
  if (replacement) tr.replaceWith(match.from, match.to, state.schema.text(replacement, marks2));
5653
6415
  else tr.delete(match.from, match.to);
5654
6416
  const after = tr.mapping.map(match.to);
5655
- dispatch(tr.setSelection(import_prosemirror_state12.TextSelection.create(tr.doc, after)).scrollIntoView());
6417
+ dispatch(tr.setSelection(import_prosemirror_state14.TextSelection.create(tr.doc, after)).scrollIntoView());
5656
6418
  }
5657
6419
  return true;
5658
6420
  };
@@ -5674,15 +6436,15 @@ function replaceAll(replacement) {
5674
6436
  return true;
5675
6437
  };
5676
6438
  }
5677
- var import_prosemirror_state12, import_prosemirror_view3, MAX_MATCHES, LEAF, searchKey, EMPTY, clearSearch;
6439
+ var import_prosemirror_state14, import_prosemirror_view3, MAX_MATCHES, LEAF, searchKey, EMPTY, clearSearch;
5678
6440
  var init_search = __esm({
5679
6441
  "src/search.ts"() {
5680
6442
  "use strict";
5681
- import_prosemirror_state12 = require("prosemirror-state");
6443
+ import_prosemirror_state14 = require("prosemirror-state");
5682
6444
  import_prosemirror_view3 = require("prosemirror-view");
5683
6445
  MAX_MATCHES = 1e4;
5684
6446
  LEAF = "\uFFFC";
5685
- searchKey = new import_prosemirror_state12.PluginKey("nova-search");
6447
+ searchKey = new import_prosemirror_state14.PluginKey("nova-search");
5686
6448
  EMPTY = {
5687
6449
  query: "",
5688
6450
  caseSensitive: false,
@@ -6082,7 +6844,7 @@ function renderSpec(spec) {
6082
6844
  for (const [name, value] of Object.entries(first)) {
6083
6845
  if (value === null || value === void 0) continue;
6084
6846
  const attrName = name.includes(" ") ? name.split(" ")[1] : name;
6085
- if (!ATTR_RE.test(attrName)) continue;
6847
+ if (!ATTR_RE2.test(attrName)) continue;
6086
6848
  const safe = safeAttr(attrName, String(value));
6087
6849
  if (safe === null) continue;
6088
6850
  attrs += ` ${attrName}="${escapeAttr(safe)}"`;
@@ -6118,7 +6880,7 @@ function renderSpec(spec) {
6118
6880
  const close = `</${tag}>`;
6119
6881
  return { open: open + before, close: after + close, hole, html: open + before + after + close };
6120
6882
  }
6121
- var VOID_ELEMENTS, NBSP2, TAG_RE, FORBIDDEN_TAGS, LINK_ATTRS, RESOURCE_ATTRS, UNSAFE_CSS, reported, ATTR_RE, HTMLSerializer;
6883
+ var VOID_ELEMENTS, NBSP2, TAG_RE, FORBIDDEN_TAGS, LINK_ATTRS, RESOURCE_ATTRS, UNSAFE_CSS, reported, ATTR_RE2, HTMLSerializer;
6122
6884
  var init_serializer = __esm({
6123
6885
  "src/serializer.ts"() {
6124
6886
  "use strict";
@@ -6158,7 +6920,7 @@ var init_serializer = __esm({
6158
6920
  RESOURCE_ATTRS = /* @__PURE__ */ new Set(["src", "poster", "data", "background"]);
6159
6921
  UNSAFE_CSS = /url\s*\(|expression\s*\(|javascript:|@import|behavior\s*:|-moz-binding/i;
6160
6922
  reported = /* @__PURE__ */ new Set();
6161
- ATTR_RE = /^[a-z_:][a-z0-9_.:-]*$/i;
6923
+ ATTR_RE2 = /^[a-z_:][a-z0-9_.:-]*$/i;
6162
6924
  HTMLSerializer = class {
6163
6925
  cache = /* @__PURE__ */ new Map();
6164
6926
  serializeFragment(fragment) {
@@ -6492,6 +7254,15 @@ function registerTableUi(editor) {
6492
7254
  items: "tableinsertrowbefore tableinsertrowafter tabledeleterow | tableinsertcolbefore tableinsertcolafter tabledeletecol | tablemergecells tablesplitcells | tablerowheader tablecolheader tablecellbackground | advtablesort tablecellprops tableprops | tabledelete"
6493
7255
  });
6494
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
+ }
6495
7266
  function openTableProps(editor) {
6496
7267
  const { t } = editor.ui;
6497
7268
  const current = getTableProps(editor.view.state);
@@ -6510,15 +7281,17 @@ function openTableProps(editor) {
6510
7281
  { value: "right", label: t("table.alignRight") }
6511
7282
  ]
6512
7283
  });
7284
+ const styles = classSelect(editor, editor.options.tableClassList, current.class ?? null);
6513
7285
  editor.ui.openDialog({
6514
7286
  title: t("table.props"),
6515
- body: h("div", { className: "nova-form" }, width.el, align.el),
7287
+ body: h("div", { className: "nova-form" }, styles?.el ?? null, width.el, align.el),
6516
7288
  submitLabel: t("dialog.save"),
6517
7289
  onSubmit: () => {
6518
7290
  const raw = width.input.value.trim().replace(/^(\d+(\.\d+)?)$/, "$1px");
6519
7291
  const props = {
6520
7292
  width: raw || null,
6521
- align: align.select.value || null
7293
+ align: align.select.value || null,
7294
+ ...styles ? { class: styles.select.value || null } : {}
6522
7295
  };
6523
7296
  return editor.exec(setTableProps(props)) || t("table.invalidWidth");
6524
7297
  }
@@ -6551,9 +7324,10 @@ function openCellProps(editor) {
6551
7324
  hint: t("table.colWidthHint"),
6552
7325
  value: current.width ? String(current.width) : ""
6553
7326
  });
7327
+ const styles = classSelect(editor, editor.options.tableCellClassList, current.class ?? null);
6554
7328
  editor.ui.openDialog({
6555
7329
  title: t("table.cellProps"),
6556
- 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),
6557
7331
  submitLabel: t("dialog.save"),
6558
7332
  onSubmit: () => {
6559
7333
  const rawWidth = width.input.value.trim();
@@ -6564,7 +7338,8 @@ function openCellProps(editor) {
6564
7338
  setCellProps({
6565
7339
  valign: valign.select.value || null,
6566
7340
  header: type.select.value === "th",
6567
- width: px
7341
+ width: px,
7342
+ ...styles ? { class: styles.select.value || null } : {}
6568
7343
  })
6569
7344
  );
6570
7345
  return true;
@@ -6699,20 +7474,133 @@ function registerBuiltins(editor) {
6699
7474
  onAction: (e) => e.exec(currentBlock() === command ? "paragraph" : command)
6700
7475
  });
6701
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
+ };
6702
7496
  registry2.addMenuButton("blocks", {
6703
7497
  tooltip: t("blocks"),
6704
- label: () => t(currentBlock()),
7498
+ label: () => blockList().find((i) => i.command === currentBlock())?.label ?? t(currentBlock()),
6705
7499
  minChars: 11,
6706
- isEnabled: (e) => blockItems.some(({ command }) => e.can(command)),
6707
- items: (e) => blockItems.filter(({ command }) => e.isAllowed(command)).map(({ command, style }) => ({
7500
+ isEnabled: (e) => blockList().some(({ command }) => e.can(command)),
7501
+ items: (e) => blockList().filter(({ command }) => e.isAllowed(command)).map(({ command, style, label }) => ({
6708
7502
  id: command,
6709
- label: t(command),
7503
+ label: label ?? t(command),
6710
7504
  labelStyle: style,
6711
7505
  ...SHORTCUTS2[command] ? { shortcut: SHORTCUTS2[command] } : {},
6712
7506
  active: currentBlock() === command,
6713
7507
  onSelect: () => e.exec(command)
6714
7508
  }))
6715
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
+ });
6716
7604
  const families = editor.options.fontFamilies ?? defaultFontFamilies;
6717
7605
  registry2.addMenuButton("fontfamily", {
6718
7606
  tooltip: t("fontFamily"),
@@ -7111,8 +7999,8 @@ var init_popover = __esm({
7111
7999
 
7112
8000
  // src/ui/link-bubble.ts
7113
8001
  function linkBubblePlugin(editor) {
7114
- return new import_prosemirror_state13.Plugin({
7115
- key: new import_prosemirror_state13.PluginKey("nova-link-bubble"),
8002
+ return new import_prosemirror_state15.Plugin({
8003
+ key: new import_prosemirror_state15.PluginKey("nova-link-bubble"),
7116
8004
  view(view) {
7117
8005
  const { t } = editor.ui;
7118
8006
  const anchor = h("a", {
@@ -7193,11 +8081,11 @@ function linkBubblePlugin(editor) {
7193
8081
  }
7194
8082
  });
7195
8083
  }
7196
- var import_prosemirror_state13;
8084
+ var import_prosemirror_state15;
7197
8085
  var init_link_bubble = __esm({
7198
8086
  "src/ui/link-bubble.ts"() {
7199
8087
  "use strict";
7200
- import_prosemirror_state13 = require("prosemirror-state");
8088
+ import_prosemirror_state15 = require("prosemirror-state");
7201
8089
  init_commands();
7202
8090
  init_link();
7203
8091
  init_commands();
@@ -7522,8 +8410,8 @@ var init_toolbar = __esm({
7522
8410
 
7523
8411
  // src/ui/context-toolbar.ts
7524
8412
  function contextToolbarPlugin(editor) {
7525
- return new import_prosemirror_state14.Plugin({
7526
- key: new import_prosemirror_state14.PluginKey("nova-context-toolbar"),
8413
+ return new import_prosemirror_state16.Plugin({
8414
+ key: new import_prosemirror_state16.PluginKey("nova-context-toolbar"),
7527
8415
  view(view) {
7528
8416
  const container = h("div", {
7529
8417
  className: "nova-bubble nova-context-toolbar",
@@ -7559,7 +8447,7 @@ function contextToolbarPlugin(editor) {
7559
8447
  };
7560
8448
  const anchorRect = (spec) => {
7561
8449
  const { selection } = view.state;
7562
- if ((spec.position ?? "node") === "node" && selection instanceof import_prosemirror_state14.NodeSelection) {
8450
+ if ((spec.position ?? "node") === "node" && selection instanceof import_prosemirror_state16.NodeSelection) {
7563
8451
  const dom = view.nodeDOM(selection.from);
7564
8452
  return dom?.getBoundingClientRect() ?? null;
7565
8453
  }
@@ -7655,11 +8543,11 @@ function focusContextToolbar(editor) {
7655
8543
  button?.focus();
7656
8544
  return !!button;
7657
8545
  }
7658
- var import_prosemirror_state14;
8546
+ var import_prosemirror_state16;
7659
8547
  var init_context_toolbar = __esm({
7660
8548
  "src/ui/context-toolbar.ts"() {
7661
8549
  "use strict";
7662
- import_prosemirror_state14 = require("prosemirror-state");
8550
+ import_prosemirror_state16 = require("prosemirror-state");
7663
8551
  init_dom();
7664
8552
  init_popover();
7665
8553
  init_toolbar();
@@ -7667,11 +8555,11 @@ var init_context_toolbar = __esm({
7667
8555
  });
7668
8556
 
7669
8557
  // src/ui/image-view.ts
7670
- var import_prosemirror_state15, MIN_WIDTH, ImageView;
8558
+ var import_prosemirror_state17, MIN_WIDTH, ImageView;
7671
8559
  var init_image_view = __esm({
7672
8560
  "src/ui/image-view.ts"() {
7673
8561
  "use strict";
7674
- import_prosemirror_state15 = require("prosemirror-state");
8562
+ import_prosemirror_state17 = require("prosemirror-state");
7675
8563
  init_schema();
7676
8564
  init_url();
7677
8565
  MIN_WIDTH = 24;
@@ -7708,6 +8596,7 @@ var init_image_view = __esm({
7708
8596
  if (this.img.getAttribute("src") !== safeSrc) this.img.setAttribute("src", safeSrc);
7709
8597
  this.setAttr("alt", alt);
7710
8598
  this.setAttr("title", title);
8599
+ this.setAttr("class", classAttr(this.node.attrs.class).class ?? null);
7711
8600
  const w = imageSize(width);
7712
8601
  const h2 = imageSize(height);
7713
8602
  this.img.style.width = w ? `${w}px` : "";
@@ -7773,7 +8662,7 @@ var init_image_view = __esm({
7773
8662
  width,
7774
8663
  height: Math.round(width * ratio)
7775
8664
  });
7776
- tr.setSelection(import_prosemirror_state15.NodeSelection.create(tr.doc, pos));
8665
+ tr.setSelection(import_prosemirror_state17.NodeSelection.create(tr.doc, pos));
7777
8666
  this.view.dispatch(tr);
7778
8667
  };
7779
8668
  handle.addEventListener("pointermove", onMove);
@@ -7905,8 +8794,8 @@ function autocompleterPlugin(editor) {
7905
8794
  renderItems(view);
7906
8795
  });
7907
8796
  };
7908
- return new import_prosemirror_state16.Plugin({
7909
- key: new import_prosemirror_state16.PluginKey("nova-autocompleter"),
8797
+ return new import_prosemirror_state18.Plugin({
8798
+ key: new import_prosemirror_state18.PluginKey("nova-autocompleter"),
7910
8799
  view(view) {
7911
8800
  list = h("div", {
7912
8801
  className: "nova-popover nova-ac",
@@ -7953,11 +8842,11 @@ function autocompleterPlugin(editor) {
7953
8842
  }
7954
8843
  });
7955
8844
  }
7956
- var import_prosemirror_state16, MAX_QUERY;
8845
+ var import_prosemirror_state18, MAX_QUERY;
7957
8846
  var init_autocompleter = __esm({
7958
8847
  "src/ui/autocompleter.ts"() {
7959
8848
  "use strict";
7960
- import_prosemirror_state16 = require("prosemirror-state");
8849
+ import_prosemirror_state18 = require("prosemirror-state");
7961
8850
  init_dom();
7962
8851
  init_popover();
7963
8852
  MAX_QUERY = 30;
@@ -8410,6 +9299,8 @@ function createStatusbar(editor, host) {
8410
9299
  const path = h("div", { className: "nova-path", "aria-hidden": "true" });
8411
9300
  const words = h("div", { className: "nova-wordcount", "aria-live": "off" });
8412
9301
  host.append(path, words);
9302
+ const resize = editor.options.resize;
9303
+ const removeHandle = resize ? createResizeHandle(editor, host, resize === "both") : null;
8413
9304
  let timer = null;
8414
9305
  const updateWords = () => {
8415
9306
  const doc = editor.view.state.doc;
@@ -8443,15 +9334,76 @@ function createStatusbar(editor, host) {
8443
9334
  update,
8444
9335
  destroy: () => {
8445
9336
  if (timer) clearTimeout(timer);
9337
+ removeHandle?.();
8446
9338
  host.replaceChildren();
8447
9339
  }
8448
9340
  };
8449
9341
  }
8450
- var TAGS, MARK_TAGS;
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;
8451
9402
  var init_statusbar = __esm({
8452
9403
  "src/ui/statusbar.ts"() {
8453
9404
  "use strict";
8454
9405
  init_dom();
9406
+ init_icons();
8455
9407
  TAGS = {
8456
9408
  paragraph: () => "p",
8457
9409
  heading: (n) => `h${n.attrs.level}`,
@@ -8475,6 +9427,9 @@ var init_statusbar = __esm({
8475
9427
  subscript: "sub",
8476
9428
  superscript: "sup"
8477
9429
  };
9430
+ MIN_HEIGHT = 100;
9431
+ MIN_WIDTH2 = 200;
9432
+ KEY_STEP = 20;
8478
9433
  }
8479
9434
  });
8480
9435
 
@@ -8493,16 +9448,18 @@ function parseContent(schema2, content) {
8493
9448
  function createEditor(options) {
8494
9449
  return new Editor(options);
8495
9450
  }
8496
- var import_prosemirror_dropcursor, import_prosemirror_gapcursor, import_prosemirror_history2, import_prosemirror_keymap6, import_prosemirror_model9, import_prosemirror_state17, import_prosemirror_view4, htmlSerializer, Editor;
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;
8497
9452
  var init_editor = __esm({
8498
9453
  "src/editor.ts"() {
8499
9454
  "use strict";
9455
+ init_formats();
9456
+ init_content_css();
8500
9457
  import_prosemirror_dropcursor = require("prosemirror-dropcursor");
8501
9458
  import_prosemirror_gapcursor = require("prosemirror-gapcursor");
8502
9459
  import_prosemirror_history2 = require("prosemirror-history");
8503
9460
  import_prosemirror_keymap6 = require("prosemirror-keymap");
8504
9461
  import_prosemirror_model9 = require("prosemirror-model");
8505
- import_prosemirror_state17 = require("prosemirror-state");
9462
+ import_prosemirror_state19 = require("prosemirror-state");
8506
9463
  import_prosemirror_view4 = require("prosemirror-view");
8507
9464
  init_commands();
8508
9465
  init_i18n();
@@ -8532,6 +9489,10 @@ var init_editor = __esm({
8532
9489
  init_statusbar();
8533
9490
  init_toolbar();
8534
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;
8535
9496
  Editor = class {
8536
9497
  view;
8537
9498
  root;
@@ -8552,10 +9513,13 @@ var init_editor = __esm({
8552
9513
  contentRules;
8553
9514
  /** Схема документа этого редактора: базовая + узлы и марки синхронных плагинов. */
8554
9515
  schema;
9516
+ /** Форматы: register / apply / remove / toggle / match. */
9517
+ formatter;
8555
9518
  statusbar;
8556
9519
  searchBar;
8557
9520
  destroyed = false;
8558
9521
  editable;
9522
+ disabled;
8559
9523
  pasteAsText;
8560
9524
  constructor(options) {
8561
9525
  this.options = options;
@@ -8622,10 +9586,24 @@ var init_editor = __esm({
8622
9586
  const pluginPm = syncPlugins.flatMap((plugin) => this.collectPmPlugins(plugin));
8623
9587
  const hasRules = options.validElements !== void 0 || options.invalidElements !== void 0 || options.validStyles !== void 0;
8624
9588
  this.contentRules = hasRules ? new ContentRules(options) : null;
8625
- this.schema = this.buildSchema(syncPlugins);
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);
8626
9604
  syncPlugins.forEach((plugin) => this.registerCommands(plugin));
8627
9605
  const initialDoc = parseContent(this.schema, options.content ?? "");
8628
- const state = import_prosemirror_state17.EditorState.create({
9606
+ const state = import_prosemirror_state19.EditorState.create({
8629
9607
  doc: this.contentRules ? this.contentRules.normalizeDoc(initialDoc) : initialDoc,
8630
9608
  plugins: [
8631
9609
  // Первым: при открытом списке Enter/Tab/стрелки принадлежат автокомплитеру, а не раскладке клавиш.
@@ -8650,11 +9628,12 @@ var init_editor = __esm({
8650
9628
  ]
8651
9629
  });
8652
9630
  this.editable = options.editable ?? true;
9631
+ this.disabled = options.disabled ?? false;
8653
9632
  this.pasteAsText = options.pasteAsText ?? false;
8654
9633
  const handleTransaction = this.handleTransaction.bind(this);
8655
9634
  this.view = new import_prosemirror_view4.EditorView(contentHost, {
8656
9635
  state,
8657
- editable: () => this.editable,
9636
+ editable: () => this.isEditable(),
8658
9637
  attributes: {
8659
9638
  class: "nova-prosemirror",
8660
9639
  role: "textbox",
@@ -8679,6 +9658,7 @@ var init_editor = __esm({
8679
9658
  }
8680
9659
  });
8681
9660
  this.root.classList.toggle("nova-readonly", !this.editable);
9661
+ this.applyDisabled();
8682
9662
  registerBuiltins(this);
8683
9663
  registerMenuItems(this);
8684
9664
  if (options.slashCommands !== false) registerSlashCommands(this, options.slashCommands ?? []);
@@ -8703,7 +9683,40 @@ var init_editor = __esm({
8703
9683
  if (!this.statusbar) statusbarHost.remove();
8704
9684
  if (options.onChange) this.on("change", options.onChange);
8705
9685
  this.updatePlaceholder();
8706
- this.ready = resolved.loaders.length ? this.loadLazyPlugins(resolved.loaders) : Promise.resolve();
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);
8707
9720
  }
8708
9721
  // ---------- плагины ----------
8709
9722
  /** Разрешён ли контрол/команда/тег по ограничениям контента (без ограничений — всегда да). */
@@ -8717,11 +9730,12 @@ var init_editor = __esm({
8717
9730
  * Схема с узлами и марками плагинов. Конфликт имён — ошибка конфигурации: сообщаем и работаем
8718
9731
  * на базовой схеме, чтобы редактор всё равно открылся.
8719
9732
  */
8720
- buildSchema(plugins) {
9733
+ buildSchema(plugins, classFilter) {
8721
9734
  const nodes2 = {};
8722
9735
  const marks2 = {};
8723
9736
  for (const plugin of plugins) {
8724
- for (const [name, spec] of Object.entries(plugin.nodes ?? {})) {
9737
+ const pluginNodes = typeof plugin.nodes === "function" ? plugin.nodes(this) : plugin.nodes;
9738
+ for (const [name, spec] of Object.entries(pluginNodes ?? {})) {
8725
9739
  if (name in nodes2) reportPluginError(`Node "${name}" is defined by several plugins`);
8726
9740
  else nodes2[name] = spec;
8727
9741
  }
@@ -8731,10 +9745,10 @@ var init_editor = __esm({
8731
9745
  }
8732
9746
  }
8733
9747
  try {
8734
- return createSchema({ nodes: nodes2, marks: marks2 });
9748
+ return createSchema({ nodes: nodes2, marks: marks2 }, classFilter);
8735
9749
  } catch (error) {
8736
9750
  reportPluginError("Failed to build the document schema from plugins", error);
8737
- return createSchema();
9751
+ return createSchema({}, classFilter);
8738
9752
  }
8739
9753
  }
8740
9754
  collectPmPlugins(plugin) {
@@ -8848,6 +9862,39 @@ var init_editor = __esm({
8848
9862
  if (!addToHistory) tr.setMeta("addToHistory", false);
8849
9863
  this.view.dispatch(tr);
8850
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
+ }
8851
9898
  isEmpty() {
8852
9899
  return this.view.dom.classList.contains("nova-empty");
8853
9900
  }
@@ -8896,8 +9943,32 @@ var init_editor = __esm({
8896
9943
  closeSearch() {
8897
9944
  this.searchBar.close();
8898
9945
  }
9946
+ /** Можно ли сейчас править текст: не «только чтение» и не отключён. */
8899
9947
  isEditable() {
8900
- 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");
8901
9972
  }
8902
9973
  setEditable(value) {
8903
9974
  if (this.editable === value) return;
@@ -9100,7 +10171,7 @@ function toDoc(editor, content) {
9100
10171
  return parseContent(editor.schema, html);
9101
10172
  }
9102
10173
  function openHistory(editor, options) {
9103
- const labels = pickLabels(editor, LABELS15);
10174
+ const labels = pickLabels(editor, LABELS16);
9104
10175
  const lang = editor.options.language ?? "en";
9105
10176
  const dateFormat = new Intl.DateTimeFormat(lang, { dateStyle: "medium", timeStyle: "short" });
9106
10177
  const titleId = uniqueId("nova-history-title");
@@ -9165,7 +10236,7 @@ function openHistory(editor, options) {
9165
10236
  };
9166
10237
  const showDoc = (doc) => {
9167
10238
  selectedDoc = doc;
9168
- const state = import_prosemirror_state18.EditorState.create({ doc });
10239
+ const state = import_prosemirror_state20.EditorState.create({ doc });
9169
10240
  const decorations = decorationsFor(doc);
9170
10241
  if (preview) {
9171
10242
  preview.setProps({ state, decorations: () => decorations });
@@ -9317,14 +10388,14 @@ function openHistory(editor, options) {
9317
10388
  });
9318
10389
  return { close, element: view };
9319
10390
  }
9320
- var import_prosemirror_model10, import_prosemirror_history3, import_prosemirror_state18, import_prosemirror_view5, LABELS15, ICON10, serializer, revisionhistory_default;
10391
+ var import_prosemirror_model10, import_prosemirror_history3, import_prosemirror_state20, import_prosemirror_view5, LABELS16, ICON10, serializer, revisionhistory_default;
9321
10392
  var init_revisionhistory = __esm({
9322
10393
  "src/plugins/revisionhistory.ts"() {
9323
10394
  "use strict";
9324
10395
  init_icons();
9325
10396
  import_prosemirror_model10 = require("prosemirror-model");
9326
10397
  import_prosemirror_history3 = require("prosemirror-history");
9327
- import_prosemirror_state18 = require("prosemirror-state");
10398
+ import_prosemirror_state20 = require("prosemirror-state");
9328
10399
  import_prosemirror_view5 = require("prosemirror-view");
9329
10400
  init_editor();
9330
10401
  init_plugins();
@@ -9332,7 +10403,7 @@ var init_revisionhistory = __esm({
9332
10403
  init_dom();
9333
10404
  init_history_diff();
9334
10405
  init_shared();
9335
- LABELS15 = {
10406
+ LABELS16 = {
9336
10407
  en: {
9337
10408
  button: "Version history",
9338
10409
  title: "Version history",
@@ -9381,7 +10452,7 @@ var init_revisionhistory = __esm({
9381
10452
  console.warn("[nova] revisionhistory: set pluginOptions.revisionhistory.list and .load");
9382
10453
  return;
9383
10454
  }
9384
- const labels = pickLabels(editor, LABELS15);
10455
+ const labels = pickLabels(editor, LABELS16);
9385
10456
  let current = null;
9386
10457
  const open = () => {
9387
10458
  if (current?.element.isConnected) return;
@@ -9410,6 +10481,7 @@ __export(index_exports, {
9410
10481
  DEFAULT_MENUBAR: () => DEFAULT_MENUBAR,
9411
10482
  DEFAULT_MENUS: () => DEFAULT_MENUS,
9412
10483
  Editor: () => Editor,
10484
+ Formatter: () => Formatter,
9413
10485
  HTMLSerializer: () => HTMLSerializer,
9414
10486
  KNOWN_STYLES: () => KNOWN_STYLES,
9415
10487
  KNOWN_TAGS: () => KNOWN_TAGS,
@@ -9614,8 +10686,8 @@ var LABELS2 = {
9614
10686
  var MENTION_ID_RE = /^[\w.@:+-]{1,128}$/;
9615
10687
  var MAX_NAME = 80;
9616
10688
  var cleanName = (value) => value.replace(/^@/, "").trim().slice(0, MAX_NAME);
9617
- async function findMentionUsers(fetch, query, max = 8) {
9618
- const result = await fetch(query);
10689
+ async function findMentionUsers(fetch2, query, max = 8) {
10690
+ const result = await fetch2(query);
9619
10691
  if (!Array.isArray(result)) return [];
9620
10692
  return result.filter((u) => u && typeof u.id === "string" && MENTION_ID_RE.test(u.id) && u.name).slice(0, max).map((u) => ({
9621
10693
  id: u.id,
@@ -10078,10 +11150,193 @@ var comments_default = definePlugin({
10078
11150
  }
10079
11151
  });
10080
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
+
10081
11336
  // src/plugins/suggestions.ts
10082
11337
  init_icons();
10083
11338
  var import_prosemirror_model = require("prosemirror-model");
10084
- var import_prosemirror_state3 = require("prosemirror-state");
11339
+ var import_prosemirror_state4 = require("prosemirror-state");
10085
11340
  var import_prosemirror_transform = require("prosemirror-transform");
10086
11341
  var import_prosemirror_view2 = require("prosemirror-view");
10087
11342
  var import_prosemirror_keymap2 = require("prosemirror-keymap");
@@ -10089,7 +11344,7 @@ init_plugins();
10089
11344
  init_shared();
10090
11345
  var ID_RE2 = /^[A-Za-z0-9_-]{1,64}$/;
10091
11346
  var USER_ID_RE = /^[\w.@:+-]{1,128}$/;
10092
- var LABELS4 = {
11347
+ var LABELS5 = {
10093
11348
  en: {
10094
11349
  toggle: "Suggest edits",
10095
11350
  review: "Review suggestions",
@@ -10125,7 +11380,7 @@ var ICON_TOGGLE = icons.suggest;
10125
11380
  var ICON_REVIEW = icons.review;
10126
11381
  var ICON_ACCEPT = icons.check;
10127
11382
  var ICON_REJECT = icons.close;
10128
- var suggestionsKey = new import_prosemirror_state3.PluginKey("nova-suggestions");
11383
+ var suggestionsKey = new import_prosemirror_state4.PluginKey("nova-suggestions");
10129
11384
  var OWN = "nova-suggestions-own";
10130
11385
  var PALETTE2 = ["#1a7f37", "#8250df", "#bf3989", "#0969da", "#bc4c00", "#1b7c83"];
10131
11386
  function colorFor2(key3) {
@@ -10274,14 +11529,14 @@ function suggestTransaction(tr, state, author) {
10274
11529
  toOut = (pos) => outMap.map(prev(inverse.map(pos, -1)), 1);
10275
11530
  });
10276
11531
  if (forwardDeleteEnd !== null) {
10277
- out.setSelection(import_prosemirror_state3.TextSelection.create(out.doc, forwardDeleteEnd));
11532
+ out.setSelection(import_prosemirror_state4.TextSelection.create(out.doc, forwardDeleteEnd));
10278
11533
  } else if (insertEnd !== null && tr.selection.empty) {
10279
- out.setSelection(import_prosemirror_state3.TextSelection.create(out.doc, insertEnd));
11534
+ out.setSelection(import_prosemirror_state4.TextSelection.create(out.doc, insertEnd));
10280
11535
  } else {
10281
11536
  const anchor = toOut(tr.selection.anchor);
10282
11537
  const head = toOut(tr.selection.head);
10283
11538
  try {
10284
- out.setSelection(import_prosemirror_state3.TextSelection.create(out.doc, anchor, head));
11539
+ out.setSelection(import_prosemirror_state4.TextSelection.create(out.doc, anchor, head));
10285
11540
  } catch {
10286
11541
  }
10287
11542
  }
@@ -10360,7 +11615,7 @@ var suggestions_default = definePlugin({
10360
11615
  const options = editor.options.pluginOptions?.suggestions ?? {};
10361
11616
  let cache = null;
10362
11617
  return [
10363
- new import_prosemirror_state3.Plugin({
11618
+ new import_prosemirror_state4.Plugin({
10364
11619
  key: suggestionsKey,
10365
11620
  state: {
10366
11621
  init: () => ({ enabled: !!(options.enabled || options.force) }),
@@ -10374,7 +11629,7 @@ var suggestions_default = definePlugin({
10374
11629
  attributes: (state) => suggestionsKey.getState(state)?.enabled ? { class: "nova-suggesting" } : {},
10375
11630
  decorations(state) {
10376
11631
  if (cache?.doc === state.doc) return cache.set;
10377
- const labels = pickLabels(editor, LABELS4);
11632
+ const labels = pickLabels(editor, LABELS5);
10378
11633
  const time = new Intl.DateTimeFormat(editor.options.language ?? "en", {
10379
11634
  dateStyle: "medium",
10380
11635
  timeStyle: "short"
@@ -10410,7 +11665,7 @@ var suggestions_default = definePlugin({
10410
11665
  transformTransaction(tr, state, editor) {
10411
11666
  if (!isSuggesting(state)) return tr;
10412
11667
  const options = editor.options.pluginOptions?.suggestions ?? {};
10413
- const labels = pickLabels(editor, LABELS4);
11668
+ const labels = pickLabels(editor, LABELS5);
10414
11669
  const author = {
10415
11670
  id: USER_ID_RE.test(options.author?.id ?? "") ? options.author.id : "guest",
10416
11671
  name: String(options.author?.name || labels.guest).slice(0, 80)
@@ -10419,7 +11674,7 @@ var suggestions_default = definePlugin({
10419
11674
  },
10420
11675
  setup(editor) {
10421
11676
  const options = editor.options.pluginOptions?.suggestions ?? {};
10422
- const labels = pickLabels(editor, LABELS4);
11677
+ const labels = pickLabels(editor, LABELS5);
10423
11678
  const canReview = options.canReview !== false;
10424
11679
  const dispatch = (tr) => editor.view.dispatch(tr);
10425
11680
  const current = () => suggestionAt(editor.view.state);
@@ -10438,7 +11693,7 @@ var suggestions_default = definePlugin({
10438
11693
  return;
10439
11694
  }
10440
11695
  dispatch(
10441
- state.tr.setSelection(import_prosemirror_state3.TextSelection.create(state.doc, target.from)).scrollIntoView()
11696
+ state.tr.setSelection(import_prosemirror_state4.TextSelection.create(state.doc, target.from)).scrollIntoView()
10442
11697
  );
10443
11698
  editor.focus();
10444
11699
  };
@@ -10507,7 +11762,8 @@ var suggestions_default = definePlugin({
10507
11762
 
10508
11763
  // src/plugins/media.ts
10509
11764
  init_icons();
10510
- var import_prosemirror_state4 = require("prosemirror-state");
11765
+ init_file_picker();
11766
+ var import_prosemirror_state5 = require("prosemirror-state");
10511
11767
  init_plugins();
10512
11768
  init_schema();
10513
11769
  init_dialog();
@@ -10527,7 +11783,7 @@ function parseMediaUrl(url) {
10527
11783
  return null;
10528
11784
  }
10529
11785
  var ICON2 = icons.media;
10530
- var LABELS5 = {
11786
+ var LABELS6 = {
10531
11787
  en: {
10532
11788
  title: "Video",
10533
11789
  url: "Video URL",
@@ -10628,7 +11884,7 @@ var media_default = definePlugin({
10628
11884
  }
10629
11885
  },
10630
11886
  prosemirrorPlugins: () => [
10631
- new import_prosemirror_state4.Plugin({
11887
+ new import_prosemirror_state5.Plugin({
10632
11888
  props: {
10633
11889
  nodeViews: {
10634
11890
  // В редакторе плеер закрыт прозрачным слоем: клик выделяет блок, а не запускает видео.
@@ -10647,10 +11903,10 @@ var media_default = definePlugin({
10647
11903
  })
10648
11904
  ],
10649
11905
  setup(editor) {
10650
- const labels = pickLabels(editor, LABELS5);
11906
+ const labels = pickLabels(editor, LABELS6);
10651
11907
  const selected = () => {
10652
11908
  const { selection } = editor.view.state;
10653
- return selection instanceof import_prosemirror_state4.NodeSelection && selection.node.type.name === "media" ? selection : null;
11909
+ return selection instanceof import_prosemirror_state5.NodeSelection && selection.node.type.name === "media" ? selection : null;
10654
11910
  };
10655
11911
  const open = () => {
10656
11912
  const current = selected();
@@ -10665,6 +11921,9 @@ var media_default = definePlugin({
10665
11921
  label: labels.name,
10666
11922
  value: current?.node.attrs.title ?? ""
10667
11923
  });
11924
+ attachFilePicker(editor, url, "media", (picked) => {
11925
+ if (picked.title) title.input.value = picked.title;
11926
+ });
10668
11927
  editor.ui.openDialog({
10669
11928
  title: labels.title,
10670
11929
  body: h("div", { className: "nova-form" }, url.el, title.el),
@@ -10701,7 +11960,7 @@ init_icons();
10701
11960
  init_plugins();
10702
11961
  init_shared();
10703
11962
  var ICON3 = icons.pageBreak;
10704
- var LABELS6 = { en: { title: "Page break" }, ru: { title: "\u0420\u0430\u0437\u0440\u044B\u0432 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B" } };
11963
+ var LABELS7 = { en: { title: "Page break" }, ru: { title: "\u0420\u0430\u0437\u0440\u044B\u0432 \u0441\u0442\u0440\u0430\u043D\u0438\u0446\u044B" } };
10705
11964
  var pagebreak_default = definePlugin({
10706
11965
  name: "pagebreak",
10707
11966
  toolbar: "pagebreak",
@@ -10726,7 +11985,7 @@ var pagebreak_default = definePlugin({
10726
11985
  }
10727
11986
  },
10728
11987
  setup(editor) {
10729
- const { title } = pickLabels(editor, LABELS6);
11988
+ const { title } = pickLabels(editor, LABELS7);
10730
11989
  const insert = () => {
10731
11990
  const { state, dispatch } = editor.view;
10732
11991
  const type = editor.schema.nodes.pagebreak;
@@ -10758,6 +12017,7 @@ registerPlugin("pagebreak", pagebreak_default);
10758
12017
  registerPlugin("media", media_default);
10759
12018
  registerPlugin("comments", comments_default);
10760
12019
  registerPlugin("mentions", mentions_default);
12020
+ registerPlugin("mergetags", mergetags_default);
10761
12021
  registerPlugin("suggestions", suggestions_default);
10762
12022
  registerPlugin("directionality", () => Promise.resolve().then(() => (init_directionality(), directionality_exports)));
10763
12023
  registerPlugin("advlist", () => Promise.resolve().then(() => (init_advlist(), advlist_exports)));
@@ -10766,6 +12026,7 @@ registerPlugin("revisionhistory", () => Promise.resolve().then(() => (init_revis
10766
12026
  // src/index.ts
10767
12027
  init_editor();
10768
12028
  init_menubar();
12029
+ init_formats();
10769
12030
  init_menu_items();
10770
12031
  init_schema();
10771
12032
  init_parser();
@@ -10796,6 +12057,7 @@ init_serializer();
10796
12057
  DEFAULT_MENUBAR,
10797
12058
  DEFAULT_MENUS,
10798
12059
  Editor,
12060
+ Formatter,
10799
12061
  HTMLSerializer,
10800
12062
  KNOWN_STYLES,
10801
12063
  KNOWN_TAGS,