@zipify/wysiwyg 1.1.1 → 1.2.1-1

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 (176) hide show
  1. package/.github/actions/lint-css/action.yaml +1 -3
  2. package/.release-it.json +2 -1
  3. package/dist/cli.js +3 -3
  4. package/dist/wysiwyg.css +24 -25
  5. package/dist/wysiwyg.mjs +641 -618
  6. package/jest.config.js +3 -0
  7. package/lib/components/base/Modal.vue +21 -2
  8. package/lib/components/base/__tests__/Modal.test.js +1 -0
  9. package/lib/components/toolbar/controls/link/LinkControl.vue +22 -10
  10. package/lib/components/toolbar/controls/link/LinkControlHeader.vue +3 -3
  11. package/lib/components/toolbar/controls/link/__tests__/LinkControl.test.js +8 -8
  12. package/lib/components/toolbar/controls/link/__tests__/LinkControlHeader.test.js +1 -1
  13. package/lib/components/toolbar/controls/link/composables/useLink.js +10 -6
  14. package/lib/composables/__tests__/__snapshots__/useEditor.test.js.snap +1 -1
  15. package/lib/composables/useEditor.js +4 -3
  16. package/lib/enums/TextSettings.js +2 -0
  17. package/lib/extensions/FontStyle.js +2 -2
  18. package/lib/extensions/FontWeight.js +2 -0
  19. package/lib/extensions/Link.js +13 -15
  20. package/lib/extensions/StylePreset.js +33 -3
  21. package/lib/extensions/TextDecoration.js +6 -12
  22. package/lib/extensions/__tests__/FontFamily.test.js +7 -6
  23. package/lib/extensions/__tests__/FontWeight.test.js +19 -10
  24. package/lib/extensions/__tests__/StylePreset.test.js +52 -2
  25. package/lib/extensions/__tests__/TextDecoration.test.js +11 -40
  26. package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +2 -2
  27. package/lib/extensions/__tests__/__snapshots__/BackgroundColor.test.js.snap +1 -1
  28. package/lib/extensions/__tests__/__snapshots__/FontColor.test.js.snap +1 -1
  29. package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +19 -1
  30. package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +2 -2
  31. package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +17 -1
  32. package/lib/extensions/__tests__/__snapshots__/FontWeight.test.js.snap +26 -1
  33. package/lib/extensions/__tests__/__snapshots__/LineHeight.test.js.snap +2 -2
  34. package/lib/extensions/__tests__/__snapshots__/Margin.test.js.snap +2 -2
  35. package/lib/extensions/__tests__/__snapshots__/StylePreset.test.js.snap +22 -2
  36. package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +3 -46
  37. package/package.json +22 -22
  38. package/lib/components/toolbar/controls/link/LinkControlApply.vue +0 -35
  39. package/node_modules_lambda/acorn-globals/node_modules/.bin/acorn +0 -4
  40. package/node_modules_lambda/acorn-globals/node_modules/acorn/CHANGELOG.md +0 -620
  41. package/node_modules_lambda/acorn-globals/node_modules/acorn/LICENSE +0 -21
  42. package/node_modules_lambda/acorn-globals/node_modules/acorn/README.md +0 -269
  43. package/node_modules_lambda/acorn-globals/node_modules/acorn/bin/acorn +0 -4
  44. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.d.ts +0 -209
  45. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.js +0 -5186
  46. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.js.map +0 -1
  47. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.mjs +0 -5155
  48. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.mjs.d.ts +0 -2
  49. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.mjs.map +0 -1
  50. package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/bin.js +0 -64
  51. package/node_modules_lambda/acorn-globals/node_modules/acorn/package.json +0 -35
  52. package/node_modules_lambda/cssstyle/node_modules/cssom/LICENSE.txt +0 -20
  53. package/node_modules_lambda/cssstyle/node_modules/cssom/README.mdown +0 -67
  54. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSDocumentRule.js +0 -39
  55. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSFontFaceRule.js +0 -36
  56. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSHostRule.js +0 -37
  57. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSImportRule.js +0 -132
  58. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSKeyframeRule.js +0 -37
  59. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSKeyframesRule.js +0 -39
  60. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSMediaRule.js +0 -41
  61. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSOM.js +0 -3
  62. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSRule.js +0 -43
  63. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSStyleDeclaration.js +0 -148
  64. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSStyleRule.js +0 -190
  65. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSStyleSheet.js +0 -88
  66. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSSupportsRule.js +0 -36
  67. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSValue.js +0 -43
  68. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSValueExpression.js +0 -344
  69. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/MatcherList.js +0 -62
  70. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/MediaList.js +0 -61
  71. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/StyleSheet.js +0 -17
  72. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/clone.js +0 -82
  73. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/index.js +0 -21
  74. package/node_modules_lambda/cssstyle/node_modules/cssom/lib/parse.js +0 -464
  75. package/node_modules_lambda/cssstyle/node_modules/cssom/package.json +0 -18
  76. package/node_modules_lambda/data-urls/node_modules/whatwg-url/LICENSE.txt +0 -21
  77. package/node_modules_lambda/data-urls/node_modules/whatwg-url/README.md +0 -106
  78. package/node_modules_lambda/data-urls/node_modules/whatwg-url/index.js +0 -27
  79. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/Function.js +0 -42
  80. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URL-impl.js +0 -209
  81. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URL.js +0 -442
  82. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URLSearchParams-impl.js +0 -130
  83. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URLSearchParams.js +0 -472
  84. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/VoidFunction.js +0 -26
  85. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/encoding.js +0 -16
  86. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/infra.js +0 -26
  87. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/percent-encoding.js +0 -142
  88. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/url-state-machine.js +0 -1244
  89. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/urlencoded.js +0 -106
  90. package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/utils.js +0 -190
  91. package/node_modules_lambda/data-urls/node_modules/whatwg-url/package.json +0 -58
  92. package/node_modules_lambda/data-urls/node_modules/whatwg-url/webidl2js-wrapper.js +0 -7
  93. package/node_modules_lambda/escodegen/node_modules/estraverse/.jshintrc +0 -16
  94. package/node_modules_lambda/escodegen/node_modules/estraverse/LICENSE.BSD +0 -19
  95. package/node_modules_lambda/escodegen/node_modules/estraverse/README.md +0 -153
  96. package/node_modules_lambda/escodegen/node_modules/estraverse/estraverse.js +0 -805
  97. package/node_modules_lambda/escodegen/node_modules/estraverse/gulpfile.js +0 -70
  98. package/node_modules_lambda/escodegen/node_modules/estraverse/package.json +0 -40
  99. package/node_modules_lambda/escodegen/node_modules/levn/LICENSE +0 -22
  100. package/node_modules_lambda/escodegen/node_modules/levn/README.md +0 -196
  101. package/node_modules_lambda/escodegen/node_modules/levn/lib/cast.js +0 -298
  102. package/node_modules_lambda/escodegen/node_modules/levn/lib/coerce.js +0 -285
  103. package/node_modules_lambda/escodegen/node_modules/levn/lib/index.js +0 -22
  104. package/node_modules_lambda/escodegen/node_modules/levn/lib/parse-string.js +0 -113
  105. package/node_modules_lambda/escodegen/node_modules/levn/lib/parse.js +0 -102
  106. package/node_modules_lambda/escodegen/node_modules/levn/package.json +0 -47
  107. package/node_modules_lambda/escodegen/node_modules/optionator/CHANGELOG.md +0 -56
  108. package/node_modules_lambda/escodegen/node_modules/optionator/LICENSE +0 -22
  109. package/node_modules_lambda/escodegen/node_modules/optionator/README.md +0 -238
  110. package/node_modules_lambda/escodegen/node_modules/optionator/lib/help.js +0 -260
  111. package/node_modules_lambda/escodegen/node_modules/optionator/lib/index.js +0 -465
  112. package/node_modules_lambda/escodegen/node_modules/optionator/lib/util.js +0 -54
  113. package/node_modules_lambda/escodegen/node_modules/optionator/package.json +0 -44
  114. package/node_modules_lambda/escodegen/node_modules/prelude-ls/CHANGELOG.md +0 -99
  115. package/node_modules_lambda/escodegen/node_modules/prelude-ls/LICENSE +0 -22
  116. package/node_modules_lambda/escodegen/node_modules/prelude-ls/README.md +0 -15
  117. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Func.js +0 -65
  118. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/List.js +0 -686
  119. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Num.js +0 -130
  120. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Obj.js +0 -154
  121. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Str.js +0 -92
  122. package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/index.js +0 -178
  123. package/node_modules_lambda/escodegen/node_modules/prelude-ls/package.json +0 -52
  124. package/node_modules_lambda/escodegen/node_modules/source-map/CHANGELOG.md +0 -301
  125. package/node_modules_lambda/escodegen/node_modules/source-map/LICENSE +0 -28
  126. package/node_modules_lambda/escodegen/node_modules/source-map/README.md +0 -742
  127. package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.debug.js +0 -3234
  128. package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.js +0 -3233
  129. package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.min.js +0 -2
  130. package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.min.js.map +0 -1
  131. package/node_modules_lambda/escodegen/node_modules/source-map/lib/array-set.js +0 -121
  132. package/node_modules_lambda/escodegen/node_modules/source-map/lib/base64-vlq.js +0 -140
  133. package/node_modules_lambda/escodegen/node_modules/source-map/lib/base64.js +0 -67
  134. package/node_modules_lambda/escodegen/node_modules/source-map/lib/binary-search.js +0 -111
  135. package/node_modules_lambda/escodegen/node_modules/source-map/lib/mapping-list.js +0 -79
  136. package/node_modules_lambda/escodegen/node_modules/source-map/lib/quick-sort.js +0 -114
  137. package/node_modules_lambda/escodegen/node_modules/source-map/lib/source-map-consumer.js +0 -1145
  138. package/node_modules_lambda/escodegen/node_modules/source-map/lib/source-map-generator.js +0 -425
  139. package/node_modules_lambda/escodegen/node_modules/source-map/lib/source-node.js +0 -413
  140. package/node_modules_lambda/escodegen/node_modules/source-map/lib/util.js +0 -488
  141. package/node_modules_lambda/escodegen/node_modules/source-map/package.json +0 -73
  142. package/node_modules_lambda/escodegen/node_modules/source-map/source-map.d.ts +0 -98
  143. package/node_modules_lambda/escodegen/node_modules/source-map/source-map.js +0 -8
  144. package/node_modules_lambda/escodegen/node_modules/type-check/LICENSE +0 -22
  145. package/node_modules_lambda/escodegen/node_modules/type-check/README.md +0 -210
  146. package/node_modules_lambda/escodegen/node_modules/type-check/lib/check.js +0 -126
  147. package/node_modules_lambda/escodegen/node_modules/type-check/lib/index.js +0 -16
  148. package/node_modules_lambda/escodegen/node_modules/type-check/lib/parse-type.js +0 -196
  149. package/node_modules_lambda/escodegen/node_modules/type-check/package.json +0 -40
  150. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/.github/dependabot.yml +0 -11
  151. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/Changelog.md +0 -212
  152. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/LICENSE +0 -21
  153. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/README.md +0 -130
  154. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/dbcs-codec.js +0 -597
  155. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/dbcs-data.js +0 -188
  156. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/index.js +0 -23
  157. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/internal.js +0 -198
  158. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/sbcs-codec.js +0 -72
  159. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/sbcs-data-generated.js +0 -451
  160. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/sbcs-data.js +0 -179
  161. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/big5-added.json +0 -122
  162. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/cp936.json +0 -264
  163. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/cp949.json +0 -273
  164. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/cp950.json +0 -177
  165. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/eucjp.json +0 -182
  166. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +0 -1
  167. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/gbk-added.json +0 -56
  168. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/shiftjis.json +0 -125
  169. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/utf16.js +0 -197
  170. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/utf32.js +0 -319
  171. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/utf7.js +0 -290
  172. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/bom-handling.js +0 -52
  173. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/index.d.ts +0 -41
  174. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/index.js +0 -180
  175. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/streams.js +0 -109
  176. package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/package.json +0 -44
