@zipify/wysiwyg 2.0.0-9 → 2.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 (29) hide show
  1. package/dist/cli.js +1 -1
  2. package/dist/wysiwyg.css +9 -9
  3. package/dist/wysiwyg.mjs +191 -213
  4. package/lib/assets/icons/indicator.svg +1 -1
  5. package/lib/cli/commands/ToJsonCommand.js +15 -6
  6. package/lib/components/toolbar/controls/AlignmentControl.vue +1 -1
  7. package/lib/components/toolbar/controls/FontColorControl.vue +1 -1
  8. package/lib/components/toolbar/controls/FontFamilyControl.vue +1 -1
  9. package/lib/components/toolbar/controls/FontSizeControl.vue +1 -1
  10. package/lib/components/toolbar/controls/FontWeightControl.vue +1 -1
  11. package/lib/components/toolbar/controls/ItalicControl.vue +1 -1
  12. package/lib/components/toolbar/controls/LineHeightControl.vue +1 -1
  13. package/lib/entry-lib.js +1 -1
  14. package/lib/extensions/StylePreset.js +2 -1
  15. package/lib/extensions/Superscript.js +25 -12
  16. package/lib/extensions/__tests__/StylePreset.test.js +4 -4
  17. package/lib/extensions/__tests__/__snapshots__/Superscript.test.js.snap +5 -5
  18. package/lib/extensions/core/NodeProcessor.js +0 -4
  19. package/lib/extensions/core/index.js +14 -7
  20. package/lib/extensions/core/plugins/PastePlugin.js +4 -0
  21. package/lib/extensions/core/plugins/PlaceholderPlugin.js +30 -0
  22. package/lib/extensions/core/plugins/ProseMirrorPlugin.js +4 -3
  23. package/lib/extensions/core/plugins/index.js +1 -0
  24. package/lib/extensions/index.js +2 -1
  25. package/lib/extensions/list/List.js +7 -4
  26. package/lib/extensions/list/ListItem.js +35 -4
  27. package/lib/styles/content.css +1 -1
  28. package/package.json +9 -3
  29. package/lib/extensions/core/CopyPasteProcessor.js +0 -10
package/dist/wysiwyg.css CHANGED
@@ -547,20 +547,20 @@
547
547
  color: rgb(var(--zw-color-white));
548
548
  }
549
549
 
