@zipify/wysiwyg 1.0.0-dev.72 → 1.0.0-dev.75

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/wysiwyg.mjs CHANGED
@@ -22776,7 +22776,7 @@ const Toolbar = /* @__PURE__ */ function() {
22776
22776
  function useEditor({ content, onChange, extensions: extensions2, isReadonlyRef }) {
22777
22777
  const editor = reactive(new Editor({
22778
22778
  content: ContentNormalizer.normalize(content.value),
22779
- onUpdate: () => onChange(editor.getJSON()),
22779
+ onUpdate: () => onChange({ ...editor.getJSON(), __wswg__: true }),
22780
22780
  extensions: extensions2,
22781
22781
  injectCSS: false
22782
22782
  }));
@@ -22811,7 +22811,7 @@ function useToolbar({ wrapperRef, offsets, isActiveRef }) {
22811
22811
  },
22812
22812
  {
22813
22813
  name: "flip",
22814
- enabled: false
22814
+ options: { rootBoundary: "document" }
22815
22815
  }
22816
22816
  ]
22817
22817
  });
@@ -25537,6 +25537,60 @@ const History = Extension.create({
25537
25537
  };
25538
25538
  }
25539
25539
  });
25540
+ const HardBreak = Node$1.create({
25541
+ name: "hardBreak",
25542
+ addOptions() {
25543
+ return {
25544
+ keepMarks: true,
25545
+ HTMLAttributes: {}
25546
+ };
25547
+ },
25548
+ inline: true,
25549
+ group: "inline",
25550
+ selectable: false,
25551
+ parseHTML() {
25552
+ return [
25553
+ { tag: "br" }
25554
+ ];
25555
+ },
25556
+ renderHTML({ HTMLAttributes }) {
25557
+ return ["br", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
25558
+ },
25559
+ renderText() {
25560
+ return "\n";
25561
+ },
25562
+ addCommands() {
25563
+ return {
25564
+ setHardBreak: () => ({ commands: commands2, chain, state, editor }) => {
25565
+ return commands2.first([
25566
+ () => commands2.exitCode(),
25567
+ () => commands2.command(() => {
25568
+ const { selection, storedMarks } = state;
25569
+ if (selection.$from.parent.type.spec.isolating) {
25570
+ return false;
25571
+ }
25572
+ const { keepMarks } = this.options;
25573
+ const { splittableMarks } = editor.extensionManager;
25574
+ const marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();
25575
+ return chain().insertContent({ type: this.name }).command(({ tr, dispatch }) => {
25576
+ if (dispatch && marks && keepMarks) {
25577
+ const filteredMarks = marks.filter((mark) => splittableMarks.includes(mark.type.name));
25578
+ tr.ensureMarks(filteredMarks);
25579
+ }
25580
+ return true;
25581
+ }).run();
25582
+ })
25583
+ ]);
25584
+ }
25585
+ };
25586
+ },
25587
+ addKeyboardShortcuts() {
25588
+ return {
25589
+ "Mod-Enter": () => this.editor.commands.setHardBreak(),
25590
+ "Shift-Enter": () => this.editor.commands.setHardBreak()
25591
+ };
25592
+ }
25593
+ });
25540
25594
  const NodeProcessor = Extension.create({
25541
25595
  name: "node_processor",
25542
25596
  addCommands() {
@@ -25686,12 +25740,15 @@ const buildCoreExtensions = () => [
25686
25740
  Paragraph.configure({
25687
25741
  HTMLAttributes: { class: "zw-style" }
25688
25742
  }),
25689
- Text,
25690
25743
  Placeholder.configure({
25691
25744
  placeholder: "Type your text here...",
25692
25745
  emptyNodeClass: "zw-wysiwyg__placeholder"
25693
25746
  }),
25747
+ Text,
25694
25748
  History,
25749
+ HardBreak.configure({
25750
+ keepMarks: false
25751
+ }),
25695
25752
  NodeProcessor,
25696
25753
  TextProcessor,
25697
25754
  SelectionProcessor,
@@ -4,6 +4,7 @@ exports[`life cycle should emit changes 1`] = `
4
4
  Array [
5
5
  Array [
6
6
  Object {
7
+ "__wswg__": true,
7
8
  "content": Array [
8
9
  Object {
9
10
  "content": Array [
@@ -5,7 +5,7 @@ import { ContentNormalizer } from '../services';
5
5
  export function useEditor({ content, onChange, extensions, isReadonlyRef }) {
6
6
  const editor = reactive(new Editor({
7
7
  content: ContentNormalizer.normalize(content.value),
8
- onUpdate: () => onChange(editor.getJSON()),
8
+ onUpdate: () => onChange({ ...editor.getJSON(), __wswg__: true }),
9
9
  extensions,
10
10
  injectCSS: false
11
11
  }));
@@ -22,7 +22,7 @@ export function useToolbar({ wrapperRef, offsets, isActiveRef }) {
22
22
  },
23
23
  {
24
24
  name: 'flip',
25
- enabled: false
25
+ options: { rootBoundary: 'document' }
26
26
  }
27
27
  ]
28
28
  });
@@ -3,6 +3,7 @@ import Paragraph from '@tiptap/extension-paragraph';
3
3
  import Text from '@tiptap/extension-text';
4
4
  import Placeholder from '@tiptap/extension-placeholder';
5
5
  import History from '@tiptap/extension-history';
6
+ import HardBreak from '@tiptap/extension-hard-break';
6
7
  import { NodeProcessor } from './NodeProcessor';
7
8
  import { TextProcessor } from './TextProcessor';
8
9
  import { SelectionProcessor } from './SelectionProcessor';
@@ -13,12 +14,15 @@ export const buildCoreExtensions = () => [
13
14
  Paragraph.configure({
14
15
  HTMLAttributes: { class: 'zw-style' }
15
16
  }),
16
- Text,
17
17
  Placeholder.configure({
18
18
  placeholder: 'Type your text here...',
19
19
  emptyNodeClass: 'zw-wysiwyg__placeholder'
20
20
  }),
21
+ Text,
21
22
  History,
23
+ HardBreak.configure({
24
+ keepMarks: false
25
+ }),
22
26
  NodeProcessor,
23
27
  TextProcessor,
24
28
  SelectionProcessor,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipify/wysiwyg",
3
- "version": "1.0.0-dev.72",
3
+ "version": "1.0.0-dev.75",
4
4
  "description": "Zipify modification of TipTap text editor",
5
5
  "main": "dist/wysiwyg.mjs",
6
6
  "repository": {
@@ -30,6 +30,7 @@
30
30
  "@popperjs/core": "^2.11.5",
31
31
  "@tiptap/core": "^2.0.0-beta.182",
32
32
  "@tiptap/extension-document": "^2.0.0-beta.17",
33
+ "@tiptap/extension-hard-break": "^2.0.0-beta.33",
33
34
  "@tiptap/extension-heading": "^2.0.0-beta.29",
34
35
  "@tiptap/extension-history": "^2.0.0-beta.26",
35
36
  "@tiptap/extension-link": "^2.0.0-beta.43",