@wordpress/block-editor
Version:
43 lines (35 loc) • 985 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.useInsertReplacementText = useInsertReplacementText;
var _compose = require("@wordpress/compose");
var _data = require("@wordpress/data");
var _store = require("../../store");
/**
* WordPress dependencies
*/
/**
* Internal dependencies
*/
/**
* When the browser is about to auto correct, add an undo level so the user can
* revert the change.
*/
function useInsertReplacementText() {
const {
__unstableMarkLastChangeAsPersistent
} = (0, _data.useDispatch)(_store.store);
return (0, _compose.useRefEffect)(element => {
function onInput(event) {
if (event.inputType === 'insertReplacementText') {
__unstableMarkLastChangeAsPersistent();
}
}
element.addEventListener('beforeinput', onInput);
return () => {
element.removeEventListener('beforeinput', onInput);
};
}, []);
}
//# sourceMappingURL=use-insert-replacement-text.js.map