550
- .zw-font-family-control[data-v-2f66bfa6] {
550
+ .zw-font-family-control[data-v-5f8e49dc] {
551
551
  width: 96px;
552
552
  }
553
- .zw-font-family-control__option[data-v-2f66bfa6] {
553
+ .zw-font-family-control__option[data-v-5f8e49dc] {
554
554
  font-weight: 400;
555
555
  font-family: var(--zw-font-family-option);
556
556
  width: 150px;
557
557
  }
558
558
 
559
- .zw-font-weight-control[data-v-5a87e48e] {
559
+ .zw-font-weight-control[data-v-00378d67] {
560
560
  width: 60px;
561
561
  }
562
562
 
563
- .zw-font-size-control[data-v-3f8185ea] {
563
+ .zw-font-size-control[data-v-13bfe2fe] {
564
564
  width: 72px;
565
565
  }
566
566
 
@@ -571,17 +571,17 @@
571
571
  flex-direction: column;
572
572
  }
573
573
 
574
- .zw-line-height-control__modal[data-v-c316d7dc] {
574
+ .zw-line-height-control__modal[data-v-2f58c40f] {
575
575
  padding: var(--zw-offset-sm);
576
576
  }
577
- .zw-line-height-control__row[data-v-c316d7dc] {
577
+ .zw-line-height-control__row[data-v-2f58c40f] {
578
578
  display: flex;
579
579
  align-items: center;
580
580
  }
581
- .zw-line-height-control__range[data-v-c316d7dc] {
581
+ .zw-line-height-control__range[data-v-2f58c40f] {
582
582
  width: 156px;
583
583
  }
584
- .zw-line-height-control__field[data-v-c316d7dc] {
584
+ .zw-line-height-control__field[data-v-2f58c40f] {
585
585
  width: 64px;
586
586
  margin-left: var(--zw-offset-sm);
587
587
  }
@@ -743,7 +743,7 @@ $font-height--xs: 1.33;
743
743
  $font-height--sm: 1.43;
744
744
  $font-height--md: 1.72;
745
745
  */
746
- .zw-wysiwyg__placeholder:first-child:last-child::before {
746
+ .zw-wysiwyg__placeholder::before {
747
747
  content: attr(data-placeholder);
748
748
  color: rgb(var(--zw-color-n70));
749
749
  float: left;
package/dist/wysiwyg.mjs CHANGED
@@ -26,7 +26,7 @@ var __privateMethod = (obj, member, method) => {
26
26
  __accessCheck(obj, member, "access private method");
27
27
  return method;
28
28
  };
29
- var _domParser, _parser, _NodeFilter, NodeFilter_get, _Node, Node_get, _removeComments, removeComments_fn, _normalizeRootTags, normalizeRootTags_fn, _createNodeIterator, createNodeIterator_fn, _iterateNodes, iterateNodes_fn, _runIterator, runIterator_fn, _removeEmptyNodes, removeEmptyNodes_fn, _normalizeListItems, normalizeListItems_fn, _isBlockNode, isBlockNode_fn, _isRootNode, isRootNode_fn, _assignElementProperties, assignElementProperties_fn, _removeStyleProperties, removeStyleProperties_fn, _normalizeBreakLines, normalizeBreakLines_fn, _normalizeBlockTextDecoration, normalizeBlockTextDecoration_fn, _moveTextDecorationToChildren, moveTextDecorationToChildren_fn, _parseTextDecoration, parseTextDecoration_fn, _normalizeBlockBackgroundColor, normalizeBlockBackgroundColor_fn, _moveBackgroundColorToChildren, moveBackgroundColorToChildren_fn, _wrapTextNode, wrapTextNode_fn, _iterateNodes2, iterateNodes_fn2, _iterateChildNodes, iterateChildNodes_fn, _bubbleMarks, bubbleMarks_fn, _canBubbleMark, canBubbleMark_fn, _includesMark, includesMark_fn, _includesMarkType, includesMarkType_fn, _removeMark, removeMark_fn, _addMark, addMark_fn, _findMarkIndexByType, findMarkIndexByType_fn, _buildHtml, buildHtml_fn, _buildJson, buildJson_fn, _textBlock, textBlock_fn, _normalizeTextBlockArgs, normalizeTextBlockArgs_fn;
29
+ var _domParser, _parser, _NodeFilter, NodeFilter_get, _Node, Node_get, _removeComments, removeComments_fn, _normalizeRootTags, normalizeRootTags_fn, _createNodeIterator, createNodeIterator_fn, _iterateNodes, iterateNodes_fn, _runIterator, runIterator_fn, _removeEmptyNodes, removeEmptyNodes_fn, _normalizeListItems, normalizeListItems_fn, _isBlockNode, isBlockNode_fn, _isRootNode, isRootNode_fn, _assignElementProperties, assignElementProperties_fn, _removeStyleProperties, removeStyleProperties_fn, _normalizeBreakLines, normalizeBreakLines_fn, _normalizeBlockTextDecoration, normalizeBlockTextDecoration_fn, _moveTextDecorationToChildren, moveTextDecorationToChildren_fn, _parseTextDecoration, parseTextDecoration_fn, _normalizeBlockBackgroundColor, normalizeBlockBackgroundColor_fn, _moveBackgroundColorToChildren, moveBackgroundColorToChildren_fn, _wrapTextNode, wrapTextNode_fn, _iterateNodes2, iterateNodes_fn2, _iterateChildNodes, iterateChildNodes_fn, _bubbleMarks, bubbleMarks_fn, _canBubbleMark, canBubbleMark_fn, _includesMark, includesMark_fn, _includesMarkType, includesMarkType_fn, _removeMark, removeMark_fn, _addMark, addMark_fn, _findMarkIndexByType, findMarkIndexByType_fn, _buildHtml, buildHtml_fn, _buildJson, buildJson_fn, _textBlock, textBlock_fn, _normalizeTextBlockArgs, normalizeTextBlockArgs_fn, _buildDecorations, buildDecorations_fn;
30
30
  import { computed, ref, watch, inject, onUnmounted, nextTick, provide, onMounted, toRef, unref, reactive } from "vue";
31
31
  import { ColorModel, ZipifyColorPicker } from "@zipify/colorpicker";
32
32
  function OrderedMap(content) {
@@ -14427,7 +14427,7 @@ const __vite_glob_0_4 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" sty
14427
14427
  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';
14428
14428
  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';
14429
14429
  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';
14430
- const __vite_glob_0_8 = '<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 9 9">\n <path fill="#FFAB00" d="M0 4.5a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0Z"/>\n <path fill="#fff" fill-rule="evenodd" d="M5.063 2.25H3.938v3.375h1.124V2.25Zm-1.125 4.5a.562.562 0 1 1 1.123-.001.562.562 0 0 1-1.123.001Z" clip-rule="evenodd"/>\n</svg>\n';
14430
+ 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 9 9">\n <path fill="#FFAB00" d="M0 4.5a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0Z"/>\n <path fill="#fff" fill-rule="evenodd" d="M5.063 2.25H3.938v3.375h1.124V2.25Zm-1.125 4.5a.562.562 0 1 1 1.123-.001.562.562 0 0 1-1.123.001Z" clip-rule="evenodd"/>\n</svg>\n';
14431
14431
  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';
14432
14432
  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';
14433
14433
  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';
@@ -14450,6 +14450,9 @@ function importIcon(name) {
14450
14450
  function isWysiwygContent(content) {
14451
14451
  return typeof content === "object" && content.__wswg__;
14452
14452
  }
14453
+ function unmarkWysiwygContent({ __wswg__, ...content }) {
14454
+ return content;
14455
+ }
14453
14456
  function markWysiwygContent(content) {
14454
14457
  return { ...content, __wswg__: true };
14455
14458
  }
@@ -22398,7 +22401,7 @@ const __vue2_script$n = {
22398
22401
  return { "--zw-font-family-option": `"${option.id}"` };
22399
22402
  }
22400
22403
  const currentValue = editor.commands.getFontFamily();
22401
- const isCustomized = editor.commands.isSettingCustomized("marks", TextSettings.FONT_FAMILY);
22404
+ const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_FAMILY);
22402
22405
  const apply2 = (fontFamily) => {
22403
22406
  recentFontNames.add(fontFamily);
22404
22407
  editor.chain().focus().applyFontFamily(fontFamily).run();
@@ -22419,7 +22422,7 @@ var __component__$n = /* @__PURE__ */ normalizeComponent(
22419
22422
  staticRenderFns$n,
22420
22423
  false,
22421
22424
  __vue2_injectStyles$n,
22422
- "2f66bfa6",
22425
+ "5f8e49dc",
22423
22426
  null,
22424
22427
  null
22425
22428
  );
@@ -22471,7 +22474,7 @@ const __vue2_script$m = {
22471
22474
  const font = editor.commands.getFont();
22472
22475
  const options = computed(() => unref(font).weights.map((style2) => ({ id: style2 })));
22473
22476
  const currentValue = editor.commands.getFontWeight();
22474
- const isCustomized = editor.commands.isSettingCustomized("marks", TextSettings.FONT_WEIGHT);
22477
+ const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_WEIGHT);
22475
22478
  const apply2 = (value) => editor.chain().focus().applyFontWeight(value).run();
22476
22479
  return {
22477
22480
  options,
@@ -22488,7 +22491,7 @@ var __component__$m = /* @__PURE__ */ normalizeComponent(
22488
22491
  staticRenderFns$m,
22489
22492
  false,
22490
22493
  __vue2_injectStyles$m,
22491
- "5a87e48e",
22494
+ "00378d67",
22492
22495
  null,
22493
22496
  null
22494
22497
  );
@@ -22542,7 +22545,7 @@ const __vue2_script$l = {
22542
22545
  return fontSizes.map((size2) => ({ id: size2, title: `${size2}px` }));
22543
22546
  });
22544
22547
  const currentValue = editor.commands.getFontSize();
22545
- const isCustomized = editor.commands.isSettingCustomized("marks", TextSettings.FONT_SIZE);
22548
+ const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_SIZE);
22546
22549
  const apply2 = (value) => editor.chain().focus().applyFontSize(value).run();
22547
22550
  return {
22548
22551
  options,
@@ -22559,7 +22562,7 @@ var __component__$l = /* @__PURE__ */ normalizeComponent(
22559
22562
  staticRenderFns$l,
22560
22563
  false,
22561
22564
  __vue2_injectStyles$l,
22562
- "3f8185ea",
22565
+ "13bfe2fe",
22563
22566
  null,
22564
22567
  null
22565
22568
  );
@@ -22643,7 +22646,7 @@ const __vue2_script$k = {
22643
22646
  setup() {
22644
22647
  const editor = inject(InjectionTokens$1.EDITOR);
22645
22648
  const currentValue = editor.commands.getFontColor();
22646
- const isCustomized = editor.commands.isSettingCustomized("marks", TextSettings.FONT_COLOR);
22649
+ const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_COLOR);
22647
22650
  const apply2 = (color) => editor.chain().applyFontColor(color).run();
22648
22651
  return {
22649
22652
  currentValue,
@@ -22813,7 +22816,7 @@ const __vue2_script$i = {
22813
22816
  setup() {
22814
22817
  const editor = inject(InjectionTokens$1.EDITOR);
22815
22818
  const currentValue = editor.commands.isItalic();
22816
- const isCustomized = editor.commands.isSettingCustomized("marks", TextSettings.FONT_STYLE);
22819
+ const isCustomized = editor.commands.isSettingCustomized(TextSettings.FONT_STYLE);
22817
22820
  const isAvailable = editor.commands.isItalicAvailable();
22818
22821
  const apply2 = () => editor.chain().focus().toggleItalic().run();
22819
22822
  return {
@@ -23236,7 +23239,7 @@ const __vue2_script$d = {
23236
23239
  setup(_, { emit }) {
23237
23240
  const editor = inject(InjectionTokens$1.EDITOR);
23238
23241
  const currentValue = editor.commands.getAlignment();
23239
- const isCustomized = editor.commands.isSettingCustomized("attributes", TextSettings.ALIGNMENT);
23242
+ const isCustomized = editor.commands.isSettingCustomized(TextSettings.ALIGNMENT);
23240
23243
  function apply2(value) {
23241
23244
  editor.chain().focus().applyAlignment(value).run();
23242
23245
  emit("applied");
@@ -23459,7 +23462,7 @@ const __vue2_script$b = {
23459
23462
  const editor = inject(InjectionTokens$1.EDITOR);
23460
23463
  const toggler = useModalToggler({ wrapperRef, modalRef });
23461
23464
  const currentValue = editor.commands.getLineHeight();
23462
- const isCustomized = editor.commands.isSettingCustomized("attributes", TextSettings.LINE_HEIGHT);
23465
+ const isCustomized = editor.commands.isSettingCustomized(TextSettings.LINE_HEIGHT);
23463
23466
  const apply2 = (value) => editor.commands.applyLineHeight(String(value));
23464
23467
  return {
23465
23468
  wrapperRef,
@@ -23479,7 +23482,7 @@ var __component__$b = /* @__PURE__ */ normalizeComponent(
23479
23482
  staticRenderFns$b,
23480
23483
  false,
23481
23484
  __vue2_injectStyles$b,
23482
- "c316d7dc",
23485
+ "2f58c40f",
23483
23486
  null,
23484
23487
  null
23485
23488
  );
@@ -24718,8 +24721,9 @@ const StylePreset = Extension.create({
24718
24721
  };
24719
24722
  });
24720
24723
  }),
24721
- isSettingCustomized: createCommand(({ commands: commands2 }, group, name) => {
24724
+ isSettingCustomized: createCommand(({ commands: commands2 }, name) => {
24722
24725
  const customization = commands2.getPresetCustomization();
24726
+ const group = TextSettings.attributes.includes(name) ? "attributes" : "marks";
24723
24727
  return computed(() => {
24724
24728
  var _a, _b;
24725
24729
  return (_b = (_a = unref(customization)[group]) == null ? void 0 : _a.includes(name)) != null ? _b : false;
@@ -25473,13 +25477,38 @@ const ListItem$1 = Node.create({
25473
25477
  const ListItem = ListItem$1.extend({
25474
25478
  name: NodeTypes.LIST_ITEM,
25475
25479
  marks: MarkGroups.SETTINGS,
25480
+ addCommands() {
25481
+ const getItemPosition = ({ selection }) => selection.$cursor.before(selection.$cursor.depth - 1);
25482
+ return {
25483
+ listItemNewline: createCommand(({ commands: commands2, tr }) => {
25484
+ const initialNode = tr.doc.nodeAt(getItemPosition(tr));
25485
+ const isEmptyParagraph = !tr.selection.$cursor.node().textContent;
25486
+ if (isEmptyParagraph)
25487
+ return false;
25488
+ commands2.splitListItem(this.name);
25489
+ const position = getItemPosition(tr);
25490
+ for (const mark of initialNode.marks) {
25491
+ tr.step(new AddNodeMarkStep(position, copyMark(mark)));
25492
+ }
25493
+ return true;
25494
+ })
25495
+ };
25496
+ },
25476
25497
  addOptions: () => ({
25477
25498
  HTMLAttributes: { class: "zw-style" }
25478
25499
  }),
25479
- addKeyboardShortcuts() {
25480
- const { Enter } = this.parent();
25481
- return { Enter };
25482
- }
25500
+ addKeyboardShortcuts: () => ({
25501
+ Enter: (context) => {
25502
+ var _a;
25503
+ const { state, commands: commands2 } = context.editor;
25504
+ const isListSelected = (_a = state.selection.$cursor) == null ? void 0 : _a.path.some((node) => {
25505
+ var _a2;
25506
+ return ((_a2 = node.type) == null ? void 0 : _a2.name) === NodeTypes.LIST;
25507
+ });
25508
+ if (isListSelected)
25509
+ return commands2.listItemNewline();
25510
+ }
25511
+ })
25483
25512
  });
25484
25513
  const List = Node.create({
25485
25514
  name: NodeTypes.LIST,
@@ -25490,7 +25519,8 @@ const List = Node.create({
25490
25519
  ListItem
25491
25520
  ],
25492
25521
  addOptions: () => ({
25493
- baseClass: ""
25522
+ baseClass: "",
25523
+ presetClass: ""
25494
25524
  }),
25495
25525
  addAttributes: () => ({
25496
25526
  bullet: {
@@ -25528,10 +25558,12 @@ const List = Node.create({
25528
25558
  ];
25529
25559
  },
25530
25560
  renderHTML({ HTMLAttributes: attrs }) {
25561
+ const classes = [
25562
+ this.options.baseClass + attrs.bullet.type,
25563
+ this.options.presetClass
25564
+ ];
25531
25565
  const isOrdered = ListTypes.ordered.includes(attrs.bullet.type);
25532
- const tag = isOrdered ? "ol" : "ul";
25533
- const bulletClass = this.options.baseClass + attrs.bullet.type;
25534
- return [tag, { class: bulletClass }, 0];
25566
+ return [isOrdered ? "ol" : "ul", { class: classes.join(" ") }, 0];
25535
25567
  },
25536
25568
  addCommands() {
25537
25569
  return {
@@ -26665,128 +26697,43 @@ const Link = Link$1.extend({
26665
26697
  return ["a", linkAttrs, 0];
26666
26698
  }
26667
26699
  });
26668
- const Superscript$1 = Mark.create({
26669
- name: "superscript",
26670
- addOptions() {
26671
- return {
26672
- HTMLAttributes: {}
26673
- };
26674
- },
26675
- parseHTML() {
26676
- return [
26677
- {
26678
- tag: "sup"
26679
- },
26680
- {
26681
- style: "vertical-align",
26682
- getAttrs(value) {
26683
- if (value !== "super") {
26684
- return false;
26685
- }
26686
- return null;
26687
- }
26688
- }
26689
- ];
26690
- },
26691
- renderHTML({ HTMLAttributes }) {
26692
- return ["sup", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes), 0];
26693
- },
26694
- addCommands() {
26695
- return {
26696
- setSuperscript: () => ({ commands: commands2 }) => {
26697
- return commands2.setMark(this.name);
26698
- },
26699
- toggleSuperscript: () => ({ commands: commands2 }) => {
26700
- return commands2.toggleMark(this.name);
26701
- },
26702
- unsetSuperscript: () => ({ commands: commands2 }) => {
26703
- return commands2.unsetMark(this.name);
26704
- }
26705
- };
26706
- },
26707
- addKeyboardShortcuts() {
26708
- return {
26709
- "Mod-.": () => this.editor.commands.toggleSuperscript()
26710
- };
26711
- }
26712
- });
26713
- const Superscript = Superscript$1.extend({
26700
+ const Superscript = Mark.create({
26714
26701
  name: TextSettings.SUPERSCRIPT,
26715
- addKeyboardShortcuts: null,
26716
- addOptions: () => ({
26717
- HTMLAttributes: { class: "zw-superscript" }
26718
- }),
26719
26702
  addCommands() {
26720
- const { setSuperscript, unsetSuperscript } = this.parent();
26721
26703
  return {
26722
- applySuperscript: setSuperscript,
26723
- removeSuperscript: unsetSuperscript,
26704
+ applySuperscript: createCommand(({ commands: commands2 }) => {
26705
+ commands2.setMark(this.name);
26706
+ }),
26707
+ removeSuperscript: createCommand(({ commands: commands2 }) => {
26708
+ commands2.unsetMark(this.name);
26709
+ }),
26724
26710
  toggleSuperscript: createCommand(({ commands: commands2 }) => {
26725
26711
  const isActive2 = unref(commands2.isSuperscript());
26726
- isActive2 ? commands2.applySuperscript() : commands2.removeSuperscript();
26712
+ isActive2 ? commands2.removeSuperscript() : commands2.applySuperscript();
26727
26713
  }),
26728
26714
  isSuperscript: createCommand(({ commands: commands2 }) => {
26729
26715
  const selectionRef = commands2.getMark(this.name);
26730
26716
  return computed(() => !!unref(selectionRef));
26731
26717
  })
26732
26718
  };
26719
+ },
26720
+ parseHTML() {
26721
+ return [
26722
+ { tag: "sup" },
26723
+ {
26724
+ style: "vertical-align",
26725
+ getAttrs: (value) => value !== "super" ? false : null
26726
+ }
26727
+ ];
26728
+ },
26729
+ renderHTML() {
26730
+ return ["sup", { class: "zw-superscript" }, 0];
26733
26731
  }
26734
26732
  });
26735
26733
  const Text = Node.create({
26736
26734
  name: "text",
26737
26735
  group: "inline"
26738
26736
  });
26739
- const Placeholder = Extension.create({
26740
- name: "placeholder",
26741
- addOptions() {
26742
- return {
26743
- emptyEditorClass: "is-editor-empty",
26744
- emptyNodeClass: "is-empty",
26745
- placeholder: "Write something \u2026",
26746
- showOnlyWhenEditable: true,
26747
- showOnlyCurrent: true,
26748
- includeChildren: false
26749
- };
26750
- },
26751
- addProseMirrorPlugins() {
26752
- return [
26753
- new Plugin({
26754
- props: {
26755
- decorations: ({ doc: doc2, selection }) => {
26756
- const active = this.editor.isEditable || !this.options.showOnlyWhenEditable;
26757
- const { anchor } = selection;
26758
- const decorations = [];
26759
- if (!active) {
26760
- return null;
26761
- }
26762
- doc2.descendants((node, pos) => {
26763
- const hasAnchor = anchor >= pos && anchor <= pos + node.nodeSize;
26764
- const isEmpty = !node.isLeaf && !node.childCount;
26765
- if ((hasAnchor || !this.options.showOnlyCurrent) && isEmpty) {
26766
- const classes = [this.options.emptyNodeClass];
26767
- if (this.editor.isEmpty) {
26768
- classes.push(this.options.emptyEditorClass);
26769
- }
26770
- const decoration = Decoration.node(pos, pos + node.nodeSize, {
26771
- class: classes.join(" "),
26772
- "data-placeholder": typeof this.options.placeholder === "function" ? this.options.placeholder({
26773
- editor: this.editor,
26774
- node,
26775
- pos,
26776
- hasAnchor
26777
- }) : this.options.placeholder
26778
- });
26779
- decorations.push(decoration);
26780
- }
26781
- return this.options.includeChildren;
26782
- });
26783
- return DecorationSet.create(doc2, decorations);
26784
- }
26785
- }
26786
- })
26787
- ];
26788
- }
26789
- });
26790
26737
  var GOOD_LEAF_SIZE = 200;
26791
26738
  var RopeSequence = function RopeSequence2() {
26792
26739
  };
@@ -27453,9 +27400,6 @@ const NodeProcessor = Extension.create({
27453
27400
  }
27454
27401
  });
27455
27402
  }),
27456
- removeMark: createCommand(({ commands: commands2, state }, node, position, mark) => {
27457
- commands2._removeNodeMark({ tr: state.tr, node, position, mark });
27458
- }),
27459
27403
  _removeNodeMark: createCommand((context, { tr, node, position, mark }) => {
27460
27404
  return node.isText ? tr.removeMark(position, position + node.nodeSize, mark) : tr.step(new RemoveNodeMarkStep(position, mark));
27461
27405
  })
@@ -27517,82 +27461,6 @@ const SelectionProcessor = Extension.create({
27517
27461
  };
27518
27462
  }
27519
27463
  });
27520
- class ProseMirrorPlugin {
27521
- static create(options) {
27522
- const plugin = new this(options || {});
27523
- return new Plugin({
27524
- key: new PluginKey(this.name),
27525
- props: plugin.buildProps()
27526
- });
27527
- }
27528
- constructor(options) {
27529
- this.options = options;
27530
- }
27531
- buildProps() {
27532
- return {};
27533
- }
27534
- }
27535
- class PastePlugin extends ProseMirrorPlugin {
27536
- buildProps() {
27537
- return {
27538
- transformPastedHTML: this._transformPastedHTML.bind(this),
27539
- handlePaste: this._handlePaste.bind(this)
27540
- };
27541
- }
27542
- _transformPastedHTML(html2) {
27543
- const normalizer = ContentNormalizer.build(html2);
27544
- normalizer.normalizeHTML();
27545
- this._removeDeprecatedStyles(normalizer);
27546
- return normalizer.normalizedHTML;
27547
- }
27548
- _removeDeprecatedStyles(normalizer) {
27549
- const elements = normalizer.dom.querySelectorAll('[style*="margin"]');
27550
- for (const element of Array.from(elements)) {
27551
- element.style.removeProperty("margin");
27552
- element.style.removeProperty("margin-top");
27553
- element.style.removeProperty("margin-right");
27554
- element.style.removeProperty("margin-bottom");
27555
- element.style.removeProperty("margin-left");
27556
- }
27557
- }
27558
- _handlePaste(view, _, slice2) {
27559
- const transaction = this._insertPastedContent(view, slice2).scrollIntoView().setMeta("paste", true).setMeta("uiEvent", "paste");
27560
- view.dispatch(transaction);
27561
- return true;
27562
- }
27563
- _insertPastedContent({ state, input }, slice2) {
27564
- if (!this._isFullBlockSelected(state)) {
27565
- return state.tr.replaceSelection(slice2);
27566
- }
27567
- return state.tr.replaceSelectionWith(slice2.content, input.shiftKey);
27568
- }
27569
- _isFullBlockSelected(state) {
27570
- const blocksSelection = this._expandSelectionToBlocks(state);
27571
- const isFromMatch = this._isMatchPosition(blocksSelection.from, state.selection.from);
27572
- const isToMatch = this._isMatchPosition(blocksSelection.to, state.selection.to);
27573
- return isFromMatch && isToMatch;
27574
- }
27575
- _expandSelectionToBlocks({ selection, doc: doc2 }) {
27576
- let from2 = selection.from;
27577
- let to = selection.to;
27578
- doc2.nodesBetween(from2, to, (node, position, parent) => {
27579
- if (parent.type.name !== NodeTypes.DOCUMENT)
27580
- return;
27581
- from2 = Math.min(from2, position + 1);
27582
- to = Math.max(to, position + node.nodeSize - 1);
27583
- });
27584
- return { from: from2, to };
27585
- }
27586
- _isMatchPosition(position1, position2) {
27587
- return Math.abs(position1 - position2) < 5;
27588
- }
27589
- }
27590
- const CopyPasteProcessor = Extension.create({
27591
- name: "copy_paste_processor",
27592
- addProseMirrorPlugins() {
27593
- return [PastePlugin.create()];
27594
- }
27595
- });
27596
27464
  const Document$1 = Node.create({
27597
27465
  name: "doc",
27598
27466
  topNode: true,
@@ -27711,12 +27579,119 @@ const Heading = Heading$1.extend({
27711
27579
  HTMLAttributes: { class: "zw-style" }
27712
27580
  })
27713
27581
  });
27582
+ class ProseMirrorPlugin {
27583
+ static create(editor, options) {
27584
+ const plugin = new this(editor, options || {});
27585
+ return new Plugin({
27586
+ key: new PluginKey(this.name),
27587
+ props: plugin.buildProps()
27588
+ });
27589
+ }
27590
+ constructor(editor, options) {
27591
+ this.options = options;
27592
+ this.editor = editor;
27593
+ }
27594
+ buildProps() {
27595
+ return {};
27596
+ }
27597
+ }
27598
+ class PastePlugin extends ProseMirrorPlugin {
27599
+ buildProps() {
27600
+ return {
27601
+ transformPastedHTML: this._transformPastedHTML.bind(this),
27602
+ handlePaste: this._handlePaste.bind(this)
27603
+ };
27604
+ }
27605
+ _transformPastedHTML(html2) {
27606
+ if (html2.includes("data-pm-slice") && html2.includes("zw-style")) {
27607
+ return html2;
27608
+ }
27609
+ const normalizer = ContentNormalizer.build(html2);
27610
+ normalizer.normalizeHTML();
27611
+ this._removeDeprecatedStyles(normalizer);
27612
+ return normalizer.normalizedHTML;
27613
+ }
27614
+ _removeDeprecatedStyles(normalizer) {
27615
+ const elements = normalizer.dom.querySelectorAll('[style*="margin"]');
27616
+ for (const element of Array.from(elements)) {
27617
+ element.style.removeProperty("margin");
27618
+ element.style.removeProperty("margin-top");
27619
+ element.style.removeProperty("margin-right");
27620
+ element.style.removeProperty("margin-bottom");
27621
+ element.style.removeProperty("margin-left");
27622
+ }
27623
+ }
27624
+ _handlePaste(view, _, slice2) {
27625
+ const transaction = this._insertPastedContent(view, slice2).scrollIntoView().setMeta("paste", true).setMeta("uiEvent", "paste");
27626
+ view.dispatch(transaction);
27627
+ return true;
27628
+ }
27629
+ _insertPastedContent({ state, input }, slice2) {
27630
+ if (!this._isFullBlockSelected(state)) {
27631
+ return state.tr.replaceSelection(slice2);
27632
+ }
27633
+ return state.tr.replaceSelectionWith(slice2.content, input.shiftKey);
27634
+ }
27635
+ _isFullBlockSelected(state) {
27636
+ const blocksSelection = this._expandSelectionToBlocks(state);
27637
+ const isFromMatch = this._isMatchPosition(blocksSelection.from, state.selection.from);
27638
+ const isToMatch = this._isMatchPosition(blocksSelection.to, state.selection.to);
27639
+ return isFromMatch && isToMatch;
27640
+ }
27641
+ _expandSelectionToBlocks({ selection, doc: doc2 }) {
27642
+ let from2 = selection.from;
27643
+ let to = selection.to;
27644
+ doc2.nodesBetween(from2, to, (node, position, parent) => {
27645
+ if (parent.type.name !== NodeTypes.DOCUMENT)
27646
+ return;
27647
+ from2 = Math.min(from2, position + 1);
27648
+ to = Math.max(to, position + node.nodeSize - 1);
27649
+ });
27650
+ return { from: from2, to };
27651
+ }
27652
+ _isMatchPosition(position1, position2) {
27653
+ return Math.abs(position1 - position2) < 5;
27654
+ }
27655
+ }
27656
+ class PlaceholderPlugin extends ProseMirrorPlugin {
27657
+ constructor() {
27658
+ super(...arguments);
27659
+ __privateAdd(this, _buildDecorations);
27660
+ }
27661
+ buildProps() {
27662
+ return { decorations: __privateMethod(this, _buildDecorations, buildDecorations_fn).bind(this) };
27663
+ }
27664
+ }
27665
+ _buildDecorations = new WeakSet();
27666
+ buildDecorations_fn = function({ doc: doc2 }) {
27667
+ const decorations = [];
27668
+ if (!this.editor.isEditable)
27669
+ return null;
27670
+ if (doc2.childCount > 1)
27671
+ return;
27672
+ doc2.descendants((node, pos) => {
27673
+ if (!node.childCount) {
27674
+ const decoration = Decoration.node(pos, pos + node.nodeSize, {
27675
+ class: "zw-wysiwyg__placeholder",
27676
+ "data-placeholder": "Type your text here..."
27677
+ });
27678
+ decorations.push(decoration);
27679
+ }
27680
+ return false;
27681
+ });
27682
+ return DecorationSet.create(doc2, decorations);
27683
+ };
27684
+ const ProseMirrorPlugins = Extension.create({
27685
+ name: "prose_mirror_plugins",
27686
+ addProseMirrorPlugins() {
27687
+ return [
27688
+ PastePlugin.create(this.editor),
27689
+ PlaceholderPlugin.create(this.editor)
27690
+ ];
27691
+ }
27692
+ });
27714
27693
  const buildCoreExtensions = () => [
27715
27694
  Document,
27716
- Placeholder.configure({
27717
- placeholder: "Type your text here...",
27718
- emptyNodeClass: "zw-wysiwyg__placeholder"
27719
- }),
27720
27695
  Paragraph,
27721
27696
  Heading,
27722
27697
  Text,
@@ -27724,7 +27699,7 @@ const buildCoreExtensions = () => [
27724
27699
  NodeProcessor,
27725
27700
  TextProcessor,
27726
27701
  SelectionProcessor,
27727
- CopyPasteProcessor
27702
+ ProseMirrorPlugins
27728
27703
  ];
27729
27704
  const Margin = Extension.create({
27730
27705
  name: TextSettings.MARGIN,
@@ -27769,7 +27744,8 @@ function buildExtensions(options) {
27769
27744
  makeVariable: options.makePresetVariable
27770
27745
  }),
27771
27746
  List.configure({
27772
- baseClass: options.baseListClass
27747
+ baseClass: options.baseListClass,
27748
+ presetClass: options.basePresetClass + options.defaultPresetId
27773
27749
  }),
27774
27750
  DeviceManager.configure({
27775
27751
  device: options.deviceRef
@@ -28032,5 +28008,7 @@ export {
28032
28008
  NodeTypes,
28033
28009
  TextSettings,
28034
28010
  Wysiwyg,
28035
- isWysiwygContent
28011
+ isWysiwygContent,
28012
+ markWysiwygContent,
28013
+ unmarkWysiwygContent
28036
28014
  };
@@ -1,4 +1,4 @@
1
- <svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 9 9">
1
+ <svg xmlns="http://www.w3.org/2000/svg" fill="none" style="width:var(--zw-icon-width);height:var(--zw-icon-height)" viewBox="0 0 9 9">
2
2
  <path fill="#FFAB00" d="M0 4.5a4.5 4.5 0 1 1 9 0 4.5 4.5 0 0 1-9 0Z"/>
3
3
  <path fill="#fff" fill-rule="evenodd" d="M5.063 2.25H3.938v3.375h1.124V2.25Zm-1.125 4.5a.562.562 0 1 1 1.123-.001.562.562 0 0 1-1.123.001Z" clip-rule="evenodd"/>
4
4
  </svg>