@zipify/wysiwyg 1.3.0-0 → 2.0.0-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 (84) hide show
  1. package/dist/cli.js +2 -2
  2. package/dist/wysiwyg.css +31 -42
  3. package/dist/wysiwyg.mjs +454 -399
  4. package/lib/__tests__/utils/buildTestExtensions.js +14 -0
  5. package/lib/__tests__/utils/index.js +1 -0
  6. package/lib/components/base/Button.vue +0 -7
  7. package/lib/components/base/dropdown/Dropdown.vue +1 -7
  8. package/lib/components/base/dropdown/DropdownActivator.vue +4 -19
  9. package/lib/components/base/dropdown/__tests__/DropdownActivator.test.js +1 -23
  10. package/lib/components/toolbar/controls/AlignmentControl.vue +1 -11
  11. package/lib/components/toolbar/controls/FontColorControl.vue +0 -13
  12. package/lib/components/toolbar/controls/FontFamilyControl.vue +0 -4
  13. package/lib/components/toolbar/controls/FontSizeControl.vue +1 -6
  14. package/lib/components/toolbar/controls/FontWeightControl.vue +0 -12
  15. package/lib/components/toolbar/controls/ItalicControl.vue +0 -13
  16. package/lib/components/toolbar/controls/LineHeightControl.vue +0 -14
  17. package/lib/components/toolbar/controls/SuperscriptControl.vue +2 -2
  18. package/lib/components/toolbar/controls/UnderlineControl.vue +0 -12
  19. package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +5 -72
  20. package/lib/components/toolbar/controls/__tests__/FontColorControl.test.js +1 -22
  21. package/lib/components/toolbar/controls/__tests__/FontFamilyControl.test.js +0 -1
  22. package/lib/components/toolbar/controls/__tests__/FontSizeControl.test.js +0 -1
  23. package/lib/components/toolbar/controls/__tests__/FontWeightControl.test.js +0 -1
  24. package/lib/components/toolbar/controls/__tests__/ItalicControl.test.js +1 -23
  25. package/lib/components/toolbar/controls/__tests__/LineHeightControl.test.js +1 -23
  26. package/lib/components/toolbar/controls/__tests__/SuperscriptControl.test.js +2 -2
  27. package/lib/components/toolbar/controls/__tests__/UnderlineControl.test.js +1 -25
  28. package/lib/composables/__tests__/useEditor.test.js +2 -2
  29. package/lib/extensions/BackgroundColor.js +4 -4
  30. package/lib/extensions/FontColor.js +4 -5
  31. package/lib/extensions/FontFamily.js +4 -5
  32. package/lib/extensions/FontSize.js +5 -7
  33. package/lib/extensions/FontStyle.js +13 -11
  34. package/lib/extensions/FontWeight.js +6 -9
  35. package/lib/extensions/StylePreset.js +0 -14
  36. package/lib/extensions/Superscript.js +23 -1
  37. package/lib/extensions/TextDecoration.js +33 -20
  38. package/lib/extensions/__tests__/Alignment.test.js +10 -7
  39. package/lib/extensions/__tests__/BackgroundColor.test.js +6 -3
  40. package/lib/extensions/__tests__/CaseStyle.test.js +11 -7
  41. package/lib/extensions/__tests__/FontColor.test.js +6 -3
  42. package/lib/extensions/__tests__/FontFamily.test.js +29 -22
  43. package/lib/extensions/__tests__/FontSize.test.js +24 -17
  44. package/lib/extensions/__tests__/FontStyle.test.js +22 -16
  45. package/lib/extensions/__tests__/FontWeight.test.js +26 -19
  46. package/lib/extensions/__tests__/LineHeight.test.js +14 -11
  47. package/lib/extensions/__tests__/Link.test.js +14 -10
  48. package/lib/extensions/__tests__/Margin.test.js +2 -2
  49. package/lib/extensions/__tests__/StylePreset.test.js +49 -100
  50. package/lib/extensions/__tests__/TextDecoration.test.js +72 -46
  51. package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +24 -24
  52. package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +24 -24
  53. package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +86 -82
  54. package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +70 -70
  55. package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +53 -45
  56. package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +64 -60
  57. package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +148 -83
  58. package/lib/extensions/core/Document.js +5 -0
  59. package/lib/extensions/core/Heading.js +10 -0
  60. package/lib/extensions/core/NodeProcessor.js +84 -4
  61. package/lib/extensions/core/Paragraph.js +9 -0
  62. package/lib/extensions/core/TextProcessor.js +10 -12
  63. package/lib/extensions/core/__tests__/NodeProcessor.test.js +82 -10
  64. package/lib/extensions/core/__tests__/SelectionProcessor.test.js +2 -2
  65. package/lib/extensions/core/__tests__/TextProcessor.test.js +18 -20
  66. package/lib/extensions/core/__tests__/__snapshots__/NodeProcessor.test.js.snap +132 -0
  67. package/lib/extensions/core/index.js +5 -5
  68. package/lib/extensions/core/steps/AddNodeMarkStep.js +60 -0
  69. package/lib/extensions/core/steps/RemoveNodeMarkStep.js +50 -0
  70. package/lib/extensions/core/steps/index.js +2 -0
  71. package/lib/extensions/list/List.js +1 -0
  72. package/lib/extensions/list/ListItem.js +5 -0
  73. package/lib/extensions/list/__tests__/List.test.js +30 -25
  74. package/lib/services/ContentNormalizer.js +1 -100
  75. package/lib/services/NodeFactory.js +16 -6
  76. package/lib/services/__tests__/ContentNormalizer.test.js +0 -64
  77. package/lib/utils/findMarkByType.js +5 -0
  78. package/lib/utils/index.js +5 -0
  79. package/lib/utils/isMarkAppliedToParent.js +15 -0
  80. package/lib/utils/isNodeFullySelected.js +10 -0
  81. package/lib/utils/resolveNodePosition.js +6 -0
  82. package/lib/utils/resolveTextPosition.js +6 -0
  83. package/package.json +1 -1
  84. package/lib/assets/icons/indicator.svg +0 -5
package/dist/wysiwyg.mjs CHANGED
@@ -17,7 +17,11 @@ var __privateAdd = (obj, member, value) => {
17
17
  throw TypeError("Cannot add the same private member more than once");
18
18
  member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
19
19
  };
20
- var _domParser;
20
+ var __privateMethod = (obj, member, method) => {
21
+ __accessCheck(obj, member, "access private method");
22
+ return method;
23
+ };
24
+ var _domParser, _textBlock, textBlock_fn, _normalizeTextBlockArgs, normalizeTextBlockArgs_fn;
21
25
  import { computed, ref, watch, inject, onUnmounted, nextTick, provide, onMounted, toRef, unref, reactive } from "vue";
22
26
  import { ColorModel, ZipifyColorPicker } from "@zipify/colorpicker";
