UNPKG

@wordpress/block-editor

Version:
34 lines (29 loc) 984 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.START_OF_SELECTED_AREA = void 0; exports.retrieveSelectedAttribute = retrieveSelectedAttribute; /** * A robust way to retain selection position through various * transforms is to insert a special character at the position and * then recover it. */ const START_OF_SELECTED_AREA = '\u0086'; /** * Retrieve the block attribute that contains the selection position. * * @param {Object} blockAttributes Block attributes. * @return {string|void} The name of the block attribute that was previously selected. */ exports.START_OF_SELECTED_AREA = START_OF_SELECTED_AREA; function retrieveSelectedAttribute(blockAttributes) { if (!blockAttributes) { return; } return Object.keys(blockAttributes).find(name => { const value = blockAttributes[name]; return typeof value === 'string' && value.indexOf(START_OF_SELECTED_AREA) !== -1; }); } //# sourceMappingURL=selection.js.map