UNPKG

@gechiui/block-editor

Version:
43 lines (37 loc) 939 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.useCaretInFormat = useCaretInFormat; var _element = require("@gechiui/element"); var _data = require("@gechiui/data"); var _store = require("../../store"); /** * GeChiUI dependencies */ /** * Internal dependencies */ function useCaretInFormat(_ref) { let { value } = _ref; const hasActiveFormats = value.activeFormats && !!value.activeFormats.length; const { isCaretWithinFormattedText } = (0, _data.useSelect)(_store.store); const { enterFormattedText, exitFormattedText } = (0, _data.useDispatch)(_store.store); (0, _element.useEffect)(() => { if (hasActiveFormats) { if (!isCaretWithinFormattedText()) { enterFormattedText(); } } else if (isCaretWithinFormattedText()) { exitFormattedText(); } }, [hasActiveFormats]); } //# sourceMappingURL=use-caret-in-format.js.map