23
27
  function OrderedMap(content) {
@@ -14286,7 +14290,7 @@ var __component__$F = /* @__PURE__ */ normalizeComponent(
14286
14290
  staticRenderFns$F,
14287
14291
  false,
14288
14292
  __vue2_injectStyles$F,
14289
- "2fa65564",
14293
+ "562f4e4a",
14290
14294
  null,
14291
14295
  null
14292
14296
  );
@@ -14415,23 +14419,22 @@ const __vite_glob_0_4 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" sty
14415
14419
  const __vite_glob_0_5 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="#fff" stroke="#B3B3B3" d="M4.5 4.5h19v19h-19z"/>\n <path fill="#3B3B3B" d="M26 20.7a2.51 2.51 0 0 1-5 0c0-1.31 2.5-4.7 2.5-4.7s2.5 3.39 2.5 4.7Z"/>\n <path fill="#3B3B3B" fill-rule="evenodd" d="M19.64 19.93h-1.715a.75.75 0 0 1-.475-.145.82.82 0 0 1-.268-.359l-.89-2.433h-4.943l-.89 2.433a.78.78 0 0 1-.26.347.73.73 0 0 1-.475.157H8L12.686 8h2.269l4.686 11.93Zm-7.721-4.505h3.803l-1.452-3.968a18.048 18.048 0 0 1-.219-.623c-.08-.24-.158-.5-.235-.78-.077.28-.152.542-.227.784a8.742 8.742 0 0 1-.218.635l-1.452 3.952Z" clip-rule="evenodd"/>\n</svg>\n';
14416
14420
  const __vite_glob_0_6 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="M16.64 19.93h-1.715a.75.75 0 0 1-.475-.145.82.82 0 0 1-.268-.359l-.89-2.433H8.35l-.891 2.433a.78.78 0 0 1-.26.347.73.73 0 0 1-.475.157H5L9.686 8h2.269l4.686 11.93Zm-7.72-4.505h3.803l-1.452-3.968a18.048 18.048 0 0 1-.219-.623c-.08-.24-.158-.5-.235-.78-.077.28-.152.542-.227.784a8.742 8.742 0 0 1-.218.635L8.92 15.425Zm14.968 4.505h-.915a.987.987 0 0 1-.454-.087c-.11-.058-.192-.175-.248-.35l-.181-.603a7.005 7.005 0 0 1-.631.507c-.206.146-.42.269-.64.368a3.26 3.26 0 0 1-.7.222c-.248.05-.523.075-.826.075-.357 0-.687-.049-.99-.145a2.134 2.134 0 0 1-.78-.433 1.967 1.967 0 0 1-.507-.718 2.545 2.545 0 0 1-.181-.998c0-.319.084-.634.251-.945.168-.31.447-.59.838-.841.39-.25.91-.458 1.559-.623.649-.165 1.455-.258 2.417-.28v-.495c0-.567-.12-.986-.359-1.259-.239-.272-.587-.408-1.043-.408-.33 0-.605.039-.825.116a3.17 3.17 0 0 0-.574.26 25.11 25.11 0 0 1-.45.26.912.912 0 0 1-.453.115.59.59 0 0 1-.355-.107.843.843 0 0 1-.239-.264l-.371-.652c.973-.891 2.148-1.337 3.523-1.337.494 0 .936.081 1.324.244.387.162.716.387.985.676.27.289.475.634.615 1.036.14.401.21.841.21 1.32v5.346Zm-3.96-1.271c.21 0 .402-.02.578-.058.176-.038.342-.096.5-.173.156-.077.307-.172.453-.285a4.13 4.13 0 0 0 .441-.4v-1.427c-.594.027-1.09.078-1.489.153a3.967 3.967 0 0 0-.961.284c-.242.116-.414.25-.516.404a.894.894 0 0 0-.152.504c0 .357.106.613.317.767.212.154.489.231.83.231Z" clip-rule="evenodd"/>\n</svg>\n';
14417
14421
  const __vite_glob_0_7 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="M22 20.62a2.42 2.42 0 0 1-4.84 0c0-1.25 2.42-4.54 2.42-4.54S22 19.37 22 20.62ZM9.92 15.425l1.452-3.951c.071-.182.145-.394.219-.636.074-.242.149-.503.226-.783a17.223 17.223 0 0 0 .454 1.402l1.452 3.968H9.919Zm5.411 4.199c.226-.795.658-1.684 1.184-2.562L12.955 8h-2.269L6 19.93h1.725a.736.736 0 0 0 .474-.157.792.792 0 0 0 .26-.347l.891-2.434h4.941l.891 2.434c.031.079.097.134.148.198Z" clip-rule="evenodd"/>\n</svg>\n';
14418
- const __vite_glob_0_8 = '<svg width="9" height="9" viewBox="0 0 9 9" fill="none" xmlns="http://www.w3.org/2000/svg">\n <path d="M0 4.5C0 2.01472 2.01472 0 4.5 0C6.98528 0 9 2.01472 9 4.5C9 6.98528 6.98528 9 4.5 9C2.01472 9 0 6.98528 0 4.5Z" fill="#FFAB00"/>\n <path fill-rule="evenodd" clip-rule="evenodd" d="M5.0625 2.25H3.9375V5.625H5.0625V2.25Z" fill="white"/>\n <path fill-rule="evenodd" clip-rule="evenodd" d="M3.9375 6.75C3.9375 6.43894 4.18894 6.1875 4.5 6.1875C4.8105 6.1875 5.0625 6.43894 5.0625 6.75C5.0625 7.06106 4.8105 7.3125 4.5 7.3125C4.18894 7.3125 3.9375 7.06106 3.9375 6.75Z" fill="white"/>\n</svg>\n';
14419
- const __vite_glob_0_9 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" d="M18 9V7h-7v2h2.64l-1.22 10H10v2h7v-2h-2.83L15.4 9H18Z"/>\n</svg>\n';
14420
- const __vite_glob_0_10 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="m5 10 3-3 3 3H9v8h2l-3 3-3-3h2v-8H5Zm8-3h10v2H13V7Zm10 6H13v2h10v-2Zm0 6H13v2h10v-2Z" clip-rule="evenodd"/>\n</svg>\n';
14421
- const __vite_glob_0_11 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="M12 17.5h-2a3.5 3.5 0 1 1 0-7h2V9h-2a5 5 0 0 0 0 10h2v-1.5Zm6-4.5h-8v2h8v-2Zm-2-4h2a5 5 0 0 1 0 10h-2v-1.5h2a3.5 3.5 0 1 0 0-7h-2V9Z" clip-rule="evenodd"/>\n</svg>\n';
14422
- const __vite_glob_0_12 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <rect width="9" height="9" x="9.5" y="9.5" stroke="var(--zw-icon-foreground)" rx="4.5"/>\n</svg>\n';
14423
- const __vite_glob_0_13 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" d="M15.108 18.184V19H10.5v-.816h1.842v-5.862c0-.176.006-.354.018-.534l-1.53 1.314a.375.375 0 0 1-.156.084.373.373 0 0 1-.27-.048.318.318 0 0 1-.084-.078l-.336-.462 2.562-2.214h.87v7.8h1.692Zm1.519.156a.8.8 0 0 1 .054-.294.829.829 0 0 1 .156-.24.77.77 0 0 1 .534-.222.77.77 0 0 1 .696.462c.04.092.06.19.06.294a.744.744 0 0 1-.222.534.692.692 0 0 1-.24.156.73.73 0 0 1-.294.06.73.73 0 0 1-.294-.06.692.692 0 0 1-.396-.39.816.816 0 0 1-.054-.3Z"/>\n</svg>\n';
14424
- const __vite_glob_0_14 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <rect width="10" height="10" x="9" y="9" fill="var(--zw-icon-foreground)" rx="5"/>\n</svg>\n';
14425
- const __vite_glob_0_15 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" d="M12.086 9.802h.834v11.292h-.834V9.802Zm2.592 8.538a.8.8 0 0 1 .054-.294.829.829 0 0 1 .156-.24.77.77 0 0 1 .534-.222.77.77 0 0 1 .696.462c.04.092.06.19.06.294a.744.744 0 0 1-.222.534.692.692 0 0 1-.24.156.73.73 0 0 1-.294.06.73.73 0 0 1-.294-.06.692.692 0 0 1-.396-.39.816.816 0 0 1-.054-.3Z"/>\n</svg>\n';
14426
- const __vite_glob_0_16 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" d="m13.664 15.808-1.35-3.498a7.11 7.11 0 0 1-.252-.804c-.084.324-.17.594-.258.81l-1.35 3.492h3.21ZM16.088 19h-.9a.387.387 0 0 1-.252-.078.48.48 0 0 1-.144-.198l-.804-2.076H10.13l-.804 2.076a.421.421 0 0 1-.138.192.383.383 0 0 1-.252.084h-.9l3.438-8.598h1.176L16.088 19Zm.7-.66a.8.8 0 0 1 .053-.294.829.829 0 0 1 .156-.24.77.77 0 0 1 .534-.222.77.77 0 0 1 .696.462c.04.092.06.19.06.294a.744.744 0 0 1-.222.534.692.692 0 0 1-.24.156.73.73 0 0 1-.294.06.73.73 0 0 1-.294-.06.692.692 0 0 1-.396-.39.816.816 0 0 1-.054-.3Z"/>\n</svg>\n';
14427
- const __vite_glob_0_17 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" d="M9 9h10v10H9z"/>\n</svg>\n';
14428
- const __vite_glob_0_18 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="M14.089 6.726a1 1 0 0 1 1.425-.003l6.8 6.882a1 1 0 0 1 .007 1.398L17.2 20.3l-.2.2c-2.2 2.1-5.7 2-7.8-.2l-3.516-3.6a1 1 0 0 1 0-1.399l8.405-8.575Zm1.81 12.674c.1 0 .2 0 .2-.1l4.8-5-6.1-6.2-5 5.1 6.1 6.2Z" clip-rule="evenodd"/>\n</svg>\n';
14429
- const __vite_glob_0_19 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" d="M14 9.333V6.666l-3.334 3.333L14 13.333v-2.667c2.206 0 4 1.793 4 4s-1.794 4-4 4c-2.207 0-4-1.793-4-4H8.666A5.332 5.332 0 0 0 14 19.999a5.332 5.332 0 0 0 5.333-5.333A5.332 5.332 0 0 0 14 9.333Z"/>\n</svg>\n';
14430
- const __vite_glob_0_20 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="m14 12.731.77.27H20v2H8v-2h2.84a2.892 2.892 0 0 1-.46-.71 3.61 3.61 0 0 1-.29-1.52c0-.484.1-.964.29-1.41a3.5 3.5 0 0 1 .83-1.2 4 4 0 0 1 1.35-.84 4.74 4.74 0 0 1 1.83-.32 6 6 0 0 1 2.11.41 5 5 0 0 1 1.68 1l-.46.88a.69.69 0 0 1-.18.22.41.41 0 0 1-.25.07.69.69 0 0 1-.39-.16 5.551 5.551 0 0 0-.56-.36 4.641 4.641 0 0 0-.8-.36 3.44 3.44 0 0 0-1.14-.16 3.16 3.16 0 0 0-1.11.17 2.29 2.29 0 0 0-.8.45 1.87 1.87 0 0 0-.49.67 2.138 2.138 0 0 0-.11.79c-.023.357.08.711.29 1 .206.267.465.489.76.65.338.187.693.34 1.06.46Zm1.99 6.06c.24-.22.427-.49.55-.79.135-.315.2-.657.19-1h1.74a4.58 4.58 0 0 1-.25 1.38 4 4 0 0 1-.91 1.37 4.231 4.231 0 0 1-1.46.92 5.503 5.503 0 0 1-2 .33 6.13 6.13 0 0 1-2.5-.46 5.66 5.66 0 0 1-1.89-1.31l.54-.88a.61.61 0 0 1 .19-.17.45.45 0 0 1 .25-.07.5.5 0 0 1 .28.1c.128.077.251.16.37.25l.46.33c.19.13.391.243.6.34.245.107.5.191.76.25.328.076.664.11 1 .1a3.67 3.67 0 0 0 1.19-.18c.328-.109.63-.282.89-.51Z" clip-rule="evenodd"/>\n</svg>\n';
14431
- const __vite_glob_0_21 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" d="M21.985 8.625h-1.75V9.5h2.625v.875h-3.5v-1.75c0-.481.394-.875.875-.875h1.75v-.875H19.36V6h2.625c.481 0 .875.394.875.875v.875a.878.878 0 0 1-.875.875ZM7.88 20h2.327l2.975-4.742h.105L16.262 20h2.328l-4.069-6.361L18.32 7.75h-2.345l-2.687 4.366h-.105L10.48 7.75H8.15l3.78 5.889L7.88 20Z"/>\n</svg>\n';
14432
- const __vite_glob_0_22 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="M15.4 16.06a3.3 3.3 0 0 1-1.4.29 3.12 3.12 0 0 1-1.39-.29 2.88 2.88 0 0 1-1.05-.81 3.711 3.711 0 0 1-.65-1.25 5.659 5.659 0 0 1-.22-1.6V7H9v5.41a6.89 6.89 0 0 0 .34 2.22 5.29 5.29 0 0 0 1 1.77c.437.501.975.904 1.58 1.18A5 5 0 0 0 14 18a5 5 0 0 0 2.08-.42 4.61 4.61 0 0 0 1.57-1.18 5.27 5.27 0 0 0 1-1.77 6.89 6.89 0 0 0 .35-2.22V7h-1.69v5.41a5.659 5.659 0 0 1-.22 1.59 3.71 3.71 0 0 1-.69 1.25c-.27.34-.61.617-1 .81ZM20 19H8v2h12v-2Z" clip-rule="evenodd"/>\n</svg>\n';
14433
- const __vite_glob_0_23 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 20 20">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="M18.96 10a5 5 0 0 0-5-5h-2v1.5h2a3.49 3.49 0 0 1 1.58 6.61L13.43 11h.53V9h-2.53l-7-7-1.47 1.47L17.49 18l1.47-1.47-2.34-2.34A4.93 4.93 0 0 0 18.96 10Zm-13 1h1.59L5.96 9.41V11ZM3.81 7.26A3.47 3.47 0 0 0 2.46 10a3.5 3.5 0 0 0 3.5 3.5h2V15h-2a5 5 0 0 1-3.21-8.8l1.06 1.06Z" clip-rule="evenodd"/>\n</svg>\n';
14434
- const modules = /* @__PURE__ */ Object.assign({ "../assets/icons/alignment-center.svg": __vite_glob_0_0, "../assets/icons/alignment-justify.svg": __vite_glob_0_1, "../assets/icons/alignment-left.svg": __vite_glob_0_2, "../assets/icons/alignment-right.svg": __vite_glob_0_3, "../assets/icons/arrow.svg": __vite_glob_0_4, "../assets/icons/background-color.svg": __vite_glob_0_5, "../assets/icons/case-style.svg": __vite_glob_0_6, "../assets/icons/font-color.svg": __vite_glob_0_7, "../assets/icons/indicator.svg": __vite_glob_0_8, "../assets/icons/italic.svg": __vite_glob_0_9, "../assets/icons/line-height.svg": __vite_glob_0_10, "../assets/icons/link.svg": __vite_glob_0_11, "../assets/icons/list-circle.svg": __vite_glob_0_12, "../assets/icons/list-decimal.svg": __vite_glob_0_13, "../assets/icons/list-disc.svg": __vite_glob_0_14, "../assets/icons/list-latin.svg": __vite_glob_0_15, "../assets/icons/list-roman.svg": __vite_glob_0_16, "../assets/icons/list-square.svg": __vite_glob_0_17, "../assets/icons/remove-format.svg": __vite_glob_0_18, "../assets/icons/reset-styles.svg": __vite_glob_0_19, "../assets/icons/strike-through.svg": __vite_glob_0_20, "../assets/icons/superscript.svg": __vite_glob_0_21, "../assets/icons/underline.svg": __vite_glob_0_22, "../assets/icons/unlink.svg": __vite_glob_0_23 });
14422
+ const __vite_glob_0_8 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" d="M18 9V7h-7v2h2.64l-1.22 10H10v2h7v-2h-2.83L15.4 9H18Z"/>\n</svg>\n';
14423
+ const __vite_glob_0_9 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="m5 10 3-3 3 3H9v8h2l-3 3-3-3h2v-8H5Zm8-3h10v2H13V7Zm10 6H13v2h10v-2Zm0 6H13v2h10v-2Z" clip-rule="evenodd"/>\n</svg>\n';
14424
+ const __vite_glob_0_10 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="M12 17.5h-2a3.5 3.5 0 1 1 0-7h2V9h-2a5 5 0 0 0 0 10h2v-1.5Zm6-4.5h-8v2h8v-2Zm-2-4h2a5 5 0 0 1 0 10h-2v-1.5h2a3.5 3.5 0 1 0 0-7h-2V9Z" clip-rule="evenodd"/>\n</svg>\n';
14425
+ const __vite_glob_0_11 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <rect width="9" height="9" x="9.5" y="9.5" stroke="var(--zw-icon-foreground)" rx="4.5"/>\n</svg>\n';
14426
+ const __vite_glob_0_12 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" d="M15.108 18.184V19H10.5v-.816h1.842v-5.862c0-.176.006-.354.018-.534l-1.53 1.314a.375.375 0 0 1-.156.084.373.373 0 0 1-.27-.048.318.318 0 0 1-.084-.078l-.336-.462 2.562-2.214h.87v7.8h1.692Zm1.519.156a.8.8 0 0 1 .054-.294.829.829 0 0 1 .156-.24.77.77 0 0 1 .534-.222.77.77 0 0 1 .696.462c.04.092.06.19.06.294a.744.744 0 0 1-.222.534.692.692 0 0 1-.24.156.73.73 0 0 1-.294.06.73.73 0 0 1-.294-.06.692.692 0 0 1-.396-.39.816.816 0 0 1-.054-.3Z"/>\n</svg>\n';
14427
+ const __vite_glob_0_13 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <rect width="10" height="10" x="9" y="9" fill="var(--zw-icon-foreground)" rx="5"/>\n</svg>\n';
14428
+ const __vite_glob_0_14 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" d="M12.086 9.802h.834v11.292h-.834V9.802Zm2.592 8.538a.8.8 0 0 1 .054-.294.829.829 0 0 1 .156-.24.77.77 0 0 1 .534-.222.77.77 0 0 1 .696.462c.04.092.06.19.06.294a.744.744 0 0 1-.222.534.692.692 0 0 1-.24.156.73.73 0 0 1-.294.06.73.73 0 0 1-.294-.06.692.692 0 0 1-.396-.39.816.816 0 0 1-.054-.3Z"/>\n</svg>\n';
14429
+ const __vite_glob_0_15 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" d="m13.664 15.808-1.35-3.498a7.11 7.11 0 0 1-.252-.804c-.084.324-.17.594-.258.81l-1.35 3.492h3.21ZM16.088 19h-.9a.387.387 0 0 1-.252-.078.48.48 0 0 1-.144-.198l-.804-2.076H10.13l-.804 2.076a.421.421 0 0 1-.138.192.383.383 0 0 1-.252.084h-.9l3.438-8.598h1.176L16.088 19Zm.7-.66a.8.8 0 0 1 .053-.294.829.829 0 0 1 .156-.24.77.77 0 0 1 .534-.222.77.77 0 0 1 .696.462c.04.092.06.19.06.294a.744.744 0 0 1-.222.534.692.692 0 0 1-.24.156.73.73 0 0 1-.294.06.73.73 0 0 1-.294-.06.692.692 0 0 1-.396-.39.816.816 0 0 1-.054-.3Z"/>\n</svg>\n';
14430
+ const __vite_glob_0_16 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" d="M9 9h10v10H9z"/>\n</svg>\n';
14431
+ const __vite_glob_0_17 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="M14.089 6.726a1 1 0 0 1 1.425-.003l6.8 6.882a1 1 0 0 1 .007 1.398L17.2 20.3l-.2.2c-2.2 2.1-5.7 2-7.8-.2l-3.516-3.6a1 1 0 0 1 0-1.399l8.405-8.575Zm1.81 12.674c.1 0 .2 0 .2-.1l4.8-5-6.1-6.2-5 5.1 6.1 6.2Z" clip-rule="evenodd"/>\n</svg>\n';
14432
+ const __vite_glob_0_18 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" d="M14 9.333V6.666l-3.334 3.333L14 13.333v-2.667c2.206 0 4 1.793 4 4s-1.794 4-4 4c-2.207 0-4-1.793-4-4H8.666A5.332 5.332 0 0 0 14 19.999a5.332 5.332 0 0 0 5.333-5.333A5.332 5.332 0 0 0 14 9.333Z"/>\n</svg>\n';
14433
+ const __vite_glob_0_19 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="m14 12.731.77.27H20v2H8v-2h2.84a2.892 2.892 0 0 1-.46-.71 3.61 3.61 0 0 1-.29-1.52c0-.484.1-.964.29-1.41a3.5 3.5 0 0 1 .83-1.2 4 4 0 0 1 1.35-.84 4.74 4.74 0 0 1 1.83-.32 6 6 0 0 1 2.11.41 5 5 0 0 1 1.68 1l-.46.88a.69.69 0 0 1-.18.22.41.41 0 0 1-.25.07.69.69 0 0 1-.39-.16 5.551 5.551 0 0 0-.56-.36 4.641 4.641 0 0 0-.8-.36 3.44 3.44 0 0 0-1.14-.16 3.16 3.16 0 0 0-1.11.17 2.29 2.29 0 0 0-.8.45 1.87 1.87 0 0 0-.49.67 2.138 2.138 0 0 0-.11.79c-.023.357.08.711.29 1 .206.267.465.489.76.65.338.187.693.34 1.06.46Zm1.99 6.06c.24-.22.427-.49.55-.79.135-.315.2-.657.19-1h1.74a4.58 4.58 0 0 1-.25 1.38 4 4 0 0 1-.91 1.37 4.231 4.231 0 0 1-1.46.92 5.503 5.503 0 0 1-2 .33 6.13 6.13 0 0 1-2.5-.46 5.66 5.66 0 0 1-1.89-1.31l.54-.88a.61.61 0 0 1 .19-.17.45.45 0 0 1 .25-.07.5.5 0 0 1 .28.1c.128.077.251.16.37.25l.46.33c.19.13.391.243.6.34.245.107.5.191.76.25.328.076.664.11 1 .1a3.67 3.67 0 0 0 1.19-.18c.328-.109.63-.282.89-.51Z" clip-rule="evenodd"/>\n</svg>\n';
14434
+ const __vite_glob_0_20 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" d="M21.985 8.625h-1.75V9.5h2.625v.875h-3.5v-1.75c0-.481.394-.875.875-.875h1.75v-.875H19.36V6h2.625c.481 0 .875.394.875.875v.875a.878.878 0 0 1-.875.875ZM7.88 20h2.327l2.975-4.742h.105L16.262 20h2.328l-4.069-6.361L18.32 7.75h-2.345l-2.687 4.366h-.105L10.48 7.75H8.15l3.78 5.889L7.88 20Z"/>\n</svg>\n';
14435
+ const __vite_glob_0_21 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 28 28">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="M15.4 16.06a3.3 3.3 0 0 1-1.4.29 3.12 3.12 0 0 1-1.39-.29 2.88 2.88 0 0 1-1.05-.81 3.711 3.711 0 0 1-.65-1.25 5.659 5.659 0 0 1-.22-1.6V7H9v5.41a6.89 6.89 0 0 0 .34 2.22 5.29 5.29 0 0 0 1 1.77c.437.501.975.904 1.58 1.18A5 5 0 0 0 14 18a5 5 0 0 0 2.08-.42 4.61 4.61 0 0 0 1.57-1.18 5.27 5.27 0 0 0 1-1.77 6.89 6.89 0 0 0 .35-2.22V7h-1.69v5.41a5.659 5.659 0 0 1-.22 1.59 3.71 3.71 0 0 1-.69 1.25c-.27.34-.61.617-1 .81ZM20 19H8v2h12v-2Z" clip-rule="evenodd"/>\n</svg>\n';
14436
+ const __vite_glob_0_22 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 20 20">\n <path fill="var(--zw-icon-foreground)" fill-rule="evenodd" d="M18.96 10a5 5 0 0 0-5-5h-2v1.5h2a3.49 3.49 0 0 1 1.58 6.61L13.43 11h.53V9h-2.53l-7-7-1.47 1.47L17.49 18l1.47-1.47-2.34-2.34A4.93 4.93 0 0 0 18.96 10Zm-13 1h1.59L5.96 9.41V11ZM3.81 7.26A3.47 3.47 0 0 0 2.46 10a3.5 3.5 0 0 0 3.5 3.5h2V15h-2a5 5 0 0 1-3.21-8.8l1.06 1.06Z" clip-rule="evenodd"/>\n</svg>\n';
14437
+ const modules = /* @__PURE__ */ Object.assign({ "../assets/icons/alignment-center.svg": __vite_glob_0_0, "../assets/icons/alignment-justify.svg": __vite_glob_0_1, "../assets/icons/alignment-left.svg": __vite_glob_0_2, "../assets/icons/alignment-right.svg": __vite_glob_0_3, "../assets/icons/arrow.svg": __vite_glob_0_4, "../assets/icons/background-color.svg": __vite_glob_0_5, "../assets/icons/case-style.svg": __vite_glob_0_6, "../assets/icons/font-color.svg": __vite_glob_0_7, "../assets/icons/italic.svg": __vite_glob_0_8, "../assets/icons/line-height.svg": __vite_glob_0_9, "../assets/icons/link.svg": __vite_glob_0_10, "../assets/icons/list-circle.svg": __vite_glob_0_11, "../assets/icons/list-decimal.svg": __vite_glob_0_12, "../assets/icons/list-disc.svg": __vite_glob_0_13, "../assets/icons/list-latin.svg": __vite_glob_0_14, "../assets/icons/list-roman.svg": __vite_glob_0_15, "../assets/icons/list-square.svg": __vite_glob_0_16, "../assets/icons/remove-format.svg": __vite_glob_0_17, "../assets/icons/reset-styles.svg": __vite_glob_0_18, "../assets/icons/strike-through.svg": __vite_glob_0_19, "../assets/icons/superscript.svg": __vite_glob_0_20, "../assets/icons/underline.svg": __vite_glob_0_21, "../assets/icons/unlink.svg": __vite_glob_0_22 });
14435
14438
  function importIcon(name) {
14436
14439
  return modules[`../assets/icons/${name}.svg`] || "";
14437
14440
  }
@@ -14444,6 +14447,41 @@ function unmarkWysiwygContent({ __wswg__, ...content }) {
14444
14447
  function markWysiwygContent(content) {
14445
14448
  return { ...content, __wswg__: true };
14446
14449
  }
14450
+ function resolveNodePosition({ path, pos }, node, modifier) {
14451
+ const index = path.indexOf(node);
14452
+ const slice2 = path.slice(index).reverse().filter((step) => typeof step === "object");
14453
+ return pos + modifier * slice2.length;
14454
+ }
14455
+ function resolveTextPosition($from, $to, node, position) {
14456
+ return {
14457
+ from: Math.max(position, $from.pos),
14458
+ to: Math.min(position + node.nodeSize, $to.pos)
14459
+ };
14460
+ }
14461
+ function isNodeFullySelected($from, $to, node, position) {
14462
+ const fromPosition = resolveNodePosition($from, node, -1);
14463
+ const toPosition = resolveNodePosition($to, node, 1);
14464
+ const isFromMatch = fromPosition <= position;
14465
+ const isToMatch = toPosition >= node.nodeSize + position;
14466
+ return isFromMatch && isToMatch;
14467
+ }
14468
+ const DEFAULT_COMPARATOR = (parent, child) => child.eq(parent);
14469
+ function isMarkAppliedToParent({ doc: doc2 }, position, checkingMark, comparator = DEFAULT_COMPARATOR) {
14470
+ const steps = doc2.resolve(position).path.reverse();
14471
+ for (const step of steps) {
14472
+ if (typeof step === "number")
14473
+ continue;
14474
+ for (const mark of step.marks) {
14475
+ if (comparator(mark, checkingMark))
14476
+ return true;
14477
+ }
14478
+ }
14479
+ return false;
14480
+ }
14481
+ function findMarkByType(list, typeOrName) {
14482
+ const name = typeof typeOrName === "string" ? typeOrName : typeOrName.name;
14483
+ return list.find((mark) => mark.type.name === name);
14484
+ }
14447
14485
  var render$D = function __render__6() {
14448
14486
  var _vm = this;
14449
14487
  var _h = _vm.$createElement;
@@ -19519,8 +19557,6 @@ const _ContentNormalizer = class {
19519
19557
  this.iterateNodes(this._normalizeBreakLines, (node) => node.tagName === "BR");
19520
19558
  this.iterateNodes(this._removeEmptyNodes, this._isBlockNode);
19521
19559
  this.iterateNodes(this._normalizeListItems, (node) => node.tagName === "LI");
19522
- this.iterateNodes(this._normalizeSettingsStructure, (node) => node.tagName === "SPAN");
19523
- this.iterateNodes(this._normalizeStyles, (node) => node.tagName !== "SPAN");
19524
19560
  }
19525
19561
  get normalizedHTML() {
19526
19562
  return this.dom.body.innerHTML;
@@ -19528,9 +19564,6 @@ const _ContentNormalizer = class {
19528
19564
  get _NodeFilter() {
19529
19565
  return this._parser.types.NodeFilter;
19530
19566
  }
19531
- get _Node() {
19532
- return this._parser.types.Node;
19533
- }
19534
19567
  _removeComments() {
19535
19568
  const iterator = this.createNodeIterator(this._NodeFilter.SHOW_COMMENT);
19536
19569
  this.runIterator(iterator, (node) => node.remove());
@@ -19596,78 +19629,17 @@ const _ContentNormalizer = class {
19596
19629
  itemEl.append(fragment);
19597
19630
  this._removeStyleProperties(itemEl, _ContentNormalizer.BLOCK_STYLES);
19598
19631
  }
19599
- _normalizeSettingsStructure(element) {
19600
- if (this._isOnlyTextContent(element))
19601
- return;
19602
- const cloned = element.cloneNode(true);
19603
- const migratingStyles = this._getMigratingStyles(element, { customProperties: true });
19604
- const content = [];
19605
- for (const node of cloned.childNodes) {
19606
- let child = node;
19607
- if (migratingStyles.length) {
19608
- child = this._wrapTextNode(cloned, node);
19609
- this._assignElementProperties(child, cloned, migratingStyles);
19610
- }
19611
- content.push(child);
19612
- }
19613
- element.replaceWith(...content);
19614
- }
19615
- _normalizeStyles(element) {
19616
- if (!this._isBlockNode(element) && this._isOnlyTextContent(element))
19617
- return;
19618
- const properties = this._getMigratingStyles(element);
19619
- if (!properties.length)
19620
- return;
19621
- for (const node of element.childNodes) {
19622
- const child = this._wrapTextNode(element, node);
19623
- this._assignElementProperties(child, element, properties);
19624
- }
19625
- this._removeStyleProperties(element, properties);
19626
- }
19627
- _isOnlyTextContent(node) {
19628
- return Array.from(node.childNodes).every((node2) => node2.nodeType === this._Node.TEXT_NODE);
19629
- }
19630
19632
  _isBlockNode(node) {
19631
19633
  return _ContentNormalizer.BLOCK_NODE_NAMES.includes(node.tagName);
19632
19634
  }
19633
- _getMigratingStyles(element, { customProperties } = {}) {
19634
- const blacklist = _ContentNormalizer.BLOCK_STYLES;
19635
- const properties = [];
19636
- for (let index = 0; index < element.style.length; index++) {
19637
- const property = element.style.item(index);
19638
- if (blacklist.includes(property))
19639
- continue;
19640
- if (!customProperties && property.startsWith("--"))
19641
- continue;
19642
- properties.push(property);
19643
- }
19644
- return properties;
19645
- }
19646
- _wrapTextNode(parent, node) {
19647
- if (node.nodeType !== this._Node.TEXT_NODE)
19648
- return node;
19649
- const span = this.dom.createElement("span");
19650
- span.append(node.cloneNode());
19651
- parent.replaceChild(span, node);
19652
- return span;
19653
- }
19654
19635
  _assignElementProperties(target, source, properties) {
19655
19636
  for (const property of properties) {
19656
19637
  const value = source.style.getPropertyValue(property);
19657
- if (value && this._canAssignElementProperty(target, source, property)) {
19638
+ if (value && !target.style.getPropertyValue(property)) {
19658
19639
  target.style.setProperty(property, value);
19659
19640
  }
19660
19641
  }
19661
19642
  }
19662
- _canAssignElementProperty(target, source, property) {
19663
- if (target.style.getPropertyValue(property))
19664
- return false;
19665
- return _ContentNormalizer.ASSIGN_STYLE_RULES.every((rule) => {
19666
- if (!rule.tag.test(target.tagName.toLowerCase()))
19667
- return true;
19668
- return !rule.ignore.test(property);
19669
- });
19670
- }
19671
19643
  _removeStyleProperties(element, properties) {
19672
19644
  for (const property of properties) {
19673
19645
  element.style.removeProperty(property);
@@ -19713,20 +19685,6 @@ __publicField(ContentNormalizer, "BLOCK_STYLES", [
19713
19685
  "margin-left",
19714
19686
  "margin-right"
19715
19687
  ]);
19716
- __publicField(ContentNormalizer, "ASSIGN_STYLE_RULES", [
19717
- {
19718
- tag: /^(b|strong)$/,
19719
- ignore: /font-weight/
19720
- },
19721
- {
19722
- tag: /^i$/,
19723
- ignore: /font-style/
19724
- },
19725
- {
19726
- tag: /^s$/,
19727
- ignore: /text-decoration(.+)?/
19728
- }
19729
- ]);
19730
19688
  class ContextWindow {
19731
19689
  static use(window2) {
19732
19690
  this.window = window2;
@@ -19767,7 +19725,7 @@ class NodeFactory {
19767
19725
  }
19768
19726
  static heading(level, ...args) {
19769
19727
  var _a;
19770
- const config = this._textBlock(args);
19728
+ const config = __privateMethod(this, _textBlock, textBlock_fn).call(this, args);
19771
19729
  (_a = config.attrs) != null ? _a : config.attrs = {};
19772
19730
  config.attrs.level = level;
19773
19731
  return {
@@ -19778,16 +19736,7 @@ class NodeFactory {
19778
19736
  static paragraph(...args) {
19779
19737
  return {
19780
19738
  type: NodeTypes.PARAGRAPH,
19781
- ...this._textBlock(args)
19782
- };
19783
- }
19784
- static _textBlock(args) {
19785
- const attrs = args.length === 1 ? null : args[0];
19786
- const content = args.length === 1 ? args[0] : args[1];
19787
- const children = typeof content === "string" ? [this.text(content)] : content;
19788
- return {
19789
- content: children,
19790
- ...attrs ? { attrs } : {}
19739
+ ...__privateMethod(this, _textBlock, textBlock_fn).call(this, args)
19791
19740
  };
19792
19741
  }
19793
19742
  static text(text2, marks) {
@@ -19804,6 +19753,28 @@ class NodeFactory {
19804
19753
  return { mobile: null, tablet: value, desktop: value };
19805
19754
  }
19806
19755
  }
19756
+ _textBlock = new WeakSet();
19757
+ textBlock_fn = function(args) {
19758
+ const { attrs, content, marks } = __privateMethod(this, _normalizeTextBlockArgs, normalizeTextBlockArgs_fn).call(this, args);
19759
+ const children = typeof content === "string" ? [this.text(content)] : content;
19760
+ return {
19761
+ content: children,
19762
+ ...attrs ? { attrs } : {},
19763
+ ...marks ? { marks } : {}
19764
+ };
19765
+ };
19766
+ _normalizeTextBlockArgs = new WeakSet();
19767
+ normalizeTextBlockArgs_fn = function(args) {
19768
+ if (args.length === 1) {
19769
+ return { attrs: null, marks: null, content: args[0] };
19770
+ }
19771
+ if (args.length === 2) {
19772
+ return { attrs: args[0], marks: null, content: args[1] };
19773
+ }
19774
+ return { attrs: args[0], marks: args[1], content: args[2] };
19775
+ };
19776
+ __privateAdd(NodeFactory, _textBlock);
19777
+ __privateAdd(NodeFactory, _normalizeTextBlockArgs);
19807
19778
  const dataStorage = /* @__PURE__ */ new WeakMap();
19808
19779
  function toggleListener(toEnable, onClick) {
19809
19780
  const args = ["click", onClick, { capture: true }];
@@ -20144,14 +20115,7 @@ var render$v = function __render__14() {
20144
20115
  }
20145
20116
  }, [_c("span", {
20146
20117
  staticClass: "zw-dropdown__activator-title zw-text--truncate"
20147
- }, [_vm._v(" " + _vm._s(_vm.activeOptionTitle) + " ")]), _vm.isCustomized ? _c("Icon", {
20148
- staticClass: "zw-dropdown__customized-indicator",
20149
- attrs: {
20150
- "name": "indicator",
20151
- "size": "9px",
20152
- "data-test-selector": "customizedIndicator"
20153
- }
20154
- }) : _vm._e(), _c("Icon", {
20118
+ }, [_vm._v(" " + _vm._s(_vm.activeOptionTitle) + " ")]), _c("Icon", {
20155
20119
  staticClass: "zw-dropdown__activator-arrow",
20156
20120
  attrs: {
20157
20121
  "name": "arrow",
@@ -20180,11 +20144,6 @@ const __vue2_script$v = {
20180
20144
  type: String,
20181
20145
  required: false,
20182
20146
  default: "none"
20183
- },
20184
- isCustomized: {
20185
- type: Boolean,
20186
- required: false,
20187
- default: false
20188
20147
  }
20189
20148
  },
20190
20149
  setup(props) {
@@ -20211,7 +20170,7 @@ var __component__$v = /* @__PURE__ */ normalizeComponent(
20211
20170
  staticRenderFns$v,
20212
20171
  false,
20213
20172
  __vue2_injectStyles$v,
20214
- "58b29148",
20173
+ "021ac370",
20215
20174
  null,
20216
20175
  null
20217
20176
  );
@@ -20475,8 +20434,7 @@ var render$q = function __render__19() {
20475
20434
  staticClass: "zw-dropdown"
20476
20435
  }, [_c("DropdownActivator", {
20477
20436
  attrs: {
20478
- "color": _vm.color,
20479
- "is-customized": _vm.isCustomized
20437
+ "color": _vm.color
20480
20438
  },
20481
20439
  scopedSlots: _vm._u([{
20482
20440
  key: "default",
@@ -20534,11 +20492,6 @@ const __vue2_script$q = {
20534
20492
  type: String,
20535
20493
  required: false,
20536
20494
  default: "none"
20537
- },
20538
- isCustomized: {
20539
- type: Boolean,
20540
- required: false,
20541
- default: false
20542
20495
  }
20543
20496
  },
20544
20497
  setup(props, { emit }) {
@@ -20570,7 +20523,7 @@ var __component__$q = /* @__PURE__ */ normalizeComponent(
20570
20523
  staticRenderFns$q,
20571
20524
  false,
20572
20525
  __vue2_injectStyles$q,
20573
- "29e6a104",
20526
+ "885109ea",
20574
20527
  null,
20575
20528
  null
20576
20529
  );
@@ -20889,8 +20842,7 @@ var render$n = function __render__22() {
20889
20842
  staticClass: "zw-font-family-control",
20890
20843
  attrs: {
20891
20844
  "options": _vm.options,
20892
- "value": _vm.currentValue,
20893
- "is-customized": _vm.isCustomized
20845
+ "value": _vm.currentValue
20894
20846
  },
20895
20847
  on: {
20896
20848
  "change": _vm.apply
@@ -20951,7 +20903,6 @@ const __vue2_script$n = {
20951
20903
  return { "--zw-font-family-option": `"${option.id}"` };
20952
20904
  }
20953
20905
  const currentValue = editor.commands.getFontFamily();
20954
- const isCustomized = editor.commands.isSettingCustomized("marks", TextSettings.FONT_FAMILY);
20955
20906
  const apply2 = (fontFamily) => {
20956
20907
  recentFontNames.add(fontFamily);
20957
20908
  editor.chain().focus().applyFontFamily(fontFamily).run();
@@ -20959,7 +20910,6 @@ const __vue2_script$n = {
20959
20910
  return {
20960
20911
  options,
20961
20912
  currentValue,
20962
- isCustomized,
20963
20913
  renderOptionStyles,
20964
20914
  apply: apply2
20965
20915
  };
@@ -20972,7 +20922,7 @@ var __component__$n = /* @__PURE__ */ normalizeComponent(
20972
20922
  staticRenderFns$n,
20973
20923
  false,
20974
20924
  __vue2_injectStyles$n,
20975
- "2f66bfa6",
20925
+ "07a47462",
20976
20926
  null,
20977
20927
  null
20978
20928
  );
@@ -20998,11 +20948,9 @@ var render$m = function __render__23() {
20998
20948
  },
20999
20949
  expression: "{ text: 'Font Weight', hotkey: 'Mod B' }"
21000
20950
  }],
21001
- staticClass: "zw-font-weight-control",
21002
20951
  attrs: {
21003
20952
  "options": _vm.options,
21004
- "value": _vm.currentValue,
21005
- "is-customized": _vm.isCustomized
20953
+ "value": _vm.currentValue
21006
20954
  },
21007
20955
  on: {
21008
20956
  "change": _vm.apply
@@ -21010,7 +20958,6 @@ var render$m = function __render__23() {
21010
20958
  });
21011
20959
  };
21012
20960
  var staticRenderFns$m = [];
21013
- const FontWeightControl_vue_vue_type_style_index_0_scoped_true_lang = "";
21014
20961
  const __vue2_script$m = {
21015
20962
  name: "FontWeightControl",
21016
20963
  components: {
@@ -21024,12 +20971,10 @@ const __vue2_script$m = {
21024
20971
  const font = editor.commands.getFont();
21025
20972
  const options = computed(() => unref(font).weights.map((style2) => ({ id: style2 })));
21026
20973
  const currentValue = editor.commands.getFontWeight();
21027
- const isCustomized = editor.commands.isSettingCustomized("marks", TextSettings.FONT_WEIGHT);
21028
20974
  const apply2 = (value) => editor.chain().focus().applyFontWeight(value).run();
21029
20975
  return {
21030
20976
  options,
21031
20977
  currentValue,
21032
- isCustomized,
21033
20978
  apply: apply2
21034
20979
  };
21035
20980
  }
@@ -21041,7 +20986,7 @@ var __component__$m = /* @__PURE__ */ normalizeComponent(
21041
20986
  staticRenderFns$m,
21042
20987
  false,
21043
20988
  __vue2_injectStyles$m,
21044
- "5a87e48e",
20989
+ null,
21045
20990
  null,
21046
20991
  null
21047
20992
  );
@@ -21070,8 +21015,7 @@ var render$l = function __render__24() {
21070
21015
  staticClass: "zw-font-size-control",
21071
21016
  attrs: {
21072
21017
  "options": _vm.options,
21073
- "value": _vm.currentValue,
21074
- "is-customized": _vm.isCustomized
21018
+ "value": _vm.currentValue
21075
21019
  },
21076
21020
  on: {
21077
21021
  "change": _vm.apply
@@ -21095,12 +21039,10 @@ const __vue2_script$l = {
21095
21039
  return fontSizes.map((size2) => ({ id: size2, title: `${size2}px` }));
21096
21040
  });
21097
21041
  const currentValue = editor.commands.getFontSize();
21098
- const isCustomized = editor.commands.isSettingCustomized("marks", TextSettings.FONT_SIZE);
21099
21042
  const apply2 = (value) => editor.chain().focus().applyFontSize(value).run();
21100
21043
  return {
21101
21044
  options,
21102
21045
  currentValue,
21103
- isCustomized,
21104
21046
  apply: apply2
21105
21047
  };
21106
21048
  }
@@ -21112,7 +21054,7 @@ var __component__$l = /* @__PURE__ */ normalizeComponent(
21112
21054
  staticRenderFns$l,
21113
21055
  false,
21114
21056
  __vue2_injectStyles$l,
21115
- "3f8185ea",
21057
+ "71dd7ffc",
21116
21058
  null,
21117
21059
  null
21118
21060
  );
@@ -21146,7 +21088,6 @@ var render$k = function __render__25() {
21146
21088
  value: "Font Color",
21147
21089
  expression: "'Font Color'"
21148
21090
  }],
21149
- staticClass: "zw-position--relative",
21150
21091
  attrs: {
21151
21092
  "icon": "",
21152
21093
  "skin": "toolbar",
@@ -21161,14 +21102,7 @@ var render$k = function __render__25() {
21161
21102
  "size": "28px",
21162
21103
  "auto-color": ""
21163
21104
  }
21164
- }), _vm.isCustomized ? _c("Icon", {
21165
- staticClass: "zw-button__customized-indicator",
21166
- attrs: {
21167
- "name": "indicator",
21168
- "size": "9px",
21169
- "data-test-selector": "customizedIndicator"
21170
- }
21171
- }) : _vm._e()], 1)];
21105
+ })], 1)];
21172
21106
  }
21173
21107
  }])
21174
21108
  });
@@ -21187,11 +21121,9 @@ const __vue2_script$k = {
21187
21121
  setup() {
21188
21122
  const editor = inject(InjectionTokens$1.EDITOR);
21189
21123
  const currentValue = editor.commands.getFontColor();
21190
- const isCustomized = editor.commands.isSettingCustomized("marks", TextSettings.FONT_COLOR);
21191
21124
  const apply2 = (color) => editor.chain().applyFontColor(color).run();
21192
21125
  return {
21193
21126
  currentValue,
21194
- isCustomized,
21195
21127
  apply: apply2
21196
21128
  };
21197
21129
  }
@@ -21310,7 +21242,6 @@ var render$i = function __render__27() {
21310
21242
  },
21311
21243
  expression: "{ text: 'Italic', hotkey: 'Mod I' }"
21312
21244
  }],
21313
- staticClass: "zw-position--relative",
21314
21245
  attrs: {
21315
21246
  "skin": "toolbar",
21316
21247
  "icon": "",
@@ -21326,14 +21257,7 @@ var render$i = function __render__27() {
21326
21257
  "size": "28px",
21327
21258
  "auto-color": ""
21328
21259
  }
21329
- }), _vm.isCustomized ? _c("Icon", {
21330
- staticClass: "zw-button__customized-indicator",
21331
- attrs: {
21332
- "name": "indicator",
21333
- "size": "9px",
21334
- "data-test-selector": "customizedIndicator"
21335
- }
21336
- }) : _vm._e()], 1);
21260
+ })], 1);
21337
21261
  };
21338
21262
  var staticRenderFns$i = [];
21339
21263
  const __vue2_script$i = {
@@ -21348,13 +21272,11 @@ const __vue2_script$i = {
21348
21272
  setup() {
21349
21273
  const editor = inject(InjectionTokens$1.EDITOR);
21350
21274
  const currentValue = editor.commands.isItalic();
21351
- const isCustomized = editor.commands.isSettingCustomized("marks", TextSettings.FONT_STYLE);
21352
21275
  const isAvailable = editor.commands.isItalicAvailable();
21353
21276
  const apply2 = () => editor.chain().focus().toggleItalic().run();
21354
21277
  return {
21355
21278
  isAvailable,
21356
21279
  currentValue,
21357
- isCustomized,
21358
21280
  apply: apply2
21359
21281
  };
21360
21282
  }
@@ -21392,7 +21314,6 @@ var render$h = function __render__28() {
21392
21314
  },
21393
21315
  expression: "{ text: 'Underline', hotkey: 'Mod U' }"
21394
21316
  }],
21395
- staticClass: "zw-position--relative",
21396
21317
  attrs: {
21397
21318
  "skin": "toolbar",
21398
21319
  "icon": "",
@@ -21407,14 +21328,7 @@ var render$h = function __render__28() {
21407
21328
  "size": "28px",
21408
21329
  "auto-color": ""
21409
21330
  }
21410
- }), _vm.isCustomized ? _c("Icon", {
21411
- staticClass: "zw-button__customized-indicator",
21412
- attrs: {
21413
- "name": "indicator",
21414
- "size": "9px",
21415
- "data-test-selector": "customizedIndicator"
21416
- }
21417
- }) : _vm._e()], 1);
21331
+ })], 1);
21418
21332
  };
