@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
20 lines • 716 B
JavaScript
import { isValidLayout } from './is-valid-layout';
export const getExtensionAttrs = (dom, isInline = false) => {
const extensionType = dom.getAttribute('data-extension-type');
const extensionKey = dom.getAttribute('data-extension-key');
if (!extensionType || !extensionKey) {
return false;
}
const attrs = {
extensionType,
extensionKey,
text: dom.getAttribute('data-text') || undefined,
parameters: JSON.parse(dom.getAttribute('data-parameters') || '{}'),
localId: dom.getAttribute('data-local-id') || undefined
};
if (!isInline) {
const rawLayout = dom.getAttribute('data-layout');
attrs.layout = isValidLayout(rawLayout) ? rawLayout : 'default';
}
return attrs;
};