@zipify/wysiwyg 3.1.3 → 3.3.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.
@@ -17,6 +17,10 @@ export const TextSettings = Object.freeze({
17
17
  return [this.ALIGNMENT, this.LINE_HEIGHT, this.MARGIN];
18
18
  },
19
19
 
20
+ get resetAttributes() {
21
+ return [this.LINE_HEIGHT, this.MARGIN];
22
+ },
23
+
20
24
  get inlineMarks() {
21
25
  return [this.TEXT_DECORATION, this.LINK, this.SUPERSCRIPT, this.BACKGROUND_COLOR];
22
26
  },
@@ -135,7 +135,7 @@ export const StylePreset = Extension.create({
135
135
 
136
136
  isSettingCustomized: createCommand(({ commands }, name) => {
137
137
  const customization = commands.getPresetCustomization();
138
- const group = TextSettings.attributes.includes(name) ? 'attributes' : 'marks';
138
+ const group = TextSettings.resetAttributes.includes(name) ? 'attributes' : 'marks';
139
139
 
140
140
  return computed(() => unref(customization)[group]?.includes(name) ?? false);
141
141
  }),
@@ -156,7 +156,7 @@ export const StylePreset = Extension.create({
156
156
 
157
157
  doc.nodesBetween(from, to, (node) => {
158
158
  for (const [name, value] of Object.entries(node.attrs)) {
159
- const isSetting = TextSettings.attributes.includes(name);
159
+ const isSetting = TextSettings.resetAttributes.includes(name);
160
160
 
161
161
  if (isSetting && value) attributes.add(name);
162
162
  }
@@ -179,8 +179,8 @@ export const StylePreset = Extension.create({
179
179
  .storeSelection()
180
180
  .expandSelectionToBlock()
181
181
  .removeMarks(TextSettings.marks)
182
- .resetAttributes(NodeTypes.PARAGRAPH, TextSettings.attributes)
183
- .resetAttributes(NodeTypes.HEADING, TextSettings.attributes)
182
+ .resetAttributes(NodeTypes.PARAGRAPH, TextSettings.resetAttributes)
183
+ .resetAttributes(NodeTypes.HEADING, TextSettings.resetAttributes)
184
184
  .restoreSelection()
185
185
  .run();
186
186
  }),
@@ -118,6 +118,25 @@ const MockLink = Extension.create({
118
118
  }
119
119
  });
120
120
 
121
+ const MockLineHeight = Extension.create({
122
+ name: TextSettings.LINE_HEIGHT,
123
+
124
+ addGlobalAttributes: () => [
125
+ {
126
+ types: [NodeTypes.PARAGRAPH],
127
+ attributes: {
128
+ line_height: {
129
+ isRequired: false,
130
+ renderHTML: (attrs) => ({ style: `line-height: ${attrs.line_height}` })
131
+ },
132
+ alignment: {
133
+ isRequired: false
134
+ }
135
+ }
136
+ }
137
+ ]
138
+ });
139
+
121
140
  function createEditor({ content, presets, defaultId, link }) {
122
141
  return new Editor({
123
142
  content: ContentNormalizer.normalize(content),
@@ -144,6 +163,7 @@ function createEditor({ content, presets, defaultId, link }) {
144
163
  MockFontColor,
145
164
  MockFontFamily,
146
165
  MockFontStyle,
166
+ MockLineHeight,
147
167
  MockTextDecoration,
148
168
  MockSuperscript,
149
169
  MockLink.configure(link)
@@ -453,16 +473,16 @@ describe('get preset customization', () => {
453
473
  content: NodeFactory.doc([
454
474
  NodeFactory.paragraph({
455
475
  preset: { id: 'regular-1' },
456
- alignment: { value: 'center' }
476
+ line_height: { value: '1.1' }
457
477
  }, 'test')
458
478
  ]),
459
479
  presets: [createPreset({ id: 'regular-1' })]
460
480
  });
461
481
 
462
482
  editor.commands.selectAll();
463
- const isAlignmentCustomized = editor.commands.isSettingCustomized(TextSettings.ALIGNMENT);
483
+ const isLineHeightCustomized = editor.commands.isSettingCustomized(TextSettings.LINE_HEIGHT);
464
484
 
465
- expect(isAlignmentCustomized.value).toBe(true);
485
+ expect(isLineHeightCustomized.value).toBe(true);
466
486
  });
467
487
  });
468
488
 
@@ -6,6 +6,7 @@ Object {
6
6
  Object {
7
7
  "attrs": Object {
8
8
  "alignment": null,
9
+ "line_height": null,
9
10
  "preset": Object {
10
11
  "id": "regular-1",
11
12
  },
@@ -93,6 +94,7 @@ Object {
93
94
  Object {
94
95
  "attrs": Object {
95
96
  "alignment": null,
97
+ "line_height": null,
96
98
  "preset": Object {
97
99
  "id": "regular-1",
98
100
  },
@@ -116,6 +118,7 @@ Object {
116
118
  Object {
117
119
  "attrs": Object {
118
120
  "alignment": null,
121
+ "line_height": null,
119
122
  "preset": Object {
120
123
  "id": "regular-1",
121
124
  },
@@ -131,6 +134,7 @@ Object {
131
134
  Object {
132
135
  "attrs": Object {
133
136
  "alignment": null,
137
+ "line_height": null,
134
138
  "preset": Object {
135
139
  "id": "regular-1",
136
140
  },
@@ -180,6 +184,7 @@ Object {
180
184
  "alignment": Object {
181
185
  "value": "center",
182
186
  },
187
+ "line_height": null,
183
188
  "preset": Object {
184
189
  "id": "regular-2",
185
190
  },
@@ -199,9 +204,7 @@ Object {
199
204
 
200
205
  exports[`get content customization should find attributes 1`] = `
201
206
  Object {
202
- "attributes": Array [
203
- "alignment",
204
- ],
207
+ "attributes": Array [],
205
208
  "marks": Array [],
206
209
  }
207
210
  `;
@@ -225,9 +228,7 @@ Object {
225
228
 
226
229
  exports[`get preset customization should find attributes 1`] = `
227
230
  Object {
228
- "attributes": Array [
229
- "alignment",
230
- ],
231
+ "attributes": Array [],
231
232
  "marks": Array [],
232
233
  }
233
234
  `;
@@ -293,6 +294,7 @@ Object {
293
294
  Object {
294
295
  "attrs": Object {
295
296
  "alignment": null,
297
+ "line_height": null,
296
298
  "preset": Object {
297
299
  "id": "regular-2",
298
300
  },
@@ -340,6 +342,7 @@ Object {
340
342
  Object {
341
343
  "attrs": Object {
342
344
  "alignment": null,
345
+ "line_height": null,
343
346
  "preset": Object {
344
347
  "id": "regular-2",
345
348
  },
@@ -363,6 +366,7 @@ Object {
363
366
  Object {
364
367
  "attrs": Object {
365
368
  "alignment": null,
369
+ "line_height": null,
366
370
  "preset": Object {
367
371
  "id": "regular-1",
368
372
  },
@@ -395,6 +399,7 @@ Object {
395
399
  Object {
396
400
  "attrs": Object {
397
401
  "alignment": null,
402
+ "line_height": null,
398
403
  "preset": Object {
399
404
  "id": "regular-1",
400
405
  },
@@ -433,6 +438,7 @@ Object {
433
438
  Object {
434
439
  "attrs": Object {
435
440
  "alignment": null,
441
+ "line_height": null,
436
442
  "preset": Object {
437
443
  "id": "regular-1",
438
444
  },
@@ -461,7 +467,9 @@ Object {
461
467
  "content": Array [
462
468
  Object {
463
469
  "attrs": Object {
464
- "alignment": null,
470
+ "alignment": Object {
471
+ "value": "center",
472
+ },
465
473
  "level": 1,
466
474
  "preset": Object {
467
475
  "id": "regular-1",
@@ -477,7 +485,10 @@ Object {
477
485
  },
478
486
  Object {
479
487
  "attrs": Object {
480
- "alignment": null,
488
+ "alignment": Object {
489
+ "value": "center",
490
+ },
491
+ "line_height": null,
481
492
  "preset": Object {
482
493
  "id": "regular-1",
483
494
  },
@@ -501,6 +512,7 @@ Object {
501
512
  Object {
502
513
  "attrs": Object {
503
514
  "alignment": null,
515
+ "line_height": null,
504
516
  "preset": Object {
505
517
  "id": "regular-1",
506
518
  },
@@ -518,6 +530,6 @@ Object {
518
530
  }
519
531
  `;
520
532
 
521
- exports[`render preset styles should render node without preset 1`] = `"<p class="zw-style">test</p>"`;
533
+ exports[`render preset styles should render node without preset 1`] = `"<p class="zw-style" style="line-height: null">test</p>"`;
522
534
 
523
- exports[`render preset styles should render preset class 1`] = `"<p class="zw-style zw ts-regular-1">test</p>"`;
535
+ exports[`render preset styles should render preset class 1`] = `"<p class="zw-style zw ts-regular-1" style="line-height: null">test</p>"`;
@@ -1,4 +1,4 @@
1
- import { Decoration, DecorationSet } from 'prosemirror-view';
1
+ import { Decoration, DecorationSet } from '@tiptap/pm/view';
2
2
  import { ProseMirrorPlugin } from './ProseMirrorPlugin';
3
3
 
4
4
  export class PlaceholderPlugin extends ProseMirrorPlugin {
@@ -1,4 +1,4 @@
1
- import { Plugin, PluginKey } from 'prosemirror-state';
1
+ import { Plugin, PluginKey } from '@tiptap/pm/state';
2
2
 
3
3
  export class ProseMirrorPlugin {
4
4
  static create(editor, options) {
@@ -1,6 +1,6 @@
1
1
  import { ref } from 'vue';
2
2
  import { getSchema } from '@tiptap/core';
3
- import { DOMParser } from 'prosemirror-model';
3
+ import { DOMParser } from '@tiptap/pm/model';
4
4
  import { buildExtensions } from '../extensions';
5
5
  import { Devices } from '../enums';
6
6
  import { ContentNormalizer } from './normalizer';
@@ -1,4 +1,4 @@
1
- import { Schema } from 'prosemirror-model';
1
+ import { Schema } from '@tiptap/pm/model';
2
2
  import { NodeFactory } from '../NodeFactory';
3
3
  import { NodeSelector } from '../NodeSelector';
4
4
  import { NodeTypes, TextSettings } from '../../enums';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipify/wysiwyg",
3
- "version": "3.1.3",
3
+ "version": "3.3.0-0",
4
4
  "description": "Zipify modification of TipTap text editor",
5
5
  "main": "dist/wysiwyg.mjs",
6
6
  "bin": {
@@ -32,19 +32,20 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@popperjs/core": "^2.11.6",
35
- "@tiptap/core": "2.0.0-beta.209",
36
- "@tiptap/extension-document": "2.0.0-beta.209",
37
- "@tiptap/extension-heading": "2.0.0-beta.209",
38
- "@tiptap/extension-history": "2.0.0-beta.209",
39
- "@tiptap/extension-link": "2.0.0-beta.209",
40
- "@tiptap/extension-list-item": "2.0.0-beta.209",
41
- "@tiptap/extension-paragraph": "2.0.0-beta.209",
42
- "@tiptap/extension-text": "2.0.0-beta.209",
43
- "@tiptap/vue-2": "2.0.0-beta.209",
44
- "commander": "^9.4.1",
45
- "jsdom": "^20.0.3",
35
+ "@tiptap/core": "2.0.0-beta.215",
36
+ "@tiptap/extension-document": "2.0.0-beta.215",
37
+ "@tiptap/extension-heading": "2.0.0-beta.215",
38
+ "@tiptap/extension-history": "2.0.0-beta.215",
39
+ "@tiptap/extension-link": "2.0.0-beta.215",
40
+ "@tiptap/extension-list-item": "2.0.0-beta.215",
41
+ "@tiptap/extension-paragraph": "2.0.0-beta.215",
42
+ "@tiptap/extension-text": "2.0.0-beta.215",
43
+ "@tiptap/pm": "^2.0.0-beta.215",
44
+ "@tiptap/vue-2": "2.0.0-beta.215",
45
+ "commander": "^10.0.0",
46
+ "jsdom": "^21.1.0",
46
47
  "lodash": "^4.17.21",
47
- "simplebar": "^5.3.9"
48
+ "simplebar": "^6.2.0"
48
49
  },
49
50
  "peerDependencies": {
50
51
  "@zipify/colorpicker": "^2.2",
@@ -59,38 +60,38 @@
59
60
  }
60
61
  },
61
62
  "devDependencies": {
62
- "@babel/core": "^7.20.7",
63
+ "@babel/core": "^7.20.12",
63
64
  "@babel/eslint-parser": "^7.19.1",
64
65
  "@babel/plugin-transform-runtime": "^7.19.6",
65
66
  "@babel/preset-env": "^7.20.2",
66
- "@babel/runtime": "^7.20.7",
67
- "@optimize-lodash/rollup-plugin": "^4.0.1",
67
+ "@babel/runtime": "^7.20.13",
68
+ "@optimize-lodash/rollup-plugin": "^4.0.3",
68
69
  "@rollup/plugin-babel": "^6.0.3",
69
- "@rollup/plugin-commonjs": "^24.0.0",
70
+ "@rollup/plugin-commonjs": "^24.0.1",
70
71
  "@rollup/plugin-json": "^6.0.0",
71
72
  "@rollup/plugin-node-resolve": "^15.0.1",
72
73
  "@rollup/plugin-replace": "^5.0.2",
73
- "@rollup/plugin-terser": "^0.2.1",
74
- "@vue/test-utils": "^1.3.3",
74
+ "@rollup/plugin-terser": "^0.4.0",
75
+ "@vue/test-utils": "^1.3.4",
75
76
  "@vue/vue2-jest": "^29.2.2",
76
- "@zipify/colorpicker": "^2.2.1",
77
- "@zipify/eslint-config": "^1.0.0",
78
- "babel-jest": "^29.3.1",
79
- "eslint": "8.30.0",
80
- "eslint-plugin-import": "^2.26.0",
81
- "eslint-plugin-jest": "^27.1.7",
82
- "eslint-plugin-vue": "^9.8.0",
77
+ "@zipify/colorpicker": "^2.2.2",
78
+ "@zipify/eslint-config": "^1.1.2",
79
+ "babel-jest": "^29.4.2",
80
+ "eslint": "8.33.0",
81
+ "eslint-plugin-import": "^2.27.5",
82
+ "eslint-plugin-jest": "^27.2.1",
83
+ "eslint-plugin-vue": "^9.9.0",
83
84
  "gzipper": "^7.2.0",
84
- "husky": "^8.0.2",
85
- "jest": "^29.3.1",
86
- "jest-environment-jsdom": "^29.3.1",
87
- "lint-staged": "^13.1.0",
85
+ "husky": "^8.0.3",
86
+ "jest": "^29.4.2",
87
+ "jest-environment-jsdom": "^29.4.2",
88
+ "lint-staged": "^13.1.1",
88
89
  "postcss-html": "^1.5.0",
89
90
  "release-it": "^15.6.0",
90
- "rollup": "^3.9.0",
91
- "stylelint": "^14.16.0",
91
+ "rollup": "^3.14.0",
92
+ "stylelint": "^14.16.1",
92
93
  "svgo": "^3.0.2",
93
- "vite": "^4.0.3",
94
+ "vite": "^4.1.1",
94
95
  "vite-plugin-vue2": "^2.0.3",
95
96
  "vue": "^2.7.14",
96
97
  "vue-template-compiler": "^2.7.14"