UNPKG

@atlaskit/editor-plugin-synced-block

Version:

SyncedBlock plugin for @atlaskit/editor-core

19 lines 722 B
/** * Cheap detector for the presence of any synced block (source or reference) * at the top level of the document. * * Both `syncBlock` and `bodiedSyncBlock` are top-level nodes in the schema, so * a single shallow scan is sufficient — no need for a recursive `descendants` * walk. This is used to avoid spinning up the synced block subsystem on * documents that don't contain any * synced blocks (which is ~99.97% of pages, see EDITOR-6586). */ export var hasSyncedBlocks = function hasSyncedBlocks(doc) { for (var i = 0; i < doc.childCount; i++) { var node = doc.child(i); if (node.type.name === 'syncBlock' || node.type.name === 'bodiedSyncBlock') { return true; } } return false; };