@limetech/lime-elements
Version:
27 lines (26 loc) • 769 B
JavaScript
import { tableNodes, tableEditing } from "prosemirror-tables";
export const getTableEditingPlugins = (tablesEnabled) => {
if (tablesEnabled) {
return [tableEditing()];
}
return [];
};
const createStyleAttribute = (cssProperty) => ({
default: null,
getFromDOM: (dom) => dom.style[cssProperty] || null,
setDOMAttr: (value, attrs) => {
if (value) {
attrs.style = (attrs.style || '') + `${cssProperty}: ${value};`;
}
},
});
export const getTableNodes = () => {
return tableNodes({
tableGroup: 'block',
cellContent: 'block+',
cellAttributes: {
background: createStyleAttribute('background-color'),
color: createStyleAttribute('color'),
},
});
};