@@ -6,10 +6,11 @@ import { FontWeight } from '../FontWeight';
6
6
  import { FontFamily } from '../FontFamily';
7
7
  import { FontStyle } from '../FontStyle';
8
8
  import { ContentNormalizer, NodeFactory } from '../../services';
9
+ import { TextSettings } from '../../enums';
9
10
  import { buildCoreExtensions } from '../core';
10
11
 
11
12
  const MockStylePreset = Extension.create({
12
- name: 'style_preset',
13
+ name: TextSettings.STYLE_PRESET,
13
14
 
14
15
  addCommands() {
15
16
  return {
@@ -30,8 +31,8 @@ function createEditor({ content }) {
30
31
  MockStylePreset,
31
32
  FontFamily.configure({
32
33
  fonts: [
33
- new Font({ name: 'Lato', styles: ['400', '700'] }),
34
- new Font({ name: 'Bungee', styles: ['300', '800'] })
34
+ new Font({ name: 'Lato', styles: ['400', '400i', '700', '700i'] }),
35
+ new Font({ name: 'Bungee', styles: ['300', '300i', '800', '800i'] })
35
36
  ]
36
37
  }),
37
38
  FontWeight,
@@ -48,7 +49,7 @@ describe('get font weight', () => {
48
49
  test('should get from selection', () => {
49
50
  const editor = createEditor({
50
51
  content: createContent(NodeFactory.text('hello world', [
51
- NodeFactory.mark('font_weight', { value: '700' })
52
+ NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '700' })
52
53
  ]))
53
54
  });
54
55
 
@@ -78,7 +79,7 @@ describe('get font weight', () => {
78
79
  test('should get closest available font weight', () => {
79
80
  const editor = createEditor({
80
81
  content: createContent(NodeFactory.text('hello world', [
81
- NodeFactory.mark('font_weight', { value: '800' })
82
+ NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '800' })
82
83
  ]))
83
84
  });
84
85
 
@@ -102,7 +103,7 @@ describe('apply font weight', () => {
102
103
  test('should toggle weight to bold', () => {
103
104
  const editor = createEditor({
104
105
  content: createContent(NodeFactory.text('hello world', [
105
- NodeFactory.mark('font_weight', { value: '400' })
106
+ NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '400' })
106
107
  ]))
107
108
  });
108
109
 
@@ -115,7 +116,7 @@ describe('apply font weight', () => {
115
116
  const editor = createEditor({
116
117
  content: createContent(NodeFactory.text('hello world', [
117
118
  NodeFactory.mark('font_family', { value: 'Bungee' }),
118
- NodeFactory.mark('font_weight', { value: '400' })
119
+ NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '400' })
119
120
  ]))
120
121
  });
121
122
 
@@ -127,7 +128,7 @@ describe('apply font weight', () => {
127
128
  test('should toggle weight to medium', () => {
128
129
  const editor = createEditor({
129
130
  content: createContent(NodeFactory.text('hello world', [
130
- NodeFactory.mark('font_weight', { value: '700' })
131
+ NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '700' })
131
132
  ]))
132
133
  });
133
134
 
@@ -140,7 +141,7 @@ describe('apply font weight', () => {
140
141
  const editor = createEditor({
141
142
  content: createContent(NodeFactory.text('hello world', [
142
143
  NodeFactory.mark('font_family', { value: 'Bungee' }),
143
- NodeFactory.mark('font_weight', { value: '800' })
144
+ NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '800' })
144
145
  ]))
145
146
  });
146
147
 
@@ -154,7 +155,7 @@ describe('rendering', () => {
154
155
  test('should render html', () => {
155
156
  const editor = createEditor({
156
157
  content: createContent(NodeFactory.text('hello world', [
157
- NodeFactory.mark('font_weight', { value: '700' })
158
+ NodeFactory.mark(TextSettings.FONT_WEIGHT, { value: '700' })
158
159
  ]))
159
160
  });
160
161
 
@@ -218,4 +219,12 @@ describe('parsing html', () => {
218
219
 
219
220
  expect(editor.getJSON()).toMatchSnapshot();
220
221
  });
222
+
223
+ test('should parse style shorthand', () => {
224
+ const editor = createEditor({
225
+ content: '<p style="font-weight: bold">test</p>'
226
+ });
227
+
228
+ expect(editor.getJSON()).toMatchSnapshot();
229
+ });
221
230
  });
@@ -4,6 +4,7 @@ import { List } from '../list';
4
4
  import { ListTypes, NodeTypes, TextSettings } from '../../enums';
5
5
  import { ContentNormalizer, NodeFactory } from '../../services';
6
6
  import { buildCoreExtensions } from '../core';
7
+ import { createCommand } from '../../utils';
7
8
 
8
9
  const MockFontSize = Mark.create({
9
10
  name: TextSettings.FONT_SIZE,
@@ -101,7 +102,23 @@ const MockSuperscript = Mark.create({
101
102
  renderHTML: () => ['span', {}, 0]
102
103
  });
103
104
 
104
- function createEditor({ content, presets, defaultId }) {
105
+ const MockLink = Extension.create({
106
+ name: TextSettings.LINK,
107
+
108
+ addOptions: () => ({
109
+ isActive: false,
110
+ preset: {}
111
+ }),
112
+
113
+ addCommands() {
114
+ return {
115
+ isLink: createCommand(() => this.options.isActive),
116
+ getLinkPreset: createCommand(() => this.options.preset)
117
+ };
118
+ }
119
+ });
120
+
121
+ function createEditor({ content, presets, defaultId, link }) {
105
122
  return new Promise((resolve) => {
106
123
  const editor = new Editor({
107
124
  content: ContentNormalizer.normalize(content),
@@ -130,7 +147,8 @@ function createEditor({ content, presets, defaultId }) {
130
147
  MockFontFamily,
131
148
  MockFontStyle,
132
149
  MockTextDecoration,
133
- MockSuperscript
150
+ MockSuperscript,
151
+ MockLink.configure(link)
134
152
  )
135
153
  });
136
154
  });
@@ -218,6 +236,38 @@ describe('get preset', () => {
218
236
 
219
237
  expect(preset.value).toBeFalsy();
220
238
  });
239
+
240
+ test('should get setting from link if selected', async () => {
241
+ const editor = await createEditor({
242
+ content: NodeFactory.doc([
243
+ NodeFactory.paragraph({ preset: { id: 'regular-1' } }, 'test')
244
+ ]),
245
+ presets: [
246
+ createPreset({
247
+ id: 'regular-1',
248
+ common: {
249
+ text_decoration: 'none',
250
+ font_style: 'normal',
251
+ font_size: '20'
252
+ }
253
+ })
254
+ ],
255
+ link: {
256
+ preset: createPreset({
257
+ id: 'link',
258
+ common: {
259
+ text_decoration: 'underline',
260
+ font_style: 'italic',
261
+ font_size: 'inherit'
262
+ }
263
+ }),
264
+ isActive: true
265
+ }
266
+ });
267
+ const preset = editor.commands.getPreset();
268
+
269
+ expect(preset.value).toMatchSnapshot();
270
+ });
221
271
  });
222
272
 
223
273
  describe('apply preset', () => {
@@ -4,9 +4,10 @@ import { createCommand } from '../../utils';
4
4
  import { TextDecoration } from '../TextDecoration';
5
5
  import { ContentNormalizer, NodeFactory } from '../../services';
6
6
  import { buildCoreExtensions } from '../core';
7
+ import { TextSettings } from '../../enums';
7
8
 
8
9
  const MockStylePreset = Extension.create({
9
- name: 'style_preset',
10
+ name: TextSettings.TEXT_DECORATION,
10
11
 
11
12
  addCommands() {
12
13
  return {
@@ -32,7 +33,7 @@ describe('get decoration', () => {
32
33
  test('should get from selection', () => {
33
34
  const editor = createEditor({
34
35
  content: createContent(NodeFactory.text('hello world', [
35
- NodeFactory.mark('text_decoration', {
36
+ NodeFactory.mark(TextSettings.TEXT_DECORATION, {
36
37
  underline: true,
37
38
  strike_through: true
38
39
  })
@@ -60,7 +61,7 @@ describe('get decoration', () => {
60
61
  test('should get from selection', () => {
61
62
  const editor = createEditor({
62
63
  content: createContent(NodeFactory.text('hello world', [
63
- NodeFactory.mark('text_decoration', { underline: true })
64
+ NodeFactory.mark(TextSettings.TEXT_DECORATION, { underline: true })
64
65
  ]))
65
66
  });
66
67
 
@@ -84,7 +85,7 @@ describe('get decoration', () => {
84
85
  test('should get from selection', () => {
85
86
  const editor = createEditor({
86
87
  content: createContent(NodeFactory.text('hello world', [
87
- NodeFactory.mark('text_decoration', { strike_through: true })
88
+ NodeFactory.mark(TextSettings.TEXT_DECORATION, { strike_through: true })
88
89
  ]))
89
90
  });
90
91
 
@@ -119,7 +120,7 @@ describe('apply decoration', () => {
119
120
  test('should second decoration', () => {
120
121
  const editor = createEditor({
121
122
  content: createContent(NodeFactory.text('hello world', [
122
- NodeFactory.mark('text_decoration', {
123
+ NodeFactory.mark(TextSettings.TEXT_DECORATION, {
123
124
  strike_through: false,
124
125
  underline: true
125
126
  })
@@ -131,41 +132,11 @@ describe('apply decoration', () => {
131
132
  expect(editor.getJSON()).toMatchSnapshot();
132
133
  });
133
134
 
134
- test('should remove decoration', () => {
135
- const editor = createEditor({
136
- content: createContent(NodeFactory.text('hello world', [
137
- NodeFactory.mark('text_decoration', {
138
- strike_through: true,
139
- underline: true
140
- })
141
- ]))
142
- });
143
-
144
- editor.chain().selectAll().removeTextDecoration('strike_through').run();
145
-
146
- expect(editor.getJSON()).toMatchSnapshot();
147
- });
148
-
149
- test('should remove mark if no decoration', () => {
150
- const editor = createEditor({
151
- content: createContent(NodeFactory.text('hello world', [
152
- NodeFactory.mark('text_decoration', {
153
- strike_through: false,
154
- underline: true
155
- })
156
- ]))
157
- });
158
-
159
- editor.chain().selectAll().removeTextDecoration('underline').run();
160
-
161
- expect(editor.getJSON()).toMatchSnapshot();
162
- });
163
-
164
135
  describe('underline', () => {
165
136
  test('should toggle to removed', () => {
166
137
  const editor = createEditor({
167
138
  content: createContent(NodeFactory.text('hello world', [
168
- NodeFactory.mark('text_decoration', {
139
+ NodeFactory.mark(TextSettings.TEXT_DECORATION, {
169
140
  strike_through: true,
170
141
  underline: true
171
142
  })
@@ -192,7 +163,7 @@ describe('apply decoration', () => {
192
163
  test('should toggle to removed', () => {
193
164
  const editor = createEditor({
194
165
  content: createContent(NodeFactory.text('hello world', [
195
- NodeFactory.mark('text_decoration', {
166
+ NodeFactory.mark(TextSettings.TEXT_DECORATION, {
196
167
  strike_through: true,
197
168
  underline: true
198
169
  })
@@ -220,7 +191,7 @@ describe('rendering', () => {
220
191
  test('should render underline only', () => {
221
192
  const editor = createEditor({
222
193
  content: createContent(NodeFactory.text('hello world', [
223
- NodeFactory.mark('text_decoration', {
194
+ NodeFactory.mark(TextSettings.TEXT_DECORATION, {
224
195
  strike_through: false,
225
196
  underline: true
226
197
  })
@@ -233,7 +204,7 @@ describe('rendering', () => {
233
204
  test('should render strike through only', () => {
234
205
  const editor = createEditor({
235
206
  content: createContent(NodeFactory.text('hello world', [
236
- NodeFactory.mark('text_decoration', {
207
+ NodeFactory.mark(TextSettings.TEXT_DECORATION, {
237
208
  strike_through: true,
238
209
  underline: false
239
210
  })
@@ -246,7 +217,7 @@ describe('rendering', () => {
246
217
  test('should render both', () => {
247
218
  const editor = createEditor({
248
219
  content: createContent(NodeFactory.text('hello world', [
249
- NodeFactory.mark('text_decoration', {
220
+ NodeFactory.mark(TextSettings.TEXT_DECORATION, {
250
221
  strike_through: true,
251
222
  underline: true
252
223
  })
@@ -92,6 +92,6 @@ Object {
92
92
  }
93
93
  `;
94
94
 
95
- exports[`rendering should render all devices 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-text-align-mobile:left;--zw-text-align-tablet:right;--zw-text-align-desktop:center;\\">hello world</p>"`;
95
+ exports[`rendering should render all devices 1`] = `"<p class="zw-style" style="--zw-text-align-mobile:left;--zw-text-align-tablet:right;--zw-text-align-desktop:center;">hello world</p>"`;
96
96
 
97
- exports[`rendering should render only desktop 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-text-align-desktop:center;\\">hello world</p>"`;
97
+ exports[`rendering should render only desktop 1`] = `"<p class="zw-style" style="--zw-text-align-desktop:center;">hello world</p>"`;
@@ -145,4 +145,4 @@ Object {
145
145
  }
146
146
  `;
147
147
 
148
- exports[`rendering should render html 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-background-color:green;\\" class=\\"zw-style\\">hello world</span></p>"`;
148
+ exports[`rendering should render html 1`] = `"<p class="zw-style"><span style="--zw-background-color:green;" class="zw-style">hello world</span></p>"`;
@@ -133,4 +133,4 @@ Object {
133
133
  }
134
134
  `;
135
135
 
136
- exports[`rendering should render html 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-font-color:green;\\" class=\\"zw-style\\">hello world</span></p>"`;
136
+ exports[`rendering should render html 1`] = `"<p class="zw-style"><span style="--zw-font-color:green;" class="zw-style">hello world</span></p>"`;
@@ -19,6 +19,12 @@ Object {
19
19
  },
20
20
  "type": "font_weight",
21
21
  },
22
+ Object {
23
+ "attrs": Object {
24
+ "italic": false,
25
+ },
26
+ "type": "font_style",
27
+ },
22
28
  ],
23
29
  "text": "hello world",
24
30
  "type": "text",
@@ -44,6 +50,12 @@ Object {
44
50
  },
45
51
  "type": "font_family",
46
52
  },
53
+ Object {
54
+ "attrs": Object {
55
+ "italic": false,
56
+ },
57
+ "type": "font_style",
58
+ },
47
59
  ],
48
60
  "text": "hello world",
49
61
  "type": "text",
@@ -143,6 +155,12 @@ Object {
143
155
  },
144
156
  "type": "font_weight",
145
157
  },
158
+ Object {
159
+ "attrs": Object {
160
+ "italic": false,
161
+ },
162
+ "type": "font_style",
163
+ },
146
164
  ],
147
165
  "text": "hello world",
148
166
  "type": "text",
@@ -333,4 +351,4 @@ Object {
333
351
  }
334
352
  `;
335
353
 
336
- exports[`rendering should render html 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-font-family:&quot;Bungee&quot;;\\" class=\\"zw-style\\">hello world</span></p>"`;
354
+ exports[`rendering should render html 1`] = `"<p class="zw-style"><span style="--zw-font-family:&quot;Bungee&quot;;" class="zw-style">hello world</span></p>"`;
@@ -265,6 +265,6 @@ Object {
265
265
  }
266
266
  `;
267
267
 
268
- exports[`rendering should render all devices 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-font-size-mobile:12px;--zw-font-size-tablet:14px;--zw-font-size-desktop:16px;\\" class=\\"zw-style\\">hello world</span></p>"`;
268
+ exports[`rendering should render all devices 1`] = `"<p class="zw-style"><span style="--zw-font-size-mobile:12px;--zw-font-size-tablet:14px;--zw-font-size-desktop:16px;" class="zw-style">hello world</span></p>"`;
269
269
 
270
- exports[`rendering should render only desktop 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-font-size-desktop:14px;\\" class=\\"zw-style\\">hello world</span></p>"`;
270
+ exports[`rendering should render only desktop 1`] = `"<p class="zw-style"><span style="--zw-font-size-desktop:14px;" class="zw-style">hello world</span></p>"`;
@@ -31,6 +31,14 @@ Object {
31
31
  Object {
32
32
  "content": Array [
33
33
  Object {
34
+ "marks": Array [
35
+ Object {
36
+ "attrs": Object {
37
+ "italic": false,
38
+ },
39
+ "type": "font_style",
40
+ },
41
+ ],
34
42
  "text": "hello world",
35
43
  "type": "text",
36
44
  },
@@ -48,6 +56,14 @@ Object {
48
56
  Object {
49
57
  "content": Array [
50
58
  Object {
59
+ "marks": Array [
60
+ Object {
61
+ "attrs": Object {
62
+ "italic": false,
63
+ },
64
+ "type": "font_style",
65
+ },
66
+ ],
51
67
  "text": "hello world",
52
68
  "type": "text",
53
69
  },
@@ -225,4 +241,4 @@ Object {
225
241
  }
226
242
  `;
227
243
 
228
- exports[`rendering should render html 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-font-style:italic;\\" class=\\"zw-style\\">hello world</span></p>"`;
244
+ exports[`rendering should render html 1`] = `"<p class="zw-style"><span style="--zw-font-style:italic;" class="zw-style">hello world</span></p>"`;
@@ -332,4 +332,29 @@ Object {
332
332
  }
333
333
  `;
334
334
 
335
- exports[`rendering should render html 1`] = `"<p class=\\"zw-style\\"><span style=\\"--zw-font-weight:700;\\" class=\\"zw-style\\">hello world</span></p>"`;
335
+ exports[`parsing html should parse style shorthand 1`] = `
336
+ Object {
337
+ "content": Array [
338
+ Object {
339
+ "content": Array [
340
+ Object {
341
+ "marks": Array [
342
+ Object {
343
+ "attrs": Object {
344
+ "value": "700",
345
+ },
346
+ "type": "font_weight",
347
+ },
348
+ ],
349
+ "text": "test",
350
+ "type": "text",
351
+ },
352
+ ],
353
+ "type": "paragraph",
354
+ },
355
+ ],
356
+ "type": "doc",
357
+ }
358
+ `;
359
+
360
+ exports[`rendering should render html 1`] = `"<p class="zw-style"><span style="--zw-font-weight:700;" class="zw-style">hello world</span></p>"`;
@@ -140,6 +140,6 @@ Object {
140
140
  }
141
141
  `;
142
142
 
143
- exports[`rendering should render all devices 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-line-height-mobile:1.21;--zw-line-height-tablet:1.4;--zw-line-height-desktop:1.6;\\">hello world</p>"`;
143
+ exports[`rendering should render all devices 1`] = `"<p class="zw-style" style="--zw-line-height-mobile:1.21;--zw-line-height-tablet:1.4;--zw-line-height-desktop:1.6;">hello world</p>"`;
144
144
 
145
- exports[`rendering should render only desktop 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-line-height-desktop:1.3;\\">hello world</p>"`;
145
+ exports[`rendering should render only desktop 1`] = `"<p class="zw-style" style="--zw-line-height-desktop:1.3;">hello world</p>"`;
@@ -64,6 +64,6 @@ Object {
64
64
  }
65
65
  `;
66
66
 
67
- exports[`render html should not render empty 1`] = `"<p class=\\"zw-style\\">lorem ipsum</p>"`;
67
+ exports[`render html should not render empty 1`] = `"<p class="zw-style">lorem ipsum</p>"`;
68
68
 
69
- exports[`render html should render value 1`] = `"<p class=\\"zw-style\\" style=\\"--zw-margin:10px;\\">lorem ipsum</p>"`;
69
+ exports[`render html should render value 1`] = `"<p class="zw-style" style="--zw-margin:10px;">lorem ipsum</p>"`;
@@ -241,6 +241,26 @@ Object {
241
241
  }
242
242
  `;
243
243
 
244
+ exports[`get preset should get setting from link if selected 1`] = `
245
+ Object {
246
+ "common": Object {
247
+ "font_size": "20",
248
+ "font_style": "italic",
249
+ "text_decoration": "underline",
250
+ },
251
+ "desktop": Object {
252
+ "font_size": "16",
253
+ },
254
+ "id": "regular-1",
255
+ "mobile": Object {
256
+ "font_size": "12",
257
+ },
258
+ "tablet": Object {
259
+ "font_size": "14",
260
+ },
261
+ }
262
+ `;
263
+
244
264
  exports[`parsing html should get by fallback class 1`] = `
245
265
  Object {
246
266
  "content": Array [
@@ -472,8 +492,8 @@ Object {
472
492
  }
473
493
  `;
474
494
 
475
- exports[`render preset styles should render node without preset 1`] = `"<p class=\\"zw-style\\">test</p>"`;
495
+ exports[`render preset styles should render node without preset 1`] = `"<p class="zw-style">test</p>"`;
476
496
 
477
- exports[`render preset styles should render preset class 1`] = `"<p class=\\"zw-style zw ts-regular-1\\">test</p>"`;
497
+ exports[`render preset styles should render preset class 1`] = `"<p class="zw-style zw ts-regular-1">test</p>"`;
478
498
 
479
499
  exports[`render preset styles should render styles 1`] = `" .zw.ts-regular-1 { --zw-preset-font-weight: var(--common-regular-1-font-weight, inherit); --zw-preset-mobile-font-size: var(--mobile-regular-1-font-size, inherit); --zw-preset-tablet-font-size: var(--tablet-regular-1-font-size, inherit); --zw-preset-desktop-font-size: var(--desktop-regular-1-font-size, inherit); }"`;
@@ -26,49 +26,6 @@ Object {
26
26
  }
27
27
  `;
28
28
 
29
- exports[`apply decoration should remove decoration 1`] = `
30
- Object {
31
- "content": Array [
32
- Object {
33
- "content": Array [
34
- Object {
35
- "marks": Array [
36
- Object {
37
- "attrs": Object {
38
- "strike_through": false,
39
- "underline": true,
40
- },
41
- "type": "text_decoration",
42
- },
43
- ],
44
- "text": "hello world",
45
- "type": "text",
46
- },
47
- ],
48
- "type": "paragraph",
49
- },
50
- ],
51
- "type": "doc",
52
- }
53
- `;
54
-
55
- exports[`apply decoration should remove mark if no decoration 1`] = `
56
- Object {
57
- "content": Array [
58
- Object {
59
- "content": Array [
60
- Object {
61
- "text": "hello world",
62
- "type": "text",
63
- },
64
- ],
65
- "type": "paragraph",
66
- },
67
- ],
68
- "type": "doc",
69
- }
70
- `;
71
-
72
29
  exports[`apply decoration should second decoration 1`] = `
73
30
  Object {
74
31
  "content": Array [
@@ -586,8 +543,8 @@ Object {
586
543
  }
587
544
  `;
588
545
 
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>"`;
546
+ 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>"`;
590
547
 
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>"`;
548
+ 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>"`;
592
549
 
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>"`;
550
+ exports[`rendering should render underline only 1`] = `"<p class="zw-style"><span style="--zw-text-decoration:underline;" class="zw-style">hello world</span></p>"`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zipify/wysiwyg",
3
- "version": "1.1.1",
3
+ "version": "1.2.1-1",
4
4
  "description": "Zipify modification of TipTap text editor",
5
5
  "main": "dist/wysiwyg.mjs",
6
6
  "bin": {
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@popperjs/core": "^2.11.5",
35
- "@tiptap/core": "^2.0.0-beta.182",
35
+ "@tiptap/core": "^2.0.0-beta.183",
36
36
  "@tiptap/extension-document": "^2.0.0-beta.17",
37
37
  "@tiptap/extension-heading": "^2.0.0-beta.29",
38
38
  "@tiptap/extension-history": "^2.0.0-beta.26",
@@ -42,9 +42,9 @@
42
42
  "@tiptap/extension-placeholder": "^2.0.0-beta.53",
43
43
  "@tiptap/extension-superscript": "^2.0.0-beta.13",
44
44
  "@tiptap/extension-text": "^2.0.0-beta.17",
45
- "@tiptap/vue-2": "^2.0.0-beta.84",
45
+ "@tiptap/vue-2": "^2.0.0-beta.85",
46
46
  "commander": "^9.4.0",
47
- "jsdom": "^19.0.0",
47
+ "jsdom": "^20.0.0",
48
48
  "simplebar": "^5.3.8"
49
49
  },
50
50
  "peerDependencies": {
@@ -52,36 +52,36 @@
52
52
  "vue": "^2.7"
53
53
  },
54
54
  "devDependencies": {
55
- "@babel/core": "^7.18.9",
55
+ "@babel/core": "^7.19.0",
56
56
  "@babel/eslint-parser": "^7.18.9",
57
- "@babel/plugin-transform-runtime": "^7.18.9",
58
- "@babel/preset-env": "^7.18.9",
59
- "@babel/runtime": "^7.18.9",
57
+ "@babel/plugin-transform-runtime": "^7.18.10",
58
+ "@babel/preset-env": "^7.19.0",
59
+ "@babel/runtime": "^7.19.0",
60
60
  "@rollup/plugin-commonjs": "^22.0.2",
61
- "@rollup/plugin-node-resolve": "^13.3.0",
61
+ "@rollup/plugin-node-resolve": "^14.0.0",
62
62
  "@rollup/plugin-replace": "^4.0.0",
63
63
  "@vue/test-utils": "^1.3.0",
64
- "@vue/vue2-jest": "^28.0.1",
65
- "@zipify/colorpicker": "^2.0.0",
66
- "babel-jest": "^28.1.3",
67
- "eslint": "^8.20.0",
64
+ "@vue/vue2-jest": "^29.0.0",
65
+ "@zipify/colorpicker": "^2.2.1",
66
+ "babel-jest": "^29.0.2",
67
+ "eslint": "8.22.0",
68
68
  "eslint-plugin-import": "^2.26.0",
69
- "eslint-plugin-vue": "^9.3.0",
69
+ "eslint-plugin-vue": "^9.4.0",
70
70
  "gzipper": "^7.1.0",
71
71
  "husky": "^8.0.1",
72
- "jest": "^28.1.3",
73
- "jest-environment-jsdom": "^28.1.3",
72
+ "jest": "^29.0.2",
73
+ "jest-environment-jsdom": "^29.0.2",
74
74
  "lint-staged": "^13.0.3",
75
75
  "npm-run-all": "^4.1.5",
76
76
  "postcss-html": "^1.5.0",
77
- "release-it": "^15.1.2",
78
- "rollup": "^2.77.2",
77
+ "release-it": "^15.4.1",
78
+ "rollup": "^2.79.0",
79
79
  "rollup-plugin-terser": "^7.0.2",
80
- "stylelint": "^14.9.1",
80
+ "stylelint": "^14.11.0",
81
81
  "svgo": "^2.8.0",
82
- "vite": "^3.0.4",
82
+ "vite": "^3.1.0",
83
83
  "vite-plugin-vue2": "^2.0.2",
84
- "vue": "^2.7.8",
85
- "vue-template-compiler": "^2.7.8"
84
+ "vue": "^2.7.10",
85
+ "vue-template-compiler": "^2.7.10"
86
86
  }
87
87
  }