@micromag/transforms 0.3.463 → 0.3.465
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/es/apple-news.js +242 -247
- package/lib/apple-news.js +242 -247
- package/package.json +3 -3
package/es/apple-news.js
CHANGED
|
@@ -1,12 +1,54 @@
|
|
|
1
1
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
2
|
-
import { validate as validate$1, stripTags } from '@micromag/transforms/utils';
|
|
3
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
4
3
|
import isString from 'lodash/isString';
|
|
5
4
|
import isInteger from 'lodash/isInteger';
|
|
6
5
|
import isNumber from 'lodash/isNumber';
|
|
7
6
|
import isEmpty from 'lodash/isEmpty';
|
|
7
|
+
import { validate as validate$1, stripTags } from '@micromag/transforms/utils';
|
|
8
8
|
import hash from 'object-hash';
|
|
9
9
|
|
|
10
|
+
var validate = function validate() {
|
|
11
|
+
var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
12
|
+
var definition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
13
|
+
var validated = content ? Object.keys(content).reduce(function (values, name) {
|
|
14
|
+
var value = content[name] || null;
|
|
15
|
+
// Find the reference
|
|
16
|
+
if (definition && definition.properties) {
|
|
17
|
+
var property = definition.properties.find(function (prop) {
|
|
18
|
+
return prop.name === name;
|
|
19
|
+
}) || null;
|
|
20
|
+
if (property !== null) {
|
|
21
|
+
var isValid = true;
|
|
22
|
+
switch (property.type) {
|
|
23
|
+
case 'string':
|
|
24
|
+
isValid = isString(value);
|
|
25
|
+
break;
|
|
26
|
+
case 'integer':
|
|
27
|
+
isValid = isInteger(value);
|
|
28
|
+
break;
|
|
29
|
+
case 'float':
|
|
30
|
+
isValid = isNumber(value);
|
|
31
|
+
break;
|
|
32
|
+
default:
|
|
33
|
+
isValid = value !== null;
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
// Skip the whole thing it cause it aint gonna work
|
|
37
|
+
if (!isValid && property.required) {
|
|
38
|
+
console.log('VALIDATION ERROR: SKIPPED BECAUSE REQUIRED', content, name); // eslint-disable-line
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
if (values !== null && isValid) {
|
|
42
|
+
return _objectSpread(_objectSpread({}, values), {}, _defineProperty({}, name, value));
|
|
43
|
+
}
|
|
44
|
+
console.log('VALIDATION ERROR: VALID TYPE', name, content); // eslint-disable-line
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return values;
|
|
48
|
+
}, {}) : {};
|
|
49
|
+
return !isEmpty(validated) ? validated : null;
|
|
50
|
+
};
|
|
51
|
+
|
|
10
52
|
var getArticleComponents = function getArticleComponents(story) {
|
|
11
53
|
var _ref = story || {},
|
|
12
54
|
_ref$title = _ref.title,
|
|
@@ -67,128 +109,20 @@ var getArticleComponents = function getArticleComponents(story) {
|
|
|
67
109
|
};
|
|
68
110
|
};
|
|
69
111
|
|
|
70
|
-
var name$f = "Format\\
|
|
71
|
-
var description$f = "The object for
|
|
112
|
+
var name$f = "Format\\DocumentStyle";
|
|
113
|
+
var description$f = "The object for setting the background color for your article.";
|
|
72
114
|
var version$f = "1.7+";
|
|
73
115
|
var from_class$f = null;
|
|
74
116
|
var typed$f = null;
|
|
75
|
-
var url$f = "https://developer.apple.com/documentation/apple_news/
|
|
117
|
+
var url$f = "https://developer.apple.com/documentation/apple_news/documentstyle";
|
|
76
118
|
var properties$f = [{
|
|
77
119
|
name: "backgroundColor",
|
|
78
120
|
type: "Color",
|
|
79
121
|
required: false,
|
|
80
|
-
description: "The background color
|
|
81
|
-
typed: false
|
|
82
|
-
}, {
|
|
83
|
-
name: "conditional",
|
|
84
|
-
type: "array:Format\\ConditionalTextStyle",
|
|
85
|
-
required: false,
|
|
86
|
-
description: "An array of text style properties that can be applied conditionally, and the conditions that cause them to be applied.",
|
|
87
|
-
typed: false
|
|
88
|
-
}, {
|
|
89
|
-
name: "fontFamily",
|
|
90
|
-
type: "string",
|
|
91
|
-
required: false,
|
|
92
|
-
description: "The font family to use for text rendering, for example Gill Sans. Using a combination of fontFamily, fontWeight, fontWidth and fontStyle you can define the appearance of the text. News automatically selects the appropriate font variant from the available variants in that family.",
|
|
93
|
-
typed: false
|
|
94
|
-
}, {
|
|
95
|
-
name: "fontName",
|
|
96
|
-
type: "string",
|
|
97
|
-
required: false,
|
|
98
|
-
description: "The fontName to refer to an explicit font variant’s PostScript name, such as GillSans-Bold. Alternatively, you can use a combination of fontFamily, fontWeight, fontWidth and/or fontStyle to have News automatically select the appropriate variant depending on the text formatting used.",
|
|
99
|
-
typed: false
|
|
100
|
-
}, {
|
|
101
|
-
name: "fontSize",
|
|
102
|
-
type: "integer",
|
|
103
|
-
required: false,
|
|
104
|
-
description: "The size of the font, in points. By default, the font size will be inherited from a parent component or a default style. As a best practice, try not to go below 16 points for body text. The fontSize may be automatically resized for different device sizes or for iOS devices with Larger Accessibility Sizes enabled.",
|
|
105
|
-
typed: false
|
|
106
|
-
}, {
|
|
107
|
-
name: "fontStyle",
|
|
108
|
-
type: "enum:string",
|
|
109
|
-
required: false,
|
|
110
|
-
description: "The font style to apply for the selected font.",
|
|
111
|
-
enum_values: ["normal", "italic", "oblique"],
|
|
112
|
-
typed: false
|
|
113
|
-
}, {
|
|
114
|
-
name: "fontWeight",
|
|
115
|
-
type: "enum:integer|string",
|
|
116
|
-
required: false,
|
|
117
|
-
description: "The font weight to apply for font selection. In addition to explicit weights (named or numerical), lighter and bolder are available, to set text in a lighter or bolder font as compared to its surrounding text.",
|
|
118
|
-
enum_values: [100, 200, 300, 400, 500, 600, 700, 800, 900, "thin", "extra-light", "extralight", "ultra-light", "light", "regular", "normal", "book", "roman", "medium", "semi-bold", "semibold", "demi-bold", "demibold", "bold", "extra-bold", "extrabold", "ultra-bold", "ultrabold", "black", "heavy", "lighter", "bolder"],
|
|
119
|
-
typed: false
|
|
120
|
-
}, {
|
|
121
|
-
name: "fontWidth",
|
|
122
|
-
type: "enum:string",
|
|
123
|
-
required: false,
|
|
124
|
-
description: "The font width for font selection (known in CSS as font-stretch). Defines the width characteristics of a font variant between normal, condensed and expanded. Some font families have separate families assigned for different widths (for example, Avenir Next and Avenir Next Condensed), so make sure that the fontFamily you select supports the specified fontWidth.",
|
|
125
|
-
enum_values: ["ultra-condensed", "extra-condensed", "condensed", "semi-condensed", "normal", "semi-expanded", "expanded", "extra-expanded", "ultra-expanded"],
|
|
126
|
-
typed: false
|
|
127
|
-
}, {
|
|
128
|
-
name: "orderedListItems",
|
|
129
|
-
type: "Format\\ListItemStyle",
|
|
130
|
-
required: false,
|
|
131
|
-
description: "An object for use with text components with HTML markup. You can create text styles containing an orderedListItems definition to configure how list items inside <ol> tags should be displayed.",
|
|
132
|
-
typed: false
|
|
133
|
-
}, {
|
|
134
|
-
name: "strikethrough",
|
|
135
|
-
type: ["Format\\TextDecoration", "boolean"],
|
|
136
|
-
required: false,
|
|
137
|
-
description: "The text strikethrough. Set strikethrough to true to use the text color inherited from the textColor property as the strikethrough color, or provide a text decoration definition with a different color. By default strikethrough is omitted (false).",
|
|
138
|
-
typed: false
|
|
139
|
-
}, {
|
|
140
|
-
name: "stroke",
|
|
141
|
-
type: "Format\\TextStrokeStyle",
|
|
142
|
-
required: false,
|
|
143
|
-
description: "The stroke style for the text outline. By default, stroke will be omitted.",
|
|
144
|
-
typed: false
|
|
145
|
-
}, {
|
|
146
|
-
name: "textColor",
|
|
147
|
-
type: "Color",
|
|
148
|
-
required: false,
|
|
149
|
-
description: "The text color.",
|
|
150
|
-
typed: false
|
|
151
|
-
}, {
|
|
152
|
-
name: "textShadow",
|
|
153
|
-
type: "Format\\Shadow",
|
|
154
|
-
required: false,
|
|
155
|
-
description: "The text shadow for this style.",
|
|
156
|
-
typed: false
|
|
157
|
-
}, {
|
|
158
|
-
name: "textTransform",
|
|
159
|
-
type: "enum:string",
|
|
160
|
-
required: false,
|
|
161
|
-
description: "The transform to apply to the text.",
|
|
162
|
-
enum_values: ["uppercase", "lowercase", "capitalize", "none"],
|
|
163
|
-
typed: false
|
|
164
|
-
}, {
|
|
165
|
-
name: "tracking",
|
|
166
|
-
type: "number",
|
|
167
|
-
required: false,
|
|
168
|
-
description: "The amount of tracking (spacing between characters) in text, as a percentage of the fontSize. The actual spacing between letters is determined by combining information from the font and font size.",
|
|
169
|
-
"default": 0,
|
|
170
|
-
typed: false
|
|
171
|
-
}, {
|
|
172
|
-
name: "underline",
|
|
173
|
-
type: ["Format\\TextDecoration", "boolean"],
|
|
174
|
-
required: false,
|
|
175
|
-
description: "The text underlining. This style can be used for links. Set underline to true to use the text color as the underline color, or provide a text decoration with a different color. By default underline is omitted (false).",
|
|
176
|
-
typed: false
|
|
177
|
-
}, {
|
|
178
|
-
name: "unorderedListItems",
|
|
179
|
-
type: "Format\\ListItemStyle",
|
|
180
|
-
required: false,
|
|
181
|
-
description: "An object for use with text components with HTML markup. You can create text styles containing an unorderedListItems definition to configure how list items inside <ul> tags should be displayed.",
|
|
182
|
-
typed: false
|
|
183
|
-
}, {
|
|
184
|
-
name: "verticalAlignment",
|
|
185
|
-
type: "enum:string",
|
|
186
|
-
required: false,
|
|
187
|
-
description: "The vertical alignment of the text. You can use this property for superscripts and subscripts.",
|
|
188
|
-
enum_values: ["superscript", "subscript", "baseline"],
|
|
122
|
+
description: "The article’s background color. The value defaults to white.",
|
|
189
123
|
typed: false
|
|
190
124
|
}];
|
|
191
|
-
var
|
|
125
|
+
var DocumentStyleDefinition = {
|
|
192
126
|
name: name$f,
|
|
193
127
|
description: description$f,
|
|
194
128
|
version: version$f,
|
|
@@ -199,85 +133,22 @@ var TextStyleDefinition = {
|
|
|
199
133
|
properties: properties$f
|
|
200
134
|
};
|
|
201
135
|
|
|
202
|
-
var
|
|
136
|
+
var DocumentStyle = function DocumentStyle() {
|
|
203
137
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
204
|
-
_ref$
|
|
205
|
-
|
|
206
|
-
_ref$fontSize = _ref.fontSize,
|
|
207
|
-
fontSize = _ref$fontSize === void 0 ? null : _ref$fontSize,
|
|
208
|
-
_ref$lineHeight = _ref.lineHeight,
|
|
209
|
-
lineHeight = _ref$lineHeight === void 0 ? null : _ref$lineHeight,
|
|
210
|
-
_ref$color = _ref.color,
|
|
211
|
-
color = _ref$color === void 0 ? null : _ref$color;
|
|
138
|
+
_ref$backgroundColor = _ref.backgroundColor,
|
|
139
|
+
backgroundColor = _ref$backgroundColor === void 0 ? null : _ref$backgroundColor;
|
|
212
140
|
var content = {
|
|
213
|
-
|
|
214
|
-
fontSize: fontSize,
|
|
215
|
-
lineHeight: lineHeight ? Math.floor(fontSize * lineHeight) : null,
|
|
216
|
-
textColor: color && color.color ? color.color : null
|
|
141
|
+
backgroundColor: backgroundColor
|
|
217
142
|
};
|
|
218
|
-
return validate$1(content,
|
|
143
|
+
return validate$1(content, DocumentStyleDefinition);
|
|
219
144
|
};
|
|
220
145
|
|
|
221
|
-
var
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
// const { heading1 = {}, text = {} } = textStyle || {};
|
|
225
|
-
|
|
226
|
-
// const titleStyles = TextStyle(heading1);
|
|
227
|
-
// const textStyles = TextStyle(text);
|
|
228
|
-
|
|
229
|
-
var fontSize = 18;
|
|
230
|
-
var lineHeight = 1.35;
|
|
231
|
-
var titleStyles = TextStyle({
|
|
232
|
-
fontFamily: 'Futura',
|
|
233
|
-
// stylelint-disable-line
|
|
234
|
-
fontSize: fontSize * 2,
|
|
235
|
-
fontWeight: 'bold',
|
|
236
|
-
lineHeight: lineHeight
|
|
237
|
-
});
|
|
238
|
-
var textStyles = TextStyle({
|
|
239
|
-
fontFamily: 'Palatino',
|
|
240
|
-
// stylelint-disable-line
|
|
241
|
-
fontSize: fontSize,
|
|
242
|
-
lineHeight: lineHeight
|
|
146
|
+
var getArticleDocumentStyle = function getArticleDocumentStyle() {
|
|
147
|
+
var documentStyle = DocumentStyle({
|
|
148
|
+
backgroundColor: '#FFF'
|
|
243
149
|
});
|
|
244
150
|
return {
|
|
245
|
-
|
|
246
|
-
"default": _objectSpread({
|
|
247
|
-
textColor: '#000',
|
|
248
|
-
linkStyle: {
|
|
249
|
-
textColor: '#F0F',
|
|
250
|
-
underline: true
|
|
251
|
-
}
|
|
252
|
-
}, textStyles !== null ? textStyles : {}),
|
|
253
|
-
'default-heading1': _objectSpread(_objectSpread({}, titleStyles !== null ? titleStyles : {}), {}, {
|
|
254
|
-
fontSize: fontSize * 2,
|
|
255
|
-
lineHeight: 36,
|
|
256
|
-
fontWeight: 'regular',
|
|
257
|
-
fontWidth: 'expanded',
|
|
258
|
-
textTransform: 'uppercase'
|
|
259
|
-
}),
|
|
260
|
-
'default-heading2': _objectSpread(_objectSpread({}, titleStyles !== null ? titleStyles : {}), {}, {
|
|
261
|
-
fontSize: 26,
|
|
262
|
-
fontWeight: 'regular',
|
|
263
|
-
fontWidth: 'expanded',
|
|
264
|
-
textTransform: 'uppercase'
|
|
265
|
-
}),
|
|
266
|
-
'default-title': _objectSpread(_objectSpread({}, titleStyles !== null ? titleStyles : {}), {}, {
|
|
267
|
-
fontSize: 26,
|
|
268
|
-
fontWeight: 'regular',
|
|
269
|
-
fontWidth: 'expanded',
|
|
270
|
-
textTransform: 'uppercase'
|
|
271
|
-
}),
|
|
272
|
-
'default-body': _objectSpread({}, textStyles !== null ? textStyles : {}),
|
|
273
|
-
'default-text': _objectSpread({}, textStyles !== null ? textStyles : {}),
|
|
274
|
-
'default-quote': _objectSpread(_objectSpread({}, textStyles !== null ? textStyles : {}), {}, {
|
|
275
|
-
fontSize: 26
|
|
276
|
-
}),
|
|
277
|
-
'style-author': _objectSpread(_objectSpread({}, textStyles !== null ? textStyles : {}), {}, {
|
|
278
|
-
fontStyle: 'italic'
|
|
279
|
-
})
|
|
280
|
-
}
|
|
151
|
+
documentStyle: documentStyle
|
|
281
152
|
};
|
|
282
153
|
};
|
|
283
154
|
|
|
@@ -566,20 +437,128 @@ var getArticleLayouts = function getArticleLayouts() {
|
|
|
566
437
|
};
|
|
567
438
|
};
|
|
568
439
|
|
|
569
|
-
var name$c = "Format\\
|
|
570
|
-
var description$c = "The object for
|
|
440
|
+
var name$c = "Format\\TextStyle";
|
|
441
|
+
var description$c = "The object for defining the text style (font family, size, color, and so on) that you can apply to ranges of text.";
|
|
571
442
|
var version$c = "1.7+";
|
|
572
443
|
var from_class$c = null;
|
|
573
444
|
var typed$c = null;
|
|
574
|
-
var url$c = "https://developer.apple.com/documentation/apple_news/
|
|
445
|
+
var url$c = "https://developer.apple.com/documentation/apple_news/textstyle";
|
|
575
446
|
var properties$c = [{
|
|
576
447
|
name: "backgroundColor",
|
|
577
448
|
type: "Color",
|
|
578
449
|
required: false,
|
|
579
|
-
description: "The
|
|
450
|
+
description: "The background color for text lines. The value defaults to transparent.",
|
|
451
|
+
typed: false
|
|
452
|
+
}, {
|
|
453
|
+
name: "conditional",
|
|
454
|
+
type: "array:Format\\ConditionalTextStyle",
|
|
455
|
+
required: false,
|
|
456
|
+
description: "An array of text style properties that can be applied conditionally, and the conditions that cause them to be applied.",
|
|
457
|
+
typed: false
|
|
458
|
+
}, {
|
|
459
|
+
name: "fontFamily",
|
|
460
|
+
type: "string",
|
|
461
|
+
required: false,
|
|
462
|
+
description: "The font family to use for text rendering, for example Gill Sans. Using a combination of fontFamily, fontWeight, fontWidth and fontStyle you can define the appearance of the text. News automatically selects the appropriate font variant from the available variants in that family.",
|
|
463
|
+
typed: false
|
|
464
|
+
}, {
|
|
465
|
+
name: "fontName",
|
|
466
|
+
type: "string",
|
|
467
|
+
required: false,
|
|
468
|
+
description: "The fontName to refer to an explicit font variant’s PostScript name, such as GillSans-Bold. Alternatively, you can use a combination of fontFamily, fontWeight, fontWidth and/or fontStyle to have News automatically select the appropriate variant depending on the text formatting used.",
|
|
469
|
+
typed: false
|
|
470
|
+
}, {
|
|
471
|
+
name: "fontSize",
|
|
472
|
+
type: "integer",
|
|
473
|
+
required: false,
|
|
474
|
+
description: "The size of the font, in points. By default, the font size will be inherited from a parent component or a default style. As a best practice, try not to go below 16 points for body text. The fontSize may be automatically resized for different device sizes or for iOS devices with Larger Accessibility Sizes enabled.",
|
|
475
|
+
typed: false
|
|
476
|
+
}, {
|
|
477
|
+
name: "fontStyle",
|
|
478
|
+
type: "enum:string",
|
|
479
|
+
required: false,
|
|
480
|
+
description: "The font style to apply for the selected font.",
|
|
481
|
+
enum_values: ["normal", "italic", "oblique"],
|
|
482
|
+
typed: false
|
|
483
|
+
}, {
|
|
484
|
+
name: "fontWeight",
|
|
485
|
+
type: "enum:integer|string",
|
|
486
|
+
required: false,
|
|
487
|
+
description: "The font weight to apply for font selection. In addition to explicit weights (named or numerical), lighter and bolder are available, to set text in a lighter or bolder font as compared to its surrounding text.",
|
|
488
|
+
enum_values: [100, 200, 300, 400, 500, 600, 700, 800, 900, "thin", "extra-light", "extralight", "ultra-light", "light", "regular", "normal", "book", "roman", "medium", "semi-bold", "semibold", "demi-bold", "demibold", "bold", "extra-bold", "extrabold", "ultra-bold", "ultrabold", "black", "heavy", "lighter", "bolder"],
|
|
489
|
+
typed: false
|
|
490
|
+
}, {
|
|
491
|
+
name: "fontWidth",
|
|
492
|
+
type: "enum:string",
|
|
493
|
+
required: false,
|
|
494
|
+
description: "The font width for font selection (known in CSS as font-stretch). Defines the width characteristics of a font variant between normal, condensed and expanded. Some font families have separate families assigned for different widths (for example, Avenir Next and Avenir Next Condensed), so make sure that the fontFamily you select supports the specified fontWidth.",
|
|
495
|
+
enum_values: ["ultra-condensed", "extra-condensed", "condensed", "semi-condensed", "normal", "semi-expanded", "expanded", "extra-expanded", "ultra-expanded"],
|
|
496
|
+
typed: false
|
|
497
|
+
}, {
|
|
498
|
+
name: "orderedListItems",
|
|
499
|
+
type: "Format\\ListItemStyle",
|
|
500
|
+
required: false,
|
|
501
|
+
description: "An object for use with text components with HTML markup. You can create text styles containing an orderedListItems definition to configure how list items inside <ol> tags should be displayed.",
|
|
502
|
+
typed: false
|
|
503
|
+
}, {
|
|
504
|
+
name: "strikethrough",
|
|
505
|
+
type: ["Format\\TextDecoration", "boolean"],
|
|
506
|
+
required: false,
|
|
507
|
+
description: "The text strikethrough. Set strikethrough to true to use the text color inherited from the textColor property as the strikethrough color, or provide a text decoration definition with a different color. By default strikethrough is omitted (false).",
|
|
508
|
+
typed: false
|
|
509
|
+
}, {
|
|
510
|
+
name: "stroke",
|
|
511
|
+
type: "Format\\TextStrokeStyle",
|
|
512
|
+
required: false,
|
|
513
|
+
description: "The stroke style for the text outline. By default, stroke will be omitted.",
|
|
514
|
+
typed: false
|
|
515
|
+
}, {
|
|
516
|
+
name: "textColor",
|
|
517
|
+
type: "Color",
|
|
518
|
+
required: false,
|
|
519
|
+
description: "The text color.",
|
|
520
|
+
typed: false
|
|
521
|
+
}, {
|
|
522
|
+
name: "textShadow",
|
|
523
|
+
type: "Format\\Shadow",
|
|
524
|
+
required: false,
|
|
525
|
+
description: "The text shadow for this style.",
|
|
526
|
+
typed: false
|
|
527
|
+
}, {
|
|
528
|
+
name: "textTransform",
|
|
529
|
+
type: "enum:string",
|
|
530
|
+
required: false,
|
|
531
|
+
description: "The transform to apply to the text.",
|
|
532
|
+
enum_values: ["uppercase", "lowercase", "capitalize", "none"],
|
|
533
|
+
typed: false
|
|
534
|
+
}, {
|
|
535
|
+
name: "tracking",
|
|
536
|
+
type: "number",
|
|
537
|
+
required: false,
|
|
538
|
+
description: "The amount of tracking (spacing between characters) in text, as a percentage of the fontSize. The actual spacing between letters is determined by combining information from the font and font size.",
|
|
539
|
+
"default": 0,
|
|
540
|
+
typed: false
|
|
541
|
+
}, {
|
|
542
|
+
name: "underline",
|
|
543
|
+
type: ["Format\\TextDecoration", "boolean"],
|
|
544
|
+
required: false,
|
|
545
|
+
description: "The text underlining. This style can be used for links. Set underline to true to use the text color as the underline color, or provide a text decoration with a different color. By default underline is omitted (false).",
|
|
546
|
+
typed: false
|
|
547
|
+
}, {
|
|
548
|
+
name: "unorderedListItems",
|
|
549
|
+
type: "Format\\ListItemStyle",
|
|
550
|
+
required: false,
|
|
551
|
+
description: "An object for use with text components with HTML markup. You can create text styles containing an unorderedListItems definition to configure how list items inside <ul> tags should be displayed.",
|
|
552
|
+
typed: false
|
|
553
|
+
}, {
|
|
554
|
+
name: "verticalAlignment",
|
|
555
|
+
type: "enum:string",
|
|
556
|
+
required: false,
|
|
557
|
+
description: "The vertical alignment of the text. You can use this property for superscripts and subscripts.",
|
|
558
|
+
enum_values: ["superscript", "subscript", "baseline"],
|
|
580
559
|
typed: false
|
|
581
560
|
}];
|
|
582
|
-
var
|
|
561
|
+
var TextStyleDefinition = {
|
|
583
562
|
name: name$c,
|
|
584
563
|
description: description$c,
|
|
585
564
|
version: version$c,
|
|
@@ -590,22 +569,85 @@ var DocumentStyleDefinition = {
|
|
|
590
569
|
properties: properties$c
|
|
591
570
|
};
|
|
592
571
|
|
|
593
|
-
var
|
|
572
|
+
var TextStyle = function TextStyle() {
|
|
594
573
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
595
|
-
_ref$
|
|
596
|
-
|
|
574
|
+
_ref$fontFamily = _ref.fontFamily,
|
|
575
|
+
fontFamily = _ref$fontFamily === void 0 ? null : _ref$fontFamily,
|
|
576
|
+
_ref$fontSize = _ref.fontSize,
|
|
577
|
+
fontSize = _ref$fontSize === void 0 ? null : _ref$fontSize,
|
|
578
|
+
_ref$lineHeight = _ref.lineHeight,
|
|
579
|
+
lineHeight = _ref$lineHeight === void 0 ? null : _ref$lineHeight,
|
|
580
|
+
_ref$color = _ref.color,
|
|
581
|
+
color = _ref$color === void 0 ? null : _ref$color;
|
|
597
582
|
var content = {
|
|
598
|
-
|
|
583
|
+
fontFamily: fontFamily,
|
|
584
|
+
fontSize: fontSize,
|
|
585
|
+
lineHeight: lineHeight ? Math.floor(fontSize * lineHeight) : null,
|
|
586
|
+
textColor: color && color.color ? color.color : null
|
|
599
587
|
};
|
|
600
|
-
return validate$1(content,
|
|
588
|
+
return validate$1(content, TextStyleDefinition);
|
|
601
589
|
};
|
|
602
590
|
|
|
603
|
-
var
|
|
604
|
-
|
|
605
|
-
|
|
591
|
+
var getArticleTextStyles = function getArticleTextStyles() {
|
|
592
|
+
// const { theme = {} } = story || {};
|
|
593
|
+
// const { textStyle = {} } = theme || {};
|
|
594
|
+
// const { heading1 = {}, text = {} } = textStyle || {};
|
|
595
|
+
|
|
596
|
+
// const titleStyles = TextStyle(heading1);
|
|
597
|
+
// const textStyles = TextStyle(text);
|
|
598
|
+
|
|
599
|
+
var fontSize = 18;
|
|
600
|
+
var lineHeight = 1.35;
|
|
601
|
+
var titleStyles = TextStyle({
|
|
602
|
+
fontFamily: 'Futura',
|
|
603
|
+
// stylelint-disable-line
|
|
604
|
+
fontSize: fontSize * 2,
|
|
605
|
+
fontWeight: 'bold',
|
|
606
|
+
lineHeight: lineHeight
|
|
607
|
+
});
|
|
608
|
+
var textStyles = TextStyle({
|
|
609
|
+
fontFamily: 'Palatino',
|
|
610
|
+
// stylelint-disable-line
|
|
611
|
+
fontSize: fontSize,
|
|
612
|
+
lineHeight: lineHeight
|
|
606
613
|
});
|
|
607
614
|
return {
|
|
608
|
-
|
|
615
|
+
componentTextStyles: {
|
|
616
|
+
"default": _objectSpread({
|
|
617
|
+
textColor: '#000',
|
|
618
|
+
linkStyle: {
|
|
619
|
+
textColor: '#F0F',
|
|
620
|
+
underline: true
|
|
621
|
+
}
|
|
622
|
+
}, textStyles !== null ? textStyles : {}),
|
|
623
|
+
'default-heading1': _objectSpread(_objectSpread({}, titleStyles !== null ? titleStyles : {}), {}, {
|
|
624
|
+
fontSize: fontSize * 2,
|
|
625
|
+
lineHeight: 36,
|
|
626
|
+
fontWeight: 'regular',
|
|
627
|
+
fontWidth: 'expanded',
|
|
628
|
+
textTransform: 'uppercase'
|
|
629
|
+
}),
|
|
630
|
+
'default-heading2': _objectSpread(_objectSpread({}, titleStyles !== null ? titleStyles : {}), {}, {
|
|
631
|
+
fontSize: 26,
|
|
632
|
+
fontWeight: 'regular',
|
|
633
|
+
fontWidth: 'expanded',
|
|
634
|
+
textTransform: 'uppercase'
|
|
635
|
+
}),
|
|
636
|
+
'default-title': _objectSpread(_objectSpread({}, titleStyles !== null ? titleStyles : {}), {}, {
|
|
637
|
+
fontSize: 26,
|
|
638
|
+
fontWeight: 'regular',
|
|
639
|
+
fontWidth: 'expanded',
|
|
640
|
+
textTransform: 'uppercase'
|
|
641
|
+
}),
|
|
642
|
+
'default-body': _objectSpread({}, textStyles !== null ? textStyles : {}),
|
|
643
|
+
'default-text': _objectSpread({}, textStyles !== null ? textStyles : {}),
|
|
644
|
+
'default-quote': _objectSpread(_objectSpread({}, textStyles !== null ? textStyles : {}), {}, {
|
|
645
|
+
fontSize: 26
|
|
646
|
+
}),
|
|
647
|
+
'style-author': _objectSpread(_objectSpread({}, textStyles !== null ? textStyles : {}), {}, {
|
|
648
|
+
fontStyle: 'italic'
|
|
649
|
+
})
|
|
650
|
+
}
|
|
609
651
|
};
|
|
610
652
|
};
|
|
611
653
|
|
|
@@ -717,51 +759,7 @@ var ArticleDefinition = {
|
|
|
717
759
|
properties: properties$b
|
|
718
760
|
};
|
|
719
761
|
|
|
720
|
-
var validate = function validate() {
|
|
721
|
-
var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
722
|
-
var definition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
723
|
-
var validated = content ? Object.keys(content).reduce(function (values, name) {
|
|
724
|
-
var value = content[name] || null;
|
|
725
|
-
// Find the reference
|
|
726
|
-
if (definition && definition.properties) {
|
|
727
|
-
var property = definition.properties.find(function (prop) {
|
|
728
|
-
return prop.name === name;
|
|
729
|
-
}) || null;
|
|
730
|
-
if (property !== null) {
|
|
731
|
-
var isValid = true;
|
|
732
|
-
switch (property.type) {
|
|
733
|
-
case 'string':
|
|
734
|
-
isValid = isString(value);
|
|
735
|
-
break;
|
|
736
|
-
case 'integer':
|
|
737
|
-
isValid = isInteger(value);
|
|
738
|
-
break;
|
|
739
|
-
case 'float':
|
|
740
|
-
isValid = isNumber(value);
|
|
741
|
-
break;
|
|
742
|
-
default:
|
|
743
|
-
isValid = value !== null;
|
|
744
|
-
break;
|
|
745
|
-
}
|
|
746
|
-
// Skip the whole thing it cause it aint gonna work
|
|
747
|
-
if (!isValid && property.required) {
|
|
748
|
-
console.log('VALIDATION ERROR: SKIPPED BECAUSE REQUIRED', content, name); // eslint-disable-line
|
|
749
|
-
return null;
|
|
750
|
-
}
|
|
751
|
-
if (values !== null && isValid) {
|
|
752
|
-
return _objectSpread(_objectSpread({}, values), {}, _defineProperty({}, name, value));
|
|
753
|
-
}
|
|
754
|
-
console.log('VALIDATION ERROR: VALID TYPE', name, content); // eslint-disable-line
|
|
755
|
-
}
|
|
756
|
-
}
|
|
757
|
-
return values;
|
|
758
|
-
}, {}) : {};
|
|
759
|
-
return !isEmpty(validated) ? validated : null;
|
|
760
|
-
};
|
|
761
|
-
|
|
762
762
|
var Article = function Article(story, settings) {
|
|
763
|
-
// console.log('ARTICLE', story); // eslint-disable-line
|
|
764
|
-
|
|
765
763
|
var _story$title = story.title,
|
|
766
764
|
title = _story$title === void 0 ? 'Article' : _story$title;
|
|
767
765
|
var _ref = settings || {},
|
|
@@ -780,9 +778,6 @@ var Article = function Article(story, settings) {
|
|
|
780
778
|
componentTextStyles: {},
|
|
781
779
|
componentLayouts: {}
|
|
782
780
|
}, getArticleDocumentStyle()), getArticleTextStyles()), getArticleLayouts()), getArticleComponents(story));
|
|
783
|
-
|
|
784
|
-
// console.log('KONTENT', content);
|
|
785
|
-
|
|
786
781
|
return validate(content, ArticleDefinition);
|
|
787
782
|
};
|
|
788
783
|
|
package/lib/apple-news.js
CHANGED
|
@@ -1,14 +1,56 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
4
|
-
var utils = require('@micromag/transforms/utils');
|
|
5
4
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
6
5
|
var isString = require('lodash/isString');
|
|
7
6
|
var isInteger = require('lodash/isInteger');
|
|
8
7
|
var isNumber = require('lodash/isNumber');
|
|
9
8
|
var isEmpty = require('lodash/isEmpty');
|
|
9
|
+
var utils = require('@micromag/transforms/utils');
|
|
10
10
|
var hash = require('object-hash');
|
|
11
11
|
|
|
12
|
+
var validate = function validate() {
|
|
13
|
+
var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
14
|
+
var definition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
15
|
+
var validated = content ? Object.keys(content).reduce(function (values, name) {
|
|
16
|
+
var value = content[name] || null;
|
|
17
|
+
// Find the reference
|
|
18
|
+
if (definition && definition.properties) {
|
|
19
|
+
var property = definition.properties.find(function (prop) {
|
|
20
|
+
return prop.name === name;
|
|
21
|
+
}) || null;
|
|
22
|
+
if (property !== null) {
|
|
23
|
+
var isValid = true;
|
|
24
|
+
switch (property.type) {
|
|
25
|
+
case 'string':
|
|
26
|
+
isValid = isString(value);
|
|
27
|
+
break;
|
|
28
|
+
case 'integer':
|
|
29
|
+
isValid = isInteger(value);
|
|
30
|
+
break;
|
|
31
|
+
case 'float':
|
|
32
|
+
isValid = isNumber(value);
|
|
33
|
+
break;
|
|
34
|
+
default:
|
|
35
|
+
isValid = value !== null;
|
|
36
|
+
break;
|
|
37
|
+
}
|
|
38
|
+
// Skip the whole thing it cause it aint gonna work
|
|
39
|
+
if (!isValid && property.required) {
|
|
40
|
+
console.log('VALIDATION ERROR: SKIPPED BECAUSE REQUIRED', content, name); // eslint-disable-line
|
|
41
|
+
return null;
|
|
42
|
+
}
|
|
43
|
+
if (values !== null && isValid) {
|
|
44
|
+
return _objectSpread(_objectSpread({}, values), {}, _defineProperty({}, name, value));
|
|
45
|
+
}
|
|
46
|
+
console.log('VALIDATION ERROR: VALID TYPE', name, content); // eslint-disable-line
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return values;
|
|
50
|
+
}, {}) : {};
|
|
51
|
+
return !isEmpty(validated) ? validated : null;
|
|
52
|
+
};
|
|
53
|
+
|
|
12
54
|
var getArticleComponents = function getArticleComponents(story) {
|
|
13
55
|
var _ref = story || {},
|
|
14
56
|
_ref$title = _ref.title,
|
|
@@ -69,128 +111,20 @@ var getArticleComponents = function getArticleComponents(story) {
|
|
|
69
111
|
};
|
|
70
112
|
};
|
|
71
113
|
|
|
72
|
-
var name$f = "Format\\
|
|
73
|
-
var description$f = "The object for
|
|
114
|
+
var name$f = "Format\\DocumentStyle";
|
|
115
|
+
var description$f = "The object for setting the background color for your article.";
|
|
74
116
|
var version$f = "1.7+";
|
|
75
117
|
var from_class$f = null;
|
|
76
118
|
var typed$f = null;
|
|
77
|
-
var url$f = "https://developer.apple.com/documentation/apple_news/
|
|
119
|
+
var url$f = "https://developer.apple.com/documentation/apple_news/documentstyle";
|
|
78
120
|
var properties$f = [{
|
|
79
121
|
name: "backgroundColor",
|
|
80
122
|
type: "Color",
|
|
81
123
|
required: false,
|
|
82
|
-
description: "The background color
|
|
83
|
-
typed: false
|
|
84
|
-
}, {
|
|
85
|
-
name: "conditional",
|
|
86
|
-
type: "array:Format\\ConditionalTextStyle",
|
|
87
|
-
required: false,
|
|
88
|
-
description: "An array of text style properties that can be applied conditionally, and the conditions that cause them to be applied.",
|
|
89
|
-
typed: false
|
|
90
|
-
}, {
|
|
91
|
-
name: "fontFamily",
|
|
92
|
-
type: "string",
|
|
93
|
-
required: false,
|
|
94
|
-
description: "The font family to use for text rendering, for example Gill Sans. Using a combination of fontFamily, fontWeight, fontWidth and fontStyle you can define the appearance of the text. News automatically selects the appropriate font variant from the available variants in that family.",
|
|
95
|
-
typed: false
|
|
96
|
-
}, {
|
|
97
|
-
name: "fontName",
|
|
98
|
-
type: "string",
|
|
99
|
-
required: false,
|
|
100
|
-
description: "The fontName to refer to an explicit font variant’s PostScript name, such as GillSans-Bold. Alternatively, you can use a combination of fontFamily, fontWeight, fontWidth and/or fontStyle to have News automatically select the appropriate variant depending on the text formatting used.",
|
|
101
|
-
typed: false
|
|
102
|
-
}, {
|
|
103
|
-
name: "fontSize",
|
|
104
|
-
type: "integer",
|
|
105
|
-
required: false,
|
|
106
|
-
description: "The size of the font, in points. By default, the font size will be inherited from a parent component or a default style. As a best practice, try not to go below 16 points for body text. The fontSize may be automatically resized for different device sizes or for iOS devices with Larger Accessibility Sizes enabled.",
|
|
107
|
-
typed: false
|
|
108
|
-
}, {
|
|
109
|
-
name: "fontStyle",
|
|
110
|
-
type: "enum:string",
|
|
111
|
-
required: false,
|
|
112
|
-
description: "The font style to apply for the selected font.",
|
|
113
|
-
enum_values: ["normal", "italic", "oblique"],
|
|
114
|
-
typed: false
|
|
115
|
-
}, {
|
|
116
|
-
name: "fontWeight",
|
|
117
|
-
type: "enum:integer|string",
|
|
118
|
-
required: false,
|
|
119
|
-
description: "The font weight to apply for font selection. In addition to explicit weights (named or numerical), lighter and bolder are available, to set text in a lighter or bolder font as compared to its surrounding text.",
|
|
120
|
-
enum_values: [100, 200, 300, 400, 500, 600, 700, 800, 900, "thin", "extra-light", "extralight", "ultra-light", "light", "regular", "normal", "book", "roman", "medium", "semi-bold", "semibold", "demi-bold", "demibold", "bold", "extra-bold", "extrabold", "ultra-bold", "ultrabold", "black", "heavy", "lighter", "bolder"],
|
|
121
|
-
typed: false
|
|
122
|
-
}, {
|
|
123
|
-
name: "fontWidth",
|
|
124
|
-
type: "enum:string",
|
|
125
|
-
required: false,
|
|
126
|
-
description: "The font width for font selection (known in CSS as font-stretch). Defines the width characteristics of a font variant between normal, condensed and expanded. Some font families have separate families assigned for different widths (for example, Avenir Next and Avenir Next Condensed), so make sure that the fontFamily you select supports the specified fontWidth.",
|
|
127
|
-
enum_values: ["ultra-condensed", "extra-condensed", "condensed", "semi-condensed", "normal", "semi-expanded", "expanded", "extra-expanded", "ultra-expanded"],
|
|
128
|
-
typed: false
|
|
129
|
-
}, {
|
|
130
|
-
name: "orderedListItems",
|
|
131
|
-
type: "Format\\ListItemStyle",
|
|
132
|
-
required: false,
|
|
133
|
-
description: "An object for use with text components with HTML markup. You can create text styles containing an orderedListItems definition to configure how list items inside <ol> tags should be displayed.",
|
|
134
|
-
typed: false
|
|
135
|
-
}, {
|
|
136
|
-
name: "strikethrough",
|
|
137
|
-
type: ["Format\\TextDecoration", "boolean"],
|
|
138
|
-
required: false,
|
|
139
|
-
description: "The text strikethrough. Set strikethrough to true to use the text color inherited from the textColor property as the strikethrough color, or provide a text decoration definition with a different color. By default strikethrough is omitted (false).",
|
|
140
|
-
typed: false
|
|
141
|
-
}, {
|
|
142
|
-
name: "stroke",
|
|
143
|
-
type: "Format\\TextStrokeStyle",
|
|
144
|
-
required: false,
|
|
145
|
-
description: "The stroke style for the text outline. By default, stroke will be omitted.",
|
|
146
|
-
typed: false
|
|
147
|
-
}, {
|
|
148
|
-
name: "textColor",
|
|
149
|
-
type: "Color",
|
|
150
|
-
required: false,
|
|
151
|
-
description: "The text color.",
|
|
152
|
-
typed: false
|
|
153
|
-
}, {
|
|
154
|
-
name: "textShadow",
|
|
155
|
-
type: "Format\\Shadow",
|
|
156
|
-
required: false,
|
|
157
|
-
description: "The text shadow for this style.",
|
|
158
|
-
typed: false
|
|
159
|
-
}, {
|
|
160
|
-
name: "textTransform",
|
|
161
|
-
type: "enum:string",
|
|
162
|
-
required: false,
|
|
163
|
-
description: "The transform to apply to the text.",
|
|
164
|
-
enum_values: ["uppercase", "lowercase", "capitalize", "none"],
|
|
165
|
-
typed: false
|
|
166
|
-
}, {
|
|
167
|
-
name: "tracking",
|
|
168
|
-
type: "number",
|
|
169
|
-
required: false,
|
|
170
|
-
description: "The amount of tracking (spacing between characters) in text, as a percentage of the fontSize. The actual spacing between letters is determined by combining information from the font and font size.",
|
|
171
|
-
"default": 0,
|
|
172
|
-
typed: false
|
|
173
|
-
}, {
|
|
174
|
-
name: "underline",
|
|
175
|
-
type: ["Format\\TextDecoration", "boolean"],
|
|
176
|
-
required: false,
|
|
177
|
-
description: "The text underlining. This style can be used for links. Set underline to true to use the text color as the underline color, or provide a text decoration with a different color. By default underline is omitted (false).",
|
|
178
|
-
typed: false
|
|
179
|
-
}, {
|
|
180
|
-
name: "unorderedListItems",
|
|
181
|
-
type: "Format\\ListItemStyle",
|
|
182
|
-
required: false,
|
|
183
|
-
description: "An object for use with text components with HTML markup. You can create text styles containing an unorderedListItems definition to configure how list items inside <ul> tags should be displayed.",
|
|
184
|
-
typed: false
|
|
185
|
-
}, {
|
|
186
|
-
name: "verticalAlignment",
|
|
187
|
-
type: "enum:string",
|
|
188
|
-
required: false,
|
|
189
|
-
description: "The vertical alignment of the text. You can use this property for superscripts and subscripts.",
|
|
190
|
-
enum_values: ["superscript", "subscript", "baseline"],
|
|
124
|
+
description: "The article’s background color. The value defaults to white.",
|
|
191
125
|
typed: false
|
|
192
126
|
}];
|
|
193
|
-
var
|
|
127
|
+
var DocumentStyleDefinition = {
|
|
194
128
|
name: name$f,
|
|
195
129
|
description: description$f,
|
|
196
130
|
version: version$f,
|
|
@@ -201,85 +135,22 @@ var TextStyleDefinition = {
|
|
|
201
135
|
properties: properties$f
|
|
202
136
|
};
|
|
203
137
|
|
|
204
|
-
var
|
|
138
|
+
var DocumentStyle = function DocumentStyle() {
|
|
205
139
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
206
|
-
_ref$
|
|
207
|
-
|
|
208
|
-
_ref$fontSize = _ref.fontSize,
|
|
209
|
-
fontSize = _ref$fontSize === void 0 ? null : _ref$fontSize,
|
|
210
|
-
_ref$lineHeight = _ref.lineHeight,
|
|
211
|
-
lineHeight = _ref$lineHeight === void 0 ? null : _ref$lineHeight,
|
|
212
|
-
_ref$color = _ref.color,
|
|
213
|
-
color = _ref$color === void 0 ? null : _ref$color;
|
|
140
|
+
_ref$backgroundColor = _ref.backgroundColor,
|
|
141
|
+
backgroundColor = _ref$backgroundColor === void 0 ? null : _ref$backgroundColor;
|
|
214
142
|
var content = {
|
|
215
|
-
|
|
216
|
-
fontSize: fontSize,
|
|
217
|
-
lineHeight: lineHeight ? Math.floor(fontSize * lineHeight) : null,
|
|
218
|
-
textColor: color && color.color ? color.color : null
|
|
143
|
+
backgroundColor: backgroundColor
|
|
219
144
|
};
|
|
220
|
-
return utils.validate(content,
|
|
145
|
+
return utils.validate(content, DocumentStyleDefinition);
|
|
221
146
|
};
|
|
222
147
|
|
|
223
|
-
var
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
// const { heading1 = {}, text = {} } = textStyle || {};
|
|
227
|
-
|
|
228
|
-
// const titleStyles = TextStyle(heading1);
|
|
229
|
-
// const textStyles = TextStyle(text);
|
|
230
|
-
|
|
231
|
-
var fontSize = 18;
|
|
232
|
-
var lineHeight = 1.35;
|
|
233
|
-
var titleStyles = TextStyle({
|
|
234
|
-
fontFamily: 'Futura',
|
|
235
|
-
// stylelint-disable-line
|
|
236
|
-
fontSize: fontSize * 2,
|
|
237
|
-
fontWeight: 'bold',
|
|
238
|
-
lineHeight: lineHeight
|
|
239
|
-
});
|
|
240
|
-
var textStyles = TextStyle({
|
|
241
|
-
fontFamily: 'Palatino',
|
|
242
|
-
// stylelint-disable-line
|
|
243
|
-
fontSize: fontSize,
|
|
244
|
-
lineHeight: lineHeight
|
|
148
|
+
var getArticleDocumentStyle = function getArticleDocumentStyle() {
|
|
149
|
+
var documentStyle = DocumentStyle({
|
|
150
|
+
backgroundColor: '#FFF'
|
|
245
151
|
});
|
|
246
152
|
return {
|
|
247
|
-
|
|
248
|
-
"default": _objectSpread({
|
|
249
|
-
textColor: '#000',
|
|
250
|
-
linkStyle: {
|
|
251
|
-
textColor: '#F0F',
|
|
252
|
-
underline: true
|
|
253
|
-
}
|
|
254
|
-
}, textStyles !== null ? textStyles : {}),
|
|
255
|
-
'default-heading1': _objectSpread(_objectSpread({}, titleStyles !== null ? titleStyles : {}), {}, {
|
|
256
|
-
fontSize: fontSize * 2,
|
|
257
|
-
lineHeight: 36,
|
|
258
|
-
fontWeight: 'regular',
|
|
259
|
-
fontWidth: 'expanded',
|
|
260
|
-
textTransform: 'uppercase'
|
|
261
|
-
}),
|
|
262
|
-
'default-heading2': _objectSpread(_objectSpread({}, titleStyles !== null ? titleStyles : {}), {}, {
|
|
263
|
-
fontSize: 26,
|
|
264
|
-
fontWeight: 'regular',
|
|
265
|
-
fontWidth: 'expanded',
|
|
266
|
-
textTransform: 'uppercase'
|
|
267
|
-
}),
|
|
268
|
-
'default-title': _objectSpread(_objectSpread({}, titleStyles !== null ? titleStyles : {}), {}, {
|
|
269
|
-
fontSize: 26,
|
|
270
|
-
fontWeight: 'regular',
|
|
271
|
-
fontWidth: 'expanded',
|
|
272
|
-
textTransform: 'uppercase'
|
|
273
|
-
}),
|
|
274
|
-
'default-body': _objectSpread({}, textStyles !== null ? textStyles : {}),
|
|
275
|
-
'default-text': _objectSpread({}, textStyles !== null ? textStyles : {}),
|
|
276
|
-
'default-quote': _objectSpread(_objectSpread({}, textStyles !== null ? textStyles : {}), {}, {
|
|
277
|
-
fontSize: 26
|
|
278
|
-
}),
|
|
279
|
-
'style-author': _objectSpread(_objectSpread({}, textStyles !== null ? textStyles : {}), {}, {
|
|
280
|
-
fontStyle: 'italic'
|
|
281
|
-
})
|
|
282
|
-
}
|
|
153
|
+
documentStyle: documentStyle
|
|
283
154
|
};
|
|
284
155
|
};
|
|
285
156
|
|
|
@@ -568,20 +439,128 @@ var getArticleLayouts = function getArticleLayouts() {
|
|
|
568
439
|
};
|
|
569
440
|
};
|
|
570
441
|
|
|
571
|
-
var name$c = "Format\\
|
|
572
|
-
var description$c = "The object for
|
|
442
|
+
var name$c = "Format\\TextStyle";
|
|
443
|
+
var description$c = "The object for defining the text style (font family, size, color, and so on) that you can apply to ranges of text.";
|
|
573
444
|
var version$c = "1.7+";
|
|
574
445
|
var from_class$c = null;
|
|
575
446
|
var typed$c = null;
|
|
576
|
-
var url$c = "https://developer.apple.com/documentation/apple_news/
|
|
447
|
+
var url$c = "https://developer.apple.com/documentation/apple_news/textstyle";
|
|
577
448
|
var properties$c = [{
|
|
578
449
|
name: "backgroundColor",
|
|
579
450
|
type: "Color",
|
|
580
451
|
required: false,
|
|
581
|
-
description: "The
|
|
452
|
+
description: "The background color for text lines. The value defaults to transparent.",
|
|
453
|
+
typed: false
|
|
454
|
+
}, {
|
|
455
|
+
name: "conditional",
|
|
456
|
+
type: "array:Format\\ConditionalTextStyle",
|
|
457
|
+
required: false,
|
|
458
|
+
description: "An array of text style properties that can be applied conditionally, and the conditions that cause them to be applied.",
|
|
459
|
+
typed: false
|
|
460
|
+
}, {
|
|
461
|
+
name: "fontFamily",
|
|
462
|
+
type: "string",
|
|
463
|
+
required: false,
|
|
464
|
+
description: "The font family to use for text rendering, for example Gill Sans. Using a combination of fontFamily, fontWeight, fontWidth and fontStyle you can define the appearance of the text. News automatically selects the appropriate font variant from the available variants in that family.",
|
|
465
|
+
typed: false
|
|
466
|
+
}, {
|
|
467
|
+
name: "fontName",
|
|
468
|
+
type: "string",
|
|
469
|
+
required: false,
|
|
470
|
+
description: "The fontName to refer to an explicit font variant’s PostScript name, such as GillSans-Bold. Alternatively, you can use a combination of fontFamily, fontWeight, fontWidth and/or fontStyle to have News automatically select the appropriate variant depending on the text formatting used.",
|
|
471
|
+
typed: false
|
|
472
|
+
}, {
|
|
473
|
+
name: "fontSize",
|
|
474
|
+
type: "integer",
|
|
475
|
+
required: false,
|
|
476
|
+
description: "The size of the font, in points. By default, the font size will be inherited from a parent component or a default style. As a best practice, try not to go below 16 points for body text. The fontSize may be automatically resized for different device sizes or for iOS devices with Larger Accessibility Sizes enabled.",
|
|
477
|
+
typed: false
|
|
478
|
+
}, {
|
|
479
|
+
name: "fontStyle",
|
|
480
|
+
type: "enum:string",
|
|
481
|
+
required: false,
|
|
482
|
+
description: "The font style to apply for the selected font.",
|
|
483
|
+
enum_values: ["normal", "italic", "oblique"],
|
|
484
|
+
typed: false
|
|
485
|
+
}, {
|
|
486
|
+
name: "fontWeight",
|
|
487
|
+
type: "enum:integer|string",
|
|
488
|
+
required: false,
|
|
489
|
+
description: "The font weight to apply for font selection. In addition to explicit weights (named or numerical), lighter and bolder are available, to set text in a lighter or bolder font as compared to its surrounding text.",
|
|
490
|
+
enum_values: [100, 200, 300, 400, 500, 600, 700, 800, 900, "thin", "extra-light", "extralight", "ultra-light", "light", "regular", "normal", "book", "roman", "medium", "semi-bold", "semibold", "demi-bold", "demibold", "bold", "extra-bold", "extrabold", "ultra-bold", "ultrabold", "black", "heavy", "lighter", "bolder"],
|
|
491
|
+
typed: false
|
|
492
|
+
}, {
|
|
493
|
+
name: "fontWidth",
|
|
494
|
+
type: "enum:string",
|
|
495
|
+
required: false,
|
|
496
|
+
description: "The font width for font selection (known in CSS as font-stretch). Defines the width characteristics of a font variant between normal, condensed and expanded. Some font families have separate families assigned for different widths (for example, Avenir Next and Avenir Next Condensed), so make sure that the fontFamily you select supports the specified fontWidth.",
|
|
497
|
+
enum_values: ["ultra-condensed", "extra-condensed", "condensed", "semi-condensed", "normal", "semi-expanded", "expanded", "extra-expanded", "ultra-expanded"],
|
|
498
|
+
typed: false
|
|
499
|
+
}, {
|
|
500
|
+
name: "orderedListItems",
|
|
501
|
+
type: "Format\\ListItemStyle",
|
|
502
|
+
required: false,
|
|
503
|
+
description: "An object for use with text components with HTML markup. You can create text styles containing an orderedListItems definition to configure how list items inside <ol> tags should be displayed.",
|
|
504
|
+
typed: false
|
|
505
|
+
}, {
|
|
506
|
+
name: "strikethrough",
|
|
507
|
+
type: ["Format\\TextDecoration", "boolean"],
|
|
508
|
+
required: false,
|
|
509
|
+
description: "The text strikethrough. Set strikethrough to true to use the text color inherited from the textColor property as the strikethrough color, or provide a text decoration definition with a different color. By default strikethrough is omitted (false).",
|
|
510
|
+
typed: false
|
|
511
|
+
}, {
|
|
512
|
+
name: "stroke",
|
|
513
|
+
type: "Format\\TextStrokeStyle",
|
|
514
|
+
required: false,
|
|
515
|
+
description: "The stroke style for the text outline. By default, stroke will be omitted.",
|
|
516
|
+
typed: false
|
|
517
|
+
}, {
|
|
518
|
+
name: "textColor",
|
|
519
|
+
type: "Color",
|
|
520
|
+
required: false,
|
|
521
|
+
description: "The text color.",
|
|
522
|
+
typed: false
|
|
523
|
+
}, {
|
|
524
|
+
name: "textShadow",
|
|
525
|
+
type: "Format\\Shadow",
|
|
526
|
+
required: false,
|
|
527
|
+
description: "The text shadow for this style.",
|
|
528
|
+
typed: false
|
|
529
|
+
}, {
|
|
530
|
+
name: "textTransform",
|
|
531
|
+
type: "enum:string",
|
|
532
|
+
required: false,
|
|
533
|
+
description: "The transform to apply to the text.",
|
|
534
|
+
enum_values: ["uppercase", "lowercase", "capitalize", "none"],
|
|
535
|
+
typed: false
|
|
536
|
+
}, {
|
|
537
|
+
name: "tracking",
|
|
538
|
+
type: "number",
|
|
539
|
+
required: false,
|
|
540
|
+
description: "The amount of tracking (spacing between characters) in text, as a percentage of the fontSize. The actual spacing between letters is determined by combining information from the font and font size.",
|
|
541
|
+
"default": 0,
|
|
542
|
+
typed: false
|
|
543
|
+
}, {
|
|
544
|
+
name: "underline",
|
|
545
|
+
type: ["Format\\TextDecoration", "boolean"],
|
|
546
|
+
required: false,
|
|
547
|
+
description: "The text underlining. This style can be used for links. Set underline to true to use the text color as the underline color, or provide a text decoration with a different color. By default underline is omitted (false).",
|
|
548
|
+
typed: false
|
|
549
|
+
}, {
|
|
550
|
+
name: "unorderedListItems",
|
|
551
|
+
type: "Format\\ListItemStyle",
|
|
552
|
+
required: false,
|
|
553
|
+
description: "An object for use with text components with HTML markup. You can create text styles containing an unorderedListItems definition to configure how list items inside <ul> tags should be displayed.",
|
|
554
|
+
typed: false
|
|
555
|
+
}, {
|
|
556
|
+
name: "verticalAlignment",
|
|
557
|
+
type: "enum:string",
|
|
558
|
+
required: false,
|
|
559
|
+
description: "The vertical alignment of the text. You can use this property for superscripts and subscripts.",
|
|
560
|
+
enum_values: ["superscript", "subscript", "baseline"],
|
|
582
561
|
typed: false
|
|
583
562
|
}];
|
|
584
|
-
var
|
|
563
|
+
var TextStyleDefinition = {
|
|
585
564
|
name: name$c,
|
|
586
565
|
description: description$c,
|
|
587
566
|
version: version$c,
|
|
@@ -592,22 +571,85 @@ var DocumentStyleDefinition = {
|
|
|
592
571
|
properties: properties$c
|
|
593
572
|
};
|
|
594
573
|
|
|
595
|
-
var
|
|
574
|
+
var TextStyle = function TextStyle() {
|
|
596
575
|
var _ref = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
|
|
597
|
-
_ref$
|
|
598
|
-
|
|
576
|
+
_ref$fontFamily = _ref.fontFamily,
|
|
577
|
+
fontFamily = _ref$fontFamily === void 0 ? null : _ref$fontFamily,
|
|
578
|
+
_ref$fontSize = _ref.fontSize,
|
|
579
|
+
fontSize = _ref$fontSize === void 0 ? null : _ref$fontSize,
|
|
580
|
+
_ref$lineHeight = _ref.lineHeight,
|
|
581
|
+
lineHeight = _ref$lineHeight === void 0 ? null : _ref$lineHeight,
|
|
582
|
+
_ref$color = _ref.color,
|
|
583
|
+
color = _ref$color === void 0 ? null : _ref$color;
|
|
599
584
|
var content = {
|
|
600
|
-
|
|
585
|
+
fontFamily: fontFamily,
|
|
586
|
+
fontSize: fontSize,
|
|
587
|
+
lineHeight: lineHeight ? Math.floor(fontSize * lineHeight) : null,
|
|
588
|
+
textColor: color && color.color ? color.color : null
|
|
601
589
|
};
|
|
602
|
-
return utils.validate(content,
|
|
590
|
+
return utils.validate(content, TextStyleDefinition);
|
|
603
591
|
};
|
|
604
592
|
|
|
605
|
-
var
|
|
606
|
-
|
|
607
|
-
|
|
593
|
+
var getArticleTextStyles = function getArticleTextStyles() {
|
|
594
|
+
// const { theme = {} } = story || {};
|
|
595
|
+
// const { textStyle = {} } = theme || {};
|
|
596
|
+
// const { heading1 = {}, text = {} } = textStyle || {};
|
|
597
|
+
|
|
598
|
+
// const titleStyles = TextStyle(heading1);
|
|
599
|
+
// const textStyles = TextStyle(text);
|
|
600
|
+
|
|
601
|
+
var fontSize = 18;
|
|
602
|
+
var lineHeight = 1.35;
|
|
603
|
+
var titleStyles = TextStyle({
|
|
604
|
+
fontFamily: 'Futura',
|
|
605
|
+
// stylelint-disable-line
|
|
606
|
+
fontSize: fontSize * 2,
|
|
607
|
+
fontWeight: 'bold',
|
|
608
|
+
lineHeight: lineHeight
|
|
609
|
+
});
|
|
610
|
+
var textStyles = TextStyle({
|
|
611
|
+
fontFamily: 'Palatino',
|
|
612
|
+
// stylelint-disable-line
|
|
613
|
+
fontSize: fontSize,
|
|
614
|
+
lineHeight: lineHeight
|
|
608
615
|
});
|
|
609
616
|
return {
|
|
610
|
-
|
|
617
|
+
componentTextStyles: {
|
|
618
|
+
"default": _objectSpread({
|
|
619
|
+
textColor: '#000',
|
|
620
|
+
linkStyle: {
|
|
621
|
+
textColor: '#F0F',
|
|
622
|
+
underline: true
|
|
623
|
+
}
|
|
624
|
+
}, textStyles !== null ? textStyles : {}),
|
|
625
|
+
'default-heading1': _objectSpread(_objectSpread({}, titleStyles !== null ? titleStyles : {}), {}, {
|
|
626
|
+
fontSize: fontSize * 2,
|
|
627
|
+
lineHeight: 36,
|
|
628
|
+
fontWeight: 'regular',
|
|
629
|
+
fontWidth: 'expanded',
|
|
630
|
+
textTransform: 'uppercase'
|
|
631
|
+
}),
|
|
632
|
+
'default-heading2': _objectSpread(_objectSpread({}, titleStyles !== null ? titleStyles : {}), {}, {
|
|
633
|
+
fontSize: 26,
|
|
634
|
+
fontWeight: 'regular',
|
|
635
|
+
fontWidth: 'expanded',
|
|
636
|
+
textTransform: 'uppercase'
|
|
637
|
+
}),
|
|
638
|
+
'default-title': _objectSpread(_objectSpread({}, titleStyles !== null ? titleStyles : {}), {}, {
|
|
639
|
+
fontSize: 26,
|
|
640
|
+
fontWeight: 'regular',
|
|
641
|
+
fontWidth: 'expanded',
|
|
642
|
+
textTransform: 'uppercase'
|
|
643
|
+
}),
|
|
644
|
+
'default-body': _objectSpread({}, textStyles !== null ? textStyles : {}),
|
|
645
|
+
'default-text': _objectSpread({}, textStyles !== null ? textStyles : {}),
|
|
646
|
+
'default-quote': _objectSpread(_objectSpread({}, textStyles !== null ? textStyles : {}), {}, {
|
|
647
|
+
fontSize: 26
|
|
648
|
+
}),
|
|
649
|
+
'style-author': _objectSpread(_objectSpread({}, textStyles !== null ? textStyles : {}), {}, {
|
|
650
|
+
fontStyle: 'italic'
|
|
651
|
+
})
|
|
652
|
+
}
|
|
611
653
|
};
|
|
612
654
|
};
|
|
613
655
|
|
|
@@ -719,51 +761,7 @@ var ArticleDefinition = {
|
|
|
719
761
|
properties: properties$b
|
|
720
762
|
};
|
|
721
763
|
|
|
722
|
-
var validate = function validate() {
|
|
723
|
-
var content = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
724
|
-
var definition = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
|
725
|
-
var validated = content ? Object.keys(content).reduce(function (values, name) {
|
|
726
|
-
var value = content[name] || null;
|
|
727
|
-
// Find the reference
|
|
728
|
-
if (definition && definition.properties) {
|
|
729
|
-
var property = definition.properties.find(function (prop) {
|
|
730
|
-
return prop.name === name;
|
|
731
|
-
}) || null;
|
|
732
|
-
if (property !== null) {
|
|
733
|
-
var isValid = true;
|
|
734
|
-
switch (property.type) {
|
|
735
|
-
case 'string':
|
|
736
|
-
isValid = isString(value);
|
|
737
|
-
break;
|
|
738
|
-
case 'integer':
|
|
739
|
-
isValid = isInteger(value);
|
|
740
|
-
break;
|
|
741
|
-
case 'float':
|
|
742
|
-
isValid = isNumber(value);
|
|
743
|
-
break;
|
|
744
|
-
default:
|
|
745
|
-
isValid = value !== null;
|
|
746
|
-
break;
|
|
747
|
-
}
|
|
748
|
-
// Skip the whole thing it cause it aint gonna work
|
|
749
|
-
if (!isValid && property.required) {
|
|
750
|
-
console.log('VALIDATION ERROR: SKIPPED BECAUSE REQUIRED', content, name); // eslint-disable-line
|
|
751
|
-
return null;
|
|
752
|
-
}
|
|
753
|
-
if (values !== null && isValid) {
|
|
754
|
-
return _objectSpread(_objectSpread({}, values), {}, _defineProperty({}, name, value));
|
|
755
|
-
}
|
|
756
|
-
console.log('VALIDATION ERROR: VALID TYPE', name, content); // eslint-disable-line
|
|
757
|
-
}
|
|
758
|
-
}
|
|
759
|
-
return values;
|
|
760
|
-
}, {}) : {};
|
|
761
|
-
return !isEmpty(validated) ? validated : null;
|
|
762
|
-
};
|
|
763
|
-
|
|
764
764
|
var Article = function Article(story, settings) {
|
|
765
|
-
// console.log('ARTICLE', story); // eslint-disable-line
|
|
766
|
-
|
|
767
765
|
var _story$title = story.title,
|
|
768
766
|
title = _story$title === void 0 ? 'Article' : _story$title;
|
|
769
767
|
var _ref = settings || {},
|
|
@@ -782,9 +780,6 @@ var Article = function Article(story, settings) {
|
|
|
782
780
|
componentTextStyles: {},
|
|
783
781
|
componentLayouts: {}
|
|
784
782
|
}, getArticleDocumentStyle()), getArticleTextStyles()), getArticleLayouts()), getArticleComponents(story));
|
|
785
|
-
|
|
786
|
-
// console.log('KONTENT', content);
|
|
787
|
-
|
|
788
783
|
return validate(content, ArticleDefinition);
|
|
789
784
|
};
|
|
790
785
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/transforms",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.465",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -72,7 +72,7 @@
|
|
|
72
72
|
},
|
|
73
73
|
"dependencies": {
|
|
74
74
|
"@babel/runtime": "^7.13.10",
|
|
75
|
-
"@micromag/core": "^0.3.
|
|
75
|
+
"@micromag/core": "^0.3.465",
|
|
76
76
|
"lodash": "^4.17.21",
|
|
77
77
|
"object-hash": "^2.1.1",
|
|
78
78
|
"prop-types": "^15.7.2",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"access": "public",
|
|
83
83
|
"registry": "https://registry.npmjs.org/"
|
|
84
84
|
},
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "5595546150eb35a0d670e00d4259fd9a43256ed6"
|
|
86
86
|
}
|