@harbour-enterprises/superdoc 0.20.2 → 0.21.0-RC1

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 (96) hide show
  1. package/dist/chunks/{PdfViewer-BhwyCIho.cjs → PdfViewer-BdrjIRpr.cjs} +1 -1
  2. package/dist/chunks/{PdfViewer-BceCsygM.es.js → PdfViewer-DK1etjvu.es.js} +1 -1
  3. package/dist/chunks/{index-B6tAKGVb.cjs → index-C_zTr1ZR.cjs} +14 -33
  4. package/dist/chunks/{index-C0kV6dM8.es.js → index-ucP9WQ5I.es.js} +14 -33
  5. package/dist/chunks/{super-editor.es-BollA_Sr.es.js → super-editor.es-KKA9G1l1.es.js} +1851 -434
  6. package/dist/chunks/{super-editor.es-Dzt_HBkR.cjs → super-editor.es-XC168Mlw.cjs} +1851 -434
  7. package/dist/core/SuperDoc.d.ts.map +1 -1
  8. package/dist/stores/comments-store.d.ts.map +1 -1
  9. package/dist/super-editor/ai-writer.es.js +2 -2
  10. package/dist/super-editor/chunks/{converter-DyzbfydS.js → converter-B61ZUb-V.js} +1405 -339
  11. package/dist/super-editor/chunks/{docx-zipper-Bk9SAmal.js → docx-zipper-B8nhsVFW.js} +2 -2
  12. package/dist/super-editor/chunks/{editor-BWE7oMgS.js → editor-CQ0o4v54.js} +420 -65
  13. package/dist/super-editor/chunks/{toolbar-BmHEsvA1.js → toolbar-DWzoslZk.js} +11 -21
  14. package/dist/super-editor/converter.es.js +1 -1
  15. package/dist/super-editor/docx-zipper.es.js +2 -2
  16. package/dist/super-editor/editor.es.js +3 -3
  17. package/dist/super-editor/file-zipper.es.js +1 -1
  18. package/dist/super-editor/src/core/commands/index.d.ts +1 -0
  19. package/dist/super-editor/src/core/commands/toggleMarkCascade.d.ts +41 -0
  20. package/dist/super-editor/src/core/super-converter/SuperConverter.d.ts +5 -0
  21. package/dist/super-editor/src/core/super-converter/helpers.d.ts +2 -0
  22. package/dist/super-editor/src/core/super-converter/v2/importer/markImporter.d.ts +12 -0
  23. package/dist/super-editor/src/core/super-converter/v2/importer/runNodeImporter.d.ts +6 -6
  24. package/dist/super-editor/src/core/super-converter/v3/handlers/index.d.ts +20 -4
  25. package/dist/super-editor/src/core/super-converter/v3/handlers/w/b/attributes/index.d.ts +3 -0
  26. package/dist/super-editor/src/core/super-converter/v3/handlers/w/b/attributes/w-val.d.ts +4 -0
  27. package/dist/super-editor/src/core/super-converter/v3/handlers/w/b/b-translator.d.ts +7 -0
  28. package/dist/super-editor/src/core/super-converter/v3/handlers/w/b/index.d.ts +1 -0
  29. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/index.d.ts +2 -0
  30. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-color.d.ts +4 -0
  31. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-shade.d.ts +4 -0
  32. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-theme-tint.d.ts +4 -0
  33. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/attributes/w-val.d.ts +4 -0
  34. package/dist/super-editor/src/core/super-converter/v3/handlers/w/color/color-translator.d.ts +7 -0
  35. package/dist/super-editor/src/core/super-converter/v3/handlers/w/highlight/attributes/index.d.ts +2 -0
  36. package/dist/super-editor/src/core/super-converter/v3/handlers/w/highlight/attributes/w-val.d.ts +4 -0
  37. package/dist/super-editor/src/core/super-converter/v3/handlers/w/highlight/highlight-translator.d.ts +4 -0
  38. package/dist/super-editor/src/core/super-converter/v3/handlers/w/i/attributes/index.d.ts +2 -0
  39. package/dist/super-editor/src/core/super-converter/v3/handlers/w/i/attributes/w-val.d.ts +4 -0
  40. package/dist/super-editor/src/core/super-converter/v3/handlers/w/i/i-translator.d.ts +7 -0
  41. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/attributes/index.d.ts +2 -0
  42. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/attributes/w-rsid-del.d.ts +4 -0
  43. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/attributes/w-rsid-r-pr.d.ts +4 -0
  44. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/attributes/w-rsid-r.d.ts +4 -0
  45. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/helpers/helpers.d.ts +40 -0
  46. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/helpers/index.d.ts +2 -0
  47. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/helpers/split-run-properties.d.ts +9 -0
  48. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/index.d.ts +1 -0
  49. package/dist/super-editor/src/core/super-converter/v3/handlers/w/r/r-translator.d.ts +4 -0
  50. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/index.d.ts +2 -0
  51. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-ascii.d.ts +4 -0
  52. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-cs.d.ts +4 -0
  53. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-east-asia.d.ts +4 -0
  54. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-hansi.d.ts +4 -0
  55. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/attributes/w-val.d.ts +4 -0
  56. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/index.d.ts +1 -0
  57. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rFonts/rFonts-translator.d.ts +5 -0
  58. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rStyle/attributes/index.d.ts +2 -0
  59. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rStyle/attributes/w-val.d.ts +4 -0
  60. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rStyle/index.d.ts +1 -0
  61. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rStyle/rstyle-translator.d.ts +7 -0
  62. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rpr/index.d.ts +1 -0
  63. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rpr/rpr-translator.d.ts +5 -0
  64. package/dist/super-editor/src/core/super-converter/v3/handlers/w/rpr/run-property-translators.d.ts +11 -0
  65. package/dist/super-editor/src/core/super-converter/v3/handlers/w/strike/attributes/index.d.ts +2 -0
  66. package/dist/super-editor/src/core/super-converter/v3/handlers/w/strike/attributes/w-val.d.ts +4 -0
  67. package/dist/super-editor/src/core/super-converter/v3/handlers/w/strike/strike-translator.d.ts +7 -0
  68. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sz/attributes/index.d.ts +2 -0
  69. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sz/attributes/w-val.d.ts +4 -0
  70. package/dist/super-editor/src/core/super-converter/v3/handlers/w/sz/sz-translator.d.ts +4 -0
  71. package/dist/super-editor/src/core/super-converter/v3/handlers/w/szcs/attributes/index.d.ts +2 -0
  72. package/dist/super-editor/src/core/super-converter/v3/handlers/w/szcs/attributes/w-val.d.ts +4 -0
  73. package/dist/super-editor/src/core/super-converter/v3/handlers/w/szcs/szcs-translator.d.ts +4 -0
  74. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/index.d.ts +2 -0
  75. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-color.d.ts +4 -0
  76. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-theme-color.d.ts +4 -0
  77. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-theme-shade.d.ts +4 -0
  78. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-theme-tint.d.ts +4 -0
  79. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/attributes/w-val.d.ts +4 -0
  80. package/dist/super-editor/src/core/super-converter/v3/handlers/w/u/u-translator.d.ts +7 -0
  81. package/dist/super-editor/src/extensions/index.d.ts +2 -2
  82. package/dist/super-editor/src/extensions/linked-styles/index.d.ts +1 -0
  83. package/dist/super-editor/src/extensions/linked-styles/underline-css.d.ts +17 -0
  84. package/dist/super-editor/src/extensions/run/index.d.ts +1 -0
  85. package/dist/super-editor/src/extensions/run/run.d.ts +6 -0
  86. package/dist/super-editor/src/extensions/shared/cascade-toggle.d.ts +8 -0
  87. package/dist/super-editor/super-editor.es.js +49 -23
  88. package/dist/super-editor/toolbar.es.js +2 -2
  89. package/dist/super-editor.cjs +1 -1
  90. package/dist/super-editor.es.js +1 -1
  91. package/dist/superdoc.cjs +2 -2
  92. package/dist/superdoc.es.js +2 -2
  93. package/dist/superdoc.umd.js +1865 -467
  94. package/dist/superdoc.umd.js.map +1 -1
  95. package/package.json +1 -1
  96. package/dist/super-editor/src/core/super-converter/helpers/mediaHelpers.d.ts +0 -2
