UNPKG

@atlaskit/editor-plugin-synced-block

Version:

SyncedBlock plugin for @atlaskit/editor-core

25 lines (24 loc) 855 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.hasSyncedBlocks = void 0; /** * 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). */ var hasSyncedBlocks = exports.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; };