@zipify/wysiwyg 3.1.0-0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.js +17 -235
- package/.github/actions/setup/action.yaml +1 -1
- package/README.md +2 -0
- package/config/build/cli.config.js +7 -7
- package/config/build/lib.config.js +6 -4
- package/config/svgo.js +6 -3
- package/dist/cli.js +5 -4
- package/dist/wysiwyg.css +36 -33
- package/dist/wysiwyg.mjs +12403 -11604
- package/example/ExampleApp.vue +1 -1
- package/example/presets.js +7 -7
- package/example/tooltip/Tooltip.js +94 -69
- package/example/tooltip/tooltip.css +8 -31
- package/lib/Wysiwyg.vue +3 -0
- package/lib/__tests__/utils/buildTestExtensions.js +24 -2
- package/lib/cli/commands/ToJsonCommand.js +6 -6
- package/lib/components/base/__tests__/Button.test.js +1 -1
- package/lib/components/base/composables/__tests__/useDeselectionLock.test.js +2 -2
- package/lib/components/base/composables/__tests__/useElementRef.test.js +1 -1
- package/lib/components/base/composables/__tests__/useModalToggler.test.js +0 -2
- package/lib/components/base/composables/__tests__/useValidator.test.js +2 -2
- package/lib/components/base/composables/useModalToggler.js +30 -21
- package/lib/components/base/dropdown/DropdownActivator.vue +4 -0
- package/lib/components/toolbar/Toolbar.vue +1 -1
- package/lib/components/toolbar/base/__tests__/ToolbarDivider.test.js +1 -1
- package/lib/components/toolbar/controls/StylePresetControl.vue +2 -2
- package/lib/components/toolbar/controls/__tests__/LineHeightControl.test.js +0 -2
- package/lib/components/toolbar/controls/composables/__tests__/useRecentFonts.test.js +1 -1
- package/lib/components/toolbar/controls/link/composables/__tests__/useLink.test.js +2 -2
- package/lib/composables/useToolbar.js +24 -19
- package/lib/{entry-cli.js → entryCli.js} +0 -0
- package/lib/{entry-lib.js → entryLib.js} +0 -0
- package/lib/extensions/Alignment.js +6 -6
- package/lib/extensions/FontSize.js +1 -2
- package/lib/extensions/Link.js +2 -0
- package/lib/extensions/StylePreset.js +8 -46
- package/lib/extensions/__tests__/Alignment.test.js +1 -1
- package/lib/extensions/__tests__/BackgroundColor.test.js +2 -2
- package/lib/extensions/__tests__/FontColor.test.js +3 -3
- package/lib/extensions/__tests__/FontFamily.test.js +3 -3
- package/lib/extensions/__tests__/FontSize.test.js +3 -3
- package/lib/extensions/__tests__/FontWeight.test.js +4 -4
- package/lib/extensions/__tests__/LineHeight.test.js +2 -2
- package/lib/extensions/__tests__/Link.test.js +33 -5
- package/lib/extensions/__tests__/StylePreset.test.js +90 -119
- package/lib/extensions/__tests__/__snapshots__/Alignment.test.js.snap +2 -2
- package/lib/extensions/__tests__/__snapshots__/Link.test.js.snap +27 -0
- package/lib/extensions/__tests__/__snapshots__/StylePreset.test.js.snap +0 -2
- package/lib/extensions/core/NodeProcessor.js +9 -6
- package/lib/extensions/core/__tests__/NodeProcessor.test.js +6 -8
- package/lib/extensions/core/__tests__/TextProcessor.test.js +1 -1
- package/lib/extensions/core/index.js +0 -2
- package/lib/extensions/core/plugins/PlaceholderPlugin.js +2 -2
- package/lib/extensions/index.js +7 -3
- package/lib/extensions/list/List.js +4 -5
- package/lib/extensions/list/ListItem.js +1 -2
- package/lib/extensions/list/__tests__/List.test.js +7 -2
- package/lib/models/Font.js +2 -2
- package/lib/models/__tests__/Font.test.js +3 -9
- package/lib/services/ContentSerializer.js +9 -9
- package/lib/services/{ContextWidnow.js → ContextWindow.js} +0 -0
- package/lib/services/HtmlToJsonParser.js +3 -3
- package/lib/services/NodeFactory.js +6 -6
- package/lib/services/StylePresetRenderer.js +73 -0
- package/lib/services/__tests__/JsonSerializer.test.js +1 -1
- package/lib/services/__tests__/Storage.test.js +1 -1
- package/lib/services/__tests__/StylePresetRenderer.test.js +98 -0
- package/lib/services/__tests__/__snapshots__/StylePresetRenderer.test.js.snap +5 -0
- package/lib/services/index.js +2 -1
- package/lib/services/normalizer/BrowserDomParser.js +2 -2
- package/lib/services/normalizer/ContentNormalizer.js +3 -3
- package/lib/services/normalizer/HtmlNormalizer.js +52 -52
- package/lib/services/normalizer/JsonNormalizer.js +21 -21
- package/lib/styles/content.css +10 -10
- package/lib/utils/__tests__/convertAlignment.test.js +1 -1
- package/lib/utils/__tests__/renderInlineSetting.test.js +2 -2
- package/package.json +48 -46
- package/lib/extensions/core/steps/AddNodeMarkStep.js +0 -66
- package/lib/extensions/core/steps/AttrStep.js +0 -60
- package/lib/extensions/core/steps/RemoveNodeMarkStep.js +0 -56
- package/lib/extensions/core/steps/index.js +0 -3
|
@@ -2,7 +2,6 @@ import { Node, wrappingInputRule } from '@tiptap/vue-2';
|
|
|
2
2
|
import { computed, unref } from 'vue';
|
|
3
3
|
import { copyMark, createCommand } from '../../utils';
|
|
4
4
|
import { ListTypes, MarkGroups, NodeTypes, TextSettings } from '../../enums';
|
|
5
|
-
import { AddNodeMarkStep, RemoveNodeMarkStep } from '../core/steps';
|
|
6
5
|
import { ListItem } from './ListItem';
|
|
7
6
|
|
|
8
7
|
export const List = Node.create({
|
|
@@ -122,13 +121,13 @@ export const List = Node.create({
|
|
|
122
121
|
node.forEach((child) => {
|
|
123
122
|
for (const childMark of child.marks) {
|
|
124
123
|
if (childMark.isInSet(bubbled)) {
|
|
125
|
-
tr.
|
|
124
|
+
tr.removeNodeMark(position + 1, childMark);
|
|
126
125
|
continue;
|
|
127
126
|
}
|
|
128
127
|
|
|
129
128
|
if (canBubbleMark(node, childMark)) {
|
|
130
|
-
tr.
|
|
131
|
-
tr.
|
|
129
|
+
tr.removeNodeMark(position + 1, childMark);
|
|
130
|
+
tr.addNodeMark(position, copyMark(childMark));
|
|
132
131
|
bubbled.push(childMark);
|
|
133
132
|
}
|
|
134
133
|
}
|
|
@@ -152,7 +151,7 @@ export const List = Node.create({
|
|
|
152
151
|
});
|
|
153
152
|
|
|
154
153
|
for (const mark of addingMarks) {
|
|
155
|
-
tr.
|
|
154
|
+
tr.addNodeMark(position, copyMark(mark));
|
|
156
155
|
}
|
|
157
156
|
|
|
158
157
|
return false;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Base from '@tiptap/extension-list-item';
|
|
2
2
|
import { MarkGroups, NodeTypes } from '../../enums';
|
|
3
3
|
import { copyMark, createCommand } from '../../utils';
|
|
4
|
-
import { AddNodeMarkStep } from '../core/steps';
|
|
5
4
|
|
|
6
5
|
export const ListItem = Base.extend({
|
|
7
6
|
name: NodeTypes.LIST_ITEM,
|
|
@@ -22,7 +21,7 @@ export const ListItem = Base.extend({
|
|
|
22
21
|
const position = getItemPosition(tr);
|
|
23
22
|
|
|
24
23
|
for (const mark of initialNode.marks) {
|
|
25
|
-
tr.
|
|
24
|
+
tr.addNodeMark(position, copyMark(mark));
|
|
26
25
|
}
|
|
27
26
|
|
|
28
27
|
return true;
|
|
@@ -29,7 +29,12 @@ function createEditor({ content }) {
|
|
|
29
29
|
}
|
|
30
30
|
],
|
|
31
31
|
defaultId: 'regular-1',
|
|
32
|
-
|
|
32
|
+
|
|
33
|
+
styleRenderer: {
|
|
34
|
+
makePresetHtmlClass: (preset) => `zw ts-${preset.id}`,
|
|
35
|
+
makePresetCssClass: (preset) => `.zw.ts-${preset.id}`,
|
|
36
|
+
render: () => ''
|
|
37
|
+
}
|
|
33
38
|
}),
|
|
34
39
|
MockFontWeight
|
|
35
40
|
]
|
|
@@ -62,7 +67,7 @@ describe('get list type', () => {
|
|
|
62
67
|
|
|
63
68
|
editor.commands.selectAll();
|
|
64
69
|
|
|
65
|
-
expect(editor.commands.getListType().value).
|
|
70
|
+
expect(editor.commands.getListType().value).toBeNull();
|
|
66
71
|
});
|
|
67
72
|
});
|
|
68
73
|
|
package/lib/models/Font.js
CHANGED
|
@@ -3,10 +3,10 @@ export class Font {
|
|
|
3
3
|
this.name = name;
|
|
4
4
|
this.category = category;
|
|
5
5
|
this.styles = styles;
|
|
6
|
-
this.weights = this
|
|
6
|
+
this.weights = this._getWeights();
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
_getWeights() {
|
|
10
10
|
const weights = this.styles.map((style) => style.replace('i', ''));
|
|
11
11
|
|
|
12
12
|
return Array.from(new Set(weights));
|
|
@@ -19,21 +19,21 @@ describe('weights', () => {
|
|
|
19
19
|
const font = new Font({ styles: ['400', '700'] });
|
|
20
20
|
const weight = font.findClosestWeight('500');
|
|
21
21
|
|
|
22
|
-
expect(weight).
|
|
22
|
+
expect(weight).toBe('400');
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
test('should find closest font weight from upper side', () => {
|
|
26
26
|
const font = new Font({ styles: ['400', '700'] });
|
|
27
27
|
const weight = font.findClosestWeight('900');
|
|
28
28
|
|
|
29
|
-
expect(weight).
|
|
29
|
+
expect(weight).toBe('700');
|
|
30
30
|
});
|
|
31
31
|
|
|
32
32
|
test('should find closest font weight from lower side', () => {
|
|
33
33
|
const font = new Font({ styles: ['400', '700'] });
|
|
34
34
|
const weight = font.findClosestWeight('200');
|
|
35
35
|
|
|
36
|
-
expect(weight).
|
|
36
|
+
expect(weight).toBe('400');
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
39
|
|
|
@@ -56,12 +56,6 @@ describe('style checks', () => {
|
|
|
56
56
|
expect(font.isItalicSupported('400')).toBe(true);
|
|
57
57
|
});
|
|
58
58
|
|
|
59
|
-
test('should detect if weight not supported', () => {
|
|
60
|
-
const font = new Font({ styles: ['400', '700'] });
|
|
61
|
-
|
|
62
|
-
expect(font.isItalicSupported('700')).toBe(false);
|
|
63
|
-
});
|
|
64
|
-
|
|
65
59
|
test('should detect italic only weight', () => {
|
|
66
60
|
const font = new Font({ styles: ['400i'] });
|
|
67
61
|
|
|
@@ -4,7 +4,7 @@ import { DOMParser } from 'prosemirror-model';
|
|
|
4
4
|
import { buildExtensions } from '../extensions';
|
|
5
5
|
import { Devices } from '../enums';
|
|
6
6
|
import { ContentNormalizer } from './normalizer';
|
|
7
|
-
import { ContextWindow } from './
|
|
7
|
+
import { ContextWindow } from './ContextWindow';
|
|
8
8
|
|
|
9
9
|
export class ContentSerializer {
|
|
10
10
|
static build({ config, nodeDomParser }) {
|
|
@@ -31,21 +31,21 @@ export class ContentSerializer {
|
|
|
31
31
|
});
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
_schema;
|
|
35
|
+
_domParser;
|
|
36
|
+
_nodeDomParser;
|
|
37
37
|
|
|
38
38
|
constructor({ schema, domParser, nodeDomParser }) {
|
|
39
|
-
this
|
|
40
|
-
this
|
|
41
|
-
this
|
|
39
|
+
this._schema = schema;
|
|
40
|
+
this._domParser = domParser;
|
|
41
|
+
this._nodeDomParser = nodeDomParser;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
toJSON(html) {
|
|
45
|
-
const normalizer = ContentNormalizer.build(html, { parser: this
|
|
45
|
+
const normalizer = ContentNormalizer.build(html, { parser: this._nodeDomParser });
|
|
46
46
|
|
|
47
47
|
normalizer.normalizeHTML();
|
|
48
48
|
|
|
49
|
-
return this
|
|
49
|
+
return this._domParser.parse(normalizer.dom.body).toJSON();
|
|
50
50
|
}
|
|
51
51
|
}
|
|
File without changes
|
|
@@ -5,13 +5,13 @@ export class HtmlToJsonParser {
|
|
|
5
5
|
return new HtmlToJsonParser(ContentSerializer.build({ config }));
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
_contentSerializer;
|
|
9
9
|
|
|
10
10
|
constructor(contentSerializer) {
|
|
11
|
-
this
|
|
11
|
+
this._contentSerializer = contentSerializer;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
toJSON(html) {
|
|
15
|
-
return this
|
|
15
|
+
return this._contentSerializer.toJSON(html);
|
|
16
16
|
}
|
|
17
17
|
}
|
|
@@ -46,7 +46,7 @@ export class NodeFactory {
|
|
|
46
46
|
* }}
|
|
47
47
|
*/
|
|
48
48
|
static listItem(...args) {
|
|
49
|
-
const { attrs, content: children, marks } = this
|
|
49
|
+
const { attrs, content: children, marks } = this._normalizeTextBlockArgs(args);
|
|
50
50
|
|
|
51
51
|
return {
|
|
52
52
|
type: NodeTypes.LIST_ITEM,
|
|
@@ -66,7 +66,7 @@ export class NodeFactory {
|
|
|
66
66
|
* }}
|
|
67
67
|
*/
|
|
68
68
|
static heading(level, ...args) {
|
|
69
|
-
const config = this
|
|
69
|
+
const config = this._textBlock(args, this.text);
|
|
70
70
|
|
|
71
71
|
config.attrs ??= {};
|
|
72
72
|
config.attrs.level = level;
|
|
@@ -84,12 +84,12 @@ export class NodeFactory {
|
|
|
84
84
|
static paragraph(...args) {
|
|
85
85
|
return {
|
|
86
86
|
type: NodeTypes.PARAGRAPH,
|
|
87
|
-
...this
|
|
87
|
+
...this._textBlock(args, this.text)
|
|
88
88
|
};
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
-
static
|
|
92
|
-
const { attrs, content, marks } = this
|
|
91
|
+
static _textBlock(args) {
|
|
92
|
+
const { attrs, content, marks } = this._normalizeTextBlockArgs(args);
|
|
93
93
|
const children = typeof content === 'string' ? [this.text(content)] : content;
|
|
94
94
|
|
|
95
95
|
return {
|
|
@@ -99,7 +99,7 @@ export class NodeFactory {
|
|
|
99
99
|
};
|
|
100
100
|
}
|
|
101
101
|
|
|
102
|
-
static
|
|
102
|
+
static _normalizeTextBlockArgs(args) {
|
|
103
103
|
if (args.length === 1) {
|
|
104
104
|
return { attrs: null, marks: null, content: args[0] };
|
|
105
105
|
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Devices } from '../enums';
|
|
2
|
+
import { ContextWindow } from './ContextWindow';
|
|
3
|
+
|
|
4
|
+
export class StylePresetRenderer {
|
|
5
|
+
_baseClass;
|
|
6
|
+
_makeVariable;
|
|
7
|
+
_linkPresetId;
|
|
8
|
+
|
|
9
|
+
constructor({ baseClass, makeVariable, linkPresetId }) {
|
|
10
|
+
this._baseClass = baseClass;
|
|
11
|
+
this._makeVariable = makeVariable;
|
|
12
|
+
this._linkPresetId = linkPresetId;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
inject(hostEl, presets) {
|
|
16
|
+
let styleEl = hostEl.querySelector('[data-zw-styles]');
|
|
17
|
+
|
|
18
|
+
if (styleEl) return;
|
|
19
|
+
|
|
20
|
+
styleEl = ContextWindow.document.createElement('style');
|
|
21
|
+
styleEl.dataset.zwStyles = '';
|
|
22
|
+
styleEl.innerHTML = this.render(presets);
|
|
23
|
+
|
|
24
|
+
hostEl.append(styleEl);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
render(presets) {
|
|
28
|
+
let css = '';
|
|
29
|
+
|
|
30
|
+
for (const preset of presets) {
|
|
31
|
+
const isLink = preset.id === this._linkPresetId;
|
|
32
|
+
const className = this.makePresetCssClass(preset);
|
|
33
|
+
|
|
34
|
+
css += ` ${className} {`;
|
|
35
|
+
|
|
36
|
+
for (const device of Devices.values) {
|
|
37
|
+
for (const setting of Object.keys(preset[device])) {
|
|
38
|
+
const variable = this._makeVariable({ device, preset, property: setting });
|
|
39
|
+
const internalVariable = this._makeInternalVariableName(setting, device);
|
|
40
|
+
|
|
41
|
+
css += `${internalVariable}: var(${variable}, inherit);`;
|
|
42
|
+
|
|
43
|
+
// Encapsulate link styles in editor from parent
|
|
44
|
+
|
|
45
|
+
if (isLink) {
|
|
46
|
+
const overrideVariable = internalVariable.replace('preset-', '');
|
|
47
|
+
|
|
48
|
+
css += `${overrideVariable}: var(${internalVariable});`;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
css += '}';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
return css;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_makeInternalVariableName(setting, device) {
|
|
60
|
+
const property = setting === 'color' ? 'font-color' : setting.replace(/_/i, '-');
|
|
61
|
+
const prefix = device === Devices.COMMON ? '' : `-${device}`;
|
|
62
|
+
|
|
63
|
+
return `--zw-preset-${property}${prefix}`;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
makePresetHtmlClass(preset) {
|
|
67
|
+
return this._baseClass + preset.id;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
makePresetCssClass(preset) {
|
|
71
|
+
return this.makePresetHtmlClass(preset).split(' ').map((part) => `.${part}`).join('');
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { StylePresetRenderer } from '../StylePresetRenderer';
|
|
2
|
+
|
|
3
|
+
function createRenderer() {
|
|
4
|
+
return new StylePresetRenderer({
|
|
5
|
+
baseClass: 'zw ts-',
|
|
6
|
+
linkPresetId: 'link',
|
|
7
|
+
|
|
8
|
+
makeVariable({ device, preset, property }) {
|
|
9
|
+
const formattedProperty = property.replace(/_/i, '-');
|
|
10
|
+
|
|
11
|
+
return `--${device}-${preset.id}-${formattedProperty}`;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const createPreset = (attrs = {}) => ({
|
|
17
|
+
id: 'regular-1',
|
|
18
|
+
common: { font_family: 'Lato' },
|
|
19
|
+
mobile: { font_size: '14' },
|
|
20
|
+
tablet: { font_size: '16' },
|
|
21
|
+
desktop: { font_size: '18' },
|
|
22
|
+
...attrs
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
describe('inject styles', () => {
|
|
26
|
+
const createHost = () => document.createElement('div');
|
|
27
|
+
|
|
28
|
+
test('should inject stylesheet', () => {
|
|
29
|
+
const renderer = createRenderer();
|
|
30
|
+
const host = createHost();
|
|
31
|
+
|
|
32
|
+
renderer.inject(host, [
|
|
33
|
+
createPreset({ id: 'regular-1' }),
|
|
34
|
+
createPreset({ id: 'regular-2' }),
|
|
35
|
+
createPreset({ id: 'regular-3' })
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
expect(host.querySelector('[data-zw-styles]')).toBeTruthy();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
test('should not inject multiple stylesheets', () => {
|
|
42
|
+
const renderer = createRenderer();
|
|
43
|
+
const host = createHost();
|
|
44
|
+
|
|
45
|
+
const presets = [
|
|
46
|
+
createPreset({ id: 'regular-1' }),
|
|
47
|
+
createPreset({ id: 'regular-2' }),
|
|
48
|
+
createPreset({ id: 'regular-3' })
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
renderer.inject(host, presets);
|
|
52
|
+
renderer.inject(host, presets);
|
|
53
|
+
|
|
54
|
+
expect(host.querySelectorAll('[data-zw-styles]')).toHaveLength(1);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
describe('render', () => {
|
|
59
|
+
test('should render preset styles', () => {
|
|
60
|
+
const renderer = createRenderer();
|
|
61
|
+
|
|
62
|
+
const css = renderer.render([
|
|
63
|
+
createPreset({ id: 'regular-1' }),
|
|
64
|
+
createPreset({ id: 'regular-2' }),
|
|
65
|
+
createPreset({ id: 'regular-3' })
|
|
66
|
+
]);
|
|
67
|
+
|
|
68
|
+
expect(css).toMatchSnapshot();
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
test('should encapsulate link preset', () => {
|
|
72
|
+
const renderer = createRenderer();
|
|
73
|
+
|
|
74
|
+
const css = renderer.render([
|
|
75
|
+
createPreset({ id: 'link' })
|
|
76
|
+
]);
|
|
77
|
+
|
|
78
|
+
expect(css).toMatchSnapshot();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe('make html preset class', () => {
|
|
83
|
+
test('should make class name', () => {
|
|
84
|
+
const renderer = createRenderer();
|
|
85
|
+
const className = renderer.makePresetHtmlClass({ id: 'link' });
|
|
86
|
+
|
|
87
|
+
expect(className).toBe('zw ts-link');
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
describe('make css preset class', () => {
|
|
92
|
+
test('should make class name', () => {
|
|
93
|
+
const renderer = createRenderer();
|
|
94
|
+
const selector = renderer.makePresetCssClass({ id: 'link' });
|
|
95
|
+
|
|
96
|
+
expect(selector).toBe('.zw.ts-link');
|
|
97
|
+
});
|
|
98
|
+
});
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`render should encapsulate link preset 1`] = `" .zw.ts-link {--zw-preset-font-family: var(--common-link-font-family, inherit);--zw-font-family: var(--zw-preset-font-family);--zw-preset-font-size-mobile: var(--mobile-link-font-size, inherit);--zw-font-size-mobile: var(--zw-preset-font-size-mobile);--zw-preset-font-size-tablet: var(--tablet-link-font-size, inherit);--zw-font-size-tablet: var(--zw-preset-font-size-tablet);--zw-preset-font-size-desktop: var(--desktop-link-font-size, inherit);--zw-font-size-desktop: var(--zw-preset-font-size-desktop);}"`;
|
|
4
|
+
|
|
5
|
+
exports[`render should render preset styles 1`] = `" .zw.ts-regular-1 {--zw-preset-font-family: var(--common-regular-1-font-family, inherit);--zw-preset-font-size-mobile: var(--mobile-regular-1-font-size, inherit);--zw-preset-font-size-tablet: var(--tablet-regular-1-font-size, inherit);--zw-preset-font-size-desktop: var(--desktop-regular-1-font-size, inherit);} .zw.ts-regular-2 {--zw-preset-font-family: var(--common-regular-2-font-family, inherit);--zw-preset-font-size-mobile: var(--mobile-regular-2-font-size, inherit);--zw-preset-font-size-tablet: var(--tablet-regular-2-font-size, inherit);--zw-preset-font-size-desktop: var(--desktop-regular-2-font-size, inherit);} .zw.ts-regular-3 {--zw-preset-font-family: var(--common-regular-3-font-family, inherit);--zw-preset-font-size-mobile: var(--mobile-regular-3-font-size, inherit);--zw-preset-font-size-tablet: var(--tablet-regular-3-font-size, inherit);--zw-preset-font-size-desktop: var(--desktop-regular-3-font-size, inherit);}"`;
|
package/lib/services/index.js
CHANGED
|
@@ -3,6 +3,7 @@ export { ContentSerializer } from './ContentSerializer';
|
|
|
3
3
|
export { Storage } from './Storage';
|
|
4
4
|
export { FavoriteColors } from './FavoriteColors';
|
|
5
5
|
export { ContentNormalizer } from './normalizer';
|
|
6
|
-
export { ContextWindow } from './
|
|
6
|
+
export { ContextWindow } from './ContextWindow';
|
|
7
7
|
export { NodeFactory } from './NodeFactory';
|
|
8
8
|
export { HtmlToJsonParser } from './HtmlToJsonParser';
|
|
9
|
+
export { StylePresetRenderer } from './StylePresetRenderer';
|
|
@@ -4,17 +4,17 @@ import { JsonNormalizer } from './JsonNormalizer';
|
|
|
4
4
|
|
|
5
5
|
export class ContentNormalizer {
|
|
6
6
|
static build(content, options = {}) {
|
|
7
|
-
return typeof content === 'string' ? this
|
|
7
|
+
return typeof content === 'string' ? this._buildHtml(content, options) : this._buildJson(content);
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
static
|
|
10
|
+
static _buildHtml(content, options) {
|
|
11
11
|
return new HtmlNormalizer({
|
|
12
12
|
content,
|
|
13
13
|
parser: options.parser || new BrowserDomParser()
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
static
|
|
17
|
+
static _buildJson(content) {
|
|
18
18
|
return new JsonNormalizer({ content });
|
|
19
19
|
}
|
|
20
20
|
|