UNPKG

collaborative-ace

Version:

Binding for collaborative editing support in Ace Editor. Connects JSON CRDT str node to Ace Editor.

26 lines 1.08 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CollaborativeAce = void 0; const tslib_1 = require("tslib"); const React = require("react"); const react_ace_1 = require("react-ace"); const _1 = require("."); const CollaborativeAce = (_a) => { var { str, polling, onLoad } = _a, rest = tslib_1.__rest(_a, ["str", "polling", "onLoad"]); const unbindRef = React.useRef(null); const editorRef = React.useRef(null); React.useEffect(() => { return () => { var _a; (_a = unbindRef.current) === null || _a === void 0 ? void 0 : _a.call(unbindRef); }; }, []); const handleLoad = (editor) => { editorRef.current = editor; unbindRef.current = (0, _1.bind)(str, editor, !!polling); onLoad === null || onLoad === void 0 ? void 0 : onLoad(editor); }; return React.createElement(react_ace_1.default, Object.assign({}, rest, { value: str().view(), onLoad: handleLoad })); }; exports.CollaborativeAce = CollaborativeAce; //# sourceMappingURL=CollaborativeAce.js.map