@atlaskit/editor-plugin-show-diff
Version:
ShowDiff plugin for @atlaskit/editor-core
21 lines • 769 B
JavaScript
import { attrAwareTokenEncoder } from './attrAwareTokenEncoder';
import { markAwareTokenEncoder } from './markAwareTokenEncoder';
/**
* Single place the token encoder is chosen, shared by `calculateDiffDecorations` and
* `computeDiffChanges` so the two cannot drift.
*
* @param useAttrAwareEncoder Caller is running the smart classifier, which needs node attrs folded
* into the token. Also used by the NCS version-history path to detect attribute-only node changes.
*/
export const selectTokenEncoder = useAttrAwareEncoder => {
if (useAttrAwareEncoder) {
return {
tokenEncoder: attrAwareTokenEncoder,
shouldHideMarkOnlyDeletions: false
};
}
return {
tokenEncoder: markAwareTokenEncoder,
shouldHideMarkOnlyDeletions: true
};
};