@zipify/wysiwyg 1.0.0-dev.5 → 1.0.0-dev.50

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 (237) hide show
  1. package/.editorconfig +1 -1
  2. package/.eslintignore +1 -0
  3. package/.eslintrc.js +2 -2
  4. package/.github/dependabot.yaml +1 -0
  5. package/.lintstagedrc +2 -2
  6. package/.release-it.json +3 -1
  7. package/.stylelintignore +1 -0
  8. package/.stylelintrc +0 -4
  9. package/README.md +2 -2
  10. package/config/jest/setupTests.js +4 -3
  11. package/config/vite/example.config.js +25 -0
  12. package/config/vite/lib.config.js +30 -0
  13. package/config/{webpack → vite}/settings.js +0 -0
  14. package/dist/wysiwyg.css +1 -0
  15. package/dist/wysiwyg.mjs +18305 -0
  16. package/dist/wysiwyg.mjs.map +1 -0
  17. package/example/ExampleApp.vue +21 -2
  18. package/example/example.js +0 -3
  19. package/example/{example.html → index.html} +1 -0
  20. package/example/pageBlocks.js +31 -0
  21. package/example/presets.js +2 -2
  22. package/jest.config.js +3 -1
  23. package/lib/Wysiwyg.vue +50 -25
  24. package/lib/__tests__/utils/NodeFactory.js +13 -0
  25. package/lib/__tests__/utils/withComponentContext.js +1 -1
  26. package/lib/assets/icons/alignment-center.svg +3 -0
  27. package/lib/assets/icons/alignment-justify.svg +3 -0
  28. package/lib/assets/icons/alignment-left.svg +3 -0
  29. package/lib/assets/icons/alignment-right.svg +3 -0
  30. package/lib/assets/icons/arrow.svg +3 -0
  31. package/lib/assets/icons/background-color.svg +3 -0
  32. package/lib/assets/icons/case-style.svg +3 -0
  33. package/lib/assets/icons/font-color.svg +5 -0
  34. package/lib/assets/icons/italic.svg +3 -0
  35. package/lib/assets/icons/line-height.svg +3 -0
  36. package/lib/assets/icons/link.svg +3 -0
  37. package/lib/assets/icons/list-circle.svg +3 -0
  38. package/lib/assets/icons/list-decimal.svg +3 -0
  39. package/lib/assets/icons/list-disc.svg +3 -0
  40. package/lib/assets/icons/list-latin.svg +3 -0
  41. package/lib/assets/icons/list-roman.svg +3 -0
  42. package/lib/assets/icons/list-square.svg +3 -0
  43. package/lib/assets/icons/remove-format.svg +3 -0
  44. package/lib/assets/icons/reset-styles.svg +3 -0
  45. package/lib/assets/icons/strike-through.svg +3 -0
  46. package/lib/assets/icons/superscript.svg +3 -0
  47. package/lib/assets/icons/underline.svg +3 -0
  48. package/lib/assets/icons/unlink.svg +3 -0
  49. package/lib/components/base/Button.vue +22 -2
  50. package/lib/components/base/Checkbox.vue +89 -0
  51. package/lib/components/base/FieldLabel.vue +2 -1
  52. package/lib/components/base/Icon.vue +19 -11
  53. package/lib/components/base/Modal.vue +1 -2
  54. package/lib/components/base/NumberField.vue +2 -2
  55. package/lib/components/base/Range.vue +1 -1
  56. package/lib/components/base/ScrollView.vue +1 -3
  57. package/lib/components/base/TextField.vue +106 -0
  58. package/lib/components/base/__tests__/Icon.test.js +6 -13
  59. package/lib/components/base/__tests__/Modal.test.js +7 -2
  60. package/lib/components/base/__tests__/TextField.test.js +57 -0
  61. package/lib/components/base/__tests__/__snapshots__/TextField.test.js.snap +9 -0
  62. package/lib/components/base/colorPicker/ColorPicker.vue +2 -2
  63. package/lib/components/base/colorPicker/composables/__tests__/usePickerApi.test.js +1 -1
  64. package/lib/components/base/colorPicker/composables/usePickerApi.js +1 -1
  65. package/lib/components/base/colorPicker/composables/usePickerHotkeys.js +3 -2
  66. package/lib/components/base/composables/__tests__/useActivatedListener.test.js +1 -1
  67. package/lib/components/base/composables/__tests__/useDeselectionLock.test.js +1 -1
  68. package/lib/components/base/composables/__tests__/useElementRef.test.js +1 -1
  69. package/lib/components/base/composables/__tests__/useModalToggler.test.js +1 -1
  70. package/lib/components/base/composables/__tests__/useNumberValue.test.js +1 -1
  71. package/lib/components/base/composables/__tests__/useScrollView.test.js +1 -1
  72. package/lib/components/base/composables/__tests__/useTempValue.test.js +1 -1
  73. package/lib/components/base/composables/__tests__/useValidator.test.js +44 -0
  74. package/lib/components/base/composables/index.js +1 -0
  75. package/lib/components/base/composables/useActivatedListener.js +1 -1
  76. package/lib/components/base/composables/useDeselectionLock.js +1 -1
  77. package/lib/components/base/composables/useElementRef.js +1 -1
  78. package/lib/components/base/composables/useModalToggler.js +1 -1
  79. package/lib/components/base/composables/useScrollView.js +1 -1
  80. package/lib/components/base/composables/useTempValue.js +1 -1
  81. package/lib/components/base/composables/useValidator.js +23 -0
  82. package/lib/components/base/dropdown/Dropdown.vue +16 -4
  83. package/lib/components/base/dropdown/DropdownActivator.vue +19 -3
  84. package/lib/components/base/dropdown/DropdownGroup.vue +1 -1
  85. package/lib/components/base/dropdown/DropdownMenu.vue +1 -1
  86. package/lib/components/base/dropdown/DropdownOption.vue +1 -1
  87. package/lib/components/base/dropdown/__tests__/DropdownActivator.test.js +1 -1
  88. package/lib/components/base/dropdown/__tests__/DropdownMenu.test.js +1 -1
  89. package/lib/components/base/dropdown/__tests__/DropdownOption.test.js +1 -1
  90. package/lib/components/base/dropdown/composables/__tests__/useActiveOptionManager.test.js +1 -1
  91. package/lib/components/base/dropdown/composables/__tests__/useDropdownEntityTitle.test.js +1 -1
  92. package/lib/components/base/dropdown/composables/useActiveOptionManager.js +1 -1
  93. package/lib/components/base/dropdown/composables/useDropdownEntityTitle.js +1 -1
  94. package/lib/components/base/index.js +3 -1
  95. package/lib/components/toolbar/Toolbar.vue +49 -9
  96. package/lib/components/toolbar/ToolbarDivider.vue +1 -1
  97. package/lib/components/toolbar/ToolbarFull.vue +10 -2
  98. package/lib/components/toolbar/__tests__/Toolbar.test.js +6 -0
  99. package/lib/components/toolbar/controls/AlignmentControl.vue +1 -1
  100. package/lib/components/toolbar/controls/AlignmentDeviceControl.vue +1 -1
  101. package/lib/components/toolbar/controls/BackgroundColorControl.vue +1 -1
  102. package/lib/components/toolbar/controls/CaseStyleControl.vue +1 -1
  103. package/lib/components/toolbar/controls/FontColorControl.vue +1 -1
  104. package/lib/components/toolbar/controls/FontFamilyControl.vue +1 -1
  105. package/lib/components/toolbar/controls/FontSizeControl.vue +8 -1
  106. package/lib/components/toolbar/controls/FontWeightControl.vue +1 -1
  107. package/lib/components/toolbar/controls/ItalicControl.vue +1 -1
  108. package/lib/components/toolbar/controls/LineHeightControl.vue +1 -1
  109. package/lib/components/toolbar/controls/ListControl.vue +2 -6
  110. package/lib/components/toolbar/controls/RemoveFormatControl.vue +1 -1
  111. package/lib/components/toolbar/controls/StrikeThroughControl.vue +1 -1
  112. package/lib/components/toolbar/controls/StylePresetControl.vue +15 -2
  113. package/lib/components/toolbar/controls/SuperscriptControl.vue +1 -1
  114. package/lib/components/toolbar/controls/UnderlineControl.vue +2 -2
  115. package/lib/components/toolbar/controls/__tests__/AlignmentControl.test.js +1 -1
  116. package/lib/components/toolbar/controls/__tests__/AlignmentDeviceControl.test.js +1 -1
  117. package/lib/components/toolbar/controls/__tests__/BackgroundColorControl.test.js +1 -1
  118. package/lib/components/toolbar/controls/__tests__/CaseStyleControl.test.js +1 -1
  119. package/lib/components/toolbar/controls/__tests__/FontColorControl.test.js +1 -1
  120. package/lib/components/toolbar/controls/__tests__/FontFamilyControl.test.js +1 -1
  121. package/lib/components/toolbar/controls/__tests__/FontSizeControl.test.js +1 -1
  122. package/lib/components/toolbar/controls/__tests__/FontWeightControl.test.js +1 -1
  123. package/lib/components/toolbar/controls/__tests__/ItalicControl.test.js +1 -1
  124. package/lib/components/toolbar/controls/__tests__/LineHeightControl.test.js +1 -1
  125. package/lib/components/toolbar/controls/__tests__/ListControl.test.js +1 -1
  126. package/lib/components/toolbar/controls/__tests__/StrikeThroughControl.test.js +1 -1
  127. package/lib/components/toolbar/controls/__tests__/StylePresetControl.test.js +17 -1
  128. package/lib/components/toolbar/controls/__tests__/UnderlineControl.test.js +5 -1
  129. package/lib/components/toolbar/controls/composables/useRecentFonts.js +1 -1
  130. package/lib/components/toolbar/controls/index.js +1 -0
  131. package/lib/components/toolbar/controls/link/LinkControl.vue +155 -0
  132. package/lib/components/toolbar/controls/link/LinkControlApply.vue +35 -0
  133. package/lib/components/toolbar/controls/link/LinkControlHeader.vue +67 -0
  134. package/lib/components/toolbar/controls/link/__tests__/LinkControl.test.js +79 -0
  135. package/lib/components/toolbar/controls/link/__tests__/LinkControlHeader.test.js +42 -0
  136. package/lib/components/toolbar/controls/link/composables/__tests__/__snapshots__/useLink.test.js.snap +8 -0
  137. package/lib/components/toolbar/controls/link/composables/__tests__/useLink.test.js +114 -0
  138. package/lib/components/toolbar/controls/link/composables/index.js +1 -0
  139. package/lib/components/toolbar/controls/link/composables/useLink.js +61 -0
  140. package/lib/components/toolbar/controls/link/destination/LinkControlDestination.vue +103 -0
  141. package/lib/components/toolbar/controls/link/destination/LinkControlPageBlock.vue +54 -0
  142. package/lib/components/toolbar/controls/link/destination/LinkControlUrl.vue +52 -0
  143. package/lib/components/toolbar/controls/link/destination/__tests__/LinkControlPageBlock.test.js +36 -0
  144. package/lib/components/toolbar/controls/link/destination/__tests__/LinkControlUrl.test.js +46 -0
  145. package/lib/components/toolbar/controls/link/destination/__tests__/__snapshots__/LinkControlPageBlock.test.js.snap +9 -0
  146. package/lib/components/toolbar/controls/link/destination/__tests__/__snapshots__/LinkControlUrl.test.js.snap +17 -0
  147. package/lib/components/toolbar/controls/link/destination/index.js +1 -0
  148. package/lib/components/toolbar/controls/link/index.js +1 -0
  149. package/lib/composables/__tests__/useEditor.test.js +3 -3
  150. package/lib/composables/useEditor.js +6 -8
  151. package/lib/composables/useToolbar.js +23 -28
  152. package/lib/directives/__tests__/outClick.test.js +6 -0
  153. package/lib/directives/outClick.js +19 -6
  154. package/lib/enums/Alignments.js +10 -1
  155. package/lib/enums/LinkDestinations.js +4 -0
  156. package/lib/enums/LinkTargets.js +4 -0
  157. package/lib/enums/TextSettings.js +3 -1
  158. package/lib/enums/index.js +2 -0
  159. package/lib/extensions/Alignment.js +22 -8
  160. package/lib/extensions/BackgroundColor.js +15 -7
  161. package/lib/extensions/DeviceManager.js +2 -5
  162. package/lib/extensions/FontColor.js +15 -7
  163. package/lib/extensions/FontFamily.js +26 -9
  164. package/lib/extensions/FontSize.js +32 -13
  165. package/lib/extensions/FontStyle.js +24 -14
  166. package/lib/extensions/FontWeight.js +25 -15
  167. package/lib/extensions/LineHeight.js +32 -29
  168. package/lib/extensions/Link.js +89 -0
  169. package/lib/extensions/StylePreset.js +20 -19
  170. package/lib/extensions/TextDecoration.js +46 -13
  171. package/lib/extensions/__tests__/Alignment.test.js +13 -7
  172. package/lib/extensions/__tests__/BackgroundColor.test.js +12 -6
  173. package/lib/extensions/__tests__/CaseStyle.test.js +3 -5
  174. package/lib/extensions/__tests__/FontColor.test.js +12 -6
  175. package/lib/extensions/__tests__/FontFamily.test.js +33 -8
  176. package/lib/extensions/__tests__/FontSize.test.js +15 -8
  177. package/lib/extensions/__tests__/FontStyle.test.js +12 -6
  178. package/lib/extensions/__tests__/FontWeight.test.js +20 -6
  179. package/lib/extensions/__tests__/LineHeight.test.js +24 -12
  180. package/lib/extensions/__tests__/Link.test.js +102 -0
  181. package/lib/extensions/__tests__/StylePreset.test.js +71 -8
  182. package/lib/extensions/__tests__/TextDecoration.test.js +52 -6
  183. package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +26 -2
  184. package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +30 -1
  185. package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +18 -1
  186. package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +88 -1
  187. package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +33 -2
  188. package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +25 -4
  189. package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +47 -1
  190. package/lib/extensions/__tests__/__snapshots__/LineHeight.test.js.snap +26 -2
  191. package/lib/extensions/__tests__/__snapshots__/Link.test.js.snap +225 -0
  192. package/lib/extensions/__tests__/__snapshots__/StylePreset.test.js.snap +6 -2
  193. package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +183 -3
  194. package/lib/extensions/core/CopyPasteProcessor.js +10 -0
  195. package/lib/extensions/core/NodeProcessor.js +1 -1
  196. package/lib/extensions/core/TextProcessor.js +10 -0
  197. package/lib/extensions/core/__tests__/NodeProcessor.test.js +3 -5
  198. package/lib/extensions/core/__tests__/SelectionProcessor.test.js +3 -5
  199. package/lib/extensions/core/__tests__/TextProcessor.test.js +138 -12
  200. package/lib/extensions/core/__tests__/__snapshots__/TextProcessor.test.js.snap +26 -0
  201. package/lib/extensions/core/index.js +11 -2
  202. package/lib/extensions/core/plugins/PastePlugin.js +57 -0
  203. package/lib/extensions/core/plugins/ProseMirrorPlugin.js +20 -0
  204. package/lib/extensions/core/plugins/index.js +1 -0
  205. package/lib/extensions/index.js +46 -34
  206. package/lib/extensions/list/List.js +1 -1
  207. package/lib/extensions/list/__tests__/List.test.js +5 -8
  208. package/lib/extensions/list/__tests__/__snapshots__/List.test.js.snap +45 -15
  209. package/lib/injectionTokens.js +2 -1
  210. package/lib/services/ContentNormalizer.js +113 -29
  211. package/lib/services/ContextWidnow.js +23 -0
  212. package/lib/services/__tests__/ContentNormalizer.test.js +75 -7
  213. package/lib/services/__tests__/FavoriteColors.test.js +1 -1
  214. package/lib/services/index.js +1 -0
  215. package/lib/styles/content.css +102 -13
  216. package/lib/styles/helpers/offsets.css +16 -0
  217. package/lib/styles/variables.css +6 -0
  218. package/lib/utils/__tests__/__snapshots__/renderInlineSetting.test.js.snap +4 -4
  219. package/lib/utils/__tests__/convertAlignment.test.js +16 -0
  220. package/lib/utils/__tests__/convertFontSize.test.js +21 -0
  221. package/lib/utils/__tests__/convertLineHeight.test.js +21 -0
  222. package/lib/utils/convertAlignment.js +12 -0
  223. package/lib/utils/convertColor.js +1 -1
  224. package/lib/utils/convertFontSize.js +8 -0
  225. package/lib/utils/convertLineHeight.js +17 -0
  226. package/lib/utils/importIcon.js +13 -0
  227. package/lib/utils/index.js +4 -0
  228. package/lib/utils/renderInlineSetting.js +1 -1
  229. package/package.json +23 -28
  230. package/config/webpack/example.config.js +0 -86
  231. package/config/webpack/loaders/index.js +0 -6
  232. package/config/webpack/loaders/js-loader.js +0 -5
  233. package/config/webpack/loaders/style-loader.js +0 -7
  234. package/config/webpack/loaders/svg-loader.js +0 -4
  235. package/config/webpack/loaders/vue-loader.js +0 -4
  236. package/lib/assets/icons.svg +0 -69
  237. package/lib/composables/__tests__/useToolbar.test.js +0 -56
