@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
83 lines (77 loc) • 2.14 kB
JavaScript
import { nestedExpand as nestedExpandFactory, nestedExpandWithoutNonBodiedMacros as nestedExpandWithoutNonBodiedMacrosFactory } from '../../next-schema/generated/nodeTypes';
/**
* @name nestedExpand_content
* @minItems 1
* @allowUnsupportedBlock true
*/
/**
* @name nestedExpand_node
*/
/**
* @name nestedExpand_with_no_marks_node
*/
function getExpandAttrs(domNode) {
const dom = domNode;
return {
title: dom.getAttribute('data-title'),
__expanded: true
};
}
const nestedExpandFactoryOptions = {
parseDOM: [{
context: 'nestedExpand//',
tag: '[data-node-type="nestedExpand"]',
getAttrs: getExpandAttrs
}, {
tag: '[data-node-type="nestedExpand"] button',
ignore: true
}, {
tag: '[data-node-type="expand"] button',
ignore: true
}, {
tag: 'div[data-node-type="nestedExpand"]',
getAttrs: getExpandAttrs
}],
toDOM(node) {
const attrs = {
'data-node-type': 'nestedExpand',
'data-title': node.attrs.title,
'data-expanded': node.attrs.__expanded
};
return ['div', attrs, 0];
}
};
const nestedExpandWithoutNonBodiedMacrosFactoryOptions = {
parseDOM: [{
context: 'nestedExpand//',
tag: '[data-node-type="nestedExpand"]',
getAttrs: getExpandAttrs
}, {
tag: '[data-node-type="nestedExpand"] button',
ignore: true
}, {
tag: '[data-node-type="expand"] button',
ignore: true
}, {
tag: 'div[data-node-type="nestedExpand"]',
getAttrs: getExpandAttrs
}],
toDOM(node) {
const attrs = {
'data-node-type': 'nestedExpand',
'data-title': node.attrs.title,
'data-expanded': node.attrs.__expanded
};
return ['div', attrs, 0];
}
};
/**
* @name nestedExpand
* @description an expand that can be nested (eg. inside table, layout).
*/
export const nestedExpand = nestedExpandFactory(nestedExpandFactoryOptions);
/**
* @name nestedExpandWithNonBodiedMacros
* @description an expand that can be nested (eg. inside table, layout).
*/
export const nestedExpandWithoutNonBodiedMacros = nestedExpandWithoutNonBodiedMacrosFactory(nestedExpandWithoutNonBodiedMacrosFactoryOptions);