UNPKG

@atlaskit/adf-schema

Version:

Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs

21 lines 832 B
import { isValidLayout } from './is-valid-layout'; export var getExtensionAttrs = function getExtensionAttrs(dom) { var isInline = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false; var extensionType = dom.getAttribute('data-extension-type'); var extensionKey = dom.getAttribute('data-extension-key'); if (!extensionType || !extensionKey) { return false; } var attrs = { extensionType: extensionType, extensionKey: extensionKey, text: dom.getAttribute('data-text') || undefined, parameters: JSON.parse(dom.getAttribute('data-parameters') || '{}'), localId: dom.getAttribute('data-local-id') || undefined }; if (!isInline) { var rawLayout = dom.getAttribute('data-layout'); attrs.layout = isValidLayout(rawLayout) ? rawLayout : 'default'; } return attrs; };