@@ -0,0 +1,225 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`apply link should apply link 1`] = `
4
+ Object {
5
+ "content": Array [
6
+ Object {
7
+ "content": Array [
8
+ Object {
9
+ "marks": Array [
10
+ Object {
11
+ "attrs": Object {
12
+ "destination": "url",
13
+ "href": "/test",
14
+ "target": "_self",
15
+ },
16
+ "type": "link",
17
+ },
18
+ ],
19
+ "text": "Hello world link",
20
+ "type": "text",
21
+ },
22
+ ],
23
+ "type": "paragraph",
24
+ },
25
+ ],
26
+ "type": "doc",
27
+ }
28
+ `;
29
+
30
+ exports[`apply link should apply link when no selected text 1`] = `
31
+ Object {
32
+ "content": Array [
33
+ Object {
34
+ "content": Array [
35
+ Object {
36
+ "text": "Some ",
37
+ "type": "text",
38
+ },
39
+ Object {
40
+ "marks": Array [
41
+ Object {
42
+ "attrs": Object {
43
+ "destination": "url",
44
+ "href": "/test",
45
+ "target": "_self",
46
+ },
47
+ "type": "link",
48
+ },
49
+ ],
50
+ "text": "Hello world link",
51
+ "type": "text",
52
+ },
53
+ Object {
54
+ "text": " text",
55
+ "type": "text",
56
+ },
57
+ ],
58
+ "type": "paragraph",
59
+ },
60
+ ],
61
+ "type": "doc",
62
+ }
63
+ `;
64
+
65
+ exports[`parse html should add default self target for links from html without target 1`] = `
66
+ Object {
67
+ "content": Array [
68
+ Object {
69
+ "content": Array [
70
+ Object {
71
+ "marks": Array [
72
+ Object {
73
+ "attrs": Object {
74
+ "destination": "url",
75
+ "href": "https://hello.world",
76
+ "target": "_self",
77
+ },
78
+ "type": "link",
79
+ },
80
+ ],
81
+ "text": "Hello",
82
+ "type": "text",
83
+ },
84
+ ],
85
+ "type": "paragraph",
86
+ },
87
+ ],
88
+ "type": "doc",
89
+ }
90
+ `;
91
+
92
+ exports[`parse html should parse block links from html 1`] = `
93
+ Object {
94
+ "content": Array [
95
+ Object {
96
+ "content": Array [
97
+ Object {
98
+ "marks": Array [
99
+ Object {
100
+ "attrs": Object {
101
+ "destination": "block",
102
+ "href": 987654,
103
+ "target": "_blank",
104
+ },
105
+ "type": "link",
106
+ },
107
+ ],
108
+ "text": "Hello",
109
+ "type": "text",
110
+ },
111
+ ],
112
+ "type": "paragraph",
113
+ },
114
+ ],
115
+ "type": "doc",
116
+ }
117
+ `;
118
+
119
+ exports[`parse html should parse link target 1`] = `
120
+ Object {
121
+ "content": Array [
122
+ Object {
123
+ "content": Array [
124
+ Object {
125
+ "marks": Array [
126
+ Object {
127
+ "attrs": Object {
128
+ "destination": "url",
129
+ "href": "https://hello.world",
130
+ "target": "_blank",
131
+ },
132
+ "type": "link",
133
+ },
134
+ ],
135
+ "text": "Hello",
136
+ "type": "text",
137
+ },
138
+ ],
139
+ "type": "paragraph",
140
+ },
141
+ ],
142
+ "type": "doc",
143
+ }
144
+ `;
145
+
146
+ exports[`parse html should parse not valid value 1`] = `
147
+ Object {
148
+ "content": Array [
149
+ Object {
150
+ "content": Array [
151
+ Object {
152
+ "marks": Array [
153
+ Object {
154
+ "attrs": Object {
155
+ "destination": "url",
156
+ "href": "934238",
157
+ "target": "_self",
158
+ },
159
+ "type": "link",
160
+ },
161
+ ],
162
+ "text": "Hello",
163
+ "type": "text",
164
+ },
165
+ ],
166
+ "type": "paragraph",
167
+ },
168
+ ],
169
+ "type": "doc",
170
+ }
171
+ `;
172
+
173
+ exports[`parse html should parse url links from html 1`] = `
174
+ Object {
175
+ "content": Array [
176
+ Object {
177
+ "content": Array [
178
+ Object {
179
+ "marks": Array [
180
+ Object {
181
+ "attrs": Object {
182
+ "destination": "url",
183
+ "href": "https://hello.world",
184
+ "target": "_blank",
185
+ },
186
+ "type": "link",
187
+ },
188
+ ],
189
+ "text": "Hello",
190
+ "type": "text",
191
+ },
192
+ ],
193
+ "type": "paragraph",
194
+ },
195
+ ],
196
+ "type": "doc",
197
+ }
198
+ `;
199
+
200
+ exports[`parse html should parse value for relative url 1`] = `
201
+ Object {
202
+ "content": Array [
203
+ Object {
204
+ "content": Array [
205
+ Object {
206
+ "marks": Array [
207
+ Object {
208
+ "attrs": Object {
209
+ "destination": "url",
210
+ "href": "/hello-world",
211
+ "target": "_self",
212
+ },
213
+ "type": "link",
214
+ },
215
+ ],
216
+ "text": "Hello",
217
+ "type": "text",
218
+ },
219
+ ],
220
+ "type": "paragraph",
221
+ },
222
+ ],
223
+ "type": "doc",
224
+ }
225
+ `;
@@ -349,7 +349,9 @@ Object {
349
349
  Object {
350
350
  "attrs": Object {
351
351
  "alignment": null,
352
- "preset": null,
352
+ "preset": Object {
353
+ "id": "regular-1",
354
+ },
353
355
  },
354
356
  "content": Array [
355
357
  Object {
@@ -385,7 +387,9 @@ Object {
385
387
  Object {
386
388
  "attrs": Object {
387
389
  "alignment": null,
388
- "preset": null,
390
+ "preset": Object {
391
+ "id": "regular-1",
392
+ },
389
393
  },
390
394
  "content": Array [
391
395
  Object {
@@ -225,6 +225,36 @@ Object {
225
225
  }
226
226
  `;
227
227
 
228
+ exports[`parsing html should get both from rendered view 1`] = `
229
+ Object {
230
+ "content": Array [
231
+ Object {
232
+ "content": Array [
233
+ Object {
234
+ "marks": Array [
235
+ Object {
236
+ "attrs": Object {
237
+ "strike_through": true,
238
+ "underline": true,
239
+ },
240
+ "type": "text_decoration",
241
+ },
242
+ ],
243
+ "text": "lorem",
244
+ "type": "text",
245
+ },
246
+ Object {
247
+ "text": " ipsum",
248
+ "type": "text",
249
+ },
250
+ ],
251
+ "type": "paragraph",
252
+ },
253
+ ],
254
+ "type": "doc",
255
+ }
256
+ `;
257
+
228
258
  exports[`parsing html should get both from text 1`] = `
229
259
  Object {
230
260
  "content": Array [
@@ -255,6 +285,36 @@ Object {
255
285
  }
256
286
  `;
257
287
 
288
+ exports[`parsing html should get both from text with property shorthand 1`] = `
289
+ Object {
290
+ "content": Array [
291
+ Object {
292
+ "content": Array [
293
+ Object {
294
+ "marks": Array [
295
+ Object {
296
+ "attrs": Object {
297
+ "strike_through": true,
298
+ "underline": true,
299
+ },
300
+ "type": "text_decoration",
301
+ },
302
+ ],
303
+ "text": "lorem",
304
+ "type": "text",
305
+ },
306
+ Object {
307
+ "text": " ipsum",
308
+ "type": "text",
309
+ },
310
+ ],
311
+ "type": "paragraph",
312
+ },
313
+ ],
314
+ "type": "doc",
315
+ }
316
+ `;
317
+
258
318
  exports[`parsing html should get strike through from paragraph 1`] = `
259
319
  Object {
260
320
  "content": Array [
@@ -281,6 +341,36 @@ Object {
281
341
  }
282
342
  `;
283
343
 
344
+ exports[`parsing html should get strike through from rendered view 1`] = `
345
+ Object {
346
+ "content": Array [
347
+ Object {
348
+ "content": Array [
349
+ Object {
350
+ "marks": Array [
351
+ Object {
352
+ "attrs": Object {
353
+ "strike_through": true,
354
+ "underline": false,
355
+ },
356
+ "type": "text_decoration",
357
+ },
358
+ ],
359
+ "text": "lorem",
360
+ "type": "text",
361
+ },
362
+ Object {
363
+ "text": " ipsum",
364
+ "type": "text",
365
+ },
366
+ ],
367
+ "type": "paragraph",
368
+ },
369
+ ],
370
+ "type": "doc",
371
+ }
372
+ `;
373
+
284
374
  exports[`parsing html should get strike through from text 1`] = `
285
375
  Object {
286
376
  "content": Array [
@@ -337,6 +427,36 @@ Object {
337
427
  }
338
428
  `;
339
429
 
430
+ exports[`parsing html should get underline from rendered view 1`] = `
431
+ Object {
432
+ "content": Array [
433
+ Object {
434
+ "content": Array [
435
+ Object {
436
+ "marks": Array [
437
+ Object {
438
+ "attrs": Object {
439
+ "strike_through": false,
440
+ "underline": true,
441
+ },
442
+ "type": "text_decoration",
443
+ },
444
+ ],
445
+ "text": "lorem",
446
+ "type": "text",
447
+ },
448
+ Object {
449
+ "text": " ipsum",
450
+ "type": "text",
451
+ },
452
+ ],
453
+ "type": "paragraph",
454
+ },
455
+ ],
456
+ "type": "doc",
457
+ }
458
+ `;
459
+
340
460
  exports[`parsing html should get underline from text 1`] = `
341
461
  Object {
342
462
  "content": Array [
@@ -406,8 +526,68 @@ Object {
406
526
  }
407
527
  `;
408
528
 
409
- exports[`rendering should render both 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-text-decoration: underline line-through;\\" class=\\"zw-style\\">hello world</span></p>"`;
529
+ exports[`parsing html should parse strike through from tag 1`] = `
530
+ Object {
531
+ "content": Array [
532
+ Object {
533
+ "content": Array [
534
+ Object {
535
+ "marks": Array [
536
+ Object {
537
+ "attrs": Object {
538
+ "strike_through": true,
539
+ "underline": false,
540
+ },
541
+ "type": "text_decoration",
542
+ },
543
+ ],
544
+ "text": "lorem",
545
+ "type": "text",
546
+ },
547
+ Object {
548
+ "text": " ipsum",
549
+ "type": "text",
550
+ },
551
+ ],
552
+ "type": "paragraph",
553
+ },
554
+ ],
555
+ "type": "doc",
556
+ }
557
+ `;
558
+
559
+ exports[`parsing html should parse underline from tag 1`] = `
560
+ Object {
561
+ "content": Array [
562
+ Object {
563
+ "content": Array [
564
+ Object {
565
+ "marks": Array [
566
+ Object {
567
+ "attrs": Object {
568
+ "strike_through": false,
569
+ "underline": true,
570
+ },
571
+ "type": "text_decoration",
572
+ },
573
+ ],
574
+ "text": "lorem",
575
+ "type": "text",
576
+ },
577
+ Object {
578
+ "text": " ipsum",
579
+ "type": "text",
580
+ },
581
+ ],
582
+ "type": "paragraph",
583
+ },
584
+ ],
585
+ "type": "doc",
586
+ }
587
+ `;
588
+
589
+ exports[`rendering should render both 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-text-decoration:underline line-through;\\" class=\\"zw-style\\">hello world</span></p>"`;
410
590
 
411
- exports[`rendering should render strike through only 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-text-decoration: line-through;\\" class=\\"zw-style\\">hello world</span></p>"`;
591
+ exports[`rendering should render strike through only 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-text-decoration:line-through;\\" class=\\"zw-style\\">hello world</span></p>"`;
412
592
 
413
- exports[`rendering should render underline only 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-text-decoration: underline;\\" class=\\"zw-style\\">hello world</span></p>"`;
593
+ exports[`rendering should render underline only 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-text-decoration:underline;\\" class=\\"zw-style\\">hello world</span></p>"`;
@@ -0,0 +1,10 @@
1
+ import { Extension } from '@tiptap/vue-2';
2
+ import { PastePlugin } from './plugins';
3
+
4
+ export const CopyPasteProcessor = Extension.create({
5
+ name: 'copy_paste_processor',
6
+
7
+ addProseMirrorPlugins() {
8
+ return [PastePlugin.create()];
9
+ }
10
+ });
@@ -1,5 +1,5 @@
1
1
  import { Extension } from '@tiptap/vue-2';
2
- import { computed } from '@vue/composition-api';
2
+ import { computed } from 'vue';
3
3
  import { createCommand } from '../../utils';
4
4
  import { NodeTypes } from '../../enums';
5
5
 
@@ -17,6 +17,16 @@ export const TextProcessor = Extension.create({
17
17
 
18
18
  addCommands() {
19
19
  return {
20
+ getSelectedText: createCommand(({ state }) => {
21
+ const { from, to } = state.selection;
22
+
23
+ return state.doc.textBetween(from, to, ' ');
24
+ }),
25
+
26
+ unsetMarks: createCommand(({ commands }, marks) => {
27
+ marks.forEach((mark) => commands.unsetMark(mark));
28
+ }),
29
+
20
30
  transformText: createCommand(({ state }, transform) => {
21
31
  const { selection } = state.tr;
22
32
 
@@ -1,8 +1,8 @@
1
1
  import { Editor, Extension } from '@tiptap/vue-2';
2
2
  import { NodeFactory } from '../../../__tests__/utils';
3
- import { CORE_EXTENSIONS } from '../index';
4
3
  import { NodeTypes } from '../../../enums';
5
4
  import { ContentNormalizer } from '../../../services';
5
+ import { buildCoreExtensions } from '../index';
6
6
 
7
7
  const LineHeight = Extension.create({
8
8
  name: 'line_height',
@@ -21,11 +21,9 @@ const LineHeight = Extension.create({
21
21
  });
22
22
 
23
23
  function createEditor({ content }) {
24
- const normalizer = new ContentNormalizer();
25
-
26
24
  return new Editor({
27
- content: normalizer.normalize(content),
28
- extensions: CORE_EXTENSIONS.concat(LineHeight) // Included to core extensions
25
+ content: ContentNormalizer.normalize(content),
26
+ extensions: buildCoreExtensions().concat(LineHeight) // Included to core extensions
29
27
  });
30
28
  }
31
29
 
@@ -1,19 +1,17 @@
1
1
  import { Editor } from '@tiptap/vue-2';
2
- import { CORE_EXTENSIONS } from '../index';
3
2
  import { NodeFactory } from '../../../__tests__/utils';
4
3
  import { ContentNormalizer } from '../../../services';
4
+ import { buildCoreExtensions } from '../index';
5
5
 
6
6
  function createEditor() {
7
- const normalizer = new ContentNormalizer();
8
-
9
7
  const content = NodeFactory.doc([
10
8
  NodeFactory.paragraph('Lorem ipsum dolor sit amet'),
11
9
  NodeFactory.paragraph('consectetur adipisicing elit')
12
10
  ]);
13
11
 
14
12
  return new Editor({
15
- content: normalizer.normalize(content),
16
- extensions: CORE_EXTENSIONS // included to core
13
+ content: ContentNormalizer.normalize(content),
14
+ extensions: buildCoreExtensions() // included to core
17
15
  });
18
16
  }
19
17