@atlaskit/adf-schema
Version:
Shared package that contains the ADF-schema (json) and ProseMirror node/mark specs
10 lines • 356 B
JavaScript
const OPTIONAL_ATTRS = ['title', 'id', 'collection', 'occurrenceKey', '__confluenceMetadata'];
export const toJSON = mark => ({
type: mark.type.name,
attrs: Object.keys(mark.attrs).reduce((attrs, key) => {
if (OPTIONAL_ATTRS.indexOf(key) === -1 || mark.attrs[key] !== null) {
attrs[key] = mark.attrs[key];
}
return attrs;
}, {})
});