@atlaskit/editor-plugin-breakout
Version:
Breakout plugin for @atlaskit/editor-core
35 lines • 1.21 kB
JavaScript
import { expandedState } from '@atlaskit/editor-common/expand';
import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
export const updateExpandedStateNew = ({
tr,
node,
pos,
isLivePage
}) => {
if (isLivePage || expValEquals('platform_editor_single_player_expand', 'isEnabled', true)) {
const wasExpandExpanded = expandedState.get(node);
const newExpand = tr.doc.nodeAt(pos);
if (wasExpandExpanded !== undefined && newExpand) {
expandedState.set(newExpand, wasExpandExpanded);
}
}
};
export const updateExpandedState = (tr, node, isLivePage) => {
if (editorExperiment('platform_editor_breakout_resizing', true)) {
updateExpandedStateNew({
tr,
node: node.node,
pos: node.pos,
isLivePage
});
} else {
if (isLivePage || expValEquals('platform_editor_single_player_expand', 'isEnabled', true)) {
const wasExpandExpanded = expandedState.get(node.node);
const newExpand = tr.doc.nodeAt(node.pos);
if (wasExpandExpanded !== undefined && newExpand) {
expandedState.set(newExpand, wasExpandExpanded);
}
}
}
};