1 | export var isValidLayout = function isValidLayout(name) {
|
2 | return !!name && ['default', 'wide', 'full-width'].includes(name);
|
3 | };
|
4 | export var getExtensionAttrs = function getExtensionAttrs(dom) {
|
5 | var isInline = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
6 | var extensionType = dom.getAttribute('data-extension-type');
|
7 | var extensionKey = dom.getAttribute('data-extension-key');
|
8 | if (!extensionType || !extensionKey) {
|
9 | return false;
|
10 | }
|
11 | var attrs = {
|
12 | extensionType: extensionType,
|
13 | extensionKey: extensionKey,
|
14 | text: dom.getAttribute('data-text') || undefined,
|
15 | parameters: JSON.parse(dom.getAttribute('data-parameters') || '{}'),
|
16 | localId: dom.getAttribute('data-local-id') || undefined
|
17 | };
|
18 | if (!isInline) {
|
19 | var rawLayout = dom.getAttribute('data-layout');
|
20 | attrs.layout = isValidLayout(rawLayout) ? rawLayout : 'default';
|
21 | }
|
22 | return attrs;
|
23 | }; |
\ | No newline at end of file |