@@ -12,9 +12,9 @@ var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "acce
12
12
  var _Attribute_static, getGlobalAttributes_fn, getNodeAndMarksAttributes_fn, _Schema_static, createNodesSchema_fn, createMarksSchema_fn, _events, _ExtensionService_instances, setupExtensions_fn, attachEditorEvents_fn, _editor, _stateValidators, _xmlValidators, _requiredNodeTypes, _requiredMarkTypes, _SuperValidator_instances, initializeValidators_fn, collectValidatorRequirements_fn, analyzeDocument_fn, _commandService, _Editor_instances, initContainerElement_fn, init_fn, initRichText_fn, onFocus_fn, checkHeadless_fn, registerCopyHandler_fn, insertNewFileData_fn, registerPluginByNameIfNotExists_fn, createExtensionService_fn, createCommandService_fn, createConverter_fn, initMedia_fn, initFonts_fn, createSchema_fn, generatePmData_fn, createView_fn, onCollaborationReady_fn, initComments_fn, initPagination_fn, dispatchTransaction_fn, handleNodeSelection_fn, prepareDocumentForImport_fn, prepareDocumentForExport_fn, endCollaboration_fn, validateDocumentInit_fn, validateDocumentExport_fn, initDevTools_fn, _ListItemNodeView_instances, init_fn2, _FieldAnnotationView_instances, createAnnotation_fn, _AutoPageNumberNodeView_instances, renderDom_fn, scheduleUpdateNodeStyle_fn, _DocumentSectionView_instances, init_fn3, addToolTip_fn;
13
13
  import * as Y from "yjs";
14
14
  import { UndoManager, Item as Item$1, ContentType, Text as Text$1, XmlElement, encodeStateAsUpdate } from "yjs";
15
- import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as StepMap, ao as getColStyleDeclaration, ap as SelectionRange, aq as Transform, ar as isInTable$1, as as createColGroup, at as generateDocxRandomId, au as insertNewRelationship, av as htmlHandler } from "./converter-DyzbfydS.js";
15
+ import { P as PluginKey, a as Plugin, M as Mapping, N as NodeSelection, S as Selection, T as TextSelection, b as Slice, D as DOMSerializer, F as Fragment, c as DOMParser$1, d as Mark$1, e as dropPoint, A as AllSelection, p as process$1, B as Buffer2, f as callOrGet, g as getExtensionConfigField, h as getMarkType, i as getMarksFromSelection, j as getNodeType, k as getSchemaTypeNameByName, l as Schema$1, m as cleanSchemaItem, n as canSplit, o as defaultBlockAt$1, q as liftTarget, r as canJoin, s as joinPoint, t as replaceStep$1, R as ReplaceAroundStep$1, u as isTextSelection, v as getMarkRange, w as isMarkActive, x as isNodeActive, y as deleteProps, z as processContent, C as ReplaceStep, E as NodeRange, G as findWrapping, L as ListHelpers, H as findParentNode, I as isMacOS, J as isIOS, K as getSchemaTypeByName, O as inputRulesPlugin, Q as TrackDeleteMarkName, U as TrackInsertMarkName, V as v4, W as TrackFormatMarkName, X as comments_module_events, Y as findMark, Z as objectIncludes, _ as AddMarkStep, $ as RemoveMarkStep, a0 as twipsToLines, a1 as pixelsToTwips, a2 as helpers, a3 as posToDOMRect, a4 as CommandService, a5 as SuperConverter, a6 as createDocument, a7 as createDocFromMarkdown, a8 as createDocFromHTML, a9 as EditorState, aa as hasSomeParentWithClass, ab as isActive, ac as unflattenListsInHtml, ad as parseSizeUnit, ae as minMax, af as getLineHeightValueString, ag as InputRule, ah as kebabCase, ai as findParentNodeClosestToPos, aj as getListItemStyleDefinitions, ak as docxNumberigHelpers, al as parseIndentElement, am as combineIndents, an as StepMap, ao as getColStyleDeclaration, ap as SelectionRange, aq as Transform, ar as isInTable$1, as as createColGroup, at as generateDocxRandomId, au as insertNewRelationship, av as htmlHandler } from "./converter-B61ZUb-V.js";
16
16
  import { ref, computed, createElementBlock, openBlock, withModifiers, Fragment as Fragment$1, renderList, normalizeClass, createCommentVNode, toDisplayString, createElementVNode, createApp } from "vue";