21419
21333
  var staticRenderFns$h = [];
21420
21334
  const __vue2_script$h = {
@@ -21429,11 +21343,9 @@ const __vue2_script$h = {
21429
21343
  setup() {
21430
21344
  const editor = inject(InjectionTokens$1.EDITOR);
21431
21345
  const currentValue = editor.commands.isUnderline();
21432
- const isCustomized = editor.commands.isUnderlineCustomized();
21433
21346
  const apply2 = () => editor.chain().focus().toggleUnderline().run();
21434
21347
  return {
21435
21348
  currentValue,
21436
- isCustomized,
21437
21349
  apply: apply2
21438
21350
  };
21439
21351
  }
@@ -21562,7 +21474,7 @@ const __vue2_script$f = {
21562
21474
  },
21563
21475
  setup() {
21564
21476
  const editor = inject(InjectionTokens$1.EDITOR);
21565
- const currentValue = computed(() => editor.isActive("superscript"));
21477
+ const currentValue = editor.commands.isSuperscript();
21566
21478
  const apply2 = () => editor.chain().focus().toggleSuperscript().run();
21567
21479
  return {
21568
21480
  currentValue,
@@ -21694,7 +21606,6 @@ var render$d = function __render__32() {
21694
21606
  value: option.tooltip,
21695
21607
  expression: "option.tooltip"
21696
21608
  }],
21697
- staticClass: "zw-position--relative",
21698
21609
  attrs: {
21699
21610
  "icon": "",
21700
21611
  "skin": "toolbar",
@@ -21703,14 +21614,7 @@ var render$d = function __render__32() {
21703
21614
  on: {
21704
21615
  "click": activate
21705
21616
  }
21706
- }, [_vm.isCustomized && isActive2 ? _c("Icon", {
21707
- staticClass: "zw-button__customized-indicator",
21708
- attrs: {
21709
- "name": "indicator",
21710
- "size": "9px",
21711
- "data-test-selector": "customizedIndicator"
21712
- }
21713
- }) : _vm._e(), _c("Icon", {
21617
+ }, [_c("Icon", {
21714
21618
  attrs: {
21715
21619
  "name": "alignment-".concat(option.id),
21716
21620
  "size": "28px",
@@ -21753,14 +21657,12 @@ const __vue2_script$d = {
21753
21657
  setup(_, { emit }) {
21754
21658
  const editor = inject(InjectionTokens$1.EDITOR);
21755
21659
  const currentValue = editor.commands.getAlignment();
21756
- const isCustomized = editor.commands.isSettingCustomized("attributes", TextSettings.ALIGNMENT);
21757
21660
  function apply2(value) {
21758
21661
  editor.chain().focus().applyAlignment(value).run();
21759
21662
  emit("applied");
21760
21663
  }
21761
21664
  return {
21762
21665
  currentValue,
21763
- isCustomized,
21764
21666
  apply: apply2
21765
21667
  };
21766
21668
  }
@@ -21886,7 +21788,6 @@ var render$b = function __render__34() {
21886
21788
  value: "Line Height",
21887
21789
  expression: "'Line Height'"
21888
21790
  }],
21889
- staticClass: "zw-position--relative",
21890
21791
  attrs: {
21891
21792
  "icon": "",
21892
21793
  "skin": "toolbar",
@@ -21901,14 +21802,7 @@ var render$b = function __render__34() {
21901
21802
  "size": "28px",
21902
21803
  "auto-color": ""
21903
21804
  }
21904
- }), _vm.isCustomized ? _c("Icon", {
21905
- staticClass: "zw-button__customized-indicator",
21906
- attrs: {
21907
- "name": "indicator",
21908
- "size": "9px",
21909
- "data-test-selector": "customizedIndicator"
21910
- }
21911
- }) : _vm._e()], 1), _c("Modal", {
21805
+ })], 1), _c("Modal", {
21912
21806
  ref: "modalRef",
21913
21807
  staticClass: "zw-line-height-control__modal",
21914
21808
  attrs: {
@@ -21967,13 +21861,11 @@ const __vue2_script$b = {
21967
21861
  const editor = inject(InjectionTokens$1.EDITOR);
21968
21862
  const toggler = useModalToggler({ wrapperRef, modalRef });
21969
21863
  const currentValue = editor.commands.getLineHeight();
21970
- const isCustomized = editor.commands.isSettingCustomized("attributes", TextSettings.LINE_HEIGHT);
21971
21864
  const apply2 = (value) => editor.commands.applyLineHeight(String(value));
21972
21865
  return {
21973
21866
  wrapperRef,
21974
21867
  modalRef,
21975
21868
  isOpened: toggler.isOpened,
21976
- isCustomized,
21977
21869
  toggler,
21978
21870
  currentValue,
21979
21871
  apply: apply2
@@ -21987,7 +21879,7 @@ var __component__$b = /* @__PURE__ */ normalizeComponent(
21987
21879
  staticRenderFns$b,
21988
21880
  false,
21989
21881
  __vue2_injectStyles$b,
21990
- "8aeefd68",
21882
+ "9ea28b80",
21991
21883
  null,
21992
21884
  null
21993
21885
  );
@@ -23037,6 +22929,7 @@ function useToolbar({ wrapperRef, offsets, isActiveRef, placementRef }) {
23037
22929
  }
23038
22930
  const FontFamily = Mark.create({
23039
22931
  name: TextSettings.FONT_FAMILY,
22932
+ group: "settings",
23040
22933
  addOptions: () => ({
23041
22934
  fonts: []
23042
22935
  }),
@@ -23046,7 +22939,7 @@ const FontFamily = Mark.create({
23046
22939
  addCommands() {
23047
22940
  return {
23048
22941
  applyFontFamily: createCommand(({ commands: commands2 }, value) => {
23049
- commands2.setMark(this.name, { value });
22942
+ commands2.applyMark(this.name, { value });
23050
22943
  const font = commands2.findFontByName(value);
23051
22944
  let fontWeight = unref(commands2.getFontWeight());
23052
22945
  if (!font.isWeightSupported(fontWeight)) {
@@ -23067,12 +22960,8 @@ const FontFamily = Mark.create({
23067
22960
  findFontByName: createCommand((_, name) => {
23068
22961
  return this.options.fonts.find((font) => font.name === name);
23069
22962
  }),
23070
- getFontFamily: createCommand(({ editor, commands: commands2 }) => {
23071
- const defaultValue = commands2.getDefaultFontFamily();
23072
- return computed(() => {
23073
- var _a, _b;
23074
- return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.value) != null ? _b : unref(defaultValue);
23075
- });
22963
+ getFontFamily: createCommand(({ commands: commands2 }) => {
22964
+ return commands2.getCommonSettingMark(this.name, commands2.getDefaultFontFamily());
23076
22965
  }),
23077
22966
  getDefaultFontFamily: createCommand(({ commands: commands2 }) => {
23078
22967
  const preset = commands2.getPreset();
@@ -23103,84 +22992,12 @@ const FontFamily = Mark.create({
23103
22992
  return renderMark({ font_family });
23104
22993
  }
23105
22994
  });
23106
- const Heading = Node.create({
23107
- name: "heading",
23108
- addOptions() {
23109
- return {
23110
- levels: [1, 2, 3, 4, 5, 6],
23111
- HTMLAttributes: {}
23112
- };
23113
- },
23114
- content: "inline*",
23115
- group: "block",
23116
- defining: true,
23117
- addAttributes() {
23118
- return {
23119
- level: {
23120
- default: 1,
23121
- rendered: false
23122
- }
23123
- };
23124
- },
23125
- parseHTML() {
23126
- return this.options.levels.map((level) => ({
23127
- tag: `h${level}`,
23128
- attrs: { level }
23129
- }));
23130
- },
23131
- renderHTML({ node, HTMLAttributes }) {
23132
- const hasLevel = this.options.levels.includes(node.attrs.level);
23133
- const level = hasLevel ? node.attrs.level : this.options.levels[0];
23134
- return [`h${level}`, mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
23135
- },
23136
- addCommands() {
23137
- return {
23138
- setHeading: (attributes) => ({ commands: commands2 }) => {
23139
- if (!this.options.levels.includes(attributes.level)) {
23140
- return false;
23141
- }
23142
- return commands2.setNode(this.name, attributes);
23143
- },
23144
- toggleHeading: (attributes) => ({ commands: commands2 }) => {
23145
- if (!this.options.levels.includes(attributes.level)) {
23146
- return false;
23147
- }
23148
- return commands2.toggleNode(this.name, "paragraph", attributes);
23149
- }
23150
- };
23151
- },
23152
- addKeyboardShortcuts() {
23153
- return this.options.levels.reduce((items, level) => ({
23154
- ...items,
23155
- ...{
23156
- [`Mod-Alt-${level}`]: () => this.editor.commands.toggleHeading({ level })
23157
- }
23158
- }), {});
23159
- },
23160
- addInputRules() {
23161
- return this.options.levels.map((level) => {
23162
- return textblockTypeInputRule({
23163
- find: new RegExp(`^(#{1,${level}})\\s$`),
23164
- type: this.type,
23165
- getAttributes: {
23166
- level
23167
- }
23168
- });
23169
- });
23170
- }
23171
- });
23172
22995
  function makePresetClass(base2, preset) {
23173
22996
  const baseClass = base2.split(" ").map((part) => `.${part}`).join("");
23174
22997
  return baseClass + preset.id;
23175
22998
  }
23176
22999
  const StylePreset = Extension.create({
23177
23000
  name: "style_preset",
23178
- addExtensions: () => [
23179
- Heading.configure({
23180
- levels: [1, 2, 3, 4],
23181
- HTMLAttributes: { class: "zw-style" }
23182
- })
23183
- ],
23184
23001
  addStorage: () => ({
23185
23002
  presetStyleEl: null
23186
23003
  }),
@@ -23301,13 +23118,6 @@ const StylePreset = Extension.create({
23301
23118
  };
23302
23119
  });
23303
23120
  }),
23304
- isSettingCustomized: createCommand(({ commands: commands2 }, group, name) => {
23305
- const customization = commands2.getPresetCustomization();
23306
- return computed(() => {
23307
- var _a, _b;
23308
- return (_b = (_a = unref(customization)[group]) == null ? void 0 : _a.includes(name)) != null ? _b : false;
23309
- });
23310
- }),
23311
23121
  removePresetCustomization: createCommand(({ chain }) => {
23312
23122
  chain().storeSelection().expandSelectionToBlock().unsetMarks(TextSettings.marks).resetAttributes(NodeTypes.PARAGRAPH, TextSettings.attributes).resetAttributes(NodeTypes.HEADING, TextSettings.attributes).restoreSelection().run();
23313
23123
  }),
@@ -23343,13 +23153,14 @@ const StylePreset = Extension.create({
23343
23153
  });
23344
23154
  const FontWeight = Mark.create({
23345
23155
  name: TextSettings.FONT_WEIGHT,
23156
+ group: "settings",
23346
23157
  addAttributes: () => ({
23347
23158
  value: { required: true }
23348
23159
  }),
23349
23160
  addCommands() {
23350
23161
  return {
23351
23162
  applyFontWeight: createCommand(({ commands: commands2 }, value) => {
23352
- commands2.setMark(this.name, { value });
23163
+ commands2.applyMark(this.name, { value });
23353
23164
  const font = unref(commands2.getFont());
23354
23165
  if (!font.isItalicSupported(value)) {
23355
23166
  commands2.removeItalic();
@@ -23363,17 +23174,13 @@ const FontWeight = Mark.create({
23363
23174
  const nextWeight = currentFont.findClosestWeight(wantedWeight);
23364
23175
  commands2.applyFontWeight(nextWeight);
23365
23176
  }),
23366
- getFontWeight: createCommand(({ editor, commands: commands2 }) => {
23367
- const defaultValue = commands2.getDefaultFontWeight();
23177
+ getFontWeight: createCommand(({ commands: commands2 }) => {
23178
+ const selectionRef = commands2.getCommonSettingMark(this.name, commands2.getDefaultFontWeight());
23368
23179
  const fontRef = commands2.getFont();
23369
23180
  return computed(() => {
23370
- var _a, _b;
23371
- const weight = (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.value) != null ? _b : unref(defaultValue);
23181
+ const weight = unref(selectionRef);
23372
23182
  const font = unref(fontRef);
23373
- if (font.isWeightSupported(weight)) {
23374
- return weight;
23375
- }
23376
- return font.findClosestWeight(weight);
23183
+ return font.isWeightSupported(weight) ? weight : font.findClosestWeight(weight);
23377
23184
  });
23378
23185
  }),
23379
23186
  getDefaultFontWeight: createCommand(({ commands: commands2 }) => {
@@ -23417,6 +23224,7 @@ const FontWeight = Mark.create({
23417
23224
  });
23418
23225
  const FontSize = Mark.create({
23419
23226
  name: TextSettings.FONT_SIZE,
23227
+ group: "settings",
23420
23228
  addOptions: () => ({
23421
23229
  minSize: 1,
23422
23230
  maxSize: 100
@@ -23430,13 +23238,8 @@ const FontSize = Mark.create({
23430
23238
  },
23431
23239
  addCommands() {
23432
23240
  return {
23433
- getFontSize: createCommand(({ editor, commands: commands2 }) => {
23434
- const device = commands2.getDevice();
23435
- const defaultValue = commands2.getDefaultFontSize();
23436
- return computed(() => {
23437
- var _a, _b;
23438
- return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a[unref(device)]) != null ? _b : unref(defaultValue);
23439
- });
23241
+ getFontSize: createCommand(({ commands: commands2 }) => {
23242
+ return commands2.getDeviceSettingMark(this.name, commands2.getDefaultFontSize());
23440
23243
  }),
23441
23244
  getDefaultFontSize: createCommand(({ commands: commands2 }) => {
23442
23245
  const device = commands2.getDevice();
@@ -23444,7 +23247,7 @@ const FontSize = Mark.create({
23444
23247
  return computed(() => unref(preset)[unref(device)].font_size.replace("px", ""));
23445
23248
  }),
23446
23249
  applyFontSize: createCommand(({ commands: commands2 }, value) => {
23447
- commands2.setMark(this.name, { desktop: value, tablet: value, mobile: null });
23250
+ commands2.applyMark(this.name, { desktop: value, tablet: value, mobile: null });
23448
23251
  }),
23449
23252
  increaseFontSize: createCommand(({ commands: commands2 }) => {
23450
23253
  const size2 = Number(unref(commands2.getFontSize()));
@@ -23499,24 +23302,21 @@ const FontSize = Mark.create({
23499
23302
  });
23500
23303
  const FontColor = Mark.create({
23501
23304
  name: TextSettings.FONT_COLOR,
23305
+ group: "settings",
23502
23306
  addAttributes: () => ({
23503
23307
  value: { required: true }
23504
23308
  }),
23505
23309
  addCommands() {
23506
23310
  return {
23507
- getFontColor: createCommand(({ commands: commands2, editor }) => {
23508
- const defaultValue = commands2.getDefaultFontColor();
23509
- return computed(() => {
23510
- var _a, _b;
23511
- return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.value) != null ? _b : unref(defaultValue);
23512
- });
23311
+ getFontColor: createCommand(({ commands: commands2 }) => {
23312
+ return commands2.getCommonSettingMark(this.name, commands2.getDefaultFontColor());
23513
23313
  }),
23514
23314
  getDefaultFontColor: createCommand(({ commands: commands2 }) => {
23515
23315
  const preset = commands2.getPreset();
23516
23316
  return computed(() => unref(preset).common.color);
23517
23317
  }),
23518
23318
  applyFontColor: createCommand(({ commands: commands2 }, value) => {
23519
- commands2.setMark(this.name, { value });
23319
+ commands2.applyMark(this.name, { value });
23520
23320
  })
23521
23321
  };
23522
23322
  },
@@ -23539,19 +23339,17 @@ const FontColor = Mark.create({
23539
23339
  });
23540
23340
  const BackgroundColor = Mark.create({
23541
23341
  name: TextSettings.BACKGROUND_COLOR,
23342
+ group: "settings",
23542
23343
  addAttributes: () => ({
23543
23344
  value: { required: true }
23544
23345
  }),
23545
23346
  addCommands() {
23546
23347
  return {
23547
- getBackgroundColor: createCommand(({ editor }) => {
23548
- return computed(() => {
23549
- var _a, _b;
23550
- return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.value) != null ? _b : "rgba(255, 255, 255, 0%)";
23551
- });
23348
+ getBackgroundColor: createCommand(({ commands: commands2 }) => {
23349
+ return commands2.getCommonSettingMark(this.name, "rgba(255, 255, 255, 0%)");
23552
23350
  }),
23553
23351
  applyBackgroundColor: createCommand(({ commands: commands2 }, value) => {
23554
- commands2.setMark(this.name, { value });
23352
+ commands2.applyMark(this.name, { value });
23555
23353
  })
23556
23354
  };
23557
23355
  },
@@ -23582,16 +23380,18 @@ const DeviceManager = Extension.create({
23582
23380
  });
23583
23381
  const FontStyle = Mark.create({
23584
23382
  name: TextSettings.FONT_STYLE,
23383
+ group: "settings",
23585
23384
  addAttributes: () => ({
23586
23385
  italic: { required: true }
23587
23386
  }),
23588
23387
  addCommands() {
23589
23388
  return {
23590
- isItalic: createCommand(({ editor, commands: commands2 }) => {
23591
- const defaultValue = commands2.getDefaultFontStyle();
23389
+ isItalic: createCommand(({ commands: commands2 }) => {
23390
+ const selectionRef = commands2.getMark(this.name);
23391
+ const defaultValueRef = commands2.getDefaultFontStyle();
23592
23392
  return computed(() => {
23593
23393
  var _a, _b;
23594
- return (_b = (_a = editor.getAttributes(this.name)) == null ? void 0 : _a.italic) != null ? _b : unref(defaultValue).italic;
23394
+ return (_b = (_a = unref(selectionRef)) == null ? void 0 : _a.italic) != null ? _b : unref(defaultValueRef).italic;
23595
23395
  });
23596
23396
  }),
23597
23397
  isItalicAvailable: createCommand(({ commands: commands2 }) => {
@@ -23606,16 +23406,16 @@ const FontStyle = Mark.create({
23606
23406
  }));
23607
23407
  }),
23608
23408
  toggleItalic: createCommand(({ commands: commands2 }) => {
23609
- const isItalicAvailable = unref(this.editor.commands.isItalicAvailable());
23409
+ const isItalicAvailable = unref(commands2.isItalicAvailable());
23610
23410
  if (!isItalicAvailable)
23611
23411
  return;
23612
23412
  unref(commands2.isItalic()) ? commands2.removeItalic() : commands2.applyItalic();
23613
23413
  }),
23614
23414
  applyItalic: createCommand(({ commands: commands2 }) => {
23615
- commands2.setMark(this.name, { italic: true });
23415
+ commands2.applyMark(this.name, { italic: true });
23616
23416
  }),
23617
23417
  removeItalic: createCommand(({ commands: commands2 }) => {
23618
- commands2.setMark(this.name, { italic: false });
23418
+ commands2.applyMark(this.name, { italic: false });
23619
23419
  })
23620
23420
  };
23621
23421
  },
@@ -23624,8 +23424,12 @@ const FontStyle = Mark.create({
23624
23424
  "Mod-I": createKeyboardShortcut("toggleItalic")
23625
23425
  }),
23626
23426
  parseHTML() {
23627
- const getAttrs = (value) => value.includes("italic") && { italic: true };
23427
+ const getAttrs = (value) => ({ italic: value.includes("italic") });
23628
23428
  return [
23429
+ {
23430
+ tag: "i",
23431
+ attrs: { italic: true }
23432
+ },
23629
23433
  {
23630
23434
  style: "--zw-font-style",
23631
23435
  getAttrs
@@ -23633,10 +23437,6 @@ const FontStyle = Mark.create({
23633
23437
  {
23634
23438
  style: "font-style",
23635
23439
  getAttrs
23636
- },
23637
- {
23638
- tag: "i",
23639
- attrs: { italic: true }
23640
23440
  }
23641
23441
  ];
23642
23442
  },
@@ -23648,6 +23448,7 @@ const FontStyle = Mark.create({
23648
23448
  const TextDecoration = Mark.create({
23649
23449
  name: TextSettings.TEXT_DECORATION,
23650
23450
  priority: 1e3,
23451
+ group: "settings",
23651
23452
  addAttributes: () => ({
23652
23453
  underline: { default: false },
23653
23454
  strike_through: { default: false }
@@ -23662,22 +23463,16 @@ const TextDecoration = Mark.create({
23662
23463
  const decoration = commands2.getTextDecoration();
23663
23464
  return computed(() => unref(decoration).strike_through);
23664
23465
  }),
23665
- getTextDecoration: createCommand(({ editor, commands: commands2 }) => {
23666
- const defaultValue = commands2.getDefaultTextDecoration();
23466
+ getTextDecoration: createCommand(({ commands: commands2 }) => {
23467
+ const selectionRef = commands2.getMarks(this.name);
23468
+ const defaultValueRef = commands2.getDefaultTextDecoration();
23667
23469
  return computed(() => {
23668
- var _a, _b, _c;
23669
- const attrs = (_a = editor.getAttributes(this.name)) != null ? _a : {};
23670
- return {
23671
- underline: (_b = attrs.underline) != null ? _b : unref(defaultValue).underline,
23672
- strike_through: (_c = attrs.strike_through) != null ? _c : unref(defaultValue).strike_through
23673
- };
23470
+ return unref(selectionRef).reduceRight((collector, mark) => ({
23471
+ underline: collector.underline || mark.underline,
23472
+ strike_through: collector.strike_through || mark.strike_through
23473
+ }), unref(defaultValueRef));
23674
23474
  });
23675
23475
  }),
23676
- isUnderlineCustomized: createCommand(({ commands: commands2 }) => {
23677
- const currentValue = commands2.isUnderline();
23678
- const defaultValue = commands2.getDefaultTextDecoration();
23679
- return computed(() => unref(currentValue) !== unref(defaultValue).underline);
23680
- }),
23681
23476
  getDefaultTextDecoration: createCommand(({ commands: commands2 }) => {
23682
23477
  const preset = commands2.getPreset();
23683
23478
  return computed(() => {
@@ -23694,15 +23489,32 @@ const TextDecoration = Mark.create({
23694
23489
  toggleStrikeThrough: createCommand(({ commands: commands2 }) => {
23695
23490
  commands2.toggleTextDecoration("strike_through");
23696
23491
  }),
23697
- toggleTextDecoration: createCommand(({ commands: commands2 }, name) => {
23698
- const isEnabled = unref(commands2.getTextDecoration())[name];
23699
- isEnabled ? commands2.removeTextDecoration(name) : commands2.applyTextDecoration(name);
23492
+ toggleTextDecoration: createCommand(({ commands: commands2 }, name, toEnable = null) => {
23493
+ const value = unref(commands2.getTextDecoration());
23494
+ const isEnabled = toEnable != null ? toEnable : !value[name];
23495
+ commands2.applyMark(this.name, { [name]: isEnabled }, {
23496
+ compareParentMark: (parent, child) => {
23497
+ if (parent.type.name !== child.type.name)
23498
+ return false;
23499
+ return parent.attrs[name] || parent.eq(child);
23500
+ },
23501
+ onAppliedToParent: ({ tr, textPosition, initialMark, applyingMark }) => {
23502
+ if (!initialMark)
23503
+ return;
23504
+ if (initialMark.eq(applyingMark)) {
23505
+ tr.removeMark(textPosition.from, textPosition.to, applyingMark.type);
23506
+ return;
23507
+ }
23508
+ const mark = applyingMark.type.create({ ...initialMark.attrs, [name]: isEnabled });
23509
+ tr.addMark(textPosition.from, textPosition.to, mark);
23510
+ }
23511
+ });
23700
23512
  }),
23701
23513
  applyTextDecoration: createCommand(({ commands: commands2 }, name) => {
23702
- commands2.setMark(this.name, { [name]: true });
23514
+ commands2.toggleTextDecoration(name, true);
23703
23515
  }),
23704
23516
  removeTextDecoration: createCommand(({ commands: commands2 }, name) => {
23705
- commands2.setMark(this.name, { ...unref(commands2.getTextDecoration()), [name]: false });
23517
+ commands2.toggleTextDecoration(name, false);
23706
23518
  })
23707
23519
  };
23708
23520
  },
@@ -23944,6 +23756,10 @@ const ListItem$1 = Node.create({
23944
23756
  });
23945
23757
  const ListItem = ListItem$1.extend({
23946
23758
  name: NodeTypes.LIST_ITEM,
23759
+ marks: "settings",
23760
+ addOptions: () => ({
23761
+ HTMLAttributes: { class: "zw-style" }
23762
+ }),
23947
23763
  addKeyboardShortcuts() {
23948
23764
  const { Enter } = this.parent();
23949
23765
  return { Enter };
@@ -23953,6 +23769,7 @@ const List = Node.create({
23953
23769
  name: NodeTypes.LIST,
23954
23770
  content: `${NodeTypes.LIST_ITEM}+`,
23955
23771
  group: "block list",
23772
+ marks: "settings",
23956
23773
  addExtensions: () => [
23957
23774
  ListItem
23958
23775
  ],
@@ -25124,44 +24941,22 @@ const Superscript$1 = Mark.create({
25124
24941
  }
25125
24942
  });
25126
24943
  const Superscript = Superscript$1.extend({
24944
+ name: TextSettings.SUPERSCRIPT,
25127
24945
  addKeyboardShortcuts: null,
25128
24946
  addOptions: () => ({
25129
24947
  HTMLAttributes: { class: "zw-superscript" }
25130
- })
25131
- });
25132
- const Document = Node.create({
25133
- name: "doc",
25134
- topNode: true,
25135
- content: "block+"
25136
- });
25137
- const Paragraph = Node.create({
25138
- name: "paragraph",
25139
- priority: 1e3,
25140
- addOptions() {
25141
- return {
25142
- HTMLAttributes: {}
25143
- };
25144
- },
25145
- group: "block",
25146
- content: "inline*",
25147
- parseHTML() {
25148
- return [
25149
- { tag: "p" }
25150
- ];
25151
- },
25152
- renderHTML({ HTMLAttributes }) {
25153
- return ["p", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
25154
- },
24948
+ }),
25155
24949
  addCommands() {
25156
24950
  return {
25157
- setParagraph: () => ({ commands: commands2 }) => {
25158
- return commands2.setNode(this.name);
25159
- }
25160
- };
25161
- },
25162
- addKeyboardShortcuts() {
25163
- return {
25164
- "Mod-Alt-0": () => this.editor.commands.setParagraph()
24951
+ ...this.parent(),
24952
+ toggleSuperscript: createCommand(({ commands: commands2 }) => {
24953
+ const isActive2 = unref(commands2.isSuperscript());
24954
+ isActive2 ? commands2.unsetSuperscript() : commands2.setSuperscript();
24955
+ }),
24956
+ isSuperscript: createCommand(({ commands: commands2 }) => {
24957
+ const selectionRef = commands2.getMark(this.name);
24958
+ return computed(() => !!unref(selectionRef));
24959
+ })
25165
24960
  };
25166
24961
  }
25167
24962
  });
@@ -25775,6 +25570,85 @@ const History = Extension.create({
25775
25570
  };
25776
25571
  }
25777
25572
  });
25573
+ class RemoveNodeMarkStep extends Step {
25574
+ static fromJSON(schema, json) {
25575
+ if (typeof json.pos != "number") {
25576
+ throw new RangeError("Invalid input for RemoveNodeMarkStep.fromJSON");
25577
+ }
25578
+ return new RemoveNodeMarkStep(json.pos, schema.markFromJSON(json.mark));
25579
+ }
25580
+ constructor(pos, mark) {
25581
+ super();
25582
+ this.pos = pos;
25583
+ this.mark = mark;
25584
+ }
25585
+ apply(doc2) {
25586
+ const node = doc2.nodeAt(this.pos);
25587
+ if (!node)
25588
+ return StepResult.fail("No node at mark step's position");
25589
+ const updated = node.type.create(node.attrs, null, this.mark.removeFromSet(node.marks));
25590
+ const slice2 = new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1);
25591
+ return StepResult.fromReplace(doc2, this.pos, this.pos + 1, slice2);
25592
+ }
25593
+ invert(doc2) {
25594
+ const node = doc2.nodeAt(this.pos);
25595
+ if (!node || !this.mark.isInSet(node.marks))
25596
+ return this;
25597
+ return new AddNodeMarkStep(this.pos, this.mark);
25598
+ }
25599
+ map(mapping) {
25600
+ const pos = mapping.mapResult(this.pos, 1);
25601
+ return pos.deletedAfter ? null : new RemoveNodeMarkStep(pos.pos, this.mark);
25602
+ }
25603
+ toJSON() {
25604
+ return { stepType: "removeNodeMark", pos: this.pos, mark: this.mark.toJSON() };
25605
+ }
25606
+ }
25607
+ Step.jsonID("removeNodeMark", RemoveNodeMarkStep);
25608
+ class AddNodeMarkStep extends Step {
25609
+ static fromJSON(schema, json) {
25610
+ if (typeof json.pos != "number") {
25611
+ throw new RangeError("Invalid input for AddNodeMarkStep.fromJSON");
25612
+ }
25613
+ return new AddNodeMarkStep(json.pos, schema.markFromJSON(json.mark));
25614
+ }
25615
+ constructor(pos, mark) {
25616
+ super();
25617
+ this.pos = pos;
25618
+ this.mark = mark;
25619
+ }
25620
+ apply(doc2) {
25621
+ const node = doc2.nodeAt(this.pos);
25622
+ if (!node)
25623
+ return StepResult.fail("No node at mark step's position");
25624
+ const updated = node.type.create(node.attrs, null, this.mark.addToSet(node.marks));
25625
+ const slice2 = new Slice(Fragment.from(updated), 0, node.isLeaf ? 0 : 1);
25626
+ return StepResult.fromReplace(doc2, this.pos, this.pos + 1, slice2);
25627
+ }
25628
+ invert(doc2) {
25629
+ const node = doc2.nodeAt(this.pos);
25630
+ if (node) {
25631
+ const newSet = this.mark.addToSet(node.marks);
25632
+ if (newSet.length === node.marks.length) {
25633
+ for (const mark of node.marks) {
25634
+ if (!mark.isInSet(newSet)) {
25635
+ return new AddNodeMarkStep(this.pos, mark);
25636
+ }
25637
+ }
25638
+ return new AddNodeMarkStep(this.pos, this.mark);
25639
+ }
25640
+ }
25641
+ return new RemoveNodeMarkStep(this.pos, this.mark);
25642
+ }
25643
+ map(mapping) {
25644
+ const pos = mapping.mapResult(this.pos, 1);
25645
+ return pos.deletedAfter ? null : new AddNodeMarkStep(pos.pos, this.mark);
25646
+ }
25647
+ toJSON() {
25648
+ return { stepType: "addNodeMark", pos: this.pos, mark: this.mark.toJSON() };
25649
+ }
25650
+ }
25651
+ Step.jsonID("addNodeMark", AddNodeMarkStep);
25778
25652
  const NodeProcessor = Extension.create({
25779
25653
  name: "node_processor",
25780
25654
  addCommands() {
@@ -25795,7 +25669,73 @@ const NodeProcessor = Extension.create({
25795
25669
  Object.assign(attrs, ((_a = editor.getAttributes(type)) == null ? void 0 : _a[name]) || {});
25796
25670
  }
25797
25671
  return Object.keys(attrs).length ? attrs : null;
25798
- }))
25672
+ })),
25673
+ applyMark: createCommand(({ state }, name, value, customizer = {}) => {
25674
+ const { tr, doc: doc2, schema } = state;
25675
+ const { $from, $to } = tr.selection;
25676
+ const markType = getMarkType(name, schema);
25677
+ const onAppliedToParent = customizer.onAppliedToParent || ((context) => {
25678
+ const { tr: tr2, textPosition, applyingMark } = context;
25679
+ tr2.removeMark(textPosition.from, textPosition.to, applyingMark.type);
25680
+ });
25681
+ if ($from.pos === $to.pos)
25682
+ return;
25683
+ doc2.nodesBetween($from.pos, $to.pos, (node, position) => {
25684
+ if (node.type.name === NodeTypes.LIST)
25685
+ return;
25686
+ const initialMark = findMarkByType(node.marks, name);
25687
+ const applyingMark = markType.create({ ...(initialMark == null ? void 0 : initialMark.attrs) || {}, ...value });
25688
+ const textPosition = resolveTextPosition($from, $to, node, position);
25689
+ if (isMarkAppliedToParent(tr, position, applyingMark, customizer.compareParentMark)) {
25690
+ onAppliedToParent({ tr, textPosition, applyingMark, initialMark, node });
25691
+ return;
25692
+ }
25693
+ if (node.isText) {
25694
+ tr.addMark(textPosition.from, textPosition.to, applyingMark);
25695
+ return;
25696
+ }
25697
+ if (isNodeFullySelected($from, $to, node, position)) {
25698
+ tr.step(new AddNodeMarkStep(position, applyingMark));
25699
+ }
25700
+ });
25701
+ }),
25702
+ getMarks: createCommand(({ editor }, name) => {
25703
+ const stateRef = toRef(editor, "state");
25704
+ return computed(() => {
25705
+ const { selection, doc: doc2 } = unref(stateRef);
25706
+ const { from: from2, to } = unref(selection);
25707
+ const marks = [];
25708
+ doc2.nodesBetween(from2, to, (node) => {
25709
+ for (const mark of node.marks) {
25710
+ if (mark.type.name === name)
25711
+ marks.unshift(mark.attrs);
25712
+ }
25713
+ });
25714
+ return marks;
25715
+ });
25716
+ }),
25717
+ getMark: createCommand(({ commands: commands2 }, name) => {
25718
+ const marksRef = commands2.getMarks(name);
25719
+ return computed(() => {
25720
+ var _a;
25721
+ return (_a = unref(marksRef)[0]) != null ? _a : null;
25722
+ });
25723
+ }),
25724
+ getCommonSettingMark: createCommand(({ commands: commands2 }, name, defaultRef) => {
25725
+ const selectionRef = commands2.getMark(name);
25726
+ return computed(() => {
25727
+ var _a, _b;
25728
+ return (_b = (_a = unref(selectionRef)) == null ? void 0 : _a.value) != null ? _b : unref(defaultRef);
25729
+ });
25730
+ }),
25731
+ getDeviceSettingMark: createCommand(({ commands: commands2 }, name, defaultRef) => {
25732
+ const selectionRef = commands2.getMark(name);
25733
+ const deviceRef = commands2.getDevice();
25734
+ return computed(() => {
25735
+ var _a, _b;
25736
+ return (_b = (_a = unref(selectionRef)) == null ? void 0 : _a[unref(deviceRef)]) != null ? _b : unref(defaultRef);
25737
+ });
25738
+ })
25799
25739
  };
25800
25740
  }
25801
25741
  });
@@ -25811,22 +25751,20 @@ const TextProcessor = Extension.create({
25811
25751
  marks.forEach((mark) => commands2.unsetMark(mark));
25812
25752
  }),
25813
25753
  transformText: createCommand(({ state }, transform) => {
25814
- const { selection } = state.tr;
25815
- if (selection.from === selection.to)
25754
+ const { $from, $to } = state.tr.selection;
25755
+ if ($from.pos === $to.pos)
25816
25756
  return;
25817
- state.doc.nodesBetween(selection.from, selection.to, (node, position) => {
25757
+ state.doc.nodesBetween($from.pos, $to.pos, (node, position) => {
25818
25758
  if (!node.isText)
25819
25759
  return;
25820
- const startPosition = Math.max(position, selection.from);
25821
- const endPosition = Math.min(position + node.nodeSize, selection.to);
25822
- const substringFrom = Math.max(0, selection.from - position);
25823
- const substringTo = Math.max(0, selection.to - position);
25760
+ const textPosition = resolveTextPosition($from, $to, node, position);
25761
+ const substringFrom = Math.max(0, $from.pos - position);
25762
+ const substringTo = Math.max(0, $to.pos - position);
25824
25763
  const updatedText = transform({
25825
- text: node.textContent.substring(substringFrom, substringTo),
25826
- position: { start: startPosition, end: endPosition }
25764
+ text: node.textContent.substring(substringFrom, substringTo)
25827
25765
  });
25828
25766
  const updatedNode = state.schema.text(updatedText, node.marks);
25829
- state.tr.replaceWith(startPosition, endPosition, updatedNode);
25767
+ state.tr.replaceWith(textPosition.from, textPosition.to, updatedNode);
25830
25768
  });
25831
25769
  })
25832
25770
  };
@@ -25935,15 +25873,132 @@ const CopyPasteProcessor = Extension.create({
25935
25873
  return [PastePlugin.create()];
25936
25874
  }
25937
25875
  });
25876
+ const Document$1 = Node.create({
25877
+ name: "doc",
25878
+ topNode: true,
25879
+ content: "block+"
25880
+ });
25881
+ const Document = Document$1.extend({
25882
+ marks: "settings"
25883
+ });
25884
+ const Paragraph$1 = Node.create({
25885
+ name: "paragraph",
25886
+ priority: 1e3,
25887
+ addOptions() {
25888
+ return {
25889
+ HTMLAttributes: {}
25890
+ };
25891
+ },
25892
+ group: "block",
25893
+ content: "inline*",
25894
+ parseHTML() {
25895
+ return [
25896
+ { tag: "p" }
25897
+ ];
25898
+ },
25899
+ renderHTML({ HTMLAttributes }) {
25900
+ return ["p", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
25901
+ },
25902
+ addCommands() {
25903
+ return {
25904
+ setParagraph: () => ({ commands: commands2 }) => {
25905
+ return commands2.setNode(this.name);
25906
+ }
25907
+ };
25908
+ },
25909
+ addKeyboardShortcuts() {
25910
+ return {
25911
+ "Mod-Alt-0": () => this.editor.commands.setParagraph()
25912
+ };
25913
+ }
25914
+ });
25915
+ const Paragraph = Paragraph$1.extend({
25916
+ marks: "_",
25917
+ addOptions: () => ({
25918
+ HTMLAttributes: { class: "zw-style" }
25919
+ })
25920
+ });
25921
+ const Heading$1 = Node.create({
25922
+ name: "heading",
25923
+ addOptions() {
25924
+ return {
25925
+ levels: [1, 2, 3, 4, 5, 6],
25926
+ HTMLAttributes: {}
25927
+ };
25928
+ },
25929
+ content: "inline*",
25930
+ group: "block",
25931
+ defining: true,
25932
+ addAttributes() {
25933
+ return {
25934
+ level: {
25935
+ default: 1,
25936
+ rendered: false
25937
+ }
25938
+ };
25939
+ },
25940
+ parseHTML() {
25941
+ return this.options.levels.map((level) => ({
25942
+ tag: `h${level}`,
25943
+ attrs: { level }
25944
+ }));
25945
+ },
25946
+ renderHTML({ node, HTMLAttributes }) {
25947
+ const hasLevel = this.options.levels.includes(node.attrs.level);
25948
+ const level = hasLevel ? node.attrs.level : this.options.levels[0];
25949
+ return [`h${level}`, mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
25950
+ },
25951
+ addCommands() {
25952
+ return {
25953
+ setHeading: (attributes) => ({ commands: commands2 }) => {
25954
+ if (!this.options.levels.includes(attributes.level)) {
25955
+ return false;
25956
+ }
25957
+ return commands2.setNode(this.name, attributes);
25958
+ },
25959
+ toggleHeading: (attributes) => ({ commands: commands2 }) => {
25960
+ if (!this.options.levels.includes(attributes.level)) {
25961
+ return false;
25962
+ }
25963
+ return commands2.toggleNode(this.name, "paragraph", attributes);
25964
+ }
25965
+ };
25966
+ },
25967
+ addKeyboardShortcuts() {
25968
+ return this.options.levels.reduce((items, level) => ({
25969
+ ...items,
25970
+ ...{
25971
+ [`Mod-Alt-${level}`]: () => this.editor.commands.toggleHeading({ level })
25972
+ }
25973
+ }), {});
25974
+ },
25975
+ addInputRules() {
25976
+ return this.options.levels.map((level) => {
25977
+ return textblockTypeInputRule({
25978
+ find: new RegExp(`^(#{1,${level}})\\s$`),
25979
+ type: this.type,
25980
+ getAttributes: {
25981
+ level
25982
+ }
25983
+ });
25984
+ });
25985
+ }
25986
+ });
25987
+ const Heading = Heading$1.extend({
25988
+ marks: "_",
25989
+ addOptions: () => ({
25990
+ levels: [1, 2, 3, 4],
25991
+ HTMLAttributes: { class: "zw-style" }
25992
+ })
25993
+ });
25938
25994
  const buildCoreExtensions = () => [
25939
25995
  Document,
25940
- Paragraph.configure({
25941
- HTMLAttributes: { class: "zw-style" }
25942
- }),
25943
25996
  Placeholder.configure({
25944
25997
  placeholder: "Type your text here...",
25945
25998
  emptyNodeClass: "zw-wysiwyg__placeholder"
25946
25999
  }),
26000
+ Paragraph,
26001
+ Heading,
25947
26002
  Text,
25948
26003
  History,
25949
26004
  NodeProcessor,