@zipify/wysiwyg 1.1.1-0 → 1.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.
- package/dist/cli.js +2 -2
- package/dist/wysiwyg.css +11 -11
- package/dist/wysiwyg.mjs +46 -53
- package/lib/components/toolbar/controls/link/LinkControl.vue +4 -5
- package/lib/components/toolbar/controls/link/LinkControlHeader.vue +2 -2
- package/lib/components/toolbar/controls/link/__tests__/LinkControl.test.js +1 -1
- package/lib/components/toolbar/controls/link/__tests__/LinkControlHeader.test.js +1 -1
- package/lib/components/toolbar/controls/link/composables/useLink.js +5 -7
- package/lib/enums/TextSettings.js +0 -2
- package/lib/extensions/Alignment.js +10 -8
- package/lib/extensions/FontSize.js +8 -3
- package/lib/extensions/FontStyle.js +2 -2
- package/lib/extensions/LineHeight.js +10 -4
- package/lib/extensions/Link.js +15 -13
- package/lib/extensions/TextDecoration.js +13 -12
- package/lib/extensions/__tests__/FontFamily.test.js +6 -7
- package/lib/extensions/__tests__/FontWeight.test.js +10 -11
- package/lib/extensions/__tests__/TextDecoration.test.js +42 -73
- package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +3 -3
- package/lib/extensions/__tests__/__snapshots__/FontFamily.test.js.snap +0 -18
- package/lib/extensions/__tests__/__snapshots__/FontSize.test.js.snap +9 -9
- package/lib/extensions/__tests__/__snapshots__/FontStyle.test.js.snap +0 -16
- package/lib/extensions/__tests__/__snapshots__/LineHeight.test.js.snap +5 -5
- package/lib/extensions/__tests__/__snapshots__/TextDecoration.test.js.snap +43 -0
- package/lib/services/NodeFactory.js +4 -1
- package/node_modules_lambda/acorn-globals/node_modules/.bin/acorn +4 -0
- package/node_modules_lambda/acorn-globals/node_modules/acorn/CHANGELOG.md +620 -0
- package/node_modules_lambda/acorn-globals/node_modules/acorn/LICENSE +21 -0
- package/node_modules_lambda/acorn-globals/node_modules/acorn/README.md +269 -0
- package/node_modules_lambda/acorn-globals/node_modules/acorn/bin/acorn +4 -0
- package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.d.ts +209 -0
- package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.js +5186 -0
- package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.js.map +1 -0
- package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.mjs +5155 -0
- package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.mjs.d.ts +2 -0
- package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/acorn.mjs.map +1 -0
- package/node_modules_lambda/acorn-globals/node_modules/acorn/dist/bin.js +64 -0
- package/node_modules_lambda/acorn-globals/node_modules/acorn/package.json +35 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/LICENSE.txt +20 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/README.mdown +67 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSDocumentRule.js +39 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSFontFaceRule.js +36 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSHostRule.js +37 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSImportRule.js +132 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSKeyframeRule.js +37 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSKeyframesRule.js +39 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSMediaRule.js +41 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSOM.js +3 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSRule.js +43 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSStyleDeclaration.js +148 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSStyleRule.js +190 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSStyleSheet.js +88 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSSupportsRule.js +36 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSValue.js +43 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/CSSValueExpression.js +344 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/MatcherList.js +62 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/MediaList.js +61 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/StyleSheet.js +17 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/clone.js +82 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/index.js +21 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/lib/parse.js +464 -0
- package/node_modules_lambda/cssstyle/node_modules/cssom/package.json +18 -0
- package/node_modules_lambda/data-urls/node_modules/whatwg-url/LICENSE.txt +21 -0
- package/node_modules_lambda/data-urls/node_modules/whatwg-url/README.md +106 -0
- package/node_modules_lambda/data-urls/node_modules/whatwg-url/index.js +27 -0
- package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/Function.js +42 -0
- package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URL-impl.js +209 -0
- package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URL.js +442 -0
- package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URLSearchParams-impl.js +130 -0
- package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/URLSearchParams.js +472 -0
- package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/VoidFunction.js +26 -0
- package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/encoding.js +16 -0
- package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/infra.js +26 -0
- package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/percent-encoding.js +142 -0
- package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/url-state-machine.js +1244 -0
- package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/urlencoded.js +106 -0
- package/node_modules_lambda/data-urls/node_modules/whatwg-url/lib/utils.js +190 -0
- package/node_modules_lambda/data-urls/node_modules/whatwg-url/package.json +58 -0
- package/node_modules_lambda/data-urls/node_modules/whatwg-url/webidl2js-wrapper.js +7 -0
- package/node_modules_lambda/escodegen/node_modules/estraverse/.jshintrc +16 -0
- package/node_modules_lambda/escodegen/node_modules/estraverse/LICENSE.BSD +19 -0
- package/node_modules_lambda/escodegen/node_modules/estraverse/README.md +153 -0
- package/node_modules_lambda/escodegen/node_modules/estraverse/estraverse.js +805 -0
- package/node_modules_lambda/escodegen/node_modules/estraverse/gulpfile.js +70 -0
- package/node_modules_lambda/escodegen/node_modules/estraverse/package.json +40 -0
- package/node_modules_lambda/escodegen/node_modules/levn/LICENSE +22 -0
- package/node_modules_lambda/escodegen/node_modules/levn/README.md +196 -0
- package/node_modules_lambda/escodegen/node_modules/levn/lib/cast.js +298 -0
- package/node_modules_lambda/escodegen/node_modules/levn/lib/coerce.js +285 -0
- package/node_modules_lambda/escodegen/node_modules/levn/lib/index.js +22 -0
- package/node_modules_lambda/escodegen/node_modules/levn/lib/parse-string.js +113 -0
- package/node_modules_lambda/escodegen/node_modules/levn/lib/parse.js +102 -0
- package/node_modules_lambda/escodegen/node_modules/levn/package.json +47 -0
- package/node_modules_lambda/escodegen/node_modules/optionator/CHANGELOG.md +56 -0
- package/node_modules_lambda/escodegen/node_modules/optionator/LICENSE +22 -0
- package/node_modules_lambda/escodegen/node_modules/optionator/README.md +238 -0
- package/node_modules_lambda/escodegen/node_modules/optionator/lib/help.js +260 -0
- package/node_modules_lambda/escodegen/node_modules/optionator/lib/index.js +465 -0
- package/node_modules_lambda/escodegen/node_modules/optionator/lib/util.js +54 -0
- package/node_modules_lambda/escodegen/node_modules/optionator/package.json +44 -0
- package/node_modules_lambda/escodegen/node_modules/prelude-ls/CHANGELOG.md +99 -0
- package/node_modules_lambda/escodegen/node_modules/prelude-ls/LICENSE +22 -0
- package/node_modules_lambda/escodegen/node_modules/prelude-ls/README.md +15 -0
- package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Func.js +65 -0
- package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/List.js +686 -0
- package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Num.js +130 -0
- package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Obj.js +154 -0
- package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/Str.js +92 -0
- package/node_modules_lambda/escodegen/node_modules/prelude-ls/lib/index.js +178 -0
- package/node_modules_lambda/escodegen/node_modules/prelude-ls/package.json +52 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/CHANGELOG.md +301 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/LICENSE +28 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/README.md +742 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.debug.js +3234 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.js +3233 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.min.js +2 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/dist/source-map.min.js.map +1 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/lib/array-set.js +121 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/lib/base64-vlq.js +140 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/lib/base64.js +67 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/lib/binary-search.js +111 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/lib/mapping-list.js +79 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/lib/quick-sort.js +114 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/lib/source-map-consumer.js +1145 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/lib/source-map-generator.js +425 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/lib/source-node.js +413 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/lib/util.js +488 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/package.json +73 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/source-map.d.ts +98 -0
- package/node_modules_lambda/escodegen/node_modules/source-map/source-map.js +8 -0
- package/node_modules_lambda/escodegen/node_modules/type-check/LICENSE +22 -0
- package/node_modules_lambda/escodegen/node_modules/type-check/README.md +210 -0
- package/node_modules_lambda/escodegen/node_modules/type-check/lib/check.js +126 -0
- package/node_modules_lambda/escodegen/node_modules/type-check/lib/index.js +16 -0
- package/node_modules_lambda/escodegen/node_modules/type-check/lib/parse-type.js +196 -0
- package/node_modules_lambda/escodegen/node_modules/type-check/package.json +40 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/.github/dependabot.yml +11 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/Changelog.md +212 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/LICENSE +21 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/README.md +130 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/dbcs-codec.js +597 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/dbcs-data.js +188 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/index.js +23 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/internal.js +198 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/sbcs-codec.js +72 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/sbcs-data-generated.js +451 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/sbcs-data.js +179 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/big5-added.json +122 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/cp936.json +264 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/cp949.json +273 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/cp950.json +177 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/eucjp.json +182 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/gb18030-ranges.json +1 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/gbk-added.json +56 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/tables/shiftjis.json +125 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/utf16.js +197 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/utf32.js +319 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/encodings/utf7.js +290 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/bom-handling.js +52 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/index.d.ts +41 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/index.js +180 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/lib/streams.js +109 -0
- package/node_modules_lambda/whatwg-encoding/node_modules/iconv-lite/package.json +44 -0
- package/package.json +1 -1
|
@@ -5,7 +5,6 @@ import { TextSettings } from '../enums';
|
|
|
5
5
|
|
|
6
6
|
export const TextDecoration = Mark.create({
|
|
7
7
|
name: TextSettings.TEXT_DECORATION,
|
|
8
|
-
priority: 1000,
|
|
9
8
|
|
|
10
9
|
addAttributes: () => ({
|
|
11
10
|
underline: { default: false },
|
|
@@ -14,10 +13,10 @@ export const TextDecoration = Mark.create({
|
|
|
14
13
|
|
|
15
14
|
addCommands() {
|
|
16
15
|
return {
|
|
17
|
-
isUnderline: createCommand(({ commands }) => {
|
|
16
|
+
isUnderline: createCommand(({ commands, editor }) => {
|
|
18
17
|
const decoration = commands.getTextDecoration();
|
|
19
18
|
|
|
20
|
-
return computed(() => unref(decoration).underline);
|
|
19
|
+
return computed(() => editor.isActive('link') || unref(decoration).underline);
|
|
21
20
|
}),
|
|
22
21
|
|
|
23
22
|
isStrikeThrough: createCommand(({ commands }) => {
|
|
@@ -41,14 +40,9 @@ export const TextDecoration = Mark.create({
|
|
|
41
40
|
|
|
42
41
|
getDefaultTextDecoration: createCommand(({ commands }) => {
|
|
43
42
|
const preset = commands.getPreset();
|
|
44
|
-
const isLink = commands.isLink();
|
|
45
|
-
const linkPreset = commands.getLinkPreset();
|
|
46
43
|
|
|
47
44
|
return computed(() => {
|
|
48
|
-
const decoration =
|
|
49
|
-
unref(preset).common.text_decoration,
|
|
50
|
-
unref(isLink) ? unref(linkPreset).common.text_decoration : ''
|
|
51
|
-
].join(' ');
|
|
45
|
+
const decoration = unref(preset).common.text_decoration;
|
|
52
46
|
|
|
53
47
|
return {
|
|
54
48
|
underline: decoration.includes('underline'),
|
|
@@ -57,7 +51,9 @@ export const TextDecoration = Mark.create({
|
|
|
57
51
|
});
|
|
58
52
|
}),
|
|
59
53
|
|
|
60
|
-
toggleUnderline: createCommand(({ commands }) => {
|
|
54
|
+
toggleUnderline: createCommand(({ commands, editor }) => {
|
|
55
|
+
if (editor.isActive('link')) return;
|
|
56
|
+
|
|
61
57
|
commands.toggleTextDecoration('underline');
|
|
62
58
|
}),
|
|
63
59
|
|
|
@@ -76,7 +72,13 @@ export const TextDecoration = Mark.create({
|
|
|
76
72
|
}),
|
|
77
73
|
|
|
78
74
|
removeTextDecoration: createCommand(({ commands }, name) => {
|
|
79
|
-
|
|
75
|
+
const mark = {
|
|
76
|
+
...unref(commands.getTextDecoration()),
|
|
77
|
+
[name]: false
|
|
78
|
+
};
|
|
79
|
+
const isRemoveMark = !mark.underline && !mark.strike_through;
|
|
80
|
+
|
|
81
|
+
isRemoveMark ? commands.unsetMark(this.name) : commands.setMark(this.name, mark);
|
|
80
82
|
})
|
|
81
83
|
};
|
|
82
84
|
},
|
|
@@ -133,7 +135,6 @@ export const TextDecoration = Mark.create({
|
|
|
133
135
|
|
|
134
136
|
if (attrs.underline) decorations.push('underline');
|
|
135
137
|
if (attrs.strike_through) decorations.push('line-through');
|
|
136
|
-
if (!decorations.length) decorations.push('none');
|
|
137
138
|
|
|
138
139
|
return renderMark({ text_decoration: decorations.join(' ') });
|
|
139
140
|
}
|
|
@@ -6,11 +6,10 @@ import { FontFamily } from '../FontFamily';
|
|
|
6
6
|
import { FontWeight } from '../FontWeight';
|
|
7
7
|
import { FontStyle } from '../FontStyle';
|
|
8
8
|
import { ContentNormalizer, NodeFactory } from '../../services';
|
|
9
|
-
import { TextSettings } from '../../enums';
|
|
10
9
|
import { buildCoreExtensions } from '../core';
|
|
11
10
|
|
|
12
11
|
const MockStylePreset = Extension.create({
|
|
13
|
-
name:
|
|
12
|
+
name: 'style_preset',
|
|
14
13
|
|
|
15
14
|
addCommands() {
|
|
16
15
|
return {
|
|
@@ -31,10 +30,10 @@ function createEditor({ content }) {
|
|
|
31
30
|
MockStylePreset,
|
|
32
31
|
FontFamily.configure({
|
|
33
32
|
fonts: [
|
|
34
|
-
new Font({ name: 'Lato', styles: ['400', '
|
|
33
|
+
new Font({ name: 'Lato', styles: ['400', '700', '700i'] }),
|
|
35
34
|
new Font({ name: 'Bungee', styles: ['400'] }),
|
|
36
|
-
new Font({ name: 'Roboto', styles: ['400'
|
|
37
|
-
new Font({ name: 'Josefin Slab', styles: ['400'
|
|
35
|
+
new Font({ name: 'Roboto', styles: ['400'] }),
|
|
36
|
+
new Font({ name: 'Josefin Slab', styles: ['400'] })
|
|
38
37
|
],
|
|
39
38
|
defaultFont: 'Lato'
|
|
40
39
|
}),
|
|
@@ -52,7 +51,7 @@ describe('get font family', () => {
|
|
|
52
51
|
test('should get from selection', () => {
|
|
53
52
|
const editor = createEditor({
|
|
54
53
|
content: createContent(NodeFactory.text('hello world', [
|
|
55
|
-
NodeFactory.mark(
|
|
54
|
+
NodeFactory.mark('font_family', { value: 'Bungee' })
|
|
56
55
|
]))
|
|
57
56
|
});
|
|
58
57
|
|
|
@@ -166,7 +165,7 @@ describe('rendering', () => {
|
|
|
166
165
|
test('should render html', () => {
|
|
167
166
|
const editor = createEditor({
|
|
168
167
|
content: createContent(NodeFactory.text('hello world', [
|
|
169
|
-
NodeFactory.mark(
|
|
168
|
+
NodeFactory.mark('font_family', { value: 'Bungee' })
|
|
170
169
|
]))
|
|
171
170
|
});
|
|
172
171
|
|
|
@@ -6,11 +6,10 @@ 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';
|
|
10
9
|
import { buildCoreExtensions } from '../core';
|
|
11
10
|
|
|
12
11
|
const MockStylePreset = Extension.create({
|
|
13
|
-
name:
|
|
12
|
+
name: 'style_preset',
|
|
14
13
|
|
|
15
14
|
addCommands() {
|
|
16
15
|
return {
|
|
@@ -31,8 +30,8 @@ function createEditor({ content }) {
|
|
|
31
30
|
MockStylePreset,
|
|
32
31
|
FontFamily.configure({
|
|
33
32
|
fonts: [
|
|
34
|
-
new Font({ name: 'Lato', styles: ['400', '
|
|
35
|
-
new Font({ name: 'Bungee', styles: ['300', '
|
|
33
|
+
new Font({ name: 'Lato', styles: ['400', '700'] }),
|
|
34
|
+
new Font({ name: 'Bungee', styles: ['300', '800'] })
|
|
36
35
|
]
|
|
37
36
|
}),
|
|
38
37
|
FontWeight,
|
|
@@ -49,7 +48,7 @@ describe('get font weight', () => {
|
|
|
49
48
|
test('should get from selection', () => {
|
|
50
49
|
const editor = createEditor({
|
|
51
50
|
content: createContent(NodeFactory.text('hello world', [
|
|
52
|
-
NodeFactory.mark(
|
|
51
|
+
NodeFactory.mark('font_weight', { value: '700' })
|
|
53
52
|
]))
|
|
54
53
|
});
|
|
55
54
|
|
|
@@ -79,7 +78,7 @@ describe('get font weight', () => {
|
|
|
79
78
|
test('should get closest available font weight', () => {
|
|
80
79
|
const editor = createEditor({
|
|
81
80
|
content: createContent(NodeFactory.text('hello world', [
|
|
82
|
-
NodeFactory.mark(
|
|
81
|
+
NodeFactory.mark('font_weight', { value: '800' })
|
|
83
82
|
]))
|
|
84
83
|
});
|
|
85
84
|
|
|
@@ -103,7 +102,7 @@ describe('apply font weight', () => {
|
|
|
103
102
|
test('should toggle weight to bold', () => {
|
|
104
103
|
const editor = createEditor({
|
|
105
104
|
content: createContent(NodeFactory.text('hello world', [
|
|
106
|
-
NodeFactory.mark(
|
|
105
|
+
NodeFactory.mark('font_weight', { value: '400' })
|
|
107
106
|
]))
|
|
108
107
|
});
|
|
109
108
|
|
|
@@ -116,7 +115,7 @@ describe('apply font weight', () => {
|
|
|
116
115
|
const editor = createEditor({
|
|
117
116
|
content: createContent(NodeFactory.text('hello world', [
|
|
118
117
|
NodeFactory.mark('font_family', { value: 'Bungee' }),
|
|
119
|
-
NodeFactory.mark(
|
|
118
|
+
NodeFactory.mark('font_weight', { value: '400' })
|
|
120
119
|
]))
|
|
121
120
|
});
|
|
122
121
|
|
|
@@ -128,7 +127,7 @@ describe('apply font weight', () => {
|
|
|
128
127
|
test('should toggle weight to medium', () => {
|
|
129
128
|
const editor = createEditor({
|
|
130
129
|
content: createContent(NodeFactory.text('hello world', [
|
|
131
|
-
NodeFactory.mark(
|
|
130
|
+
NodeFactory.mark('font_weight', { value: '700' })
|
|
132
131
|
]))
|
|
133
132
|
});
|
|
134
133
|
|
|
@@ -141,7 +140,7 @@ describe('apply font weight', () => {
|
|
|
141
140
|
const editor = createEditor({
|
|
142
141
|
content: createContent(NodeFactory.text('hello world', [
|
|
143
142
|
NodeFactory.mark('font_family', { value: 'Bungee' }),
|
|
144
|
-
NodeFactory.mark(
|
|
143
|
+
NodeFactory.mark('font_weight', { value: '800' })
|
|
145
144
|
]))
|
|
146
145
|
});
|
|
147
146
|
|
|
@@ -155,7 +154,7 @@ describe('rendering', () => {
|
|
|
155
154
|
test('should render html', () => {
|
|
156
155
|
const editor = createEditor({
|
|
157
156
|
content: createContent(NodeFactory.text('hello world', [
|
|
158
|
-
NodeFactory.mark(
|
|
157
|
+
NodeFactory.mark('font_weight', { value: '700' })
|
|
159
158
|
]))
|
|
160
159
|
});
|
|
161
160
|
|
|
@@ -4,10 +4,9 @@ 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';
|
|
8
7
|
|
|
9
8
|
const MockStylePreset = Extension.create({
|
|
10
|
-
name:
|
|
9
|
+
name: 'style_preset',
|
|
11
10
|
|
|
12
11
|
addCommands() {
|
|
13
12
|
return {
|
|
@@ -18,26 +17,10 @@ const MockStylePreset = Extension.create({
|
|
|
18
17
|
}
|
|
19
18
|
});
|
|
20
19
|
|
|
21
|
-
|
|
22
|
-
name: TextSettings.LINK,
|
|
23
|
-
|
|
24
|
-
addOptions: () => ({
|
|
25
|
-
isLink: false,
|
|
26
|
-
preset: {}
|
|
27
|
-
}),
|
|
28
|
-
|
|
29
|
-
addCommands() {
|
|
30
|
-
return {
|
|
31
|
-
isLink: createCommand(() => this.options.isLink),
|
|
32
|
-
getLinkPreset: createCommand(() => this.options.preset)
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
function createEditor({ content, link }) {
|
|
20
|
+
function createEditor({ content }) {
|
|
38
21
|
return new Editor({
|
|
39
22
|
content: ContentNormalizer.normalize(content),
|
|
40
|
-
extensions: buildCoreExtensions().concat(MockStylePreset, TextDecoration
|
|
23
|
+
extensions: buildCoreExtensions().concat(MockStylePreset, TextDecoration)
|
|
41
24
|
});
|
|
42
25
|
}
|
|
43
26
|
|
|
@@ -49,7 +32,7 @@ describe('get decoration', () => {
|
|
|
49
32
|
test('should get from selection', () => {
|
|
50
33
|
const editor = createEditor({
|
|
51
34
|
content: createContent(NodeFactory.text('hello world', [
|
|
52
|
-
NodeFactory.mark(
|
|
35
|
+
NodeFactory.mark('text_decoration', {
|
|
53
36
|
underline: true,
|
|
54
37
|
strike_through: true
|
|
55
38
|
})
|
|
@@ -77,7 +60,7 @@ describe('get decoration', () => {
|
|
|
77
60
|
test('should get from selection', () => {
|
|
78
61
|
const editor = createEditor({
|
|
79
62
|
content: createContent(NodeFactory.text('hello world', [
|
|
80
|
-
NodeFactory.mark(
|
|
63
|
+
NodeFactory.mark('text_decoration', { underline: true })
|
|
81
64
|
]))
|
|
82
65
|
});
|
|
83
66
|
|
|
@@ -95,57 +78,13 @@ describe('get decoration', () => {
|
|
|
95
78
|
|
|
96
79
|
expect(editor.commands.isUnderline().value).toBe(false);
|
|
97
80
|
});
|
|
98
|
-
|
|
99
|
-
test('should get true from link preset', () => {
|
|
100
|
-
const editor = createEditor({
|
|
101
|
-
content: createContent(NodeFactory.text('hello world')),
|
|
102
|
-
link: {
|
|
103
|
-
isLink: true,
|
|
104
|
-
preset: { common: { text_decoration: 'underline' } }
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
|
|
108
|
-
editor.commands.selectAll();
|
|
109
|
-
|
|
110
|
-
expect(editor.commands.isUnderline().value).toBe(true);
|
|
111
|
-
});
|
|
112
|
-
|
|
113
|
-
test('should get false from link preset', () => {
|
|
114
|
-
const editor = createEditor({
|
|
115
|
-
content: createContent(NodeFactory.text('hello world')),
|
|
116
|
-
link: {
|
|
117
|
-
isLink: true,
|
|
118
|
-
preset: { common: { text_decoration: 'none' } }
|
|
119
|
-
}
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
editor.commands.selectAll();
|
|
123
|
-
|
|
124
|
-
expect(editor.commands.isUnderline().value).toBe(false);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
test('should override link by local', () => {
|
|
128
|
-
const editor = createEditor({
|
|
129
|
-
content: createContent(NodeFactory.text('hello world', [
|
|
130
|
-
NodeFactory.mark(TextSettings.TEXT_DECORATION, { underline: false })
|
|
131
|
-
])),
|
|
132
|
-
link: {
|
|
133
|
-
isLink: true,
|
|
134
|
-
preset: { common: { text_decoration: 'underline' } }
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
|
|
138
|
-
editor.commands.selectAll();
|
|
139
|
-
|
|
140
|
-
expect(editor.commands.isUnderline().value).toBe(false);
|
|
141
|
-
});
|
|
142
81
|
});
|
|
143
82
|
|
|
144
83
|
describe('strike through', () => {
|
|
145
84
|
test('should get from selection', () => {
|
|
146
85
|
const editor = createEditor({
|
|
147
86
|
content: createContent(NodeFactory.text('hello world', [
|
|
148
|
-
NodeFactory.mark(
|
|
87
|
+
NodeFactory.mark('text_decoration', { strike_through: true })
|
|
149
88
|
]))
|
|
150
89
|
});
|
|
151
90
|
|
|
@@ -180,7 +119,7 @@ describe('apply decoration', () => {
|
|
|
180
119
|
test('should second decoration', () => {
|
|
181
120
|
const editor = createEditor({
|
|
182
121
|
content: createContent(NodeFactory.text('hello world', [
|
|
183
|
-
NodeFactory.mark(
|
|
122
|
+
NodeFactory.mark('text_decoration', {
|
|
184
123
|
strike_through: false,
|
|
185
124
|
underline: true
|
|
186
125
|
})
|
|
@@ -192,11 +131,41 @@ describe('apply decoration', () => {
|
|
|
192
131
|
expect(editor.getJSON()).toMatchSnapshot();
|
|
193
132
|
});
|
|
194
133
|
|
|
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
|
+
|
|
195
164
|
describe('underline', () => {
|
|
196
165
|
test('should toggle to removed', () => {
|
|
197
166
|
const editor = createEditor({
|
|
198
167
|
content: createContent(NodeFactory.text('hello world', [
|
|
199
|
-
NodeFactory.mark(
|
|
168
|
+
NodeFactory.mark('text_decoration', {
|
|
200
169
|
strike_through: true,
|
|
201
170
|
underline: true
|
|
202
171
|
})
|
|
@@ -223,7 +192,7 @@ describe('apply decoration', () => {
|
|
|
223
192
|
test('should toggle to removed', () => {
|
|
224
193
|
const editor = createEditor({
|
|
225
194
|
content: createContent(NodeFactory.text('hello world', [
|
|
226
|
-
NodeFactory.mark(
|
|
195
|
+
NodeFactory.mark('text_decoration', {
|
|
227
196
|
strike_through: true,
|
|
228
197
|
underline: true
|
|
229
198
|
})
|
|
@@ -251,7 +220,7 @@ describe('rendering', () => {
|
|
|
251
220
|
test('should render underline only', () => {
|
|
252
221
|
const editor = createEditor({
|
|
253
222
|
content: createContent(NodeFactory.text('hello world', [
|
|
254
|
-
NodeFactory.mark(
|
|
223
|
+
NodeFactory.mark('text_decoration', {
|
|
255
224
|
strike_through: false,
|
|
256
225
|
underline: true
|
|
257
226
|
})
|
|
@@ -264,7 +233,7 @@ describe('rendering', () => {
|
|
|
264
233
|
test('should render strike through only', () => {
|
|
265
234
|
const editor = createEditor({
|
|
266
235
|
content: createContent(NodeFactory.text('hello world', [
|
|
267
|
-
NodeFactory.mark(
|
|
236
|
+
NodeFactory.mark('text_decoration', {
|
|
268
237
|
strike_through: true,
|
|
269
238
|
underline: false
|
|
270
239
|
})
|
|
@@ -277,7 +246,7 @@ describe('rendering', () => {
|
|
|
277
246
|
test('should render both', () => {
|
|
278
247
|
const editor = createEditor({
|
|
279
248
|
content: createContent(NodeFactory.text('hello world', [
|
|
280
|
-
NodeFactory.mark(
|
|
249
|
+
NodeFactory.mark('text_decoration', {
|
|
281
250
|
strike_through: true,
|
|
282
251
|
underline: true
|
|
283
252
|
})
|
|
@@ -8,7 +8,7 @@ Object {
|
|
|
8
8
|
"alignment": Object {
|
|
9
9
|
"desktop": "right",
|
|
10
10
|
"mobile": null,
|
|
11
|
-
"tablet":
|
|
11
|
+
"tablet": "right",
|
|
12
12
|
},
|
|
13
13
|
},
|
|
14
14
|
"content": Array [
|
|
@@ -31,7 +31,7 @@ Object {
|
|
|
31
31
|
"attrs": Object {
|
|
32
32
|
"alignment": Object {
|
|
33
33
|
"desktop": "right",
|
|
34
|
-
"mobile":
|
|
34
|
+
"mobile": null,
|
|
35
35
|
"tablet": null,
|
|
36
36
|
},
|
|
37
37
|
},
|
|
@@ -55,7 +55,7 @@ Object {
|
|
|
55
55
|
"attrs": Object {
|
|
56
56
|
"alignment": Object {
|
|
57
57
|
"desktop": "center",
|
|
58
|
-
"mobile":
|
|
58
|
+
"mobile": null,
|
|
59
59
|
"tablet": "center",
|
|
60
60
|
},
|
|
61
61
|
},
|
|
@@ -19,12 +19,6 @@ Object {
|
|
|
19
19
|
},
|
|
20
20
|
"type": "font_weight",
|
|
21
21
|
},
|
|
22
|
-
Object {
|
|
23
|
-
"attrs": Object {
|
|
24
|
-
"italic": false,
|
|
25
|
-
},
|
|
26
|
-
"type": "font_style",
|
|
27
|
-
},
|
|
28
22
|
],
|
|
29
23
|
"text": "hello world",
|
|
30
24
|
"type": "text",
|
|
@@ -50,12 +44,6 @@ Object {
|
|
|
50
44
|
},
|
|
51
45
|
"type": "font_family",
|
|
52
46
|
},
|
|
53
|
-
Object {
|
|
54
|
-
"attrs": Object {
|
|
55
|
-
"italic": false,
|
|
56
|
-
},
|
|
57
|
-
"type": "font_style",
|
|
58
|
-
},
|
|
59
47
|
],
|
|
60
48
|
"text": "hello world",
|
|
61
49
|
"type": "text",
|
|
@@ -155,12 +143,6 @@ Object {
|
|
|
155
143
|
},
|
|
156
144
|
"type": "font_weight",
|
|
157
145
|
},
|
|
158
|
-
Object {
|
|
159
|
-
"attrs": Object {
|
|
160
|
-
"italic": false,
|
|
161
|
-
},
|
|
162
|
-
"type": "font_style",
|
|
163
|
-
},
|
|
164
146
|
],
|
|
165
147
|
"text": "hello world",
|
|
166
148
|
"type": "text",
|
|
@@ -11,7 +11,7 @@ Object {
|
|
|
11
11
|
"attrs": Object {
|
|
12
12
|
"desktop": "16",
|
|
13
13
|
"mobile": null,
|
|
14
|
-
"tablet":
|
|
14
|
+
"tablet": "16",
|
|
15
15
|
},
|
|
16
16
|
"type": "font_size",
|
|
17
17
|
},
|
|
@@ -38,7 +38,7 @@ Object {
|
|
|
38
38
|
"attrs": Object {
|
|
39
39
|
"desktop": "13",
|
|
40
40
|
"mobile": null,
|
|
41
|
-
"tablet":
|
|
41
|
+
"tablet": "13",
|
|
42
42
|
},
|
|
43
43
|
"type": "font_size",
|
|
44
44
|
},
|
|
@@ -65,7 +65,7 @@ Object {
|
|
|
65
65
|
"attrs": Object {
|
|
66
66
|
"desktop": "15",
|
|
67
67
|
"mobile": null,
|
|
68
|
-
"tablet":
|
|
68
|
+
"tablet": "15",
|
|
69
69
|
},
|
|
70
70
|
"type": "font_size",
|
|
71
71
|
},
|
|
@@ -92,7 +92,7 @@ Object {
|
|
|
92
92
|
"attrs": Object {
|
|
93
93
|
"desktop": "5",
|
|
94
94
|
"mobile": null,
|
|
95
|
-
"tablet":
|
|
95
|
+
"tablet": "5",
|
|
96
96
|
},
|
|
97
97
|
"type": "font_size",
|
|
98
98
|
},
|
|
@@ -119,7 +119,7 @@ Object {
|
|
|
119
119
|
"attrs": Object {
|
|
120
120
|
"desktop": "20",
|
|
121
121
|
"mobile": null,
|
|
122
|
-
"tablet":
|
|
122
|
+
"tablet": "20",
|
|
123
123
|
},
|
|
124
124
|
"type": "font_size",
|
|
125
125
|
},
|
|
@@ -145,7 +145,7 @@ Object {
|
|
|
145
145
|
Object {
|
|
146
146
|
"attrs": Object {
|
|
147
147
|
"desktop": "24",
|
|
148
|
-
"mobile":
|
|
148
|
+
"mobile": null,
|
|
149
149
|
"tablet": "24",
|
|
150
150
|
},
|
|
151
151
|
"type": "font_size",
|
|
@@ -203,7 +203,7 @@ Object {
|
|
|
203
203
|
Object {
|
|
204
204
|
"attrs": Object {
|
|
205
205
|
"desktop": "24",
|
|
206
|
-
"mobile":
|
|
206
|
+
"mobile": null,
|
|
207
207
|
"tablet": "24",
|
|
208
208
|
},
|
|
209
209
|
"type": "font_size",
|
|
@@ -234,7 +234,7 @@ Object {
|
|
|
234
234
|
Object {
|
|
235
235
|
"attrs": Object {
|
|
236
236
|
"desktop": "20",
|
|
237
|
-
"mobile":
|
|
237
|
+
"mobile": null,
|
|
238
238
|
"tablet": "20",
|
|
239
239
|
},
|
|
240
240
|
"type": "font_size",
|
|
@@ -248,7 +248,7 @@ Object {
|
|
|
248
248
|
Object {
|
|
249
249
|
"attrs": Object {
|
|
250
250
|
"desktop": "24",
|
|
251
|
-
"mobile":
|
|
251
|
+
"mobile": null,
|
|
252
252
|
"tablet": "24",
|
|
253
253
|
},
|
|
254
254
|
"type": "font_size",
|
|
@@ -31,14 +31,6 @@ 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
|
-
],
|
|
42
34
|
"text": "hello world",
|
|
43
35
|
"type": "text",
|
|
44
36
|
},
|
|
@@ -56,14 +48,6 @@ Object {
|
|
|
56
48
|
Object {
|
|
57
49
|
"content": Array [
|
|
58
50
|
Object {
|
|
59
|
-
"marks": Array [
|
|
60
|
-
Object {
|
|
61
|
-
"attrs": Object {
|
|
62
|
-
"italic": false,
|
|
63
|
-
},
|
|
64
|
-
"type": "font_style",
|
|
65
|
-
},
|
|
66
|
-
],
|
|
67
51
|
"text": "hello world",
|
|
68
52
|
"type": "text",
|
|
69
53
|
},
|
|
@@ -8,7 +8,7 @@ Object {
|
|
|
8
8
|
"line_height": Object {
|
|
9
9
|
"desktop": "1.41",
|
|
10
10
|
"mobile": null,
|
|
11
|
-
"tablet":
|
|
11
|
+
"tablet": "1.41",
|
|
12
12
|
},
|
|
13
13
|
},
|
|
14
14
|
"content": Array [
|
|
@@ -31,7 +31,7 @@ Object {
|
|
|
31
31
|
"attrs": Object {
|
|
32
32
|
"line_height": Object {
|
|
33
33
|
"desktop": "1.4",
|
|
34
|
-
"mobile":
|
|
34
|
+
"mobile": null,
|
|
35
35
|
"tablet": null,
|
|
36
36
|
},
|
|
37
37
|
},
|
|
@@ -55,7 +55,7 @@ Object {
|
|
|
55
55
|
"attrs": Object {
|
|
56
56
|
"line_height": Object {
|
|
57
57
|
"desktop": "1.20",
|
|
58
|
-
"mobile":
|
|
58
|
+
"mobile": null,
|
|
59
59
|
"tablet": "1.20",
|
|
60
60
|
},
|
|
61
61
|
},
|
|
@@ -79,7 +79,7 @@ Object {
|
|
|
79
79
|
"attrs": Object {
|
|
80
80
|
"line_height": Object {
|
|
81
81
|
"desktop": "1.20",
|
|
82
|
-
"mobile":
|
|
82
|
+
"mobile": null,
|
|
83
83
|
"tablet": "1.20",
|
|
84
84
|
},
|
|
85
85
|
},
|
|
@@ -103,7 +103,7 @@ Object {
|
|
|
103
103
|
"attrs": Object {
|
|
104
104
|
"line_height": Object {
|
|
105
105
|
"desktop": "1.2",
|
|
106
|
-
"mobile":
|
|
106
|
+
"mobile": null,
|
|
107
107
|
"tablet": "1.2",
|
|
108
108
|
},
|
|
109
109
|
},
|
|
@@ -26,6 +26,49 @@ 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
|
+
|
|
29
72
|
exports[`apply decoration should second decoration 1`] = `
|
|
30
73
|
Object {
|
|
31
74
|
"content": Array [
|
|
@@ -66,6 +66,9 @@ export class NodeFactory {
|
|
|
66
66
|
}
|
|
67
67
|
|
|
68
68
|
static populateAllDevices(value) {
|
|
69
|
-
return { mobile: value, tablet: value, desktop: value };
|
|
69
|
+
// return { mobile: value, tablet: value, desktop: value };
|
|
70
|
+
|
|
71
|
+
// Temporary until release BUILDER_MODES
|
|
72
|
+
return { mobile: null, tablet: value, desktop: value };
|
|
70
73
|
}
|
|
71
74
|
}
|