17
- import { D as DocxZipper } from "./docx-zipper-Bk9SAmal.js";
17
+ import { D as DocxZipper } from "./docx-zipper-B8nhsVFW.js";
18
18
  var GOOD_LEAF_SIZE = 200;
19
19
  var RopeSequence = function RopeSequence2() {
20
20
  };
@@ -8856,6 +8856,95 @@ const toggleMark = (typeOrName, attrs = {}, options = {}) => ({ state, commands:
8856
8856
  if (isActive2) return commands2.unsetMark(type, { extendEmptyMarkRange });
8857
8857
  return commands2.setMark(type, attrs);
8858
8858
  };
8859
+ const toggleMarkCascade = (markName, options = {}) => ({ state, chain, editor }) => {
8860
+ const {
8861
+ negationAttrs = { value: "0" },
8862
+ isNegation = (attrs) => attrs?.value === "0",
8863
+ styleDetector = defaultStyleDetector,
8864
+ extendEmptyMarkRange = true
8865
+ } = options;
8866
+ const selectionMarks = getMarksFromSelection(state) || [];
8867
+ const inlineMarks = selectionMarks.filter((m) => m.type?.name === markName);
8868
+ const hasNegation = inlineMarks.some((m) => isNegation(m.attrs || {}));
8869
+ const hasInline = inlineMarks.some((m) => !isNegation(m.attrs || {}));
8870
+ const styleOn = styleDetector({ state, selectionMarks, markName, editor });
8871
+ const cmdChain = chain();
8872
+ if (hasNegation) return cmdChain.unsetMark(markName, { extendEmptyMarkRange }).run();
8873
+ if (hasInline && styleOn) {
8874
+ return cmdChain.unsetMark(markName, { extendEmptyMarkRange }).setMark(markName, negationAttrs, { extendEmptyMarkRange }).run();
8875
+ }
8876
+ if (hasInline) return cmdChain.unsetMark(markName, { extendEmptyMarkRange }).run();
8877
+ if (styleOn) return cmdChain.setMark(markName, negationAttrs, { extendEmptyMarkRange }).run();
8878
+ return cmdChain.setMark(markName, {}, { extendEmptyMarkRange }).run();
8879
+ };
8880
+ function defaultStyleDetector({ state, selectionMarks, markName, editor }) {
8881
+ try {
8882
+ const styleId = getEffectiveStyleId(state, selectionMarks);
8883
+ if (!styleId || !editor?.converter?.linkedStyles) return false;
8884
+ const styles = editor.converter.linkedStyles;
8885
+ const seen = /* @__PURE__ */ new Set();
8886
+ let current = styleId;
8887
+ const key = mapMarkToStyleKey(markName);
8888
+ while (current && !seen.has(current)) {
8889
+ seen.add(current);
8890
+ const style = styles.find((s) => s.id === current);
8891
+ const def = style?.definition?.styles || {};
8892
+ if (key in def) {
8893
+ const raw = def[key];
8894
+ if (raw === void 0) return true;
8895
+ const val = raw?.value ?? raw;
8896
+ if (val === "0" || val === false) return false;
8897
+ return !!val;
8898
+ }
8899
+ current = style?.definition?.attrs?.basedOn || null;
8900
+ }
8901
+ return false;
8902
+ } catch {
8903
+ return false;
8904
+ }
8905
+ }
8906
+ function getEffectiveStyleId(state, selectionMarks) {
8907
+ const sidFromMarks = getStyleIdFromMarks(selectionMarks);
8908
+ if (sidFromMarks) return sidFromMarks;
8909
+ const $from = state.selection.$from;
8910
+ const before = $from.nodeBefore;
8911
+ const after = $from.nodeAfter;
8912
+ if (before && before.marks) {
8913
+ const sid = getStyleIdFromMarks(before.marks);
8914
+ if (sid) return sid;
8915
+ }
8916
+ if (after && after.marks) {
8917
+ const sid = getStyleIdFromMarks(after.marks);
8918
+ if (sid) return sid;
8919
+ }
8920
+ const ts = selectionMarks.find((m) => m.type?.name === "textStyle" && m.attrs?.styleId);
8921
+ if (ts) return ts.attrs.styleId;
8922
+ const pos = state.selection.$from.pos;
8923
+ const $pos = state.doc.resolve(pos);
8924
+ for (let d = $pos.depth; d >= 0; d--) {
8925
+ const n = $pos.node(d);
8926
+ if (n?.type?.name === "paragraph") return n.attrs?.styleId || null;
8927
+ }
8928
+ return null;
8929
+ }
8930
+ function getStyleIdFromMarks(marks) {
8931
+ const run = marks.find((m) => m.type?.name === "run");
8932
+ const runProperties = run?.attrs?.runProperties;
8933
+ if (!runProperties) return null;
8934
+ if (runProperties && typeof runProperties === "object" && !Array.isArray(runProperties) && runProperties.styleId) {
8935
+ return runProperties.styleId;
8936
+ }
8937
+ if (Array.isArray(runProperties)) {
8938
+ const rStyleEntry = runProperties.find((e) => e?.xmlName === "w:rStyle");
8939
+ const sid = rStyleEntry?.attributes?.["w:val"];
8940
+ if (sid) return sid;
8941
+ }
8942
+ return null;
8943
+ }
8944
+ function mapMarkToStyleKey(markName) {
8945
+ if (markName === "textStyle" || markName === "color") return "color";
8946
+ return markName;
8947
+ }
8859
8948
  const clearNodes = () => ({ state, tr, dispatch }) => {
8860
8949
  const { selection } = tr;
8861
8950
  const { ranges } = selection;
@@ -10201,11 +10290,14 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
10201
10290
  command,
10202
10291
  createParagraphNear,
10203
10292
  decreaseListIndent,
10293
+ defaultStyleDetector,
10204
10294
  deleteListItem,
10205
10295
  deleteSelection,
10206
10296
  exitCode,
10207
10297
  first,
10298
+ getEffectiveStyleId,
10208
10299
  getParaCtx,
10300
+ getStyleIdFromMarks,
10209
10301
  handleBackspaceNextToList,
10210
10302
  handleDeleteNextToList,
10211
10303
  increaseListIndent,
@@ -10220,6 +10312,7 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
10220
10312
  joinUp,
10221
10313
  liftEmptyBlock,
10222
10314
  liftListItem,
10315
+ mapMarkToStyleKey,
10223
10316
  nearestListAt,
10224
10317
  newlineInCode,
10225
10318
  rebuildListNodeWithNewNum,
@@ -10239,6 +10332,7 @@ const commands$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.definePr
10239
10332
  splitListItem,
10240
10333
  toggleList,
10241
10334
  toggleMark,
10335
+ toggleMarkCascade,
10242
10336
  toggleNode,
10243
10337
  undoInputRule,
10244
10338
  unsetAllMarks,
@@ -11451,7 +11545,7 @@ const createHeaderFooterEditor = ({
11451
11545
  currentPageNumber
11452
11546
  }) => {
11453
11547
  const parentStyles = editor.converter.getDocumentDefaultStyles();
11454
- const { fontSizePt, typeface } = parentStyles;
11548
+ const { fontSizePt, typeface, fontFamilyCss } = parentStyles;
11455
11549
  const fontSizeInPixles = fontSizePt * 1.3333;
11456
11550
  const lineHeight = fontSizeInPixles * 1.2;
11457
11551
  Object.assign(editorContainer.style, {
@@ -11464,7 +11558,7 @@ const createHeaderFooterEditor = ({
11464
11558
  left: "0",
11465
11559
  width: "auto",
11466
11560
  maxWidth: "none",
11467
- fontFamily: typeface,
11561
+ fontFamily: fontFamilyCss || typeface,
11468
11562
  fontSize: `${fontSizeInPixles}px`,
11469
11563
  lineHeight: `${lineHeight}px`
11470
11564
  });
@@ -12294,7 +12388,6 @@ const trackedTransaction = ({ tr, state, user }) => {
12294
12388
  originalStep,
12295
12389
  originalStepIndex
12296
12390
  });
12297
- console.debug("[track-changes]: replaceStep");
12298
12391
  } else if (step instanceof AddMarkStep) {
12299
12392
  addMarkStep({
12300
12393
  state,
@@ -12304,7 +12397,6 @@ const trackedTransaction = ({ tr, state, user }) => {
12304
12397
  user,
12305
12398
  date
12306
12399
  });
12307
- console.debug("[track-changes]: addMarkStep");
12308
12400
  } else if (step instanceof RemoveMarkStep) {
12309
12401
  removeMarkStep({
12310
12402
  state,
@@ -12314,10 +12406,8 @@ const trackedTransaction = ({ tr, state, user }) => {
12314
12406
  user,
12315
12407
  date
12316
12408
  });
12317
- console.debug("[track-changes]: removeMarkStep");
12318
12409
  } else {
12319
12410
  newTr.step(step);
12320
- console.log("[track-changes]: otherStep");
12321
12411
  }
12322
12412
  });
12323
12413
  if (tr.getMeta("inputType")) {
@@ -14430,9 +14520,10 @@ const _Editor = class _Editor extends EventEmitter {
14430
14520
  element.style.isolation = "isolate";
14431
14521
  proseMirror.style.outline = "none";
14432
14522
  proseMirror.style.border = "none";
14433
- const { typeface, fontSizePt } = this.converter.getDocumentDefaultStyles() ?? {};
14434
- if (typeface) {
14435
- element.style.fontFamily = typeface;
14523
+ const { typeface, fontSizePt, fontFamilyCss } = this.converter.getDocumentDefaultStyles() ?? {};
14524
+ const resolvedFontFamily = fontFamilyCss || typeface;
14525
+ if (resolvedFontFamily) {
14526
+ element.style.fontFamily = resolvedFontFamily;
14436
14527
  }
14437
14528
  if (fontSizePt) {
14438
14529
  element.style.fontSize = `${fontSizePt}pt`;
@@ -14746,7 +14837,7 @@ const _Editor = class _Editor extends EventEmitter {
14746
14837
  * @returns {Object | void} Migration results
14747
14838
  */
14748
14839
  processCollaborationMigrations() {
14749
- console.debug("[checkVersionMigrations] Current editor version", "0.20.1");
14840
+ console.debug("[checkVersionMigrations] Current editor version", "0.21.0-RC1");
14750
14841
  if (!this.options.ydoc) return;
14751
14842
  const metaMap = this.options.ydoc.getMap("meta");
14752
14843
  let docVersion = metaMap.get("version");
@@ -15972,6 +16063,7 @@ const FormatCommands = Extension.create({
15972
16063
  },
15973
16064
  addCommands() {
15974
16065
  return {
16066
+ toggleMarkCascade,
15975
16067
  /**
15976
16068
  * Clear all formatting (nodes and marks)
15977
16069
  * @category Command
@@ -16956,24 +17048,32 @@ const Text = Node$1.create({
16956
17048
  group: "inline",
16957
17049
  inline: true
16958
17050
  });
16959
- const RunItem = Node$1.create({
17051
+ const Run = Mark.create({
16960
17052
  name: "run",
16961
- group: "inline",
16962
- content: "text*",
16963
- inline: true,
16964
- parseDOM() {
16965
- return [{ tag: "run" }];
16966
- },
16967
- renderDOM() {
16968
- return ["run", 0];
17053
+ inclusive: false,
17054
+ addOptions() {
17055
+ return {
17056
+ htmlAttributes: {}
17057
+ };
16969
17058
  },
16970
17059
  addAttributes() {
16971
17060
  return {
16972
- attributes: {
16973
- rendered: false,
16974
- "aria-label": "Run node"
17061
+ runProperties: {
17062
+ default: null,
17063
+ rendered: false
16975
17064
  }
16976
17065
  };
17066
+ },
17067
+ parseDOM() {
17068
+ return [
17069
+ {
17070
+ tag: "span[data-run]"
17071
+ }
17072
+ ];
17073
+ },
17074
+ renderDOM({ htmlAttributes }) {
17075
+ const base2 = Attribute.mergeAttributes({ "data-run": "1" }, this.options.htmlAttributes, htmlAttributes);
17076
+ return ["span", base2, 0];
16977
17077
  }
16978
17078
  });
16979
17079
  const inputRegex$1 = /^\s*([-+*])\s$/;
@@ -17537,6 +17637,7 @@ const getMarksStyle = (attrs) => {
17537
17637
  case "textStyle":
17538
17638
  const { fontFamily, fontSize } = attr.attrs;
17539
17639
  styles += `${fontFamily ? `font-family: ${fontFamily};` : ""} ${fontSize ? `font-size: ${fontSize};` : ""}`;
17640
+ break;
17540
17641
  }
17541
17642
  }
17542
17643
  return styles.trim();
@@ -17555,12 +17656,22 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
17555
17656
  const linkedDefinitionStyles = { ...linkedStyle.definition.styles };
17556
17657
  const basedOnDefinitionStyles = { ...basedOnStyle?.definition?.styles };
17557
17658
  const resultStyles = { ...linkedDefinitionStyles };
17558
- if (!linkedDefinitionStyles["font-size"] && basedOnDefinitionStyles["font-size"]) {
17559
- resultStyles["font-size"] = basedOnDefinitionStyles["font-size"];
17560
- }
17561
- if (!linkedDefinitionStyles["text-transform"] && basedOnDefinitionStyles["text-transform"]) {
17562
- resultStyles["text-transform"] = basedOnDefinitionStyles["text-transform"];
17563
- }
17659
+ const inheritKeys = [
17660
+ "font-size",
17661
+ "font-family",
17662
+ "text-transform",
17663
+ "bold",
17664
+ "italic",
17665
+ "underline",
17666
+ "strike",
17667
+ "color",
17668
+ "highlight"
17669
+ ];
17670
+ inheritKeys.forEach((k) => {
17671
+ if (!linkedDefinitionStyles[k] && basedOnDefinitionStyles[k]) {
17672
+ resultStyles[k] = basedOnDefinitionStyles[k];
17673
+ }
17674
+ });
17564
17675
  Object.entries(resultStyles).forEach(([k, value]) => {
17565
17676
  const key = kebabCase(k);
17566
17677
  const flattenedMarks = [];
@@ -17575,6 +17686,10 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
17575
17686
  }
17576
17687
  flattenedMarks.push({ key: n.type.name, value: n.attrs[key] });
17577
17688
  });
17689
+ const underlineNone = node?.marks?.some((m) => m.type?.name === "underline" && m.attrs?.underlineType === "none");
17690
+ if (underlineNone) {
17691
+ markValue["text-decoration"] = "none";
17692
+ }
17578
17693
  const mark = flattenedMarks.find((n) => n.key === key);
17579
17694
  const hasParentIndent = Object.keys(parent?.attrs?.indent || {});
17580
17695
  const hasParentSpacing = Object.keys(parent?.attrs?.spacing || {});
@@ -17591,10 +17706,28 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
17591
17706
  if (rightIndent) markValue["margin-right"] = rightIndent + "px";
17592
17707
  if (firstLine) markValue["text-indent"] = firstLine + "px";
17593
17708
  } else if (key === "bold" && node) {
17594
- const val = value?.value;
17595
- if (!listTypes.includes(node.type.name) && val !== "0") {
17709
+ const boldValue = typeof value === "object" && value !== null ? value.value : value;
17710
+ const hasInlineBoldOff = node.marks?.some((m) => m.type?.name === "bold" && m.attrs?.value === "0");
17711
+ const hasInlineBoldOn = node.marks?.some((m) => m.type?.name === "bold" && m.attrs?.value !== "0");
17712
+ if (!listTypes.includes(node.type.name) && !hasInlineBoldOff && !hasInlineBoldOn && boldValue !== "0" && boldValue !== false) {
17596
17713
  markValue["font-weight"] = "bold";
17597
17714
  }
17715
+ } else if (key === "italic" && node) {
17716
+ const italicValue = typeof value === "object" && value !== null ? value.value : value;
17717
+ const hasInlineItalicOff = node.marks?.some((m) => m.type?.name === "italic" && m.attrs?.value === "0");
17718
+ const hasInlineItalicOn = node.marks?.some((m) => m.type?.name === "italic" && m.attrs?.value !== "0");
17719
+ if (!listTypes.includes(node.type.name) && !hasInlineItalicOff && !hasInlineItalicOn && italicValue !== "0" && italicValue !== false) {
17720
+ markValue["font-style"] = "italic";
17721
+ }
17722
+ } else if (key === "strike" && node) {
17723
+ const strikeValue = typeof value === "object" && value !== null ? value.value : value;
17724
+ const hasInlineStrikeOff = node.marks?.some((m) => m.type?.name === "strike" && m.attrs?.value === "0");
17725
+ const hasInlineStrikeOn = node.marks?.some(
17726
+ (m) => m.type?.name === "strike" && (m.attrs?.value === void 0 || m.attrs?.value !== "0")
17727
+ );
17728
+ if (!listTypes.includes(node.type.name) && !hasInlineStrikeOff && !hasInlineStrikeOn && strikeValue !== "0" && strikeValue !== false) {
17729
+ markValue["text-decoration"] = "line-through";
17730
+ }
17598
17731
  } else if (key === "text-transform" && node) {
17599
17732
  if (!listTypes.includes(node.type.name)) {
17600
17733
  markValue[key] = value;
@@ -17603,10 +17736,44 @@ const generateLinkedStyleString = (linkedStyle, basedOnStyle, node, parent, incl
17603
17736
  if (!listTypes.includes(node.type.name)) {
17604
17737
  markValue[key] = value;
17605
17738
  }
17739
+ } else if (key === "font-family" && node) {
17740
+ if (!listTypes.includes(node.type.name)) {
17741
+ markValue[key] = value;
17742
+ }
17606
17743
  } else if (key === "color" && node) {
17607
17744
  if (!listTypes.includes(node.type.name)) {
17608
17745
  markValue[key] = value;
17609
17746
  }
17747
+ } else if (key === "highlight" && node) {
17748
+ const hasInlineHighlight = node.marks?.some((m) => m.type?.name === "highlight");
17749
+ if (!listTypes.includes(node.type.name) && !hasInlineHighlight) {
17750
+ const color = typeof value === "string" ? value : value?.color;
17751
+ if (color) markValue["background-color"] = color;
17752
+ }
17753
+ } else if (key === "underline" && node) {
17754
+ const styleValRaw = value?.value ?? value ?? "";
17755
+ const styleVal = styleValRaw.toString().toLowerCase();
17756
+ const hasInlineUnderlineOff = node.marks?.some(
17757
+ (m) => m.type?.name === "underline" && m.attrs?.underlineType === "none"
17758
+ );
17759
+ const hasInlineUnderlineOn = node.marks?.some(
17760
+ (m) => m.type?.name === "underline" && m.attrs?.underlineType && m.attrs.underlineType !== "none"
17761
+ );
17762
+ if (!listTypes.includes(node.type.name) && !hasInlineUnderlineOff && !hasInlineUnderlineOn) {
17763
+ if (styleVal && styleVal !== "none" && styleVal !== "0") {
17764
+ const colorVal = value && typeof value === "object" ? value.color || value.underlineColor || null : null;
17765
+ const css = getUnderlineCssString({ type: styleVal, color: colorVal });
17766
+ css.split(";").forEach((decl) => {
17767
+ const d = decl.trim();
17768
+ if (!d) return;
17769
+ const idx = d.indexOf(":");
17770
+ if (idx === -1) return;
17771
+ const k2 = d.slice(0, idx).trim();
17772
+ const v = d.slice(idx + 1).trim();
17773
+ markValue[k2] = v;
17774
+ });
17775
+ }
17776
+ }
17610
17777
  } else if (typeof value === "string") {
17611
17778
  markValue[key] = value;
17612
17779
  }
@@ -17739,23 +17906,51 @@ const createLinkedStylesPlugin = (editor) => {
17739
17906
  };
17740
17907
  const generateDecorations = (state, styles) => {
17741
17908
  const decorations = [];
17742
- let lastStyleId = null;
17743
17909
  const doc2 = state?.doc;
17910
+ const getParagraphStyleId = (pos) => {
17911
+ const $pos = state.doc.resolve(pos);
17912
+ for (let d = $pos.depth; d >= 0; d--) {
17913
+ const n = $pos.node(d);
17914
+ if (n?.type?.name === "paragraph") return n.attrs?.styleId || null;
17915
+ }
17916
+ return null;
17917
+ };
17744
17918
  doc2.descendants((node, pos) => {
17745
17919
  const { name } = node.type;
17746
- if (node?.attrs?.styleId) lastStyleId = node.attrs.styleId;
17747
- if (name === "paragraph" && !node.attrs?.styleId) lastStyleId = null;
17748
- if (name !== "text" && name !== "listItem" && name !== "orderedList") return;
17920
+ if (name !== "text") return;
17921
+ const paragraphStyleId = getParagraphStyleId(pos);
17922
+ let runStyleId = null;
17923
+ let inlineTextStyleId = null;
17749
17924
  for (const mark of node.marks) {
17750
- if (mark.type.name === "textStyle" && mark.attrs.styleId) {
17751
- lastStyleId = mark.attrs.styleId;
17752
- }
17753
- }
17754
- const { linkedStyle, basedOnStyle } = getLinkedStyle(lastStyleId, styles);
17755
- if (!linkedStyle) return;
17925
+ if (mark.type.name === "run") {
17926
+ const rp = mark.attrs?.runProperties;
17927
+ if (rp && typeof rp === "object" && !Array.isArray(rp) && rp.styleId) runStyleId = rp.styleId;
17928
+ else if (Array.isArray(rp)) {
17929
+ const ent = rp.find((e) => e?.xmlName === "w:rStyle");
17930
+ const sid = ent?.attributes?.["w:val"];
17931
+ if (sid) runStyleId = sid;
17932
+ }
17933
+ } else if (mark.type.name === "textStyle" && mark.attrs?.styleId) {
17934
+ inlineTextStyleId = mark.attrs.styleId;
17935
+ }
17936
+ }
17937
+ const buildStyleMap = (sid) => {
17938
+ if (!sid) return {};
17939
+ const { linkedStyle, basedOnStyle: basedOnStyle2 } = getLinkedStyle(sid, styles);
17940
+ if (!linkedStyle) return {};
17941
+ const base2 = { ...basedOnStyle2?.definition?.styles || {} };
17942
+ return { ...base2, ...linkedStyle.definition?.styles || {} };
17943
+ };
17944
+ const pMap = buildStyleMap(paragraphStyleId);
17945
+ const tMap = buildStyleMap(inlineTextStyleId);
17946
+ const rMap = buildStyleMap(runStyleId);
17947
+ const finalStyles = { ...pMap, ...tMap, ...rMap };
17948
+ if (Object.keys(finalStyles).length === 0) return;
17949
+ const mergedLinkedStyle = { definition: { styles: finalStyles, attrs: {} } };
17950
+ const basedOnStyle = null;
17756
17951
  const $pos = state.doc.resolve(pos);
17757
17952
  const parent = $pos.parent;
17758
- const styleString = generateLinkedStyleString(linkedStyle, basedOnStyle, node, parent);
17953
+ const styleString = generateLinkedStyleString(mergedLinkedStyle, basedOnStyle, node, parent);
17759
17954
  if (!styleString) return;
17760
17955
  const decoration = Decoration.inline(pos, pos + node.nodeSize, { style: styleString });
17761
17956
  decorations.push(decoration);
@@ -17890,6 +18085,70 @@ const LinkedStyles = Extension.create({
17890
18085
  };
17891
18086
  }
17892
18087
  });
18088
+ function getUnderlineCssString({ type = "single", color = null, thickness = null, approximate = true } = {}) {
18089
+ const parts = [];
18090
+ const add = (k, v) => {
18091
+ if (!v) return;
18092
+ parts.push(`${k}: ${v}`);
18093
+ };
18094
+ const lower = String(type || "single").toLowerCase();
18095
+ if (lower === "none" || lower === "0") {
18096
+ add("text-decoration", "none");
18097
+ return parts.join("; ");
18098
+ }
18099
+ add("text-decoration-line", "underline");
18100
+ const HEAVY = thickness || "0.2em";
18101
+ const THICK = thickness || "0.15em";
18102
+ switch (lower) {
18103
+ case "single":
18104
+ break;
18105
+ case "double":
18106
+ add("text-decoration-style", "double");
18107
+ break;
18108
+ case "thick":
18109
+ add("text-decoration-thickness", THICK);
18110
+ break;
18111
+ case "dotted":
18112
+ add("text-decoration-style", "dotted");
18113
+ break;
18114
+ case "dash":
18115
+ case "dashed":
18116
+ add("text-decoration-style", "dashed");
18117
+ break;
18118
+ case "dotdash":
18119
+ case "dotdotdash":
18120
+ case "dashlong":
18121
+ case "dashlongheavy":
18122
+ if (approximate) {
18123
+ add("text-decoration-style", "dashed");
18124
+ if (lower.includes("heavy")) add("text-decoration-thickness", HEAVY);
18125
+ }
18126
+ break;
18127
+ case "dottedheavy":
18128
+ add("text-decoration-style", "dotted");
18129
+ add("text-decoration-thickness", HEAVY);
18130
+ break;
18131
+ case "dashedheavy":
18132
+ add("text-decoration-style", "dashed");
18133
+ add("text-decoration-thickness", HEAVY);
18134
+ break;
18135
+ case "wavy":
18136
+ add("text-decoration-style", "wavy");
18137
+ break;
18138
+ case "wavyheavy":
18139
+ add("text-decoration-style", "wavy");
18140
+ add("text-decoration-thickness", HEAVY);
18141
+ break;
18142
+ case "wavydouble":
18143
+ if (approximate) {
18144
+ add("text-decoration-style", "wavy");
18145
+ add("text-decoration-thickness", HEAVY);
18146
+ }
18147
+ break;
18148
+ }
18149
+ if (color) add("text-decoration-color", color);
18150
+ return parts.join("; ");
18151
+ }
17893
18152
  const generateOrderedListIndex = ({ listLevel, lvlText, listNumberingType, customFormat }) => {
17894
18153
  const handler = listIndexMap[listNumberingType];
17895
18154
  return handler ? handler(listLevel, lvlText, customFormat) : null;
@@ -26175,6 +26434,30 @@ const TextStyle = Mark.create({
26175
26434
  };
26176
26435
  }
26177
26436
  });
26437
+ function createCascadeToggleCommands({
26438
+ markName,
26439
+ setCommand,
26440
+ unsetCommand,
26441
+ toggleCommand,
26442
+ negationAttrs,
26443
+ isNegation,
26444
+ extendEmptyMarkRange
26445
+ } = {}) {
26446
+ if (!markName) throw new Error("createCascadeToggleCommands requires a markName");
26447
+ const capitalized = markName.charAt(0).toUpperCase() + markName.slice(1);
26448
+ const setName = setCommand ?? `set${capitalized}`;
26449
+ const unsetName = unsetCommand ?? `unset${capitalized}`;
26450
+ const toggleName = toggleCommand ?? `toggle${capitalized}`;
26451
+ const cascadeOptions = {};
26452
+ if (negationAttrs) cascadeOptions.negationAttrs = negationAttrs;
26453
+ if (typeof isNegation === "function") cascadeOptions.isNegation = isNegation;
26454
+ if (extendEmptyMarkRange !== void 0) cascadeOptions.extendEmptyMarkRange = extendEmptyMarkRange;
26455
+ return {
26456
+ [setName]: () => ({ commands: commands2 }) => commands2.setMark(markName),
26457
+ [unsetName]: () => ({ commands: commands2 }) => commands2.unsetMark(markName),
26458
+ [toggleName]: () => ({ commands: commands2 }) => commands2.toggleMarkCascade(markName, cascadeOptions)
26459
+ };
26460
+ }
26178
26461
  const Bold = Mark.create({
26179
26462
  name: "bold",
26180
26463
  addOptions() {
@@ -26209,9 +26492,18 @@ const Bold = Mark.create({
26209
26492
  ];
26210
26493
  },
26211
26494
  renderDOM({ htmlAttributes }) {
26212
- return ["strong", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
26495
+ const merged = Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
26496
+ const { value, ...rest } = merged || {};
26497
+ if (value === "0") {
26498
+ return ["span", rest, 0];
26499
+ }
26500
+ return ["strong", rest, 0];
26213
26501
  },
26214
26502
  addCommands() {
26503
+ const { setBold, unsetBold, toggleBold } = createCascadeToggleCommands({
26504
+ markName: this.name,
26505
+ negationAttrs: { value: "0" }
26506
+ });
26215
26507
  return {
26216
26508
  /**
26217
26509
  * Apply bold formatting
@@ -26221,7 +26513,7 @@ const Bold = Mark.create({
26221
26513
  * setBold()
26222
26514
  * @note '0' renders as normal weight
26223
26515
  */
26224
- setBold: () => ({ commands: commands2 }) => commands2.setMark(this.name),
26516
+ setBold,
26225
26517
  /**
26226
26518
  * Remove bold formatting
26227
26519
  * @category Command
@@ -26229,7 +26521,7 @@ const Bold = Mark.create({
26229
26521
  * @example
26230
26522
  * unsetBold()
26231
26523
  */
26232
- unsetBold: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
26524
+ unsetBold,
26233
26525
  /**
26234
26526
  * Toggle bold formatting
26235
26527
  * @category Command
@@ -26237,7 +26529,7 @@ const Bold = Mark.create({
26237
26529
  * @example
26238
26530
  * toggleBold()
26239
26531
  */
26240
- toggleBold: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
26532
+ toggleBold
26241
26533
  };
26242
26534
  },
26243
26535
  addShortcuts() {
@@ -26254,6 +26546,22 @@ const Italic = Mark.create({
26254
26546
  htmlAttributes: {}
26255
26547
  };
26256
26548
  },
26549
+ addAttributes() {
26550
+ return {
26551
+ /**
26552
+ * @category Attribute
26553
+ * @param {string} [value] - Italic toggle value ('0' renders as normal)
26554
+ */
26555
+ value: {
26556
+ default: null,
26557
+ renderDOM: (attrs) => {
26558
+ if (!attrs.value) return {};
26559
+ if (attrs.value === "0") return { style: "font-style: normal" };
26560
+ return {};
26561
+ }
26562
+ }
26563
+ };
26564
+ },
26257
26565
  parseDOM() {
26258
26566
  return [
26259
26567
  { tag: "i" },
@@ -26263,9 +26571,18 @@ const Italic = Mark.create({
26263
26571
  ];
26264
26572
  },
26265
26573
  renderDOM({ htmlAttributes }) {
26266
- return ["em", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
26574
+ const merged = Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
26575
+ const { value, ...rest } = merged || {};
26576
+ if (value === "0") {
26577
+ return ["span", rest, 0];
26578
+ }
26579
+ return ["em", rest, 0];
26267
26580
  },
26268
26581
  addCommands() {
26582
+ const { setItalic, unsetItalic, toggleItalic } = createCascadeToggleCommands({
26583
+ markName: this.name,
26584
+ negationAttrs: { value: "0" }
26585
+ });
26269
26586
  return {
26270
26587
  /**
26271
26588
  * Apply italic formatting
@@ -26274,7 +26591,7 @@ const Italic = Mark.create({
26274
26591
  * @example
26275
26592
  * setItalic()
26276
26593
  */
26277
- setItalic: () => ({ commands: commands2 }) => commands2.setMark(this.name),
26594
+ setItalic,
26278
26595
  /**
26279
26596
  * Remove italic formatting
26280
26597
  * @category Command
@@ -26282,7 +26599,7 @@ const Italic = Mark.create({
26282
26599
  * @example
26283
26600
  * unsetItalic()
26284
26601
  */
26285
- unsetItalic: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
26602
+ unsetItalic,
26286
26603
  /**
26287
26604
  * Toggle italic formatting
26288
26605
  * @category Command
@@ -26290,7 +26607,7 @@ const Italic = Mark.create({
26290
26607
  * @example
26291
26608
  * toggleItalic()
26292
26609
  */
26293
- toggleItalic: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
26610
+ toggleItalic
26294
26611
  };
26295
26612
  },
26296
26613
  addShortcuts() {
@@ -26315,7 +26632,16 @@ const Underline = Mark.create({
26315
26632
  ];
26316
26633
  },
26317
26634
  renderDOM({ htmlAttributes }) {
26318
- return ["u", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
26635
+ const merged = Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
26636
+ const type = merged?.underlineType;
26637
+ const color = merged?.underlineColor;
26638
+ const css = getUnderlineCssString({ type, color });
26639
+ const { style, ...rest } = merged || {};
26640
+ const styleString = [style, css].filter(Boolean).join("; ");
26641
+ if (type === "none") {
26642
+ return ["span", { ...rest, ...styleString ? { style: styleString } : {} }, 0];
26643
+ }
26644
+ return ["u", { ...rest, ...styleString ? { style: styleString } : {} }, 0];
26319
26645
  },
26320
26646
  addAttributes() {
26321
26647
  return {
@@ -26325,10 +26651,18 @@ const Underline = Mark.create({
26325
26651
  */
26326
26652
  underlineType: {
26327
26653
  default: "single"
26654
+ },
26655
+ underlineColor: {
26656
+ default: null
26328
26657
  }
26329
26658
  };
26330
26659
  },
26331
26660
  addCommands() {
26661
+ const { setUnderline, unsetUnderline, toggleUnderline } = createCascadeToggleCommands({
26662
+ markName: this.name,
26663
+ negationAttrs: { underlineType: "none" },
26664
+ isNegation: (attrs) => attrs?.underlineType === "none"
26665
+ });
26332
26666
  return {
26333
26667
  /**
26334
26668
  * Apply underline formatting
@@ -26337,7 +26671,7 @@ const Underline = Mark.create({
26337
26671
  * @example
26338
26672
  * setUnderline()
26339
26673
  */
26340
- setUnderline: () => ({ commands: commands2 }) => commands2.setMark(this.name),
26674
+ setUnderline,
26341
26675
  /**
26342
26676
  * Remove underline formatting
26343
26677
  * @category Command
@@ -26345,7 +26679,7 @@ const Underline = Mark.create({
26345
26679
  * @example
26346
26680
  * unsetUnderline()
26347
26681
  */
26348
- unsetUnderline: () => ({ commands: commands2 }) => commands2.unsetMark(this.name),
26682
+ unsetUnderline,
26349
26683
  /**
26350
26684
  * Toggle underline formatting
26351
26685
  * @category Command
@@ -26353,7 +26687,7 @@ const Underline = Mark.create({
26353
26687
  * @example
26354
26688
  * toggleUnderline()
26355
26689
  */
26356
- toggleUnderline: () => ({ commands: commands2 }) => commands2.toggleMark(this.name)
26690
+ toggleUnderline
26357
26691
  };
26358
26692
  },
26359
26693
  addShortcuts() {
@@ -26448,9 +26782,18 @@ const Strike = Mark.create({
26448
26782
  ];
26449
26783
  },
26450
26784
  renderDOM({ htmlAttributes }) {
26451
- return ["s", Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes), 0];
26785
+ const merged = Attribute.mergeAttributes(this.options.htmlAttributes, htmlAttributes);
26786
+ const { value, ...rest } = merged || {};
26787
+ if (value === "0") {
26788
+ return ["span", rest, 0];
26789
+ }
26790
+ return ["s", rest, 0];
26452
26791
  },
26453
26792
  addCommands() {
26793
+ const { setStrike, unsetStrike, toggleStrike } = createCascadeToggleCommands({
26794
+ markName: this.name,
26795
+ negationAttrs: { value: "0" }
26796
+ });
26454
26797
  return {
26455
26798
  /**
26456
26799
  * Apply strikethrough formatting
@@ -26459,9 +26802,7 @@ const Strike = Mark.create({
26459
26802
  * @example
26460
26803
  * setStrike()
26461
26804
  */
26462
- setStrike: () => ({ commands: commands2 }) => {
26463
- return commands2.setMark(this.name);
26464
- },
26805
+ setStrike,
26465
26806
  /**
26466
26807
  * Remove strikethrough formatting
26467
26808
  * @category Command
@@ -26469,9 +26810,7 @@ const Strike = Mark.create({
26469
26810
  * @example
26470
26811
  * unsetStrike()
26471
26812
  */
26472
- unsetStrike: () => ({ commands: commands2 }) => {
26473
- return commands2.unsetMark(this.name);
26474
- },
26813
+ unsetStrike,
26475
26814
  /**
26476
26815
  * Toggle strikethrough formatting
26477
26816
  * @category Command
@@ -26479,8 +26818,24 @@ const Strike = Mark.create({
26479
26818
  * @example
26480
26819
  * toggleStrike()
26481
26820
  */
26482
- toggleStrike: () => ({ commands: commands2 }) => {
26483
- return commands2.toggleMark(this.name);
26821
+ toggleStrike
26822
+ };
26823
+ },
26824
+ addAttributes() {
26825
+ return {
26826
+ /**
26827
+ * @category Attribute
26828
+ * @param {string} [value] - Strike toggle value ('0' renders as normal)
26829
+ */
26830
+ value: {
26831
+ default: null,
26832
+ renderDOM: (attrs) => {
26833
+ if (!attrs.value) return {};
26834
+ if (attrs.value === "0") {
26835
+ return { style: "text-decoration: none" };
26836
+ }
26837
+ return {};
26838
+ }
26484
26839
  }
26485
26840
  };
26486
26841
  },
@@ -32635,7 +32990,7 @@ const getStarterExtensions = () => {
32635
32990
  Paragraph,
32636
32991
  LineBreak,
32637
32992
  HardBreak,
32638
- RunItem,
32993
+ Run,
32639
32994
  SlashMenu,
32640
32995
  Strike,
32641
32996
  TabNode,