@atlaskit/editor-plugin-rule
Version:
Rule plugin for @atlaskit/editor-core
21 lines • 726 B
JavaScript
import { SafePlugin } from '@atlaskit/editor-common/safe-plugin';
import { createSelectionClickHandler } from '@atlaskit/editor-common/selection';
import { RuleNodeView } from '../node-views/RuleNodeView';
const selectRuleOnClick = createSelectionClickHandler(['rule'], target => !!target.closest('[data-rule-node-view]'), {
useLongPressSelection: false
});
export const createPlugin = () => new SafePlugin({
props: {
nodeViews: {
rule: (node, view) => new RuleNodeView(node, view)
},
handleClickOn(view, ...args) {
const handled = selectRuleOnClick(view, ...args);
if (handled && view.editable) {
view.focus();
}
return handled;
}
}
});
export default createPlugin;