infinity-forge
Version:
20 lines • 792 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.useTextEditor = useTextEditor;
var react_1 = require("react");
function useTextEditor() {
var _a = (0, react_1.useState)(null), insertTextFunction = _a[0], setInsertTextFunction = _a[1];
var handleInsert = function (text) {
if (insertTextFunction) {
insertTextFunction(text);
}
else {
console.warn("Insert text function not yet available (editor might not be ready).");
}
};
var handleEditorReady = (0, react_1.useCallback)(function (insert) {
setInsertTextFunction(function () { return insert; });
}, []);
return { handleInsert: handleInsert, handleEditorReady: handleEditorReady };
}
//# sourceMappingURL=index.js.map