@wangeditor-next/yjs-for-react 0.1.1-beta.0 → 0.1.1-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm.js +6 -794
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +10 -812
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1,97 +1,4 @@
|
|
|
1
|
-
import e,
|
|
2
|
-
import { CursorEditor, relativeRangeToSlateRange } from '@wangeditor-next/yjs';
|
|
3
|
-
import { Range, Editor, Text, Path } from 'slate';
|
|
4
|
-
import { DomEditor } from '@wangeditor-next/editor';
|
|
5
|
-
|
|
6
|
-
var EditorContext = createContext(null);
|
|
7
|
-
var useEditorStatic = function () {
|
|
8
|
-
var editor = useContext(EditorContext);
|
|
9
|
-
if (!editor) {
|
|
10
|
-
// throw new Error(
|
|
11
|
-
// `The \`useEditorStatic\` hook must be used inside the <EditorContext> component's context.`
|
|
12
|
-
// )
|
|
13
|
-
console.warn("The `useEditorStatic` hook must be used inside the <EditorContext> component's context.");
|
|
14
|
-
}
|
|
15
|
-
return editor;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/******************************************************************************
|
|
19
|
-
Copyright (c) Microsoft Corporation.
|
|
20
|
-
|
|
21
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
22
|
-
purpose with or without fee is hereby granted.
|
|
23
|
-
|
|
24
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
25
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
26
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
27
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
28
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
29
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
30
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
31
|
-
***************************************************************************** */
|
|
32
|
-
|
|
33
|
-
var __assign = function() {
|
|
34
|
-
__assign = Object.assign || function __assign(t) {
|
|
35
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
36
|
-
s = arguments[i];
|
|
37
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
38
|
-
}
|
|
39
|
-
return t;
|
|
40
|
-
};
|
|
41
|
-
return __assign.apply(this, arguments);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
function __rest(s, e) {
|
|
45
|
-
var t = {};
|
|
46
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
47
|
-
t[p] = s[p];
|
|
48
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
49
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
50
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
51
|
-
t[p[i]] = s[p[i]];
|
|
52
|
-
}
|
|
53
|
-
return t;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function __values(o) {
|
|
57
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
58
|
-
if (m) return m.call(o);
|
|
59
|
-
if (o && typeof o.length === "number") return {
|
|
60
|
-
next: function () {
|
|
61
|
-
if (o && i >= o.length) o = void 0;
|
|
62
|
-
return { value: o && o[i++], done: !o };
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function __read(o, n) {
|
|
69
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
70
|
-
if (!m) return o;
|
|
71
|
-
var i = m.call(o), r, ar = [], e;
|
|
72
|
-
try {
|
|
73
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
74
|
-
}
|
|
75
|
-
catch (error) { e = { error: error }; }
|
|
76
|
-
finally {
|
|
77
|
-
try {
|
|
78
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
79
|
-
}
|
|
80
|
-
finally { if (e) throw e.error; }
|
|
81
|
-
}
|
|
82
|
-
return ar;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
86
|
-
var e = new Error(message);
|
|
87
|
-
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
88
|
-
};
|
|
89
|
-
|
|
90
|
-
function createCommonjsModule(fn) {
|
|
91
|
-
var module = { exports: {} };
|
|
92
|
-
return fn(module, module.exports), module.exports;
|
|
93
|
-
}
|
|
94
|
-
|
|
1
|
+
import t,{createContext as e,useContext as n,useReducer as r,useRef as o,useEffect as i,useCallback as u,useState as c,useLayoutEffect as a,useMemo as f}from"react";import{CursorEditor as s,relativeRangeToSlateRange as l}from"@wangeditor-next/yjs";import{Range as v,Editor as p,Text as d,Path as h}from"slate";import{DomEditor as y}from"@wangeditor-next/editor";var g=e(null),b=function(){var t=n(g);return t||console.warn("The `useEditorStatic` hook must be used inside the <EditorContext> component's context."),t},m=function(){return m=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},m.apply(this,arguments)};function S(t,e){var n="function"==typeof Symbol&&t[Symbol.iterator];if(!n)return t;var r,o,i=n.call(t),u=[];try{for(;(void 0===e||e-- >0)&&!(r=i.next()).done;)u.push(r.value)}catch(t){o={error:t}}finally{try{r&&!r.done&&(n=i.return)&&n.call(i)}finally{if(o)throw o.error}}return u}"function"==typeof SuppressedError&&SuppressedError;var O="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function w(t){var e={exports:{}};return t(e,e.exports),e.exports
|
|
95
2
|
/**
|
|
96
3
|
* @license React
|
|
97
4
|
* use-sync-external-store-shim.production.min.js
|
|
@@ -100,10 +7,7 @@ function createCommonjsModule(fn) {
|
|
|
100
7
|
*
|
|
101
8
|
* This source code is licensed under the MIT license found in the
|
|
102
9
|
* LICENSE file in the root directory of this source tree.
|
|
103
|
-
*/
|
|
104
|
-
function h(a,b){return a===b&&(0!==a||1/a===1/b)||a!==a&&b!==b}var k="function"===typeof Object.is?Object.is:h,l=e.useState,m=e.useEffect,n=e.useLayoutEffect,p=e.useDebugValue;function q(a,b){var d=b(),f=l({inst:{value:d,getSnapshot:b}}),c=f[0].inst,g=f[1];n(function(){c.value=d;c.getSnapshot=b;r(c)&&g({inst:c});},[a,d,b]);m(function(){r(c)&&g({inst:c});return a(function(){r(c)&&g({inst:c});})},[a]);p(d);return d}
|
|
105
|
-
function r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return !k(a,d)}catch(f){return !0}}function t(a,b){return b()}var u="undefined"===typeof window||"undefined"===typeof window.document||"undefined"===typeof window.document.createElement?t:q;void 0!==e.useSyncExternalStore?e.useSyncExternalStore:u;
|
|
106
|
-
|
|
10
|
+
*/}var E="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},j=t.useState,x=t.useEffect,A=t.useLayoutEffect,T=t.useDebugValue;function P(t){var e=t.getSnapshot;t=t.value;try{var n=e();return!E(t,n)}catch(t){return!0}}var R="undefined"==typeof window||void 0===window.document||void 0===window.document.createElement?function(t,e){return e()}:function(t,e){var n=e(),r=j({inst:{value:n,getSnapshot:e}}),o=r[0].inst,i=r[1];return A((function(){o.value=n,o.getSnapshot=e,P(o)&&i({inst:o})}),[t,n,e]),x((function(){return P(o)&&i({inst:o}),t((function(){P(o)&&i({inst:o})}))}),[t]),T(n),n},k={useSyncExternalStore:void 0!==t.useSyncExternalStore?t.useSyncExternalStore:R};
|
|
107
11
|
/**
|
|
108
12
|
* @license React
|
|
109
13
|
* use-sync-external-store-shim.development.js
|
|
@@ -113,243 +17,7 @@ function r(a){var b=a.getSnapshot;a=a.value;try{var d=b();return !k(a,d)}catch(f
|
|
|
113
17
|
* This source code is licensed under the MIT license found in the
|
|
114
18
|
* LICENSE file in the root directory of this source tree.
|
|
115
19
|
*/
|
|
116
|
-
|
|
117
|
-
var useSyncExternalStoreShim_development = createCommonjsModule(function (module, exports) {
|
|
118
|
-
|
|
119
|
-
{
|
|
120
|
-
(function() {
|
|
121
|
-
|
|
122
|
-
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
123
|
-
if (
|
|
124
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
125
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
|
|
126
|
-
'function'
|
|
127
|
-
) {
|
|
128
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
129
|
-
}
|
|
130
|
-
var React = e;
|
|
131
|
-
|
|
132
|
-
var ReactSharedInternals = React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
|
|
133
|
-
|
|
134
|
-
function error(format) {
|
|
135
|
-
{
|
|
136
|
-
{
|
|
137
|
-
for (var _len2 = arguments.length, args = new Array(_len2 > 1 ? _len2 - 1 : 0), _key2 = 1; _key2 < _len2; _key2++) {
|
|
138
|
-
args[_key2 - 1] = arguments[_key2];
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
printWarning('error', format, args);
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
function printWarning(level, format, args) {
|
|
147
|
-
// When changing this logic, you might want to also
|
|
148
|
-
// update consoleWithStackDev.www.js as well.
|
|
149
|
-
{
|
|
150
|
-
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
151
|
-
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
152
|
-
|
|
153
|
-
if (stack !== '') {
|
|
154
|
-
format += '%s';
|
|
155
|
-
args = args.concat([stack]);
|
|
156
|
-
} // eslint-disable-next-line react-internal/safe-string-coercion
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
var argsWithFormat = args.map(function (item) {
|
|
160
|
-
return String(item);
|
|
161
|
-
}); // Careful: RN currently depends on this prefix
|
|
162
|
-
|
|
163
|
-
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
164
|
-
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
165
|
-
// eslint-disable-next-line react-internal/no-production-logging
|
|
166
|
-
|
|
167
|
-
Function.prototype.apply.call(console[level], console, argsWithFormat);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
/**
|
|
172
|
-
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
173
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
174
|
-
*/
|
|
175
|
-
function is(x, y) {
|
|
176
|
-
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
|
177
|
-
;
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
|
181
|
-
|
|
182
|
-
// dispatch for CommonJS interop named imports.
|
|
183
|
-
|
|
184
|
-
var useState = React.useState,
|
|
185
|
-
useEffect = React.useEffect,
|
|
186
|
-
useLayoutEffect = React.useLayoutEffect,
|
|
187
|
-
useDebugValue = React.useDebugValue;
|
|
188
|
-
var didWarnOld18Alpha = false;
|
|
189
|
-
var didWarnUncachedGetSnapshot = false; // Disclaimer: This shim breaks many of the rules of React, and only works
|
|
190
|
-
// because of a very particular set of implementation details and assumptions
|
|
191
|
-
// -- change any one of them and it will break. The most important assumption
|
|
192
|
-
// is that updates are always synchronous, because concurrent rendering is
|
|
193
|
-
// only available in versions of React that also have a built-in
|
|
194
|
-
// useSyncExternalStore API. And we only use this shim when the built-in API
|
|
195
|
-
// does not exist.
|
|
196
|
-
//
|
|
197
|
-
// Do not assume that the clever hacks used by this hook also work in general.
|
|
198
|
-
// The point of this shim is to replace the need for hacks by other libraries.
|
|
199
|
-
|
|
200
|
-
function useSyncExternalStore(subscribe, getSnapshot, // Note: The shim does not use getServerSnapshot, because pre-18 versions of
|
|
201
|
-
// React do not expose a way to check if we're hydrating. So users of the shim
|
|
202
|
-
// will need to track that themselves and return the correct value
|
|
203
|
-
// from `getSnapshot`.
|
|
204
|
-
getServerSnapshot) {
|
|
205
|
-
{
|
|
206
|
-
if (!didWarnOld18Alpha) {
|
|
207
|
-
if (React.startTransition !== undefined) {
|
|
208
|
-
didWarnOld18Alpha = true;
|
|
209
|
-
|
|
210
|
-
error('You are using an outdated, pre-release alpha of React 18 that ' + 'does not support useSyncExternalStore. The ' + 'use-sync-external-store shim will not work correctly. Upgrade ' + 'to a newer pre-release.');
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
|
-
} // Read the current snapshot from the store on every render. Again, this
|
|
214
|
-
// breaks the rules of React, and only works here because of specific
|
|
215
|
-
// implementation details, most importantly that updates are
|
|
216
|
-
// always synchronous.
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
var value = getSnapshot();
|
|
220
|
-
|
|
221
|
-
{
|
|
222
|
-
if (!didWarnUncachedGetSnapshot) {
|
|
223
|
-
var cachedValue = getSnapshot();
|
|
224
|
-
|
|
225
|
-
if (!objectIs(value, cachedValue)) {
|
|
226
|
-
error('The result of getSnapshot should be cached to avoid an infinite loop');
|
|
227
|
-
|
|
228
|
-
didWarnUncachedGetSnapshot = true;
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
} // Because updates are synchronous, we don't queue them. Instead we force a
|
|
232
|
-
// re-render whenever the subscribed state changes by updating an some
|
|
233
|
-
// arbitrary useState hook. Then, during render, we call getSnapshot to read
|
|
234
|
-
// the current value.
|
|
235
|
-
//
|
|
236
|
-
// Because we don't actually use the state returned by the useState hook, we
|
|
237
|
-
// can save a bit of memory by storing other stuff in that slot.
|
|
238
|
-
//
|
|
239
|
-
// To implement the early bailout, we need to track some things on a mutable
|
|
240
|
-
// object. Usually, we would put that in a useRef hook, but we can stash it in
|
|
241
|
-
// our useState hook instead.
|
|
242
|
-
//
|
|
243
|
-
// To force a re-render, we call forceUpdate({inst}). That works because the
|
|
244
|
-
// new object always fails an equality check.
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
var _useState = useState({
|
|
248
|
-
inst: {
|
|
249
|
-
value: value,
|
|
250
|
-
getSnapshot: getSnapshot
|
|
251
|
-
}
|
|
252
|
-
}),
|
|
253
|
-
inst = _useState[0].inst,
|
|
254
|
-
forceUpdate = _useState[1]; // Track the latest getSnapshot function with a ref. This needs to be updated
|
|
255
|
-
// in the layout phase so we can access it during the tearing check that
|
|
256
|
-
// happens on subscribe.
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
useLayoutEffect(function () {
|
|
260
|
-
inst.value = value;
|
|
261
|
-
inst.getSnapshot = getSnapshot; // Whenever getSnapshot or subscribe changes, we need to check in the
|
|
262
|
-
// commit phase if there was an interleaved mutation. In concurrent mode
|
|
263
|
-
// this can happen all the time, but even in synchronous mode, an earlier
|
|
264
|
-
// effect may have mutated the store.
|
|
265
|
-
|
|
266
|
-
if (checkIfSnapshotChanged(inst)) {
|
|
267
|
-
// Force a re-render.
|
|
268
|
-
forceUpdate({
|
|
269
|
-
inst: inst
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
}, [subscribe, value, getSnapshot]);
|
|
273
|
-
useEffect(function () {
|
|
274
|
-
// Check for changes right before subscribing. Subsequent changes will be
|
|
275
|
-
// detected in the subscription handler.
|
|
276
|
-
if (checkIfSnapshotChanged(inst)) {
|
|
277
|
-
// Force a re-render.
|
|
278
|
-
forceUpdate({
|
|
279
|
-
inst: inst
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
var handleStoreChange = function () {
|
|
284
|
-
// TODO: Because there is no cross-renderer API for batching updates, it's
|
|
285
|
-
// up to the consumer of this library to wrap their subscription event
|
|
286
|
-
// with unstable_batchedUpdates. Should we try to detect when this isn't
|
|
287
|
-
// the case and print a warning in development?
|
|
288
|
-
// The store changed. Check if the snapshot changed since the last time we
|
|
289
|
-
// read from the store.
|
|
290
|
-
if (checkIfSnapshotChanged(inst)) {
|
|
291
|
-
// Force a re-render.
|
|
292
|
-
forceUpdate({
|
|
293
|
-
inst: inst
|
|
294
|
-
});
|
|
295
|
-
}
|
|
296
|
-
}; // Subscribe to the store and return a clean-up function.
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
return subscribe(handleStoreChange);
|
|
300
|
-
}, [subscribe]);
|
|
301
|
-
useDebugValue(value);
|
|
302
|
-
return value;
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function checkIfSnapshotChanged(inst) {
|
|
306
|
-
var latestGetSnapshot = inst.getSnapshot;
|
|
307
|
-
var prevValue = inst.value;
|
|
308
|
-
|
|
309
|
-
try {
|
|
310
|
-
var nextValue = latestGetSnapshot();
|
|
311
|
-
return !objectIs(prevValue, nextValue);
|
|
312
|
-
} catch (error) {
|
|
313
|
-
return true;
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
function useSyncExternalStore$1(subscribe, getSnapshot, getServerSnapshot) {
|
|
318
|
-
// Note: The shim does not use getServerSnapshot, because pre-18 versions of
|
|
319
|
-
// React do not expose a way to check if we're hydrating. So users of the shim
|
|
320
|
-
// will need to track that themselves and return the correct value
|
|
321
|
-
// from `getSnapshot`.
|
|
322
|
-
return getSnapshot();
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
var canUseDOM = !!(typeof window !== 'undefined' && typeof window.document !== 'undefined' && typeof window.document.createElement !== 'undefined');
|
|
326
|
-
|
|
327
|
-
var isServerEnvironment = !canUseDOM;
|
|
328
|
-
|
|
329
|
-
var shim = isServerEnvironment ? useSyncExternalStore$1 : useSyncExternalStore;
|
|
330
|
-
var useSyncExternalStore$2 = React.useSyncExternalStore !== undefined ? React.useSyncExternalStore : shim;
|
|
331
|
-
|
|
332
|
-
exports.useSyncExternalStore = useSyncExternalStore$2;
|
|
333
|
-
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
334
|
-
if (
|
|
335
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
336
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
|
|
337
|
-
'function'
|
|
338
|
-
) {
|
|
339
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
})();
|
|
343
|
-
}
|
|
344
|
-
});
|
|
345
|
-
|
|
346
|
-
var shim = createCommonjsModule(function (module) {
|
|
347
|
-
|
|
348
|
-
{
|
|
349
|
-
module.exports = useSyncExternalStoreShim_development;
|
|
350
|
-
}
|
|
351
|
-
});
|
|
352
|
-
|
|
20
|
+
w((function(t,e){}));var z=w((function(t){t.exports=k}));
|
|
353
21
|
/**
|
|
354
22
|
* @license React
|
|
355
23
|
* use-sync-external-store-shim/with-selector.production.min.js
|
|
@@ -358,9 +26,7 @@ var shim = createCommonjsModule(function (module) {
|
|
|
358
26
|
*
|
|
359
27
|
* This source code is licensed under the MIT license found in the
|
|
360
28
|
* LICENSE file in the root directory of this source tree.
|
|
361
|
-
*/
|
|
362
|
-
shim.useSyncExternalStore;e.useRef;e.useEffect;e.useMemo;e.useDebugValue;
|
|
363
|
-
|
|
29
|
+
*/var I="function"==typeof Object.is?Object.is:function(t,e){return t===e&&(0!==t||1/t==1/e)||t!=t&&e!=e},L=z.useSyncExternalStore,C=t.useRef,M=t.useEffect,F=t.useMemo,_=t.useDebugValue,D={useSyncExternalStoreWithSelector:function(t,e,n,r,o){var i=C(null);if(null===i.current){var u={hasValue:!1,value:null};i.current=u}else u=i.current;i=F((function(){function t(t){if(!a){if(a=!0,i=t,t=r(t),void 0!==o&&u.hasValue){var e=u.value;if(o(e,t))return c=e}return c=t}if(e=c,I(i,t))return e;var n=r(t);return void 0!==o&&o(e,n)?e:(i=t,c=n)}var i,c,a=!1,f=void 0===n?null:n;return[function(){return t(e())},null===f?void 0:function(){return t(f())}]}),[e,n,r,o]);var c=L(t,i[0],i[1]);return M((function(){u.hasValue=!0,u.value=c}),[c]),_(c),c}};
|
|
364
30
|
/**
|
|
365
31
|
* @license React
|
|
366
32
|
* use-sync-external-store-shim/with-selector.development.js
|
|
@@ -370,459 +36,5 @@ shim.useSyncExternalStore;e.useRef;e.useEffect;e.useMemo;e.useDebugValue;
|
|
|
370
36
|
* This source code is licensed under the MIT license found in the
|
|
371
37
|
* LICENSE file in the root directory of this source tree.
|
|
372
38
|
*/
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
{
|
|
377
|
-
(function() {
|
|
378
|
-
|
|
379
|
-
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
380
|
-
if (
|
|
381
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
382
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart ===
|
|
383
|
-
'function'
|
|
384
|
-
) {
|
|
385
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error());
|
|
386
|
-
}
|
|
387
|
-
var React = e;
|
|
388
|
-
var shim$1 = shim;
|
|
389
|
-
|
|
390
|
-
/**
|
|
391
|
-
* inlined Object.is polyfill to avoid requiring consumers ship their own
|
|
392
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
393
|
-
*/
|
|
394
|
-
function is(x, y) {
|
|
395
|
-
return x === y && (x !== 0 || 1 / x === 1 / y) || x !== x && y !== y // eslint-disable-line no-self-compare
|
|
396
|
-
;
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
var objectIs = typeof Object.is === 'function' ? Object.is : is;
|
|
400
|
-
|
|
401
|
-
var useSyncExternalStore = shim$1.useSyncExternalStore;
|
|
402
|
-
|
|
403
|
-
// for CommonJS interop.
|
|
404
|
-
|
|
405
|
-
var useRef = React.useRef,
|
|
406
|
-
useEffect = React.useEffect,
|
|
407
|
-
useMemo = React.useMemo,
|
|
408
|
-
useDebugValue = React.useDebugValue; // Same as useSyncExternalStore, but supports selector and isEqual arguments.
|
|
409
|
-
|
|
410
|
-
function useSyncExternalStoreWithSelector(subscribe, getSnapshot, getServerSnapshot, selector, isEqual) {
|
|
411
|
-
// Use this to track the rendered snapshot.
|
|
412
|
-
var instRef = useRef(null);
|
|
413
|
-
var inst;
|
|
414
|
-
|
|
415
|
-
if (instRef.current === null) {
|
|
416
|
-
inst = {
|
|
417
|
-
hasValue: false,
|
|
418
|
-
value: null
|
|
419
|
-
};
|
|
420
|
-
instRef.current = inst;
|
|
421
|
-
} else {
|
|
422
|
-
inst = instRef.current;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
var _useMemo = useMemo(function () {
|
|
426
|
-
// Track the memoized state using closure variables that are local to this
|
|
427
|
-
// memoized instance of a getSnapshot function. Intentionally not using a
|
|
428
|
-
// useRef hook, because that state would be shared across all concurrent
|
|
429
|
-
// copies of the hook/component.
|
|
430
|
-
var hasMemo = false;
|
|
431
|
-
var memoizedSnapshot;
|
|
432
|
-
var memoizedSelection;
|
|
433
|
-
|
|
434
|
-
var memoizedSelector = function (nextSnapshot) {
|
|
435
|
-
if (!hasMemo) {
|
|
436
|
-
// The first time the hook is called, there is no memoized result.
|
|
437
|
-
hasMemo = true;
|
|
438
|
-
memoizedSnapshot = nextSnapshot;
|
|
439
|
-
|
|
440
|
-
var _nextSelection = selector(nextSnapshot);
|
|
441
|
-
|
|
442
|
-
if (isEqual !== undefined) {
|
|
443
|
-
// Even if the selector has changed, the currently rendered selection
|
|
444
|
-
// may be equal to the new selection. We should attempt to reuse the
|
|
445
|
-
// current value if possible, to preserve downstream memoizations.
|
|
446
|
-
if (inst.hasValue) {
|
|
447
|
-
var currentSelection = inst.value;
|
|
448
|
-
|
|
449
|
-
if (isEqual(currentSelection, _nextSelection)) {
|
|
450
|
-
memoizedSelection = currentSelection;
|
|
451
|
-
return currentSelection;
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
memoizedSelection = _nextSelection;
|
|
457
|
-
return _nextSelection;
|
|
458
|
-
} // We may be able to reuse the previous invocation's result.
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
// We may be able to reuse the previous invocation's result.
|
|
462
|
-
var prevSnapshot = memoizedSnapshot;
|
|
463
|
-
var prevSelection = memoizedSelection;
|
|
464
|
-
|
|
465
|
-
if (objectIs(prevSnapshot, nextSnapshot)) {
|
|
466
|
-
// The snapshot is the same as last time. Reuse the previous selection.
|
|
467
|
-
return prevSelection;
|
|
468
|
-
} // The snapshot has changed, so we need to compute a new selection.
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
// The snapshot has changed, so we need to compute a new selection.
|
|
472
|
-
var nextSelection = selector(nextSnapshot); // If a custom isEqual function is provided, use that to check if the data
|
|
473
|
-
// has changed. If it hasn't, return the previous selection. That signals
|
|
474
|
-
// to React that the selections are conceptually equal, and we can bail
|
|
475
|
-
// out of rendering.
|
|
476
|
-
|
|
477
|
-
// If a custom isEqual function is provided, use that to check if the data
|
|
478
|
-
// has changed. If it hasn't, return the previous selection. That signals
|
|
479
|
-
// to React that the selections are conceptually equal, and we can bail
|
|
480
|
-
// out of rendering.
|
|
481
|
-
if (isEqual !== undefined && isEqual(prevSelection, nextSelection)) {
|
|
482
|
-
return prevSelection;
|
|
483
|
-
}
|
|
484
|
-
|
|
485
|
-
memoizedSnapshot = nextSnapshot;
|
|
486
|
-
memoizedSelection = nextSelection;
|
|
487
|
-
return nextSelection;
|
|
488
|
-
}; // Assigning this to a constant so that Flow knows it can't change.
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
// Assigning this to a constant so that Flow knows it can't change.
|
|
492
|
-
var maybeGetServerSnapshot = getServerSnapshot === undefined ? null : getServerSnapshot;
|
|
493
|
-
|
|
494
|
-
var getSnapshotWithSelector = function () {
|
|
495
|
-
return memoizedSelector(getSnapshot());
|
|
496
|
-
};
|
|
497
|
-
|
|
498
|
-
var getServerSnapshotWithSelector = maybeGetServerSnapshot === null ? undefined : function () {
|
|
499
|
-
return memoizedSelector(maybeGetServerSnapshot());
|
|
500
|
-
};
|
|
501
|
-
return [getSnapshotWithSelector, getServerSnapshotWithSelector];
|
|
502
|
-
}, [getSnapshot, getServerSnapshot, selector, isEqual]),
|
|
503
|
-
getSelection = _useMemo[0],
|
|
504
|
-
getServerSelection = _useMemo[1];
|
|
505
|
-
|
|
506
|
-
var value = useSyncExternalStore(subscribe, getSelection, getServerSelection);
|
|
507
|
-
useEffect(function () {
|
|
508
|
-
inst.hasValue = true;
|
|
509
|
-
inst.value = value;
|
|
510
|
-
}, [value]);
|
|
511
|
-
useDebugValue(value);
|
|
512
|
-
return value;
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
exports.useSyncExternalStoreWithSelector = useSyncExternalStoreWithSelector;
|
|
516
|
-
/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */
|
|
517
|
-
if (
|
|
518
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' &&
|
|
519
|
-
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop ===
|
|
520
|
-
'function'
|
|
521
|
-
) {
|
|
522
|
-
__REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error());
|
|
523
|
-
}
|
|
524
|
-
|
|
525
|
-
})();
|
|
526
|
-
}
|
|
527
|
-
});
|
|
528
|
-
|
|
529
|
-
var withSelector = createCommonjsModule(function (module) {
|
|
530
|
-
|
|
531
|
-
{
|
|
532
|
-
module.exports = withSelector_development;
|
|
533
|
-
}
|
|
534
|
-
});
|
|
535
|
-
|
|
536
|
-
function useRemoteCursorEditor() {
|
|
537
|
-
var editor = useEditorStatic();
|
|
538
|
-
if (!CursorEditor.isCursorEditor(editor)) {
|
|
539
|
-
console.warn('Cannot use useSyncExternalStore outside the context of a RemoteCursorEditor');
|
|
540
|
-
}
|
|
541
|
-
return editor;
|
|
542
|
-
}
|
|
543
|
-
|
|
544
|
-
var EDITOR_TO_CURSOR_STORE = new WeakMap();
|
|
545
|
-
function createRemoteCursorStateStore(editor) {
|
|
546
|
-
var cursors = {};
|
|
547
|
-
var changed = new Set();
|
|
548
|
-
var addChanged = changed.add.bind(changed);
|
|
549
|
-
var onStoreChangeListeners = new Set();
|
|
550
|
-
var changeHandler = null;
|
|
551
|
-
var subscribe = function (onStoreChange) {
|
|
552
|
-
onStoreChangeListeners.add(onStoreChange);
|
|
553
|
-
if (!changeHandler) {
|
|
554
|
-
changeHandler = function (event) {
|
|
555
|
-
event.added.forEach(addChanged);
|
|
556
|
-
event.removed.forEach(addChanged);
|
|
557
|
-
event.updated.forEach(addChanged);
|
|
558
|
-
onStoreChangeListeners.forEach(function (listener) { return listener(); });
|
|
559
|
-
};
|
|
560
|
-
CursorEditor.on(editor, 'change', changeHandler);
|
|
561
|
-
}
|
|
562
|
-
return function () {
|
|
563
|
-
onStoreChangeListeners.delete(onStoreChange);
|
|
564
|
-
if (changeHandler && onStoreChangeListeners.size === 0) {
|
|
565
|
-
CursorEditor.off(editor, 'change', changeHandler);
|
|
566
|
-
changeHandler = null;
|
|
567
|
-
}
|
|
568
|
-
};
|
|
569
|
-
};
|
|
570
|
-
var getSnapshot = function () {
|
|
571
|
-
if (changed.size === 0) {
|
|
572
|
-
return cursors;
|
|
573
|
-
}
|
|
574
|
-
changed.forEach(function (clientId) {
|
|
575
|
-
var state = CursorEditor.cursorState(editor, clientId);
|
|
576
|
-
if (state === null) {
|
|
577
|
-
delete cursors[clientId.toString()];
|
|
578
|
-
return;
|
|
579
|
-
}
|
|
580
|
-
cursors[clientId] = state;
|
|
581
|
-
});
|
|
582
|
-
changed.clear();
|
|
583
|
-
cursors = __assign({}, cursors);
|
|
584
|
-
return cursors;
|
|
585
|
-
};
|
|
586
|
-
return [subscribe, getSnapshot];
|
|
587
|
-
}
|
|
588
|
-
function getCursorStateStore(editor) {
|
|
589
|
-
var existing = EDITOR_TO_CURSOR_STORE.get(editor);
|
|
590
|
-
if (existing) {
|
|
591
|
-
return existing;
|
|
592
|
-
}
|
|
593
|
-
var store = createRemoteCursorStateStore(editor);
|
|
594
|
-
if (editor)
|
|
595
|
-
EDITOR_TO_CURSOR_STORE.set(editor, store);
|
|
596
|
-
return store;
|
|
597
|
-
}
|
|
598
|
-
function useRemoteCursorStateStore() {
|
|
599
|
-
var editor = useRemoteCursorEditor();
|
|
600
|
-
return getCursorStateStore(editor);
|
|
601
|
-
}
|
|
602
|
-
|
|
603
|
-
function useRemoteCursorStates() {
|
|
604
|
-
var _a = __read(useRemoteCursorStateStore(), 2), subscribe = _a[0], getSnapshot = _a[1];
|
|
605
|
-
return shim.useSyncExternalStore(subscribe, getSnapshot);
|
|
606
|
-
}
|
|
607
|
-
function useRemoteCursorStatesSelector(selector, isEqual) {
|
|
608
|
-
var _a = __read(useRemoteCursorStateStore(), 2), subscribe = _a[0], getSnapshot = _a[1];
|
|
609
|
-
return withSelector.useSyncExternalStoreWithSelector(subscribe, getSnapshot, null, selector, isEqual);
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
var CHILDREN_TO_CURSOR_STATE_TO_RANGE = new WeakMap();
|
|
613
|
-
function getCursorRange(editor, cursorState) {
|
|
614
|
-
if (!cursorState.relativeSelection) {
|
|
615
|
-
return null;
|
|
616
|
-
}
|
|
617
|
-
var cursorStates = CHILDREN_TO_CURSOR_STATE_TO_RANGE.get(editor.children);
|
|
618
|
-
if (!cursorStates) {
|
|
619
|
-
cursorStates = new WeakMap();
|
|
620
|
-
CHILDREN_TO_CURSOR_STATE_TO_RANGE.set(editor.children, cursorStates);
|
|
621
|
-
}
|
|
622
|
-
var range = cursorStates.get(cursorState);
|
|
623
|
-
if (range === undefined) {
|
|
624
|
-
try {
|
|
625
|
-
range = relativeRangeToSlateRange(editor.sharedRoot, editor, cursorState.relativeSelection);
|
|
626
|
-
cursorStates.set(cursorState, range);
|
|
627
|
-
}
|
|
628
|
-
catch (e) {
|
|
629
|
-
return null;
|
|
630
|
-
}
|
|
631
|
-
}
|
|
632
|
-
return range;
|
|
633
|
-
}
|
|
634
|
-
|
|
635
|
-
function reactEditorToDomRangeSafe(editor, range) {
|
|
636
|
-
try {
|
|
637
|
-
return DomEditor.toDOMRange(editor, range);
|
|
638
|
-
}
|
|
639
|
-
catch (e) {
|
|
640
|
-
return null;
|
|
641
|
-
}
|
|
642
|
-
}
|
|
643
|
-
|
|
644
|
-
function getOverlayPosition(editor, range, _a) {
|
|
645
|
-
var e_1, _b;
|
|
646
|
-
var yOffset = _a.yOffset, xOffset = _a.xOffset, shouldGenerateOverlay = _a.shouldGenerateOverlay;
|
|
647
|
-
var _c = __read(Range.edges(range), 2), start = _c[0], end = _c[1];
|
|
648
|
-
var domRange = reactEditorToDomRangeSafe(editor, range);
|
|
649
|
-
if (!domRange) {
|
|
650
|
-
return {
|
|
651
|
-
caretPosition: null,
|
|
652
|
-
selectionRects: [],
|
|
653
|
-
};
|
|
654
|
-
}
|
|
655
|
-
var selectionRects = [];
|
|
656
|
-
var nodeIterator = Editor.nodes(editor, {
|
|
657
|
-
at: range,
|
|
658
|
-
match: function (n, p) { return Text.isText(n) && (!shouldGenerateOverlay || shouldGenerateOverlay(n, p)); },
|
|
659
|
-
});
|
|
660
|
-
var caretPosition = null;
|
|
661
|
-
var isBackward = Range.isBackward(range);
|
|
662
|
-
try {
|
|
663
|
-
for (var nodeIterator_1 = __values(nodeIterator), nodeIterator_1_1 = nodeIterator_1.next(); !nodeIterator_1_1.done; nodeIterator_1_1 = nodeIterator_1.next()) {
|
|
664
|
-
var _d = __read(nodeIterator_1_1.value, 2), node = _d[0], path = _d[1];
|
|
665
|
-
var domNode = DomEditor.toDOMNode(editor, node);
|
|
666
|
-
var isStartNode = Path.equals(path, start.path);
|
|
667
|
-
var isEndNode = Path.equals(path, end.path);
|
|
668
|
-
var clientRects = null;
|
|
669
|
-
if (isStartNode || isEndNode) {
|
|
670
|
-
var nodeRange = document.createRange();
|
|
671
|
-
nodeRange.selectNode(domNode);
|
|
672
|
-
if (isStartNode) {
|
|
673
|
-
nodeRange.setStart(domRange.startContainer, domRange.startOffset);
|
|
674
|
-
}
|
|
675
|
-
if (isEndNode) {
|
|
676
|
-
nodeRange.setEnd(domRange.endContainer, domRange.endOffset);
|
|
677
|
-
}
|
|
678
|
-
clientRects = nodeRange.getClientRects();
|
|
679
|
-
}
|
|
680
|
-
else {
|
|
681
|
-
clientRects = domNode.getClientRects();
|
|
682
|
-
}
|
|
683
|
-
var isCaret = isBackward ? isStartNode : isEndNode;
|
|
684
|
-
for (var i = 0; i < clientRects.length; i++) {
|
|
685
|
-
var clientRect = clientRects.item(i);
|
|
686
|
-
if (!clientRect) {
|
|
687
|
-
continue;
|
|
688
|
-
}
|
|
689
|
-
var isCaretRect = isCaret && (isBackward ? i === 0 : i === clientRects.length - 1);
|
|
690
|
-
var top_1 = clientRect.top - yOffset;
|
|
691
|
-
var left = clientRect.left - xOffset;
|
|
692
|
-
if (isCaretRect) {
|
|
693
|
-
caretPosition = {
|
|
694
|
-
height: clientRect.height,
|
|
695
|
-
top: top_1,
|
|
696
|
-
left: left + (isBackward || Range.isCollapsed(range) ? 0 : clientRect.width),
|
|
697
|
-
};
|
|
698
|
-
}
|
|
699
|
-
selectionRects.push({
|
|
700
|
-
width: clientRect.width,
|
|
701
|
-
height: clientRect.height,
|
|
702
|
-
top: top_1,
|
|
703
|
-
left: left,
|
|
704
|
-
});
|
|
705
|
-
}
|
|
706
|
-
}
|
|
707
|
-
}
|
|
708
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
709
|
-
finally {
|
|
710
|
-
try {
|
|
711
|
-
if (nodeIterator_1_1 && !nodeIterator_1_1.done && (_b = nodeIterator_1.return)) _b.call(nodeIterator_1);
|
|
712
|
-
}
|
|
713
|
-
finally { if (e_1) throw e_1.error; }
|
|
714
|
-
}
|
|
715
|
-
return {
|
|
716
|
-
selectionRects: selectionRects,
|
|
717
|
-
caretPosition: caretPosition,
|
|
718
|
-
};
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
function useRequestRerender() {
|
|
722
|
-
var _a = __read(useReducer(function (s) { return s + 1; }, 0), 2), rerender = _a[1];
|
|
723
|
-
var animationFrameIdRef = useRef(null);
|
|
724
|
-
var clearAnimationFrame = function () {
|
|
725
|
-
if (animationFrameIdRef.current) {
|
|
726
|
-
cancelAnimationFrame(animationFrameIdRef.current);
|
|
727
|
-
animationFrameIdRef.current = 0;
|
|
728
|
-
}
|
|
729
|
-
};
|
|
730
|
-
useEffect(clearAnimationFrame);
|
|
731
|
-
useEffect(function () { return clearAnimationFrame; }, []);
|
|
732
|
-
return useCallback(function (immediately) {
|
|
733
|
-
if (immediately === void 0) { immediately = false; }
|
|
734
|
-
if (immediately) {
|
|
735
|
-
rerender();
|
|
736
|
-
return;
|
|
737
|
-
}
|
|
738
|
-
if (animationFrameIdRef.current) {
|
|
739
|
-
return;
|
|
740
|
-
}
|
|
741
|
-
animationFrameIdRef.current = requestAnimationFrame(rerender);
|
|
742
|
-
}, []);
|
|
743
|
-
}
|
|
744
|
-
function useOnResize(ref, onResize) {
|
|
745
|
-
var onResizeRef = useRef(onResize);
|
|
746
|
-
onResizeRef.current = onResize;
|
|
747
|
-
var _a = __read(useState(function () {
|
|
748
|
-
return new ResizeObserver(function () {
|
|
749
|
-
onResizeRef.current();
|
|
750
|
-
});
|
|
751
|
-
}), 1), observer = _a[0];
|
|
752
|
-
useEffect(function () {
|
|
753
|
-
if (!(ref === null || ref === void 0 ? void 0 : ref.current)) {
|
|
754
|
-
return;
|
|
755
|
-
}
|
|
756
|
-
var element = ref.current;
|
|
757
|
-
observer.observe(element);
|
|
758
|
-
return function () { return observer.unobserve(element); };
|
|
759
|
-
}, [observer, ref]);
|
|
760
|
-
}
|
|
761
|
-
|
|
762
|
-
var FROZEN_EMPTY_ARRAY = Object.freeze([]);
|
|
763
|
-
function useRemoteCursorOverlayPositions(_a) {
|
|
764
|
-
var _b;
|
|
765
|
-
if (_a === void 0) { _a = {}; }
|
|
766
|
-
var containerRef = _a.containerRef, shouldGenerateOverlay = _a.shouldGenerateOverlay, opts = __rest(_a, ["containerRef", "shouldGenerateOverlay"]);
|
|
767
|
-
var editor = useRemoteCursorEditor();
|
|
768
|
-
var cursorStates = useRemoteCursorStates();
|
|
769
|
-
var requestRerender = useRequestRerender();
|
|
770
|
-
var overlayPositionCache = useRef(new WeakMap());
|
|
771
|
-
var _c = __read(useState({}), 2), overlayPositions = _c[0], setOverlayPositions = _c[1];
|
|
772
|
-
var refreshOnResize = 'refreshOnResize' in opts ? (_b = opts.refreshOnResize) !== null && _b !== void 0 ? _b : true : true;
|
|
773
|
-
useOnResize(refreshOnResize ? containerRef : undefined, function () {
|
|
774
|
-
overlayPositionCache.current = new WeakMap();
|
|
775
|
-
requestRerender(refreshOnResize !== 'debounced');
|
|
776
|
-
});
|
|
777
|
-
// Update selection rects after paint
|
|
778
|
-
useLayoutEffect(function () {
|
|
779
|
-
var _a, _b, _c;
|
|
780
|
-
// We have a container ref but the ref is null => container
|
|
781
|
-
// isn't mounted to we can't calculate the selection rects.
|
|
782
|
-
if (containerRef && !containerRef.current) {
|
|
783
|
-
return;
|
|
784
|
-
}
|
|
785
|
-
var containerRect = (_a = containerRef === null || containerRef === void 0 ? void 0 : containerRef.current) === null || _a === void 0 ? void 0 : _a.getBoundingClientRect();
|
|
786
|
-
var xOffset = (_b = containerRect === null || containerRect === void 0 ? void 0 : containerRect.x) !== null && _b !== void 0 ? _b : 0;
|
|
787
|
-
var yOffset = (_c = containerRect === null || containerRect === void 0 ? void 0 : containerRect.y) !== null && _c !== void 0 ? _c : 0;
|
|
788
|
-
var overlayPositionsChanged = Object.keys(overlayPositions).length !== Object.keys(cursorStates).length;
|
|
789
|
-
var updated = Object.fromEntries(Object.entries(cursorStates).map(function (_a) {
|
|
790
|
-
var _b = __read(_a, 2), key = _b[0], state = _b[1];
|
|
791
|
-
var range = state.relativeSelection && getCursorRange(editor, state);
|
|
792
|
-
if (!range) {
|
|
793
|
-
return [key, FROZEN_EMPTY_ARRAY];
|
|
794
|
-
}
|
|
795
|
-
var cached = overlayPositionCache.current.get(range);
|
|
796
|
-
if (cached) {
|
|
797
|
-
return [key, cached];
|
|
798
|
-
}
|
|
799
|
-
var overlayPosition = getOverlayPosition(editor, range, {
|
|
800
|
-
xOffset: xOffset,
|
|
801
|
-
yOffset: yOffset,
|
|
802
|
-
shouldGenerateOverlay: shouldGenerateOverlay,
|
|
803
|
-
});
|
|
804
|
-
overlayPositionsChanged = true;
|
|
805
|
-
overlayPositionCache.current.set(range, overlayPosition);
|
|
806
|
-
return [key, overlayPosition];
|
|
807
|
-
}));
|
|
808
|
-
if (overlayPositionsChanged) {
|
|
809
|
-
setOverlayPositions(updated);
|
|
810
|
-
}
|
|
811
|
-
});
|
|
812
|
-
var overlayData = useMemo(function () {
|
|
813
|
-
return Object.entries(cursorStates).map(function (_a) {
|
|
814
|
-
var _b, _c;
|
|
815
|
-
var _d = __read(_a, 2), clientId = _d[0], state = _d[1];
|
|
816
|
-
var range = state.relativeSelection && getCursorRange(editor, state);
|
|
817
|
-
var overlayPosition = overlayPositions[clientId];
|
|
818
|
-
return __assign(__assign({}, state), { range: range, caretPosition: (_b = overlayPosition === null || overlayPosition === void 0 ? void 0 : overlayPosition.caretPosition) !== null && _b !== void 0 ? _b : null, selectionRects: (_c = overlayPosition === null || overlayPosition === void 0 ? void 0 : overlayPosition.selectionRects) !== null && _c !== void 0 ? _c : FROZEN_EMPTY_ARRAY });
|
|
819
|
-
});
|
|
820
|
-
}, [cursorStates, editor, overlayPositions]);
|
|
821
|
-
var refresh = useCallback(function () {
|
|
822
|
-
overlayPositionCache.current = new WeakMap();
|
|
823
|
-
requestRerender(true);
|
|
824
|
-
}, [requestRerender]);
|
|
825
|
-
return [overlayData, refresh];
|
|
826
|
-
}
|
|
827
|
-
|
|
828
|
-
export { EditorContext, getCursorRange, useEditorStatic, useRemoteCursorOverlayPositions, useRemoteCursorStates, useRemoteCursorStatesSelector };
|
|
39
|
+
w((function(t,e){}));var N,G,W=w((function(t){t.exports=D})),V=function(t){return t&&t.Math==Math&&t},B=V("object"==typeof globalThis&&globalThis)||V("object"==typeof window&&window)||V("object"==typeof self&&self)||V("object"==typeof O&&O)||function(){return this}()||Function("return this")(),U=Function.prototype,q=U.bind,H=U.call,X=q&&q.bind(H),K=q?function(t){return t&&X(H,t)}:function(t){return t&&function(){return H.apply(t,arguments)}},Y=function(t){try{return!!t()}catch(t){return!0}},$=K({}.toString),J=K("".slice),Q=function(t){return J($(t),8,-1)},Z=B.Object,tt=K("".split),et=Y((function(){return!Z("z").propertyIsEnumerable(0)}))?function(t){return"String"==Q(t)?tt(t,""):Z(t)}:Z,nt=B.TypeError,rt=function(t){if(null==t)throw nt("Can't call method on "+t);return t},ot=function(t){return et(rt(t))},it=Object.defineProperty,ut=function(t,e){try{it(B,t,{value:e,configurable:!0,writable:!0})}catch(n){B[t]=e}return e},ct="__core-js_shared__",at=B[ct]||ut(ct,{}),ft=w((function(t){(t.exports=function(t,e){return at[t]||(at[t]=void 0!==e?e:{})})("versions",[]).push({version:"3.19.3",mode:"global",copyright:"© 2021 Denis Pushkarev (zloirock.ru)"})})),st=B.Object,lt=function(t){return st(rt(t))},vt=K({}.hasOwnProperty),pt=Object.hasOwn||function(t,e){return vt(lt(t),e)},dt=0,ht=Math.random(),yt=K(1..toString),gt=function(t){return"Symbol("+(void 0===t?"":t)+")_"+yt(++dt+ht,36)},bt=function(t){return"function"==typeof t},mt=function(t,e){return arguments.length<2?(n=B[t],bt(n)?n:void 0):B[t]&&B[t][e];var n},St=mt("navigator","userAgent")||"",Ot=B.process,wt=B.Deno,Et=Ot&&Ot.versions||wt&&wt.version,jt=Et&&Et.v8;jt&&(G=(N=jt.split("."))[0]>0&&N[0]<4?1:+(N[0]+N[1])),!G&&St&&(!(N=St.match(/Edge\/(\d+)/))||N[1]>=74)&&(N=St.match(/Chrome\/(\d+)/))&&(G=+N[1]);var xt,At=G,Tt=!!Object.getOwnPropertySymbols&&!Y((function(){var t=Symbol();return!String(t)||!(Object(t)instanceof Symbol)||!Symbol.sham&&At&&At<41})),Pt=Tt&&!Symbol.sham&&"symbol"==typeof Symbol.iterator,Rt=ft("wks"),kt=B.Symbol,zt=kt&&kt.for,It=Pt?kt:kt&&kt.withoutSetter||gt,Lt=function(t){if(!pt(Rt,t)||!Tt&&"string"!=typeof Rt[t]){var e="Symbol."+t;Tt&&pt(kt,t)?Rt[t]=kt[t]:Rt[t]=Pt&&zt?zt(e):It(e)}return Rt[t]},Ct=function(t){return"object"==typeof t?null!==t:bt(t)},Mt=B.String,Ft=B.TypeError,_t=function(t){if(Ct(t))return t;throw Ft(Mt(t)+" is not an object")},Dt=!Y((function(){return 7!=Object.defineProperty({},1,{get:function(){return 7}})[1]})),Nt=B.document,Gt=Ct(Nt)&&Ct(Nt.createElement),Wt=function(t){return Gt?Nt.createElement(t):{}},Vt=!Dt&&!Y((function(){return 7!=Object.defineProperty(Wt("div"),"a",{get:function(){return 7}}).a})),Bt=Function.prototype.call,Ut=Bt.bind?Bt.bind(Bt):function(){return Bt.apply(Bt,arguments)},qt=K({}.isPrototypeOf),Ht=B.Object,Xt=Pt?function(t){return"symbol"==typeof t}:function(t){var e=mt("Symbol");return bt(e)&&qt(e.prototype,Ht(t))},Kt=B.String,Yt=function(t){try{return Kt(t)}catch(t){return"Object"}},$t=B.TypeError,Jt=function(t){if(bt(t))return t;throw $t(Yt(t)+" is not a function")},Qt=function(t,e){var n=t[e];return null==n?void 0:Jt(n)},Zt=B.TypeError,te=B.TypeError,ee=Lt("toPrimitive"),ne=function(t,e){if(!Ct(t)||Xt(t))return t;var n,r=Qt(t,ee);if(r){if(void 0===e&&(e="default"),n=Ut(r,t,e),!Ct(n)||Xt(n))return n;throw te("Can't convert object to primitive value")}return void 0===e&&(e="number"),function(t,e){var n,r;if("string"===e&&bt(n=t.toString)&&!Ct(r=Ut(n,t)))return r;if(bt(n=t.valueOf)&&!Ct(r=Ut(n,t)))return r;if("string"!==e&&bt(n=t.toString)&&!Ct(r=Ut(n,t)))return r;throw Zt("Can't convert object to primitive value")}(t,e)},re=function(t){var e=ne(t,"string");return Xt(e)?e:e+""},oe=B.TypeError,ie=Object.defineProperty,ue={f:Dt?ie:function(t,e,n){if(_t(t),e=re(e),_t(n),Vt)try{return ie(t,e,n)}catch(t){}if("get"in n||"set"in n)throw oe("Accessors not supported");return"value"in n&&(t[e]=n.value),t}},ce=Math.ceil,ae=Math.floor,fe=function(t){var e=+t;return e!=e||0===e?0:(e>0?ae:ce)(e)},se=Math.max,le=Math.min,ve=function(t,e){var n=fe(t);return n<0?se(n+e,0):le(n,e)},pe=Math.min,de=function(t){return(e=t.length)>0?pe(fe(e),9007199254740991):0;var e},he=function(t){return function(e,n,r){var o,i=ot(e),u=de(i),c=ve(r,u);if(t&&n!=n){for(;u>c;)if((o=i[c++])!=o)return!0}else for(;u>c;c++)if((t||c in i)&&i[c]===n)return t||c||0;return!t&&-1}},ye={includes:he(!0),indexOf:he(!1)},ge={},be=ye.indexOf,me=K([].push),Se=function(t,e){var n,r=ot(t),o=0,i=[];for(n in r)!pt(ge,n)&&pt(r,n)&&me(i,n);for(;e.length>o;)pt(r,n=e[o++])&&(~be(i,n)||me(i,n));return i},Oe=["constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"],we=Object.keys||function(t){return Se(t,Oe)},Ee=Dt?Object.defineProperties:function(t,e){_t(t);for(var n,r=ot(e),o=we(e),i=o.length,u=0;i>u;)ue.f(t,n=o[u++],r[n]);return t},je=mt("document","documentElement"),xe=ft("keys"),Ae=function(t){return xe[t]||(xe[t]=gt(t))},Te="prototype",Pe="script",Re=Ae("IE_PROTO"),ke=function(){},ze=function(t){return"<"+Pe+">"+t+"</"+Pe+">"},Ie=function(t){t.write(ze("")),t.close();var e=t.parentWindow.Object;return t=null,e},Le=function(){try{xt=new ActiveXObject("htmlfile")}catch(t){}var t,e,n;Le="undefined"!=typeof document?document.domain&&xt?Ie(xt):(e=Wt("iframe"),n="java"+Pe+":",e.style.display="none",je.appendChild(e),e.src=String(n),(t=e.contentWindow.document).open(),t.write(ze("document.F=Object")),t.close(),t.F):Ie(xt);for(var r=Oe.length;r--;)delete Le[Te][Oe[r]];return Le()};ge[Re]=!0;var Ce=Object.create||function(t,e){var n;return null!==t?(ke[Te]=_t(t),n=new ke,ke[Te]=null,n[Re]=t):n=Le(),void 0===e?n:Ee(n,e)},Me=Lt("unscopables"),Fe=Array.prototype;null==Fe[Me]&&ue.f(Fe,Me,{configurable:!0,value:Ce(null)});var _e=function(t){Fe[Me][t]=!0},De={},Ne=K(Function.toString);bt(at.inspectSource)||(at.inspectSource=function(t){return Ne(t)});var Ge,We,Ve,Be=at.inspectSource,Ue=B.WeakMap,qe=bt(Ue)&&/native code/.test(Be(Ue)),He=function(t,e){return{enumerable:!(1&t),configurable:!(2&t),writable:!(4&t),value:e}},Xe=Dt?function(t,e,n){return ue.f(t,e,He(1,n))}:function(t,e,n){return t[e]=n,t},Ke="Object already initialized",Ye=B.TypeError,$e=B.WeakMap;if(qe||at.state){var Je=at.state||(at.state=new $e),Qe=K(Je.get),Ze=K(Je.has),tn=K(Je.set);Ge=function(t,e){if(Ze(Je,t))throw new Ye(Ke);return e.facade=t,tn(Je,t,e),e},We=function(t){return Qe(Je,t)||{}},Ve=function(t){return Ze(Je,t)}}else{var en=Ae("state");ge[en]=!0,Ge=function(t,e){if(pt(t,en))throw new Ye(Ke);return e.facade=t,Xe(t,en,e),e},We=function(t){return pt(t,en)?t[en]:{}},Ve=function(t){return pt(t,en)}}var nn,rn,on,un={set:Ge,get:We,has:Ve,enforce:function(t){return Ve(t)?We(t):Ge(t,{})},getterFor:function(t){return function(e){var n;if(!Ct(e)||(n=We(e)).type!==t)throw Ye("Incompatible receiver, "+t+" required");return n}}},cn={}.propertyIsEnumerable,an=Object.getOwnPropertyDescriptor,fn={f:an&&!cn.call({1:2},1)?function(t){var e=an(this,t);return!!e&&e.enumerable}:cn},sn=Object.getOwnPropertyDescriptor,ln={f:Dt?sn:function(t,e){if(t=ot(t),e=re(e),Vt)try{return sn(t,e)}catch(t){}if(pt(t,e))return He(!Ut(fn.f,t,e),t[e])}},vn=Function.prototype,pn=Dt&&Object.getOwnPropertyDescriptor,dn=pt(vn,"name"),hn={EXISTS:dn,PROPER:dn&&"something"===function(){}.name,CONFIGURABLE:dn&&(!Dt||Dt&&pn(vn,"name").configurable)},yn=w((function(t){var e=hn.CONFIGURABLE,n=un.get,r=un.enforce,o=String(String).split("String");(t.exports=function(t,n,i,u){var c,a=!!u&&!!u.unsafe,f=!!u&&!!u.enumerable,s=!!u&&!!u.noTargetGet,l=u&&void 0!==u.name?u.name:n;bt(i)&&("Symbol("===String(l).slice(0,7)&&(l="["+String(l).replace(/^Symbol\(([^)]*)\)/,"$1")+"]"),(!pt(i,"name")||e&&i.name!==l)&&Xe(i,"name",l),(c=r(i)).source||(c.source=o.join("string"==typeof l?l:""))),t!==B?(a?!s&&t[n]&&(f=!0):delete t[n],f?t[n]=i:Xe(t,n,i)):f?t[n]=i:ut(n,i)})(Function.prototype,"toString",(function(){return bt(this)&&n(this).source||Be(this)}))})),gn=Oe.concat("length","prototype"),bn={f:Object.getOwnPropertyNames||function(t){return Se(t,gn)}},mn={f:Object.getOwnPropertySymbols},Sn=K([].concat),On=mt("Reflect","ownKeys")||function(t){var e=bn.f(_t(t)),n=mn.f;return n?Sn(e,n(t)):e},wn=function(t,e){for(var n=On(e),r=ue.f,o=ln.f,i=0;i<n.length;i++){var u=n[i];pt(t,u)||r(t,u,o(e,u))}},En=/#|\.prototype\./,jn=function(t,e){var n=An[xn(t)];return n==Pn||n!=Tn&&(bt(e)?Y(e):!!e)},xn=jn.normalize=function(t){return String(t).replace(En,".").toLowerCase()},An=jn.data={},Tn=jn.NATIVE="N",Pn=jn.POLYFILL="P",Rn=jn,kn=ln.f,zn=function(t,e){var n,r,o,i,u,c=t.target,a=t.global,f=t.stat;if(n=a?B:f?B[c]||ut(c,{}):(B[c]||{}).prototype)for(r in e){if(i=e[r],o=t.noTargetGet?(u=kn(n,r))&&u.value:n[r],!Rn(a?r:c+(f?".":"#")+r,t.forced)&&void 0!==o){if(typeof i==typeof o)continue;wn(i,o)}(t.sham||o&&o.sham)&&Xe(i,"sham",!0),yn(n,r,i,t)}},In=!Y((function(){function t(){}return t.prototype.constructor=null,Object.getPrototypeOf(new t)!==t.prototype})),Ln=Ae("IE_PROTO"),Cn=B.Object,Mn=Cn.prototype,Fn=In?Cn.getPrototypeOf:function(t){var e=lt(t);if(pt(e,Ln))return e[Ln];var n=e.constructor;return bt(n)&&e instanceof n?n.prototype:e instanceof Cn?Mn:null},_n=Lt("iterator"),Dn=!1;[].keys&&("next"in(on=[].keys())?(rn=Fn(Fn(on)))!==Object.prototype&&(nn=rn):Dn=!0);var Nn=null==nn||Y((function(){var t={};return nn[_n].call(t)!==t}));Nn&&(nn={}),bt(nn[_n])||yn(nn,_n,(function(){return this}));var Gn={IteratorPrototype:nn,BUGGY_SAFARI_ITERATORS:Dn},Wn=ue.f,Vn=Lt("toStringTag"),Bn=function(t,e,n){t&&!pt(t=n?t:t.prototype,Vn)&&Wn(t,Vn,{configurable:!0,value:e})},Un=Gn.IteratorPrototype,qn=function(){return this},Hn=B.String,Xn=B.TypeError,Kn=Object.setPrototypeOf||("__proto__"in{}?function(){var t,e=!1,n={};try{(t=K(Object.getOwnPropertyDescriptor(Object.prototype,"__proto__").set))(n,[]),e=n instanceof Array}catch(t){}return function(n,r){return _t(n),function(t){if("object"==typeof t||bt(t))return t;throw Xn("Can't set "+Hn(t)+" as a prototype")}(r),e?t(n,r):n.__proto__=r,n}}():void 0),Yn=hn.PROPER,$n=hn.CONFIGURABLE,Jn=Gn.IteratorPrototype,Qn=Gn.BUGGY_SAFARI_ITERATORS,Zn=Lt("iterator"),tr="keys",er="values",nr="entries",rr=function(){return this},or=function(t,e,n,r,o,i,u){!function(t,e,n,r){var o=e+" Iterator";t.prototype=Ce(Un,{next:He(+!r,n)}),Bn(t,o,!1),De[o]=qn}(n,e,r);var c,a,f,s=function(t){if(t===o&&h)return h;if(!Qn&&t in p)return p[t];switch(t){case tr:case er:case nr:return function(){return new n(this,t)}}return function(){return new n(this)}},l=e+" Iterator",v=!1,p=t.prototype,d=p[Zn]||p["@@iterator"]||o&&p[o],h=!Qn&&d||s(o),y="Array"==e&&p.entries||d;if(y&&(c=Fn(y.call(new t)))!==Object.prototype&&c.next&&(Fn(c)!==Jn&&(Kn?Kn(c,Jn):bt(c[Zn])||yn(c,Zn,rr)),Bn(c,l,!0)),Yn&&o==er&&d&&d.name!==er&&($n?Xe(p,"name",er):(v=!0,h=function(){return Ut(d,this)})),o)if(a={values:s(er),keys:i?h:s(tr),entries:s(nr)},u)for(f in a)(Qn||v||!(f in p))&&yn(p,f,a[f]);else zn({target:e,proto:!0,forced:Qn||v},a);return p[Zn]!==h&&yn(p,Zn,h,{name:o}),De[e]=h,a},ir="Array Iterator",ur=un.set,cr=un.getterFor(ir),ar=or(Array,"Array",(function(t,e){ur(this,{type:ir,target:ot(t),index:0,kind:e})}),(function(){var t=cr(this),e=t.target,n=t.kind,r=t.index++;return!e||r>=e.length?(t.target=void 0,{value:void 0,done:!0}):"keys"==n?{value:r,done:!1}:"values"==n?{value:e[r],done:!1}:{value:[r,e[r]],done:!1}}),"values");De.Arguments=De.Array,_e("keys"),_e("values"),_e("entries");var fr={};fr[Lt("toStringTag")]="z";var sr="[object z]"===String(fr),lr=Lt("toStringTag"),vr=B.Object,pr="Arguments"==Q(function(){return arguments}()),dr=sr?Q:function(t){var e,n,r;return void 0===t?"Undefined":null===t?"Null":"string"==typeof(n=function(t,e){try{return t[e]}catch(t){}}(e=vr(t),lr))?n:pr?Q(e):"Object"==(r=Q(e))&&bt(e.callee)?"Arguments":r},hr=sr?{}.toString:function(){return"[object "+dr(this)+"]"};sr||yn(Object.prototype,"toString",hr,{unsafe:!0});var yr=B.String,gr=function(t){if("Symbol"===dr(t))throw TypeError("Cannot convert a Symbol value to a string");return yr(t)},br=hn.PROPER,mr="toString",Sr=RegExp.prototype,Or=Sr[mr],wr=K((function(){var t=_t(this),e="";return t.global&&(e+="g"),t.ignoreCase&&(e+="i"),t.multiline&&(e+="m"),t.dotAll&&(e+="s"),t.unicode&&(e+="u"),t.sticky&&(e+="y"),e})),Er=Y((function(){return"/a/b"!=Or.call({source:"a",flags:"b"})})),jr=br&&Or.name!=mr;(Er||jr)&&yn(RegExp.prototype,mr,(function(){var t=_t(this),e=gr(t.source),n=t.flags;return"/"+e+"/"+gr(void 0===n&&qt(Sr,t)&&!("flags"in Sr)?wr(t):n)}),{unsafe:!0});var xr=function(t,e,n){var r=re(e);r in t?ue.f(t,r,He(0,n)):t[r]=n},Ar=B.Array,Tr=Math.max,Pr=bn.f,Rr="object"==typeof window&&window&&Object.getOwnPropertyNames?Object.getOwnPropertyNames(window):[],kr=function(t){try{return Pr(t)}catch(t){return function(t,e,n){for(var r=de(t),o=ve(e,r),i=ve(void 0===n?r:n,r),u=Ar(Tr(i-o,0)),c=0;o<i;o++,c++)xr(u,c,t[o]);return u.length=c,u}(Rr)}},zr={f:function(t){return Rr&&"Window"==Q(t)?kr(t):Pr(ot(t))}},Ir=Y((function(){if("function"==typeof ArrayBuffer){var t=new ArrayBuffer(8);Object.isExtensible(t)&&Object.defineProperty(t,"a",{value:8})}})),Lr=Object.isExtensible,Cr=Y((function(){Lr(1)}))||Ir?function(t){return!!Ct(t)&&((!Ir||"ArrayBuffer"!=Q(t))&&(!Lr||Lr(t)))}:Lr,Mr=!Y((function(){return Object.isExtensible(Object.preventExtensions({}))})),Fr=w((function(t){var e=ue.f,n=!1,r=gt("meta"),o=0,i=function(t){e(t,r,{value:{objectID:"O"+o++,weakData:{}}})},u=t.exports={enable:function(){u.enable=function(){},n=!0;var t=bn.f,e=K([].splice),o={};o[r]=1,t(o).length&&(bn.f=function(n){for(var o=t(n),i=0,u=o.length;i<u;i++)if(o[i]===r){e(o,i,1);break}return o},zn({target:"Object",stat:!0,forced:!0},{getOwnPropertyNames:zr.f}))},fastKey:function(t,e){if(!Ct(t))return"symbol"==typeof t?t:("string"==typeof t?"S":"P")+t;if(!pt(t,r)){if(!Cr(t))return"F";if(!e)return"E";i(t)}return t[r].objectID},getWeakData:function(t,e){if(!pt(t,r)){if(!Cr(t))return!0;if(!e)return!1;i(t)}return t[r].weakData},onFreeze:function(t){return Mr&&n&&Cr(t)&&!pt(t,r)&&i(t),t}};ge[r]=!0})),_r=K(K.bind),Dr=function(t,e){return Jt(t),void 0===e?t:_r?_r(t,e):function(){return t.apply(e,arguments)}},Nr=Lt("iterator"),Gr=Array.prototype,Wr=Lt("iterator"),Vr=function(t){if(null!=t)return Qt(t,Wr)||Qt(t,"@@iterator")||De[dr(t)]},Br=B.TypeError,Ur=function(t,e,n){var r,o;_t(t);try{if(!(r=Qt(t,"return"))){if("throw"===e)throw n;return n}r=Ut(r,t)}catch(t){o=!0,r=t}if("throw"===e)throw n;if(o)throw r;return _t(r),n},qr=B.TypeError,Hr=function(t,e){this.stopped=t,this.result=e},Xr=Hr.prototype,Kr=function(t,e,n){var r,o,i,u,c,a,f,s,l=n&&n.that,v=!(!n||!n.AS_ENTRIES),p=!(!n||!n.IS_ITERATOR),d=!(!n||!n.INTERRUPTED),h=Dr(e,l),y=function(t){return r&&Ur(r,"normal",t),new Hr(!0,t)},g=function(t){return v?(_t(t),d?h(t[0],t[1],y):h(t[0],t[1])):d?h(t,y):h(t)};if(p)r=t;else{if(!(o=Vr(t)))throw qr(Yt(t)+" is not iterable");if(void 0!==(s=o)&&(De.Array===s||Gr[Nr]===s)){for(i=0,u=de(t);u>i;i++)if((c=g(t[i]))&&qt(Xr,c))return c;return new Hr(!1)}r=function(t,e){var n=arguments.length<2?Vr(t):e;if(Jt(n))return _t(Ut(n,t));throw Br(Yt(t)+" is not iterable")}(t,o)}for(a=r.next;!(f=Ut(a,r)).done;){try{c=g(f.value)}catch(t){Ur(r,"throw",t)}if("object"==typeof c&&c&&qt(Xr,c))return c}return new Hr(!1)},Yr=B.TypeError,$r=function(t,e){if(qt(e,t))return t;throw Yr("Incorrect invocation")},Jr=Lt("iterator"),Qr=!1;try{var Zr=0,to={next:function(){return{done:!!Zr++}},return:function(){Qr=!0}};to[Jr]=function(){return this},Array.from(to,(function(){throw 2}))}catch(t){}var eo=function(t,e,n){var r=-1!==t.indexOf("Map"),o=-1!==t.indexOf("Weak"),i=r?"set":"add",u=B[t],c=u&&u.prototype,a=u,f={},s=function(t){var e=K(c[t]);yn(c,t,"add"==t?function(t){return e(this,0===t?0:t),this}:"delete"==t?function(t){return!(o&&!Ct(t))&&e(this,0===t?0:t)}:"get"==t?function(t){return o&&!Ct(t)?void 0:e(this,0===t?0:t)}:"has"==t?function(t){return!(o&&!Ct(t))&&e(this,0===t?0:t)}:function(t,n){return e(this,0===t?0:t,n),this})};if(Rn(t,!bt(u)||!(o||c.forEach&&!Y((function(){(new u).entries().next()})))))a=n.getConstructor(e,t,r,i),Fr.enable();else if(Rn(t,!0)){var l=new a,v=l[i](o?{}:-0,1)!=l,p=Y((function(){l.has(1)})),d=function(t,e){if(!e&&!Qr)return!1;var n=!1;try{var r={};r[Jr]=function(){return{next:function(){return{done:n=!0}}}},t(r)}catch(t){}return n}((function(t){new u(t)})),h=!o&&Y((function(){for(var t=new u,e=5;e--;)t[i](e,e);return!t.has(-0)}));d||((a=e((function(t,e){$r(t,c);var n=function(t,e,n){var r,o;return Kn&&bt(r=e.constructor)&&r!==n&&Ct(o=r.prototype)&&o!==n.prototype&&Kn(t,o),t}(new u,t,a);return null!=e&&Kr(e,n[i],{that:n,AS_ENTRIES:r}),n}))).prototype=c,c.constructor=a),(p||h)&&(s("delete"),s("has"),r&&s("get")),(h||v)&&s(i),o&&c.clear&&delete c.clear}return f[t]=a,zn({global:!0,forced:a!=u},f),Bn(a,t),o||n.setStrong(a,t,r),a},no=function(t,e,n){for(var r in e)yn(t,r,e[r],n);return t},ro=Lt("species"),oo=ue.f,io=Fr.fastKey,uo=un.set,co=un.getterFor,ao={getConstructor:function(t,e,n,r){var o=t((function(t,o){$r(t,i),uo(t,{type:e,index:Ce(null),first:void 0,last:void 0,size:0}),Dt||(t.size=0),null!=o&&Kr(o,t[r],{that:t,AS_ENTRIES:n})})),i=o.prototype,u=co(e),c=function(t,e,n){var r,o,i=u(t),c=a(t,e);return c?c.value=n:(i.last=c={index:o=io(e,!0),key:e,value:n,previous:r=i.last,next:void 0,removed:!1},i.first||(i.first=c),r&&(r.next=c),Dt?i.size++:t.size++,"F"!==o&&(i.index[o]=c)),t},a=function(t,e){var n,r=u(t),o=io(e);if("F"!==o)return r.index[o];for(n=r.first;n;n=n.next)if(n.key==e)return n};return no(i,{clear:function(){for(var t=u(this),e=t.index,n=t.first;n;)n.removed=!0,n.previous&&(n.previous=n.previous.next=void 0),delete e[n.index],n=n.next;t.first=t.last=void 0,Dt?t.size=0:this.size=0},delete:function(t){var e=this,n=u(e),r=a(e,t);if(r){var o=r.next,i=r.previous;delete n.index[r.index],r.removed=!0,i&&(i.next=o),o&&(o.previous=i),n.first==r&&(n.first=o),n.last==r&&(n.last=i),Dt?n.size--:e.size--}return!!r},forEach:function(t){for(var e,n=u(this),r=Dr(t,arguments.length>1?arguments[1]:void 0);e=e?e.next:n.first;)for(r(e.value,e.key,this);e&&e.removed;)e=e.previous},has:function(t){return!!a(this,t)}}),no(i,n?{get:function(t){var e=a(this,t);return e&&e.value},set:function(t,e){return c(this,0===t?0:t,e)}}:{add:function(t){return c(this,t=0===t?0:t,t)}}),Dt&&oo(i,"size",{get:function(){return u(this).size}}),o},setStrong:function(t,e,n){var r=e+" Iterator",o=co(e),i=co(r);or(t,e,(function(t,e){uo(this,{type:r,target:t,state:o(t),kind:e,last:void 0})}),(function(){for(var t=i(this),e=t.kind,n=t.last;n&&n.removed;)n=n.previous;return t.target&&(t.last=n=n?n.next:t.state.first)?"keys"==e?{value:n.key,done:!1}:"values"==e?{value:n.value,done:!1}:{value:[n.key,n.value],done:!1}:(t.target=void 0,{value:void 0,done:!0})}),n?"entries":"values",!n,!0),function(t){var e=mt(t),n=ue.f;Dt&&e&&!e[ro]&&n(e,ro,{configurable:!0,get:function(){return this}})}(e)}};eo("Set",(function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}}),ao);var fo=K("".charAt),so=K("".charCodeAt),lo=K("".slice),vo=function(t){return function(e,n){var r,o,i=gr(rt(e)),u=fe(n),c=i.length;return u<0||u>=c?t?"":void 0:(r=so(i,u))<55296||r>56319||u+1===c||(o=so(i,u+1))<56320||o>57343?t?fo(i,u):r:t?lo(i,u,u+2):o-56320+(r-55296<<10)+65536}},po={codeAt:vo(!1),charAt:vo(!0)}.charAt,ho="String Iterator",yo=un.set,go=un.getterFor(ho);or(String,"String",(function(t){yo(this,{type:ho,string:gr(t),index:0})}),(function(){var t,e=go(this),n=e.string,r=e.index;return r>=n.length?{value:void 0,done:!0}:(t=po(n,r),e.index+=t.length,{value:t,done:!1})}));var bo=Array.isArray||function(t){return"Array"==Q(t)},mo=function(){},So=[],Oo=mt("Reflect","construct"),wo=/^\s*(?:class|function)\b/,Eo=K(wo.exec),jo=!wo.exec(mo),xo=function(t){if(!bt(t))return!1;try{return Oo(mo,So,t),!0}catch(t){return!1}},Ao=!Oo||Y((function(){var t;return xo(xo.call)||!xo(Object)||!xo((function(){t=!0}))||t}))?function(t){if(!bt(t))return!1;switch(dr(t)){case"AsyncFunction":case"GeneratorFunction":case"AsyncGeneratorFunction":return!1}return jo||!!Eo(wo,Be(t))}:xo,To=Lt("species"),Po=B.Array,Ro=function(t,e){return new(function(t){var e;return bo(t)&&(e=t.constructor,(Ao(e)&&(e===Po||bo(e.prototype))||Ct(e)&&null===(e=e[To]))&&(e=void 0)),void 0===e?Po:e}(t))(0===e?0:e)},ko=K([].push),zo=function(t){var e=1==t,n=2==t,r=3==t,o=4==t,i=6==t,u=7==t,c=5==t||i;return function(a,f,s,l){for(var v,p,d=lt(a),h=et(d),y=Dr(f,s),g=de(h),b=0,m=l||Ro,S=e?m(a,g):n||u?m(a,0):void 0;g>b;b++)if((c||b in h)&&(p=y(v=h[b],b,d),t))if(e)S[b]=p;else if(p)switch(t){case 3:return!0;case 5:return v;case 6:return b;case 2:ko(S,v)}else switch(t){case 4:return!1;case 7:ko(S,v)}return i?-1:r||o?o:S}},Io={forEach:zo(0),map:zo(1),filter:zo(2),some:zo(3),every:zo(4),find:zo(5),findIndex:zo(6),filterReject:zo(7)},Lo=Fr.getWeakData,Co=un.set,Mo=un.getterFor,Fo=Io.find,_o=Io.findIndex,Do=K([].splice),No=0,Go=function(t){return t.frozen||(t.frozen=new Wo)},Wo=function(){this.entries=[]},Vo=function(t,e){return Fo(t.entries,(function(t){return t[0]===e}))};Wo.prototype={get:function(t){var e=Vo(this,t);if(e)return e[1]},has:function(t){return!!Vo(this,t)},set:function(t,e){var n=Vo(this,t);n?n[1]=e:this.entries.push([t,e])},delete:function(t){var e=_o(this.entries,(function(e){return e[0]===t}));return~e&&Do(this.entries,e,1),!!~e}};var Bo,Uo={getConstructor:function(t,e,n,r){var o=t((function(t,o){$r(t,i),Co(t,{type:e,id:No++,frozen:void 0}),null!=o&&Kr(o,t[r],{that:t,AS_ENTRIES:n})})),i=o.prototype,u=Mo(e),c=function(t,e,n){var r=u(t),o=Lo(_t(e),!0);return!0===o?Go(r).set(e,n):o[r.id]=n,t};return no(i,{delete:function(t){var e=u(this);if(!Ct(t))return!1;var n=Lo(t);return!0===n?Go(e).delete(t):n&&pt(n,e.id)&&delete n[e.id]},has:function(t){var e=u(this);if(!Ct(t))return!1;var n=Lo(t);return!0===n?Go(e).has(t):n&&pt(n,e.id)}}),no(i,n?{get:function(t){var e=u(this);if(Ct(t)){var n=Lo(t);return!0===n?Go(e).get(t):n?n[e.id]:void 0}},set:function(t,e){return c(this,t,e)}}:{add:function(t){return c(this,t,!0)}}),o}},qo=un.enforce,Ho=!B.ActiveXObject&&"ActiveXObject"in B,Xo=function(t){return function(){return t(this,arguments.length?arguments[0]:void 0)}},Ko=eo("WeakMap",Xo,Uo);if(qe&&Ho){Bo=Uo.getConstructor(Xo,"WeakMap",!0),Fr.enable();var Yo=Ko.prototype,$o=K(Yo.delete),Jo=K(Yo.has),Qo=K(Yo.get),Zo=K(Yo.set);no(Yo,{delete:function(t){if(Ct(t)&&!Cr(t)){var e=qo(this);return e.frozen||(e.frozen=new Bo),$o(this,t)||e.frozen.delete(t)}return $o(this,t)},has:function(t){if(Ct(t)&&!Cr(t)){var e=qo(this);return e.frozen||(e.frozen=new Bo),Jo(this,t)||e.frozen.has(t)}return Jo(this,t)},get:function(t){if(Ct(t)&&!Cr(t)){var e=qo(this);return e.frozen||(e.frozen=new Bo),Jo(this,t)?Qo(this,t):e.frozen.get(t)}return Qo(this,t)},set:function(t,e){if(Ct(t)&&!Cr(t)){var n=qo(this);n.frozen||(n.frozen=new Bo),Jo(this,t)?Zo(this,t,e):n.frozen.set(t,e)}else Zo(this,t,e);return this}})}var ti,ei,ni={CSSRuleList:0,CSSStyleDeclaration:0,CSSValueList:0,ClientRectList:0,DOMRectList:0,DOMStringList:0,DOMTokenList:1,DataTransferItemList:0,FileList:0,HTMLAllCollection:0,HTMLCollection:0,HTMLFormElement:0,HTMLSelectElement:0,MediaList:0,MimeTypeArray:0,NamedNodeMap:0,NodeList:1,PaintRequestList:0,Plugin:0,PluginArray:0,SVGLengthList:0,SVGNumberList:0,SVGPathSegList:0,SVGPointList:0,SVGStringList:0,SVGTransformList:0,SourceBufferList:0,StyleSheetList:0,TextTrackCueList:0,TextTrackList:0,TouchList:0},ri=Wt("span").classList,oi=ri&&ri.constructor&&ri.constructor.prototype,ii=oi===Object.prototype?void 0:oi,ui=Io.forEach,ci=!!(ei=[]["forEach"])&&Y((function(){ei.call(null,ti||function(){throw 1},1)}))?[].forEach:function(t){return ui(this,t,arguments.length>1?arguments[1]:void 0)},ai=function(t){if(t&&t.forEach!==ci)try{Xe(t,"forEach",ci)}catch(e){t.forEach=ci}};for(var fi in ni)ni[fi]&&ai(B[fi]&&B[fi].prototype);ai(ii);var si=Lt("iterator"),li=Lt("toStringTag"),vi=ar.values,pi=function(t,e){if(t){if(t[si]!==vi)try{Xe(t,si,vi)}catch(e){t[si]=vi}if(t[li]||Xe(t,li,e),ni[e])for(var n in ar)if(t[n]!==ar[n])try{Xe(t,n,ar[n])}catch(e){t[n]=ar[n]}}};for(var di in ni)pi(B[di]&&B[di].prototype,di);function hi(){var t=b();return s.isCursorEditor(t)||console.warn("Cannot use useSyncExternalStore outside the context of a RemoteCursorEditor"),t}pi(ii,"DOMTokenList");var yi=new WeakMap;function gi(t){var e=yi.get(t);if(e)return e;var n=function(t){var e={},n=new Set,r=n.add.bind(n),o=new Set,i=null;return[function(e){return o.add(e),i||(i=function(t){t.added.forEach(r),t.removed.forEach(r),t.updated.forEach(r),o.forEach((function(t){return t()}))},s.on(t,"change",i)),function(){o.delete(e),i&&0===o.size&&(s.off(t,"change",i),i=null)}},function(){return 0===n.size?e:(n.forEach((function(n){var r=s.cursorState(t,n);null!==r?e[n]=r:delete e[n.toString()]})),n.clear(),e=m({},e))}]}(t);return t&&yi.set(t,n),n}function bi(){return gi(hi())}function mi(){var t=S(bi(),2),e=t[0],n=t[1];return z.useSyncExternalStore(e,n)}function Si(t,e){var n=S(bi(),2),r=n[0],o=n[1];return W.useSyncExternalStoreWithSelector(r,o,null,t,e)}var Oi=new WeakMap;function wi(t,e){if(!e.relativeSelection)return null;var n=Oi.get(t.children);n||(n=new WeakMap,Oi.set(t.children,n));var r=n.get(e);if(void 0===r)try{r=l(t.sharedRoot,t,e.relativeSelection),n.set(e,r)}catch(t){return null}return r}var Ei=Lt("species"),ji=Io.map,xi=function(t){return At>=51||!Y((function(){var e=[];return(e.constructor={})[Ei]=function(){return{foo:1}},1!==e[t](Boolean).foo}))}("map");zn({target:"Array",proto:!0,forced:!xi},{map:function(t){return ji(this,t,arguments.length>1?arguments[1]:void 0)}});var Ai=K(fn.f),Ti=K([].push),Pi=function(t){return function(e){for(var n,r=ot(e),o=we(r),i=o.length,u=0,c=[];i>u;)n=o[u++],Dt&&!Ai(r,n)||Ti(c,t?[n,r[n]]:r[n]);return c}},Ri={entries:Pi(!0),values:Pi(!1)}.entries;zn({target:"Object",stat:!0},{entries:function(t){return Ri(t)}});var ki=Fr.onFreeze,zi=Object.freeze,Ii=Y((function(){zi(1)}));zn({target:"Object",stat:!0,forced:Ii,sham:!Mr},{freeze:function(t){return zi&&Ct(t)?zi(ki(t)):t}}),zn({target:"Object",stat:!0},{fromEntries:function(t){var e={};return Kr(t,(function(t,n){xr(e,t,n)}),{AS_ENTRIES:!0}),e}});var Li=Y((function(){we(1)}));function Ci(t,e,n){var r,o,i=n.yOffset,u=n.xOffset,c=n.shouldGenerateOverlay,a=S(v.edges(e),2),f=a[0],s=a[1],l=function(t,e){try{return y.toDOMRange(t,e)}catch(t){return null}}(t,e);if(!l)return{caretPosition:null,selectionRects:[]};var g=[],b=p.nodes(t,{at:e,match:function(t,e){return d.isText(t)&&(!c||c(t,e))}}),m=null,O=v.isBackward(e);try{for(var w=function(t){var e="function"==typeof Symbol&&Symbol.iterator,n=e&&t[e],r=0;if(n)return n.call(t);if(t&&"number"==typeof t.length)return{next:function(){return t&&r>=t.length&&(t=void 0),{value:t&&t[r++],done:!t}}};throw new TypeError(e?"Object is not iterable.":"Symbol.iterator is not defined.")}(b),E=w.next();!E.done;E=w.next()){var j=S(E.value,2),x=j[0],A=j[1],T=y.toDOMNode(t,x),P=h.equals(A,f.path),R=h.equals(A,s.path),k=null;if(P||R){var z=document.createRange();z.selectNode(T),P&&z.setStart(l.startContainer,l.startOffset),R&&z.setEnd(l.endContainer,l.endOffset),k=z.getClientRects()}else k=T.getClientRects();for(var I=O?P:R,L=0;L<k.length;L++){var C=k.item(L);if(C){var M=I&&(O?0===L:L===k.length-1),F=C.top-i,_=C.left-u;M&&(m={height:C.height,top:F,left:_+(O||v.isCollapsed(e)?0:C.width)}),g.push({width:C.width,height:C.height,top:F,left:_})}}}}catch(t){r={error:t}}finally{try{E&&!E.done&&(o=w.return)&&o.call(w)}finally{if(r)throw r.error}}return{selectionRects:g,caretPosition:m}}zn({target:"Object",stat:!0,forced:Li},{keys:function(t){return we(lt(t))}});var Mi=Object.freeze([]);function Fi(t){var e;void 0===t&&(t={});var n,s,l,v=t.containerRef,p=t.shouldGenerateOverlay,d=function(t,e){var n={};for(var r in t)Object.prototype.hasOwnProperty.call(t,r)&&e.indexOf(r)<0&&(n[r]=t[r]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(t);o<r.length;o++)e.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(t,r[o])&&(n[r[o]]=t[r[o]])}return n}(t,["containerRef","shouldGenerateOverlay"]),h=hi(),y=mi(),g=(n=S(r((function(t){return t+1}),0),2)[1],s=o(null),i(l=function(){s.current&&(cancelAnimationFrame(s.current),s.current=0)}),i((function(){return l}),[]),u((function(t){void 0===t&&(t=!1),t?n():s.current||(s.current=requestAnimationFrame(n))}),[])),b=o(new WeakMap),O=S(c({}),2),w=O[0],E=O[1],j=!("refreshOnResize"in d)||(null===(e=d.refreshOnResize)||void 0===e||e);!function(t,e){var n=o(e);n.current=e;var r=S(c((function(){return new ResizeObserver((function(){n.current()}))})),1)[0];i((function(){if(null==t?void 0:t.current){var e=t.current;return r.observe(e),function(){return r.unobserve(e)}}}),[r,t])}(j?v:void 0,(function(){b.current=new WeakMap,g("debounced"!==j)})),a((function(){var t,e,n;if(!v||v.current){var r=null===(t=null==v?void 0:v.current)||void 0===t?void 0:t.getBoundingClientRect(),o=null!==(e=null==r?void 0:r.x)&&void 0!==e?e:0,i=null!==(n=null==r?void 0:r.y)&&void 0!==n?n:0,u=Object.keys(w).length!==Object.keys(y).length,c=Object.fromEntries(Object.entries(y).map((function(t){var e=S(t,2),n=e[0],r=e[1],c=r.relativeSelection&&wi(h,r);if(!c)return[n,Mi];var a=b.current.get(c);if(a)return[n,a];var f=Ci(h,c,{xOffset:o,yOffset:i,shouldGenerateOverlay:p});return u=!0,b.current.set(c,f),[n,f]})));u&&E(c)}}));var x=f((function(){return Object.entries(y).map((function(t){var e,n,r=S(t,2),o=r[0],i=r[1],u=i.relativeSelection&&wi(h,i),c=w[o];return m(m({},i),{range:u,caretPosition:null!==(e=null==c?void 0:c.caretPosition)&&void 0!==e?e:null,selectionRects:null!==(n=null==c?void 0:c.selectionRects)&&void 0!==n?n:Mi})}))}),[y,h,w]);return[x,u((function(){b.current=new WeakMap,g(!0)}),[g])]}export{g as EditorContext,wi as getCursorRange,b as useEditorStatic,Fi as useRemoteCursorOverlayPositions,mi as useRemoteCursorStates,Si as useRemoteCursorStatesSelector};
|
|
40
|
+
//# sourceMappingURL=index.esm.js.map
|