@zipify/wysiwyg 1.0.0-dev.73 → 1.0.0-dev.76

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
@@ -14391,6 +14391,12 @@ function importIcon(name) {
14391
14391
  }
14392
14392
  return icon;
14393
14393
  }
14394
+ function isWysiwygContent(content) {
14395
+ return typeof content === "object" && content.__wswg__;
14396
+ }
14397
+ function markWysiwygContent(content) {
14398
+ return { ...content, __wswg__: true };
14399
+ }
14394
14400
  var render$E = function __render__6() {
14395
14401
  var _vm = this;
14396
14402
  var _h = _vm.$createElement;
@@ -25537,6 +25543,60 @@ const History = Extension.create({
25537
25543
  };
25538
25544
  }
25539
25545
  });
25546
+ const HardBreak = Node$1.create({
25547
+ name: "hardBreak",
25548
+ addOptions() {
25549
+ return {
25550
+ keepMarks: true,
25551
+ HTMLAttributes: {}
25552
+ };
25553
+ },
25554
+ inline: true,
25555
+ group: "inline",
25556
+ selectable: false,
25557
+ parseHTML() {
25558
+ return [
25559
+ { tag: "br" }
25560
+ ];
25561
+ },
25562
+ renderHTML({ HTMLAttributes }) {
25563
+ return ["br", mergeAttributes(this.options.HTMLAttributes, HTMLAttributes)];
25564
+ },
25565
+ renderText() {
25566
+ return "\n";
25567
+ },
25568
+ addCommands() {
25569
+ return {
25570
+ setHardBreak: () => ({ commands: commands2, chain, state, editor }) => {
25571
+ return commands2.first([
25572
+ () => commands2.exitCode(),
25573
+ () => commands2.command(() => {
25574
+ const { selection, storedMarks } = state;
25575
+ if (selection.$from.parent.type.spec.isolating) {
25576
+ return false;
25577
+ }
25578
+ const { keepMarks } = this.options;
25579
+ const { splittableMarks } = editor.extensionManager;
25580
+ const marks = storedMarks || selection.$to.parentOffset && selection.$from.marks();
25581
+ return chain().insertContent({ type: this.name }).command(({ tr, dispatch }) => {
25582
+ if (dispatch && marks && keepMarks) {
25583
+ const filteredMarks = marks.filter((mark) => splittableMarks.includes(mark.type.name));
25584
+ tr.ensureMarks(filteredMarks);
25585
+ }
25586
+ return true;
25587
+ }).run();
25588
+ })
25589
+ ]);
25590
+ }
25591
+ };
25592
+ },
25593
+ addKeyboardShortcuts() {
25594
+ return {
25595
+ "Mod-Enter": () => this.editor.commands.setHardBreak(),
25596
+ "Shift-Enter": () => this.editor.commands.setHardBreak()
25597
+ };
25598
+ }
25599
+ });
25540
25600
  const NodeProcessor = Extension.create({
25541
25601
  name: "node_processor",
25542
25602
  addCommands() {
@@ -25686,12 +25746,15 @@ const buildCoreExtensions = () => [
25686
25746
  Paragraph.configure({
25687
25747
  HTMLAttributes: { class: "zw-style" }
25688
25748
  }),
25689
- Text,
25690
25749
  Placeholder.configure({
25691
25750
  placeholder: "Type your text here...",
25692
25751
  emptyNodeClass: "zw-wysiwyg__placeholder"
25693
25752
  }),
25753
+ Text,
25694
25754
  History,
25755
+ HardBreak.configure({
25756
+ keepMarks: false
25757
+ }),
25695
25758
  NodeProcessor,
25696
25759
  TextProcessor,
25697
25760
  SelectionProcessor,
@@ -25895,7 +25958,7 @@ const __vue2_script = {
25895
25958
  });
25896
25959
  const updateToolbar = () => toolbar.update();
25897
25960
  function onChange(content) {
25898
- emit("input", content);
25961
+ emit("input", markWysiwygContent(content));
25899
25962
  updateToolbar();
25900
25963
  }
25901
25964
  const pageBlocks = toRef(props, "pageBlocks");
@@ -25963,5 +26026,6 @@ export {
25963
26026
  NodeFactory,
25964
26027
  NodeTypes,
25965
26028
  TextSettings,
25966
- Wysiwyg
26029
+ Wysiwyg,
26030
+ isWysiwygContent
25967
26031
  };
package/lib/Wysiwyg.vue CHANGED
@@ -21,6 +21,7 @@ import { ContextWindow, FavoriteColors, Storage } from './services';
21
21
  import { Devices } from './enums';
22
22
  import { outClick } from './directives';
23
23
  import { Font } from './models';
24
+ import { markWysiwygContent } from './utils';
24
25
 
25
26
  const MIN_FONT_SIZE = 5;
26
27
  const MAX_FONT_SIZE = 112;
@@ -150,7 +151,7 @@ export default {
150
151
  const updateToolbar = () => toolbar.update();
151
152
 
152
153
  function onChange(content) {
153
- emit('input', content);
154
+ emit('input', markWysiwygContent(content));
154
155
  updateToolbar();
155
156
  }
156
157
 
@@ -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/lib/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { default as Wysiwyg } from './Wysiwyg';
2
2
  export { NodeFactory } from './services';
3
3
  export { NodeTypes, TextSettings, Alignments } from './enums';
4
+ export { isWysiwygContent } from './utils';
@@ -7,3 +7,4 @@ export { convertLineHeight } from './convertLineHeight';
7
7
  export { convertFontSize } from './convertFontSize';
8
8
  export { convertAlignment } from './convertAlignment';
9
9
  export { importIcon } from './importIcon';
10
+ export { isWysiwygContent, markWysiwygContent } from './isWysiwygContent';
@@ -0,0 +1,7 @@
1
+ export function isWysiwygContent(content) {
2
+ return typeof content === 'object' && content.__wswg__;
3
+ }
4
+
5
+ export function markWysiwygContent(content) {
6
+ return { ...content, __wswg__: true };
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipify/wysiwyg",
3
- "version": "1.0.0-dev.73",
3
+ "version": "1.0.0-dev.76",
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",