@yoopta/exports 1.9.12-rc → 1.9.13-rc
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.js +1576 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,8 +1,1582 @@
|
|
|
1
|
-
import{Text
|
|
1
|
+
import { Text, Range, Node, createEditor as createEditor$1, Element } from 'slate';
|
|
2
|
+
|
|
3
|
+
/******************************************************************************
|
|
4
|
+
Copyright (c) Microsoft Corporation.
|
|
5
|
+
|
|
6
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
7
|
+
purpose with or without fee is hereby granted.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
16
|
+
***************************************************************************** */
|
|
17
|
+
|
|
18
|
+
function __rest(s, e) {
|
|
19
|
+
var t = {};
|
|
20
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
21
|
+
t[p] = s[p];
|
|
22
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
23
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
24
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
25
|
+
t[p[i]] = s[p[i]];
|
|
26
|
+
}
|
|
27
|
+
return t;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* lodash (Custom Build) <https://lodash.com/>
|
|
34
|
+
* Build: `lodash modularize exports="npm" -o ./`
|
|
35
|
+
* Copyright jQuery Foundation and other contributors <https://jquery.org/>
|
|
36
|
+
* Released under MIT license <https://lodash.com/license>
|
|
37
|
+
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
38
|
+
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
39
|
+
*/
|
|
40
|
+
|
|
41
|
+
/** Used as the size to enable large array optimizations. */
|
|
42
|
+
var LARGE_ARRAY_SIZE = 200;
|
|
43
|
+
|
|
44
|
+
/** Used to stand-in for `undefined` hash values. */
|
|
45
|
+
var HASH_UNDEFINED = '__lodash_hash_undefined__';
|
|
46
|
+
|
|
47
|
+
/** Used as references for various `Number` constants. */
|
|
48
|
+
var INFINITY = 1 / 0;
|
|
49
|
+
|
|
50
|
+
/** `Object#toString` result references. */
|
|
51
|
+
var funcTag = '[object Function]',
|
|
52
|
+
genTag = '[object GeneratorFunction]';
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Used to match `RegExp`
|
|
56
|
+
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
|
|
57
|
+
*/
|
|
58
|
+
var reRegExpChar = /[\\^$.*+?()[\]{}|]/g;
|
|
59
|
+
|
|
60
|
+
/** Used to detect host constructors (Safari). */
|
|
61
|
+
var reIsHostCtor = /^\[object .+?Constructor\]$/;
|
|
62
|
+
|
|
63
|
+
/** Detect free variable `global` from Node.js. */
|
|
64
|
+
var freeGlobal = typeof commonjsGlobal == 'object' && commonjsGlobal && commonjsGlobal.Object === Object && commonjsGlobal;
|
|
65
|
+
|
|
66
|
+
/** Detect free variable `self`. */
|
|
67
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
68
|
+
|
|
69
|
+
/** Used as a reference to the global object. */
|
|
70
|
+
var root = freeGlobal || freeSelf || Function('return this')();
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* A specialized version of `_.includes` for arrays without support for
|
|
74
|
+
* specifying an index to search from.
|
|
75
|
+
*
|
|
76
|
+
* @private
|
|
77
|
+
* @param {Array} [array] The array to inspect.
|
|
78
|
+
* @param {*} target The value to search for.
|
|
79
|
+
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|
80
|
+
*/
|
|
81
|
+
function arrayIncludes(array, value) {
|
|
82
|
+
var length = array ? array.length : 0;
|
|
83
|
+
return !!length && baseIndexOf(array, value, 0) > -1;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* This function is like `arrayIncludes` except that it accepts a comparator.
|
|
88
|
+
*
|
|
89
|
+
* @private
|
|
90
|
+
* @param {Array} [array] The array to inspect.
|
|
91
|
+
* @param {*} target The value to search for.
|
|
92
|
+
* @param {Function} comparator The comparator invoked per element.
|
|
93
|
+
* @returns {boolean} Returns `true` if `target` is found, else `false`.
|
|
94
|
+
*/
|
|
95
|
+
function arrayIncludesWith(array, value, comparator) {
|
|
96
|
+
var index = -1,
|
|
97
|
+
length = array ? array.length : 0;
|
|
98
|
+
|
|
99
|
+
while (++index < length) {
|
|
100
|
+
if (comparator(value, array[index])) {
|
|
101
|
+
return true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* The base implementation of `_.findIndex` and `_.findLastIndex` without
|
|
109
|
+
* support for iteratee shorthands.
|
|
110
|
+
*
|
|
111
|
+
* @private
|
|
112
|
+
* @param {Array} array The array to inspect.
|
|
113
|
+
* @param {Function} predicate The function invoked per iteration.
|
|
114
|
+
* @param {number} fromIndex The index to search from.
|
|
115
|
+
* @param {boolean} [fromRight] Specify iterating from right to left.
|
|
116
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
117
|
+
*/
|
|
118
|
+
function baseFindIndex(array, predicate, fromIndex, fromRight) {
|
|
119
|
+
var length = array.length,
|
|
120
|
+
index = fromIndex + (fromRight ? 1 : -1);
|
|
121
|
+
|
|
122
|
+
while ((fromRight ? index-- : ++index < length)) {
|
|
123
|
+
if (predicate(array[index], index, array)) {
|
|
124
|
+
return index;
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return -1;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* The base implementation of `_.indexOf` without `fromIndex` bounds checks.
|
|
132
|
+
*
|
|
133
|
+
* @private
|
|
134
|
+
* @param {Array} array The array to inspect.
|
|
135
|
+
* @param {*} value The value to search for.
|
|
136
|
+
* @param {number} fromIndex The index to search from.
|
|
137
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
138
|
+
*/
|
|
139
|
+
function baseIndexOf(array, value, fromIndex) {
|
|
140
|
+
if (value !== value) {
|
|
141
|
+
return baseFindIndex(array, baseIsNaN, fromIndex);
|
|
142
|
+
}
|
|
143
|
+
var index = fromIndex - 1,
|
|
144
|
+
length = array.length;
|
|
145
|
+
|
|
146
|
+
while (++index < length) {
|
|
147
|
+
if (array[index] === value) {
|
|
148
|
+
return index;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return -1;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* The base implementation of `_.isNaN` without support for number objects.
|
|
156
|
+
*
|
|
157
|
+
* @private
|
|
158
|
+
* @param {*} value The value to check.
|
|
159
|
+
* @returns {boolean} Returns `true` if `value` is `NaN`, else `false`.
|
|
160
|
+
*/
|
|
161
|
+
function baseIsNaN(value) {
|
|
162
|
+
return value !== value;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Checks if a cache value for `key` exists.
|
|
167
|
+
*
|
|
168
|
+
* @private
|
|
169
|
+
* @param {Object} cache The cache to query.
|
|
170
|
+
* @param {string} key The key of the entry to check.
|
|
171
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
172
|
+
*/
|
|
173
|
+
function cacheHas(cache, key) {
|
|
174
|
+
return cache.has(key);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Gets the value at `key` of `object`.
|
|
179
|
+
*
|
|
180
|
+
* @private
|
|
181
|
+
* @param {Object} [object] The object to query.
|
|
182
|
+
* @param {string} key The key of the property to get.
|
|
183
|
+
* @returns {*} Returns the property value.
|
|
184
|
+
*/
|
|
185
|
+
function getValue(object, key) {
|
|
186
|
+
return object == null ? undefined : object[key];
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Checks if `value` is a host object in IE < 9.
|
|
191
|
+
*
|
|
192
|
+
* @private
|
|
193
|
+
* @param {*} value The value to check.
|
|
194
|
+
* @returns {boolean} Returns `true` if `value` is a host object, else `false`.
|
|
195
|
+
*/
|
|
196
|
+
function isHostObject(value) {
|
|
197
|
+
// Many host objects are `Object` objects that can coerce to strings
|
|
198
|
+
// despite having improperly defined `toString` methods.
|
|
199
|
+
var result = false;
|
|
200
|
+
if (value != null && typeof value.toString != 'function') {
|
|
201
|
+
try {
|
|
202
|
+
result = !!(value + '');
|
|
203
|
+
} catch (e) {}
|
|
204
|
+
}
|
|
205
|
+
return result;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Converts `set` to an array of its values.
|
|
210
|
+
*
|
|
211
|
+
* @private
|
|
212
|
+
* @param {Object} set The set to convert.
|
|
213
|
+
* @returns {Array} Returns the values.
|
|
214
|
+
*/
|
|
215
|
+
function setToArray(set) {
|
|
216
|
+
var index = -1,
|
|
217
|
+
result = Array(set.size);
|
|
218
|
+
|
|
219
|
+
set.forEach(function(value) {
|
|
220
|
+
result[++index] = value;
|
|
221
|
+
});
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/** Used for built-in method references. */
|
|
226
|
+
var arrayProto = Array.prototype,
|
|
227
|
+
funcProto = Function.prototype,
|
|
228
|
+
objectProto = Object.prototype;
|
|
229
|
+
|
|
230
|
+
/** Used to detect overreaching core-js shims. */
|
|
231
|
+
var coreJsData = root['__core-js_shared__'];
|
|
232
|
+
|
|
233
|
+
/** Used to detect methods masquerading as native. */
|
|
234
|
+
var maskSrcKey = (function() {
|
|
235
|
+
var uid = /[^.]+$/.exec(coreJsData && coreJsData.keys && coreJsData.keys.IE_PROTO || '');
|
|
236
|
+
return uid ? ('Symbol(src)_1.' + uid) : '';
|
|
237
|
+
}());
|
|
238
|
+
|
|
239
|
+
/** Used to resolve the decompiled source of functions. */
|
|
240
|
+
var funcToString = funcProto.toString;
|
|
241
|
+
|
|
242
|
+
/** Used to check objects for own properties. */
|
|
243
|
+
var hasOwnProperty = objectProto.hasOwnProperty;
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Used to resolve the
|
|
247
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
248
|
+
* of values.
|
|
249
|
+
*/
|
|
250
|
+
var objectToString = objectProto.toString;
|
|
251
|
+
|
|
252
|
+
/** Used to detect if a method is native. */
|
|
253
|
+
var reIsNative = RegExp('^' +
|
|
254
|
+
funcToString.call(hasOwnProperty).replace(reRegExpChar, '\\$&')
|
|
255
|
+
.replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
/** Built-in value references. */
|
|
259
|
+
var splice = arrayProto.splice;
|
|
260
|
+
|
|
261
|
+
/* Built-in method references that are verified to be native. */
|
|
262
|
+
var Map = getNative(root, 'Map'),
|
|
263
|
+
Set = getNative(root, 'Set'),
|
|
264
|
+
nativeCreate = getNative(Object, 'create');
|
|
265
|
+
|
|
266
|
+
/**
|
|
267
|
+
* Creates a hash object.
|
|
268
|
+
*
|
|
269
|
+
* @private
|
|
270
|
+
* @constructor
|
|
271
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
272
|
+
*/
|
|
273
|
+
function Hash(entries) {
|
|
274
|
+
var index = -1,
|
|
275
|
+
length = entries ? entries.length : 0;
|
|
276
|
+
|
|
277
|
+
this.clear();
|
|
278
|
+
while (++index < length) {
|
|
279
|
+
var entry = entries[index];
|
|
280
|
+
this.set(entry[0], entry[1]);
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Removes all key-value entries from the hash.
|
|
286
|
+
*
|
|
287
|
+
* @private
|
|
288
|
+
* @name clear
|
|
289
|
+
* @memberOf Hash
|
|
290
|
+
*/
|
|
291
|
+
function hashClear() {
|
|
292
|
+
this.__data__ = nativeCreate ? nativeCreate(null) : {};
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/**
|
|
296
|
+
* Removes `key` and its value from the hash.
|
|
297
|
+
*
|
|
298
|
+
* @private
|
|
299
|
+
* @name delete
|
|
300
|
+
* @memberOf Hash
|
|
301
|
+
* @param {Object} hash The hash to modify.
|
|
302
|
+
* @param {string} key The key of the value to remove.
|
|
303
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
304
|
+
*/
|
|
305
|
+
function hashDelete(key) {
|
|
306
|
+
return this.has(key) && delete this.__data__[key];
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/**
|
|
310
|
+
* Gets the hash value for `key`.
|
|
311
|
+
*
|
|
312
|
+
* @private
|
|
313
|
+
* @name get
|
|
314
|
+
* @memberOf Hash
|
|
315
|
+
* @param {string} key The key of the value to get.
|
|
316
|
+
* @returns {*} Returns the entry value.
|
|
317
|
+
*/
|
|
318
|
+
function hashGet(key) {
|
|
319
|
+
var data = this.__data__;
|
|
320
|
+
if (nativeCreate) {
|
|
321
|
+
var result = data[key];
|
|
322
|
+
return result === HASH_UNDEFINED ? undefined : result;
|
|
323
|
+
}
|
|
324
|
+
return hasOwnProperty.call(data, key) ? data[key] : undefined;
|
|
325
|
+
}
|
|
326
|
+
|
|
327
|
+
/**
|
|
328
|
+
* Checks if a hash value for `key` exists.
|
|
329
|
+
*
|
|
330
|
+
* @private
|
|
331
|
+
* @name has
|
|
332
|
+
* @memberOf Hash
|
|
333
|
+
* @param {string} key The key of the entry to check.
|
|
334
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
335
|
+
*/
|
|
336
|
+
function hashHas(key) {
|
|
337
|
+
var data = this.__data__;
|
|
338
|
+
return nativeCreate ? data[key] !== undefined : hasOwnProperty.call(data, key);
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
/**
|
|
342
|
+
* Sets the hash `key` to `value`.
|
|
343
|
+
*
|
|
344
|
+
* @private
|
|
345
|
+
* @name set
|
|
346
|
+
* @memberOf Hash
|
|
347
|
+
* @param {string} key The key of the value to set.
|
|
348
|
+
* @param {*} value The value to set.
|
|
349
|
+
* @returns {Object} Returns the hash instance.
|
|
350
|
+
*/
|
|
351
|
+
function hashSet(key, value) {
|
|
352
|
+
var data = this.__data__;
|
|
353
|
+
data[key] = (nativeCreate && value === undefined) ? HASH_UNDEFINED : value;
|
|
354
|
+
return this;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
// Add methods to `Hash`.
|
|
358
|
+
Hash.prototype.clear = hashClear;
|
|
359
|
+
Hash.prototype['delete'] = hashDelete;
|
|
360
|
+
Hash.prototype.get = hashGet;
|
|
361
|
+
Hash.prototype.has = hashHas;
|
|
362
|
+
Hash.prototype.set = hashSet;
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Creates an list cache object.
|
|
366
|
+
*
|
|
367
|
+
* @private
|
|
368
|
+
* @constructor
|
|
369
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
370
|
+
*/
|
|
371
|
+
function ListCache(entries) {
|
|
372
|
+
var index = -1,
|
|
373
|
+
length = entries ? entries.length : 0;
|
|
374
|
+
|
|
375
|
+
this.clear();
|
|
376
|
+
while (++index < length) {
|
|
377
|
+
var entry = entries[index];
|
|
378
|
+
this.set(entry[0], entry[1]);
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/**
|
|
383
|
+
* Removes all key-value entries from the list cache.
|
|
384
|
+
*
|
|
385
|
+
* @private
|
|
386
|
+
* @name clear
|
|
387
|
+
* @memberOf ListCache
|
|
388
|
+
*/
|
|
389
|
+
function listCacheClear() {
|
|
390
|
+
this.__data__ = [];
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Removes `key` and its value from the list cache.
|
|
395
|
+
*
|
|
396
|
+
* @private
|
|
397
|
+
* @name delete
|
|
398
|
+
* @memberOf ListCache
|
|
399
|
+
* @param {string} key The key of the value to remove.
|
|
400
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
401
|
+
*/
|
|
402
|
+
function listCacheDelete(key) {
|
|
403
|
+
var data = this.__data__,
|
|
404
|
+
index = assocIndexOf(data, key);
|
|
405
|
+
|
|
406
|
+
if (index < 0) {
|
|
407
|
+
return false;
|
|
408
|
+
}
|
|
409
|
+
var lastIndex = data.length - 1;
|
|
410
|
+
if (index == lastIndex) {
|
|
411
|
+
data.pop();
|
|
412
|
+
} else {
|
|
413
|
+
splice.call(data, index, 1);
|
|
414
|
+
}
|
|
415
|
+
return true;
|
|
416
|
+
}
|
|
417
|
+
|
|
418
|
+
/**
|
|
419
|
+
* Gets the list cache value for `key`.
|
|
420
|
+
*
|
|
421
|
+
* @private
|
|
422
|
+
* @name get
|
|
423
|
+
* @memberOf ListCache
|
|
424
|
+
* @param {string} key The key of the value to get.
|
|
425
|
+
* @returns {*} Returns the entry value.
|
|
426
|
+
*/
|
|
427
|
+
function listCacheGet(key) {
|
|
428
|
+
var data = this.__data__,
|
|
429
|
+
index = assocIndexOf(data, key);
|
|
430
|
+
|
|
431
|
+
return index < 0 ? undefined : data[index][1];
|
|
432
|
+
}
|
|
433
|
+
|
|
434
|
+
/**
|
|
435
|
+
* Checks if a list cache value for `key` exists.
|
|
436
|
+
*
|
|
437
|
+
* @private
|
|
438
|
+
* @name has
|
|
439
|
+
* @memberOf ListCache
|
|
440
|
+
* @param {string} key The key of the entry to check.
|
|
441
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
442
|
+
*/
|
|
443
|
+
function listCacheHas(key) {
|
|
444
|
+
return assocIndexOf(this.__data__, key) > -1;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* Sets the list cache `key` to `value`.
|
|
449
|
+
*
|
|
450
|
+
* @private
|
|
451
|
+
* @name set
|
|
452
|
+
* @memberOf ListCache
|
|
453
|
+
* @param {string} key The key of the value to set.
|
|
454
|
+
* @param {*} value The value to set.
|
|
455
|
+
* @returns {Object} Returns the list cache instance.
|
|
456
|
+
*/
|
|
457
|
+
function listCacheSet(key, value) {
|
|
458
|
+
var data = this.__data__,
|
|
459
|
+
index = assocIndexOf(data, key);
|
|
460
|
+
|
|
461
|
+
if (index < 0) {
|
|
462
|
+
data.push([key, value]);
|
|
463
|
+
} else {
|
|
464
|
+
data[index][1] = value;
|
|
465
|
+
}
|
|
466
|
+
return this;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
// Add methods to `ListCache`.
|
|
470
|
+
ListCache.prototype.clear = listCacheClear;
|
|
471
|
+
ListCache.prototype['delete'] = listCacheDelete;
|
|
472
|
+
ListCache.prototype.get = listCacheGet;
|
|
473
|
+
ListCache.prototype.has = listCacheHas;
|
|
474
|
+
ListCache.prototype.set = listCacheSet;
|
|
475
|
+
|
|
476
|
+
/**
|
|
477
|
+
* Creates a map cache object to store key-value pairs.
|
|
478
|
+
*
|
|
479
|
+
* @private
|
|
480
|
+
* @constructor
|
|
481
|
+
* @param {Array} [entries] The key-value pairs to cache.
|
|
482
|
+
*/
|
|
483
|
+
function MapCache(entries) {
|
|
484
|
+
var index = -1,
|
|
485
|
+
length = entries ? entries.length : 0;
|
|
486
|
+
|
|
487
|
+
this.clear();
|
|
488
|
+
while (++index < length) {
|
|
489
|
+
var entry = entries[index];
|
|
490
|
+
this.set(entry[0], entry[1]);
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
/**
|
|
495
|
+
* Removes all key-value entries from the map.
|
|
496
|
+
*
|
|
497
|
+
* @private
|
|
498
|
+
* @name clear
|
|
499
|
+
* @memberOf MapCache
|
|
500
|
+
*/
|
|
501
|
+
function mapCacheClear() {
|
|
502
|
+
this.__data__ = {
|
|
503
|
+
'hash': new Hash,
|
|
504
|
+
'map': new (Map || ListCache),
|
|
505
|
+
'string': new Hash
|
|
506
|
+
};
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
/**
|
|
510
|
+
* Removes `key` and its value from the map.
|
|
511
|
+
*
|
|
512
|
+
* @private
|
|
513
|
+
* @name delete
|
|
514
|
+
* @memberOf MapCache
|
|
515
|
+
* @param {string} key The key of the value to remove.
|
|
516
|
+
* @returns {boolean} Returns `true` if the entry was removed, else `false`.
|
|
517
|
+
*/
|
|
518
|
+
function mapCacheDelete(key) {
|
|
519
|
+
return getMapData(this, key)['delete'](key);
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Gets the map value for `key`.
|
|
524
|
+
*
|
|
525
|
+
* @private
|
|
526
|
+
* @name get
|
|
527
|
+
* @memberOf MapCache
|
|
528
|
+
* @param {string} key The key of the value to get.
|
|
529
|
+
* @returns {*} Returns the entry value.
|
|
530
|
+
*/
|
|
531
|
+
function mapCacheGet(key) {
|
|
532
|
+
return getMapData(this, key).get(key);
|
|
533
|
+
}
|
|
534
|
+
|
|
535
|
+
/**
|
|
536
|
+
* Checks if a map value for `key` exists.
|
|
537
|
+
*
|
|
538
|
+
* @private
|
|
539
|
+
* @name has
|
|
540
|
+
* @memberOf MapCache
|
|
541
|
+
* @param {string} key The key of the entry to check.
|
|
542
|
+
* @returns {boolean} Returns `true` if an entry for `key` exists, else `false`.
|
|
543
|
+
*/
|
|
544
|
+
function mapCacheHas(key) {
|
|
545
|
+
return getMapData(this, key).has(key);
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
* Sets the map `key` to `value`.
|
|
550
|
+
*
|
|
551
|
+
* @private
|
|
552
|
+
* @name set
|
|
553
|
+
* @memberOf MapCache
|
|
554
|
+
* @param {string} key The key of the value to set.
|
|
555
|
+
* @param {*} value The value to set.
|
|
556
|
+
* @returns {Object} Returns the map cache instance.
|
|
557
|
+
*/
|
|
558
|
+
function mapCacheSet(key, value) {
|
|
559
|
+
getMapData(this, key).set(key, value);
|
|
560
|
+
return this;
|
|
561
|
+
}
|
|
562
|
+
|
|
563
|
+
// Add methods to `MapCache`.
|
|
564
|
+
MapCache.prototype.clear = mapCacheClear;
|
|
565
|
+
MapCache.prototype['delete'] = mapCacheDelete;
|
|
566
|
+
MapCache.prototype.get = mapCacheGet;
|
|
567
|
+
MapCache.prototype.has = mapCacheHas;
|
|
568
|
+
MapCache.prototype.set = mapCacheSet;
|
|
569
|
+
|
|
570
|
+
/**
|
|
571
|
+
*
|
|
572
|
+
* Creates an array cache object to store unique values.
|
|
573
|
+
*
|
|
574
|
+
* @private
|
|
575
|
+
* @constructor
|
|
576
|
+
* @param {Array} [values] The values to cache.
|
|
577
|
+
*/
|
|
578
|
+
function SetCache(values) {
|
|
579
|
+
var index = -1,
|
|
580
|
+
length = values ? values.length : 0;
|
|
581
|
+
|
|
582
|
+
this.__data__ = new MapCache;
|
|
583
|
+
while (++index < length) {
|
|
584
|
+
this.add(values[index]);
|
|
585
|
+
}
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
/**
|
|
589
|
+
* Adds `value` to the array cache.
|
|
590
|
+
*
|
|
591
|
+
* @private
|
|
592
|
+
* @name add
|
|
593
|
+
* @memberOf SetCache
|
|
594
|
+
* @alias push
|
|
595
|
+
* @param {*} value The value to cache.
|
|
596
|
+
* @returns {Object} Returns the cache instance.
|
|
597
|
+
*/
|
|
598
|
+
function setCacheAdd(value) {
|
|
599
|
+
this.__data__.set(value, HASH_UNDEFINED);
|
|
600
|
+
return this;
|
|
601
|
+
}
|
|
602
|
+
|
|
603
|
+
/**
|
|
604
|
+
* Checks if `value` is in the array cache.
|
|
605
|
+
*
|
|
606
|
+
* @private
|
|
607
|
+
* @name has
|
|
608
|
+
* @memberOf SetCache
|
|
609
|
+
* @param {*} value The value to search for.
|
|
610
|
+
* @returns {number} Returns `true` if `value` is found, else `false`.
|
|
611
|
+
*/
|
|
612
|
+
function setCacheHas(value) {
|
|
613
|
+
return this.__data__.has(value);
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
// Add methods to `SetCache`.
|
|
617
|
+
SetCache.prototype.add = SetCache.prototype.push = setCacheAdd;
|
|
618
|
+
SetCache.prototype.has = setCacheHas;
|
|
619
|
+
|
|
620
|
+
/**
|
|
621
|
+
* Gets the index at which the `key` is found in `array` of key-value pairs.
|
|
622
|
+
*
|
|
623
|
+
* @private
|
|
624
|
+
* @param {Array} array The array to inspect.
|
|
625
|
+
* @param {*} key The key to search for.
|
|
626
|
+
* @returns {number} Returns the index of the matched value, else `-1`.
|
|
627
|
+
*/
|
|
628
|
+
function assocIndexOf(array, key) {
|
|
629
|
+
var length = array.length;
|
|
630
|
+
while (length--) {
|
|
631
|
+
if (eq(array[length][0], key)) {
|
|
632
|
+
return length;
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
return -1;
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
/**
|
|
639
|
+
* The base implementation of `_.isNative` without bad shim checks.
|
|
640
|
+
*
|
|
641
|
+
* @private
|
|
642
|
+
* @param {*} value The value to check.
|
|
643
|
+
* @returns {boolean} Returns `true` if `value` is a native function,
|
|
644
|
+
* else `false`.
|
|
645
|
+
*/
|
|
646
|
+
function baseIsNative(value) {
|
|
647
|
+
if (!isObject$1(value) || isMasked(value)) {
|
|
648
|
+
return false;
|
|
649
|
+
}
|
|
650
|
+
var pattern = (isFunction(value) || isHostObject(value)) ? reIsNative : reIsHostCtor;
|
|
651
|
+
return pattern.test(toSource(value));
|
|
652
|
+
}
|
|
653
|
+
|
|
654
|
+
/**
|
|
655
|
+
* The base implementation of `_.uniqBy` without support for iteratee shorthands.
|
|
656
|
+
*
|
|
657
|
+
* @private
|
|
658
|
+
* @param {Array} array The array to inspect.
|
|
659
|
+
* @param {Function} [iteratee] The iteratee invoked per element.
|
|
660
|
+
* @param {Function} [comparator] The comparator invoked per element.
|
|
661
|
+
* @returns {Array} Returns the new duplicate free array.
|
|
662
|
+
*/
|
|
663
|
+
function baseUniq(array, iteratee, comparator) {
|
|
664
|
+
var index = -1,
|
|
665
|
+
includes = arrayIncludes,
|
|
666
|
+
length = array.length,
|
|
667
|
+
isCommon = true,
|
|
668
|
+
result = [],
|
|
669
|
+
seen = result;
|
|
670
|
+
|
|
671
|
+
if (comparator) {
|
|
672
|
+
isCommon = false;
|
|
673
|
+
includes = arrayIncludesWith;
|
|
674
|
+
}
|
|
675
|
+
else if (length >= LARGE_ARRAY_SIZE) {
|
|
676
|
+
var set = iteratee ? null : createSet(array);
|
|
677
|
+
if (set) {
|
|
678
|
+
return setToArray(set);
|
|
679
|
+
}
|
|
680
|
+
isCommon = false;
|
|
681
|
+
includes = cacheHas;
|
|
682
|
+
seen = new SetCache;
|
|
683
|
+
}
|
|
684
|
+
else {
|
|
685
|
+
seen = iteratee ? [] : result;
|
|
686
|
+
}
|
|
687
|
+
outer:
|
|
688
|
+
while (++index < length) {
|
|
689
|
+
var value = array[index],
|
|
690
|
+
computed = iteratee ? iteratee(value) : value;
|
|
691
|
+
|
|
692
|
+
value = (comparator || value !== 0) ? value : 0;
|
|
693
|
+
if (isCommon && computed === computed) {
|
|
694
|
+
var seenIndex = seen.length;
|
|
695
|
+
while (seenIndex--) {
|
|
696
|
+
if (seen[seenIndex] === computed) {
|
|
697
|
+
continue outer;
|
|
698
|
+
}
|
|
699
|
+
}
|
|
700
|
+
if (iteratee) {
|
|
701
|
+
seen.push(computed);
|
|
702
|
+
}
|
|
703
|
+
result.push(value);
|
|
704
|
+
}
|
|
705
|
+
else if (!includes(seen, computed, comparator)) {
|
|
706
|
+
if (seen !== result) {
|
|
707
|
+
seen.push(computed);
|
|
708
|
+
}
|
|
709
|
+
result.push(value);
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
return result;
|
|
713
|
+
}
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Creates a set object of `values`.
|
|
717
|
+
*
|
|
718
|
+
* @private
|
|
719
|
+
* @param {Array} values The values to add to the set.
|
|
720
|
+
* @returns {Object} Returns the new set.
|
|
721
|
+
*/
|
|
722
|
+
var createSet = !(Set && (1 / setToArray(new Set([,-0]))[1]) == INFINITY) ? noop : function(values) {
|
|
723
|
+
return new Set(values);
|
|
724
|
+
};
|
|
725
|
+
|
|
726
|
+
/**
|
|
727
|
+
* Gets the data for `map`.
|
|
728
|
+
*
|
|
729
|
+
* @private
|
|
730
|
+
* @param {Object} map The map to query.
|
|
731
|
+
* @param {string} key The reference key.
|
|
732
|
+
* @returns {*} Returns the map data.
|
|
733
|
+
*/
|
|
734
|
+
function getMapData(map, key) {
|
|
735
|
+
var data = map.__data__;
|
|
736
|
+
return isKeyable(key)
|
|
737
|
+
? data[typeof key == 'string' ? 'string' : 'hash']
|
|
738
|
+
: data.map;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
/**
|
|
742
|
+
* Gets the native function at `key` of `object`.
|
|
743
|
+
*
|
|
744
|
+
* @private
|
|
745
|
+
* @param {Object} object The object to query.
|
|
746
|
+
* @param {string} key The key of the method to get.
|
|
747
|
+
* @returns {*} Returns the function if it's native, else `undefined`.
|
|
748
|
+
*/
|
|
749
|
+
function getNative(object, key) {
|
|
750
|
+
var value = getValue(object, key);
|
|
751
|
+
return baseIsNative(value) ? value : undefined;
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/**
|
|
755
|
+
* Checks if `value` is suitable for use as unique object key.
|
|
756
|
+
*
|
|
757
|
+
* @private
|
|
758
|
+
* @param {*} value The value to check.
|
|
759
|
+
* @returns {boolean} Returns `true` if `value` is suitable, else `false`.
|
|
760
|
+
*/
|
|
761
|
+
function isKeyable(value) {
|
|
762
|
+
var type = typeof value;
|
|
763
|
+
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
|
|
764
|
+
? (value !== '__proto__')
|
|
765
|
+
: (value === null);
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Checks if `func` has its source masked.
|
|
770
|
+
*
|
|
771
|
+
* @private
|
|
772
|
+
* @param {Function} func The function to check.
|
|
773
|
+
* @returns {boolean} Returns `true` if `func` is masked, else `false`.
|
|
774
|
+
*/
|
|
775
|
+
function isMasked(func) {
|
|
776
|
+
return !!maskSrcKey && (maskSrcKey in func);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Converts `func` to its source code.
|
|
781
|
+
*
|
|
782
|
+
* @private
|
|
783
|
+
* @param {Function} func The function to process.
|
|
784
|
+
* @returns {string} Returns the source code.
|
|
785
|
+
*/
|
|
786
|
+
function toSource(func) {
|
|
787
|
+
if (func != null) {
|
|
788
|
+
try {
|
|
789
|
+
return funcToString.call(func);
|
|
790
|
+
} catch (e) {}
|
|
791
|
+
try {
|
|
792
|
+
return (func + '');
|
|
793
|
+
} catch (e) {}
|
|
794
|
+
}
|
|
795
|
+
return '';
|
|
796
|
+
}
|
|
797
|
+
|
|
798
|
+
/**
|
|
799
|
+
* This method is like `_.uniq` except that it accepts `comparator` which
|
|
800
|
+
* is invoked to compare elements of `array`. The comparator is invoked with
|
|
801
|
+
* two arguments: (arrVal, othVal).
|
|
802
|
+
*
|
|
803
|
+
* @static
|
|
804
|
+
* @memberOf _
|
|
805
|
+
* @since 4.0.0
|
|
806
|
+
* @category Array
|
|
807
|
+
* @param {Array} array The array to inspect.
|
|
808
|
+
* @param {Function} [comparator] The comparator invoked per element.
|
|
809
|
+
* @returns {Array} Returns the new duplicate free array.
|
|
810
|
+
* @example
|
|
811
|
+
*
|
|
812
|
+
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
|
|
813
|
+
*
|
|
814
|
+
* _.uniqWith(objects, _.isEqual);
|
|
815
|
+
* // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
|
|
816
|
+
*/
|
|
817
|
+
function uniqWith(array, comparator) {
|
|
818
|
+
return (array && array.length)
|
|
819
|
+
? baseUniq(array, undefined, comparator)
|
|
820
|
+
: [];
|
|
821
|
+
}
|
|
822
|
+
|
|
823
|
+
/**
|
|
824
|
+
* Performs a
|
|
825
|
+
* [`SameValueZero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
|
|
826
|
+
* comparison between two values to determine if they are equivalent.
|
|
827
|
+
*
|
|
828
|
+
* @static
|
|
829
|
+
* @memberOf _
|
|
830
|
+
* @since 4.0.0
|
|
831
|
+
* @category Lang
|
|
832
|
+
* @param {*} value The value to compare.
|
|
833
|
+
* @param {*} other The other value to compare.
|
|
834
|
+
* @returns {boolean} Returns `true` if the values are equivalent, else `false`.
|
|
835
|
+
* @example
|
|
836
|
+
*
|
|
837
|
+
* var object = { 'a': 1 };
|
|
838
|
+
* var other = { 'a': 1 };
|
|
839
|
+
*
|
|
840
|
+
* _.eq(object, object);
|
|
841
|
+
* // => true
|
|
842
|
+
*
|
|
843
|
+
* _.eq(object, other);
|
|
844
|
+
* // => false
|
|
845
|
+
*
|
|
846
|
+
* _.eq('a', 'a');
|
|
847
|
+
* // => true
|
|
848
|
+
*
|
|
849
|
+
* _.eq('a', Object('a'));
|
|
850
|
+
* // => false
|
|
851
|
+
*
|
|
852
|
+
* _.eq(NaN, NaN);
|
|
853
|
+
* // => true
|
|
854
|
+
*/
|
|
855
|
+
function eq(value, other) {
|
|
856
|
+
return value === other || (value !== value && other !== other);
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
/**
|
|
860
|
+
* Checks if `value` is classified as a `Function` object.
|
|
861
|
+
*
|
|
862
|
+
* @static
|
|
863
|
+
* @memberOf _
|
|
864
|
+
* @since 0.1.0
|
|
865
|
+
* @category Lang
|
|
866
|
+
* @param {*} value The value to check.
|
|
867
|
+
* @returns {boolean} Returns `true` if `value` is a function, else `false`.
|
|
868
|
+
* @example
|
|
869
|
+
*
|
|
870
|
+
* _.isFunction(_);
|
|
871
|
+
* // => true
|
|
872
|
+
*
|
|
873
|
+
* _.isFunction(/abc/);
|
|
874
|
+
* // => false
|
|
875
|
+
*/
|
|
876
|
+
function isFunction(value) {
|
|
877
|
+
// The use of `Object#toString` avoids issues with the `typeof` operator
|
|
878
|
+
// in Safari 8-9 which returns 'object' for typed array and other constructors.
|
|
879
|
+
var tag = isObject$1(value) ? objectToString.call(value) : '';
|
|
880
|
+
return tag == funcTag || tag == genTag;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Checks if `value` is the
|
|
885
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
886
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
887
|
+
*
|
|
888
|
+
* @static
|
|
889
|
+
* @memberOf _
|
|
890
|
+
* @since 0.1.0
|
|
891
|
+
* @category Lang
|
|
892
|
+
* @param {*} value The value to check.
|
|
893
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
894
|
+
* @example
|
|
895
|
+
*
|
|
896
|
+
* _.isObject({});
|
|
897
|
+
* // => true
|
|
898
|
+
*
|
|
899
|
+
* _.isObject([1, 2, 3]);
|
|
900
|
+
* // => true
|
|
901
|
+
*
|
|
902
|
+
* _.isObject(_.noop);
|
|
903
|
+
* // => true
|
|
904
|
+
*
|
|
905
|
+
* _.isObject(null);
|
|
906
|
+
* // => false
|
|
907
|
+
*/
|
|
908
|
+
function isObject$1(value) {
|
|
909
|
+
var type = typeof value;
|
|
910
|
+
return !!value && (type == 'object' || type == 'function');
|
|
911
|
+
}
|
|
912
|
+
|
|
913
|
+
/**
|
|
914
|
+
* This method returns `undefined`.
|
|
915
|
+
*
|
|
916
|
+
* @static
|
|
917
|
+
* @memberOf _
|
|
918
|
+
* @since 2.3.0
|
|
919
|
+
* @category Util
|
|
920
|
+
* @example
|
|
921
|
+
*
|
|
922
|
+
* _.times(2, _.noop);
|
|
923
|
+
* // => [undefined, undefined]
|
|
924
|
+
*/
|
|
925
|
+
function noop() {
|
|
926
|
+
// No operation performed.
|
|
927
|
+
}
|
|
928
|
+
|
|
929
|
+
var lodash_uniqwith = uniqWith;
|
|
930
|
+
|
|
931
|
+
function mergePlugins(plugins) {
|
|
932
|
+
const items = plugins
|
|
933
|
+
.map((instance) => {
|
|
934
|
+
const _a = instance.getPlugin, { childPlugin } = _a, componentProps = __rest(_a, ["childPlugin"]);
|
|
935
|
+
return childPlugin ? [componentProps, Object.assign(Object.assign({}, childPlugin.getPlugin), { hasParent: true })] : componentProps;
|
|
936
|
+
})
|
|
937
|
+
.flat();
|
|
938
|
+
const uniquePlugins = lodash_uniqwith(items, (a, b) => a.type === b.type);
|
|
939
|
+
return uniquePlugins;
|
|
940
|
+
}
|
|
941
|
+
function mergePluginTypesToMap(plugins) {
|
|
942
|
+
const yooptaPlugins = mergePlugins(plugins);
|
|
943
|
+
const PLUGINS_MAP = {};
|
|
944
|
+
yooptaPlugins.forEach((plugin) => (PLUGINS_MAP[plugin.type] = plugin));
|
|
945
|
+
return PLUGINS_MAP;
|
|
946
|
+
}
|
|
947
|
+
function mergePluginTypesToMapHMTLNodeName(plugins) {
|
|
948
|
+
const yooptaPlugins = mergePlugins(plugins);
|
|
949
|
+
const PLUGINS_MAP_HTML_NODE_NAMES = {};
|
|
950
|
+
yooptaPlugins.forEach((plugin) => {
|
|
951
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
952
|
+
if ((_b = (_a = plugin.exports) === null || _a === void 0 ? void 0 : _a.html.deserialize) === null || _b === void 0 ? void 0 : _b.nodeName) {
|
|
953
|
+
if (Array.isArray((_d = (_c = plugin.exports) === null || _c === void 0 ? void 0 : _c.html.deserialize) === null || _d === void 0 ? void 0 : _d.nodeName)) {
|
|
954
|
+
(_f = (_e = plugin.exports) === null || _e === void 0 ? void 0 : _e.html.deserialize) === null || _f === void 0 ? void 0 : _f.nodeName.forEach((nodeName) => {
|
|
955
|
+
PLUGINS_MAP_HTML_NODE_NAMES[nodeName] = plugin;
|
|
956
|
+
});
|
|
957
|
+
return;
|
|
958
|
+
}
|
|
959
|
+
PLUGINS_MAP_HTML_NODE_NAMES[(_h = (_g = plugin.exports) === null || _g === void 0 ? void 0 : _g.html.deserialize) === null || _h === void 0 ? void 0 : _h.nodeName] = plugin;
|
|
960
|
+
}
|
|
961
|
+
});
|
|
962
|
+
return PLUGINS_MAP_HTML_NODE_NAMES;
|
|
963
|
+
}
|
|
964
|
+
|
|
965
|
+
function escapeHtml(text) {
|
|
966
|
+
const map = {
|
|
967
|
+
'&': '&',
|
|
968
|
+
'<': '<',
|
|
969
|
+
'>': '>',
|
|
970
|
+
'"': '"',
|
|
971
|
+
"'": ''',
|
|
972
|
+
};
|
|
973
|
+
return text.replace(/[&<>"']/g, (m) => map[m]);
|
|
974
|
+
}
|
|
975
|
+
function serializeNode$1(node, plugins) {
|
|
976
|
+
var _a, _b;
|
|
977
|
+
if (Text.isText(node)) {
|
|
978
|
+
return escapeHtml(node.text);
|
|
979
|
+
}
|
|
980
|
+
const children = node.children.map((node) => serializeNode$1(node, plugins)).join('');
|
|
981
|
+
const plugin = plugins[node.type];
|
|
982
|
+
if (typeof ((_b = (_a = plugin.exports) === null || _a === void 0 ? void 0 : _a.html) === null || _b === void 0 ? void 0 : _b.serialize) === 'function') {
|
|
983
|
+
return plugin.exports.html.serialize(node, children);
|
|
984
|
+
}
|
|
985
|
+
return children;
|
|
986
|
+
}
|
|
987
|
+
function serializeHtml(data, plugins) {
|
|
988
|
+
const pluginsMap = mergePluginTypesToMap(plugins);
|
|
989
|
+
const html = data.map((node) => serializeNode$1(node, pluginsMap)).join('');
|
|
990
|
+
return html;
|
|
991
|
+
}
|
|
992
|
+
|
|
2
993
|
/*!
|
|
3
994
|
* is-plain-object <https://github.com/jonschlinkert/is-plain-object>
|
|
4
995
|
*
|
|
5
996
|
* Copyright (c) 2014-2017, Jon Schlinkert.
|
|
6
997
|
* Released under the MIT License.
|
|
7
998
|
*/
|
|
8
|
-
|
|
999
|
+
|
|
1000
|
+
function isObject(o) {
|
|
1001
|
+
return Object.prototype.toString.call(o) === '[object Object]';
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
function isPlainObject(o) {
|
|
1005
|
+
var ctor,prot;
|
|
1006
|
+
|
|
1007
|
+
if (isObject(o) === false) return false;
|
|
1008
|
+
|
|
1009
|
+
// If has modified constructor
|
|
1010
|
+
ctor = o.constructor;
|
|
1011
|
+
if (ctor === undefined) return true;
|
|
1012
|
+
|
|
1013
|
+
// If has modified prototype
|
|
1014
|
+
prot = ctor.prototype;
|
|
1015
|
+
if (isObject(prot) === false) return false;
|
|
1016
|
+
|
|
1017
|
+
// If constructor does not have an Object-specific method
|
|
1018
|
+
if (prot.hasOwnProperty('isPrototypeOf') === false) {
|
|
1019
|
+
return false;
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
// Most likely a plain Object
|
|
1023
|
+
return true;
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
function _defineProperty(obj, key, value) {
|
|
1027
|
+
if (key in obj) {
|
|
1028
|
+
Object.defineProperty(obj, key, {
|
|
1029
|
+
value: value,
|
|
1030
|
+
enumerable: true,
|
|
1031
|
+
configurable: true,
|
|
1032
|
+
writable: true
|
|
1033
|
+
});
|
|
1034
|
+
} else {
|
|
1035
|
+
obj[key] = value;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
return obj;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
/**
|
|
1042
|
+
* A weak map to hold anchor tokens.
|
|
1043
|
+
*/
|
|
1044
|
+
var ANCHOR = new WeakMap();
|
|
1045
|
+
/**
|
|
1046
|
+
* A weak map to hold focus tokens.
|
|
1047
|
+
*/
|
|
1048
|
+
|
|
1049
|
+
var FOCUS = new WeakMap();
|
|
1050
|
+
/**
|
|
1051
|
+
* All tokens inherit from a single constructor for `instanceof` checking.
|
|
1052
|
+
*/
|
|
1053
|
+
|
|
1054
|
+
class Token {}
|
|
1055
|
+
/**
|
|
1056
|
+
* Anchor tokens represent the selection's anchor point.
|
|
1057
|
+
*/
|
|
1058
|
+
|
|
1059
|
+
class AnchorToken extends Token {
|
|
1060
|
+
constructor() {
|
|
1061
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1062
|
+
super();
|
|
1063
|
+
var {
|
|
1064
|
+
offset,
|
|
1065
|
+
path
|
|
1066
|
+
} = props;
|
|
1067
|
+
this.offset = offset;
|
|
1068
|
+
this.path = path;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
}
|
|
1072
|
+
/**
|
|
1073
|
+
* Focus tokens represent the selection's focus point.
|
|
1074
|
+
*/
|
|
1075
|
+
|
|
1076
|
+
class FocusToken extends Token {
|
|
1077
|
+
constructor() {
|
|
1078
|
+
var props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1079
|
+
super();
|
|
1080
|
+
var {
|
|
1081
|
+
offset,
|
|
1082
|
+
path
|
|
1083
|
+
} = props;
|
|
1084
|
+
this.offset = offset;
|
|
1085
|
+
this.path = path;
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
}
|
|
1089
|
+
/**
|
|
1090
|
+
* Add an anchor token to the end of a text node.
|
|
1091
|
+
*/
|
|
1092
|
+
|
|
1093
|
+
var addAnchorToken = (text, token) => {
|
|
1094
|
+
var offset = text.text.length;
|
|
1095
|
+
ANCHOR.set(text, [offset, token]);
|
|
1096
|
+
};
|
|
1097
|
+
/**
|
|
1098
|
+
* Get the offset if a text node has an associated anchor token.
|
|
1099
|
+
*/
|
|
1100
|
+
|
|
1101
|
+
var getAnchorOffset = text => {
|
|
1102
|
+
return ANCHOR.get(text);
|
|
1103
|
+
};
|
|
1104
|
+
/**
|
|
1105
|
+
* Add a focus token to the end of a text node.
|
|
1106
|
+
*/
|
|
1107
|
+
|
|
1108
|
+
var addFocusToken = (text, token) => {
|
|
1109
|
+
var offset = text.text.length;
|
|
1110
|
+
FOCUS.set(text, [offset, token]);
|
|
1111
|
+
};
|
|
1112
|
+
/**
|
|
1113
|
+
* Get the offset if a text node has an associated focus token.
|
|
1114
|
+
*/
|
|
1115
|
+
|
|
1116
|
+
var getFocusOffset = text => {
|
|
1117
|
+
return FOCUS.get(text);
|
|
1118
|
+
};
|
|
1119
|
+
|
|
1120
|
+
function ownKeys$1(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
1121
|
+
|
|
1122
|
+
function _objectSpread$1(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys$1(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys$1(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1123
|
+
/**
|
|
1124
|
+
* Resolve the descedants of a node by normalizing the children that can be
|
|
1125
|
+
* passed into a hyperscript creator function.
|
|
1126
|
+
*/
|
|
1127
|
+
|
|
1128
|
+
var STRINGS = new WeakSet();
|
|
1129
|
+
|
|
1130
|
+
var resolveDescendants = children => {
|
|
1131
|
+
var nodes = [];
|
|
1132
|
+
|
|
1133
|
+
var addChild = child => {
|
|
1134
|
+
if (child == null) {
|
|
1135
|
+
return;
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
var prev = nodes[nodes.length - 1];
|
|
1139
|
+
|
|
1140
|
+
if (typeof child === 'string') {
|
|
1141
|
+
var text = {
|
|
1142
|
+
text: child
|
|
1143
|
+
};
|
|
1144
|
+
STRINGS.add(text);
|
|
1145
|
+
child = text;
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
if (Text.isText(child)) {
|
|
1149
|
+
var c = child; // HACK: fix typescript complaining
|
|
1150
|
+
|
|
1151
|
+
if (Text.isText(prev) && STRINGS.has(prev) && STRINGS.has(c) && Text.equals(prev, c, {
|
|
1152
|
+
loose: true
|
|
1153
|
+
})) {
|
|
1154
|
+
prev.text += c.text;
|
|
1155
|
+
} else {
|
|
1156
|
+
nodes.push(c);
|
|
1157
|
+
}
|
|
1158
|
+
} else if (Element.isElement(child)) {
|
|
1159
|
+
nodes.push(child);
|
|
1160
|
+
} else if (child instanceof Token) {
|
|
1161
|
+
var n = nodes[nodes.length - 1];
|
|
1162
|
+
|
|
1163
|
+
if (!Text.isText(n)) {
|
|
1164
|
+
addChild('');
|
|
1165
|
+
n = nodes[nodes.length - 1];
|
|
1166
|
+
}
|
|
1167
|
+
|
|
1168
|
+
if (child instanceof AnchorToken) {
|
|
1169
|
+
addAnchorToken(n, child);
|
|
1170
|
+
} else if (child instanceof FocusToken) {
|
|
1171
|
+
addFocusToken(n, child);
|
|
1172
|
+
}
|
|
1173
|
+
} else {
|
|
1174
|
+
throw new Error("Unexpected hyperscript child object: ".concat(child));
|
|
1175
|
+
}
|
|
1176
|
+
};
|
|
1177
|
+
|
|
1178
|
+
for (var child of children.flat(Infinity)) {
|
|
1179
|
+
addChild(child);
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
return nodes;
|
|
1183
|
+
};
|
|
1184
|
+
/**
|
|
1185
|
+
* Create an anchor token.
|
|
1186
|
+
*/
|
|
1187
|
+
|
|
1188
|
+
|
|
1189
|
+
function createAnchor(tagName, attributes, children) {
|
|
1190
|
+
return new AnchorToken(attributes);
|
|
1191
|
+
}
|
|
1192
|
+
/**
|
|
1193
|
+
* Create an anchor and a focus token.
|
|
1194
|
+
*/
|
|
1195
|
+
|
|
1196
|
+
function createCursor(tagName, attributes, children) {
|
|
1197
|
+
return [new AnchorToken(attributes), new FocusToken(attributes)];
|
|
1198
|
+
}
|
|
1199
|
+
/**
|
|
1200
|
+
* Create an `Element` object.
|
|
1201
|
+
*/
|
|
1202
|
+
|
|
1203
|
+
function createElement(tagName, attributes, children) {
|
|
1204
|
+
return _objectSpread$1(_objectSpread$1({}, attributes), {}, {
|
|
1205
|
+
children: resolveDescendants(children)
|
|
1206
|
+
});
|
|
1207
|
+
}
|
|
1208
|
+
/**
|
|
1209
|
+
* Create a focus token.
|
|
1210
|
+
*/
|
|
1211
|
+
|
|
1212
|
+
function createFocus(tagName, attributes, children) {
|
|
1213
|
+
return new FocusToken(attributes);
|
|
1214
|
+
}
|
|
1215
|
+
/**
|
|
1216
|
+
* Create a fragment.
|
|
1217
|
+
*/
|
|
1218
|
+
|
|
1219
|
+
function createFragment(tagName, attributes, children) {
|
|
1220
|
+
return resolveDescendants(children);
|
|
1221
|
+
}
|
|
1222
|
+
/**
|
|
1223
|
+
* Create a `Selection` object.
|
|
1224
|
+
*/
|
|
1225
|
+
|
|
1226
|
+
function createSelection(tagName, attributes, children) {
|
|
1227
|
+
var anchor = children.find(c => c instanceof AnchorToken);
|
|
1228
|
+
var focus = children.find(c => c instanceof FocusToken);
|
|
1229
|
+
|
|
1230
|
+
if (!anchor || anchor.offset == null || anchor.path == null) {
|
|
1231
|
+
throw new Error("The <selection> hyperscript tag must have an <anchor> tag as a child with `path` and `offset` attributes defined.");
|
|
1232
|
+
}
|
|
1233
|
+
|
|
1234
|
+
if (!focus || focus.offset == null || focus.path == null) {
|
|
1235
|
+
throw new Error("The <selection> hyperscript tag must have a <focus> tag as a child with `path` and `offset` attributes defined.");
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
return _objectSpread$1({
|
|
1239
|
+
anchor: {
|
|
1240
|
+
offset: anchor.offset,
|
|
1241
|
+
path: anchor.path
|
|
1242
|
+
},
|
|
1243
|
+
focus: {
|
|
1244
|
+
offset: focus.offset,
|
|
1245
|
+
path: focus.path
|
|
1246
|
+
}
|
|
1247
|
+
}, attributes);
|
|
1248
|
+
}
|
|
1249
|
+
/**
|
|
1250
|
+
* Create a `Text` object.
|
|
1251
|
+
*/
|
|
1252
|
+
|
|
1253
|
+
function createText(tagName, attributes, children) {
|
|
1254
|
+
var nodes = resolveDescendants(children);
|
|
1255
|
+
|
|
1256
|
+
if (nodes.length > 1) {
|
|
1257
|
+
throw new Error("The <text> hyperscript tag must only contain a single node's worth of children.");
|
|
1258
|
+
}
|
|
1259
|
+
|
|
1260
|
+
var [node] = nodes;
|
|
1261
|
+
|
|
1262
|
+
if (node == null) {
|
|
1263
|
+
node = {
|
|
1264
|
+
text: ''
|
|
1265
|
+
};
|
|
1266
|
+
}
|
|
1267
|
+
|
|
1268
|
+
if (!Text.isText(node)) {
|
|
1269
|
+
throw new Error("\n The <text> hyperscript tag can only contain text content as children.");
|
|
1270
|
+
} // COMPAT: If they used the <text> tag we want to guarantee that it won't be
|
|
1271
|
+
// merge with other string children.
|
|
1272
|
+
|
|
1273
|
+
|
|
1274
|
+
STRINGS.delete(node);
|
|
1275
|
+
Object.assign(node, attributes);
|
|
1276
|
+
return node;
|
|
1277
|
+
}
|
|
1278
|
+
/**
|
|
1279
|
+
* Create a top-level `Editor` object.
|
|
1280
|
+
*/
|
|
1281
|
+
|
|
1282
|
+
var createEditor = makeEditor => (tagName, attributes, children) => {
|
|
1283
|
+
var otherChildren = [];
|
|
1284
|
+
var selectionChild;
|
|
1285
|
+
|
|
1286
|
+
for (var child of children) {
|
|
1287
|
+
if (Range.isRange(child)) {
|
|
1288
|
+
selectionChild = child;
|
|
1289
|
+
} else {
|
|
1290
|
+
otherChildren.push(child);
|
|
1291
|
+
}
|
|
1292
|
+
}
|
|
1293
|
+
|
|
1294
|
+
var descendants = resolveDescendants(otherChildren);
|
|
1295
|
+
var selection = {};
|
|
1296
|
+
var editor = makeEditor();
|
|
1297
|
+
Object.assign(editor, attributes);
|
|
1298
|
+
editor.children = descendants; // Search the document's texts to see if any of them have tokens associated
|
|
1299
|
+
// that need incorporated into the selection.
|
|
1300
|
+
|
|
1301
|
+
for (var [node, path] of Node.texts(editor)) {
|
|
1302
|
+
var anchor = getAnchorOffset(node);
|
|
1303
|
+
var focus = getFocusOffset(node);
|
|
1304
|
+
|
|
1305
|
+
if (anchor != null) {
|
|
1306
|
+
var [offset] = anchor;
|
|
1307
|
+
selection.anchor = {
|
|
1308
|
+
path,
|
|
1309
|
+
offset
|
|
1310
|
+
};
|
|
1311
|
+
}
|
|
1312
|
+
|
|
1313
|
+
if (focus != null) {
|
|
1314
|
+
var [_offset] = focus;
|
|
1315
|
+
selection.focus = {
|
|
1316
|
+
path,
|
|
1317
|
+
offset: _offset
|
|
1318
|
+
};
|
|
1319
|
+
}
|
|
1320
|
+
}
|
|
1321
|
+
|
|
1322
|
+
if (selection.anchor && !selection.focus) {
|
|
1323
|
+
throw new Error("Slate hyperscript ranges must have both `<anchor />` and `<focus />` defined if one is defined, but you only defined `<anchor />`. For collapsed selections, use `<cursor />` instead.");
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
if (!selection.anchor && selection.focus) {
|
|
1327
|
+
throw new Error("Slate hyperscript ranges must have both `<anchor />` and `<focus />` defined if one is defined, but you only defined `<focus />`. For collapsed selections, use `<cursor />` instead.");
|
|
1328
|
+
}
|
|
1329
|
+
|
|
1330
|
+
if (selectionChild != null) {
|
|
1331
|
+
editor.selection = selectionChild;
|
|
1332
|
+
} else if (Range.isRange(selection)) {
|
|
1333
|
+
editor.selection = selection;
|
|
1334
|
+
}
|
|
1335
|
+
|
|
1336
|
+
return editor;
|
|
1337
|
+
};
|
|
1338
|
+
|
|
1339
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
1340
|
+
|
|
1341
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
1342
|
+
/**
|
|
1343
|
+
* The default creators for Slate objects.
|
|
1344
|
+
*/
|
|
1345
|
+
|
|
1346
|
+
var DEFAULT_CREATORS = {
|
|
1347
|
+
anchor: createAnchor,
|
|
1348
|
+
cursor: createCursor,
|
|
1349
|
+
editor: createEditor(createEditor$1),
|
|
1350
|
+
element: createElement,
|
|
1351
|
+
focus: createFocus,
|
|
1352
|
+
fragment: createFragment,
|
|
1353
|
+
selection: createSelection,
|
|
1354
|
+
text: createText
|
|
1355
|
+
};
|
|
1356
|
+
/**
|
|
1357
|
+
* Create a Slate hyperscript function with `options`.
|
|
1358
|
+
*/
|
|
1359
|
+
|
|
1360
|
+
var createHyperscript = function createHyperscript() {
|
|
1361
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
1362
|
+
var {
|
|
1363
|
+
elements = {}
|
|
1364
|
+
} = options;
|
|
1365
|
+
var elementCreators = normalizeElements(elements);
|
|
1366
|
+
|
|
1367
|
+
var creators = _objectSpread(_objectSpread(_objectSpread({}, DEFAULT_CREATORS), elementCreators), options.creators);
|
|
1368
|
+
|
|
1369
|
+
var jsx = createFactory(creators);
|
|
1370
|
+
return jsx;
|
|
1371
|
+
};
|
|
1372
|
+
/**
|
|
1373
|
+
* Create a Slate hyperscript function with `options`.
|
|
1374
|
+
*/
|
|
1375
|
+
|
|
1376
|
+
|
|
1377
|
+
var createFactory = creators => {
|
|
1378
|
+
var jsx = function jsx(tagName, attributes) {
|
|
1379
|
+
for (var _len = arguments.length, children = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
1380
|
+
children[_key - 2] = arguments[_key];
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
var creator = creators[tagName];
|
|
1384
|
+
|
|
1385
|
+
if (!creator) {
|
|
1386
|
+
throw new Error("No hyperscript creator found for tag: <".concat(tagName, ">"));
|
|
1387
|
+
}
|
|
1388
|
+
|
|
1389
|
+
if (attributes == null) {
|
|
1390
|
+
attributes = {};
|
|
1391
|
+
}
|
|
1392
|
+
|
|
1393
|
+
if (!isPlainObject(attributes)) {
|
|
1394
|
+
children = [attributes].concat(children);
|
|
1395
|
+
attributes = {};
|
|
1396
|
+
}
|
|
1397
|
+
|
|
1398
|
+
children = children.filter(child => Boolean(child)).flat();
|
|
1399
|
+
var ret = creator(tagName, attributes, children);
|
|
1400
|
+
return ret;
|
|
1401
|
+
};
|
|
1402
|
+
|
|
1403
|
+
return jsx;
|
|
1404
|
+
};
|
|
1405
|
+
/**
|
|
1406
|
+
* Normalize a dictionary of element shorthands into creator functions.
|
|
1407
|
+
*/
|
|
1408
|
+
|
|
1409
|
+
|
|
1410
|
+
var normalizeElements = elements => {
|
|
1411
|
+
var creators = {};
|
|
1412
|
+
|
|
1413
|
+
var _loop = function _loop(tagName) {
|
|
1414
|
+
var props = elements[tagName];
|
|
1415
|
+
|
|
1416
|
+
if (typeof props !== 'object') {
|
|
1417
|
+
throw new Error("Properties specified for a hyperscript shorthand should be an object, but for the custom element <".concat(tagName, "> tag you passed: ").concat(props));
|
|
1418
|
+
}
|
|
1419
|
+
|
|
1420
|
+
creators[tagName] = (tagName, attributes, children) => {
|
|
1421
|
+
return createElement('element', _objectSpread(_objectSpread({}, props), attributes), children);
|
|
1422
|
+
};
|
|
1423
|
+
};
|
|
1424
|
+
|
|
1425
|
+
for (var tagName in elements) {
|
|
1426
|
+
_loop(tagName);
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
return creators;
|
|
1430
|
+
};
|
|
1431
|
+
|
|
1432
|
+
/**
|
|
1433
|
+
* The default hyperscript factory that ships with Slate, without custom tags.
|
|
1434
|
+
*/
|
|
1435
|
+
|
|
1436
|
+
var jsx = createHyperscript();
|
|
1437
|
+
|
|
1438
|
+
const TEXT_TAGS$1 = {
|
|
1439
|
+
DEL: () => ({ strikethrough: true }),
|
|
1440
|
+
EM: () => ({ italic: true }),
|
|
1441
|
+
I: () => ({ italic: true }),
|
|
1442
|
+
S: () => ({ strikethrough: true }),
|
|
1443
|
+
STRONG: () => ({ bold: true }),
|
|
1444
|
+
U: () => ({ underline: true }),
|
|
1445
|
+
};
|
|
1446
|
+
const deserialize$1 = (el, pluginsMap) => {
|
|
1447
|
+
var _a, _b, _c, _d;
|
|
1448
|
+
if (el.nodeType === 3) {
|
|
1449
|
+
return el.textContent;
|
|
1450
|
+
}
|
|
1451
|
+
else if (el.nodeType !== 1) {
|
|
1452
|
+
return null;
|
|
1453
|
+
}
|
|
1454
|
+
else if (el.nodeName === 'BR') {
|
|
1455
|
+
return '\n';
|
|
1456
|
+
}
|
|
1457
|
+
const { nodeName } = el;
|
|
1458
|
+
let parent = el;
|
|
1459
|
+
let children = Array.from(parent.childNodes)
|
|
1460
|
+
.map((node) => deserialize$1(node, pluginsMap))
|
|
1461
|
+
.flat();
|
|
1462
|
+
if (children.length === 0) {
|
|
1463
|
+
children = [{ text: '' }];
|
|
1464
|
+
}
|
|
1465
|
+
if (el.nodeName === 'BODY') {
|
|
1466
|
+
return jsx('fragment', {}, children);
|
|
1467
|
+
}
|
|
1468
|
+
if (pluginsMap[nodeName]) {
|
|
1469
|
+
const plugin = pluginsMap[nodeName];
|
|
1470
|
+
if (plugin) {
|
|
1471
|
+
let node = plugin.defineElement();
|
|
1472
|
+
if (typeof ((_b = (_a = plugin.exports) === null || _a === void 0 ? void 0 : _a.html.deserialize) === null || _b === void 0 ? void 0 : _b.parse) === 'function') {
|
|
1473
|
+
const data = (_d = (_c = plugin.exports) === null || _c === void 0 ? void 0 : _c.html.deserialize) === null || _d === void 0 ? void 0 : _d.parse(el);
|
|
1474
|
+
node = Object.assign(Object.assign({}, node), { data });
|
|
1475
|
+
}
|
|
1476
|
+
return jsx('element', node, children);
|
|
1477
|
+
}
|
|
1478
|
+
}
|
|
1479
|
+
if (Text.isTextList(children)) {
|
|
1480
|
+
return jsx('element', pluginsMap.P.defineElement(), children);
|
|
1481
|
+
}
|
|
1482
|
+
if (TEXT_TAGS$1[nodeName]) {
|
|
1483
|
+
const attrs = TEXT_TAGS$1[nodeName](el);
|
|
1484
|
+
const textNodes = children.map((child) => {
|
|
1485
|
+
return Text.isText(child) ? jsx('text', attrs, child) : child;
|
|
1486
|
+
});
|
|
1487
|
+
return textNodes;
|
|
1488
|
+
}
|
|
1489
|
+
return children;
|
|
1490
|
+
};
|
|
1491
|
+
function deserializeMarkdown(htmlString, plugins) {
|
|
1492
|
+
const pluginsMap = mergePluginTypesToMapHMTLNodeName(plugins);
|
|
1493
|
+
const parsedHtml = new DOMParser().parseFromString(htmlString, 'text/html');
|
|
1494
|
+
return deserialize$1(parsedHtml.body, pluginsMap);
|
|
1495
|
+
}
|
|
1496
|
+
|
|
1497
|
+
const serializeNode = (node, pluginsMap) => {
|
|
1498
|
+
var _a, _b;
|
|
1499
|
+
if (Text.isText(node)) {
|
|
1500
|
+
return node.text;
|
|
1501
|
+
}
|
|
1502
|
+
const children = node.children.map((n) => serializeNode(n, pluginsMap)).join('');
|
|
1503
|
+
const plugin = pluginsMap[node.type];
|
|
1504
|
+
const serializeFn = (_b = (_a = plugin.exports) === null || _a === void 0 ? void 0 : _a.markdown) === null || _b === void 0 ? void 0 : _b.serialize;
|
|
1505
|
+
if (typeof serializeFn === 'function') {
|
|
1506
|
+
return `${serializeFn(node, children)}\n`;
|
|
1507
|
+
}
|
|
1508
|
+
return `\n${children}\n`;
|
|
1509
|
+
};
|
|
1510
|
+
function serializeMarkdown(data, plugins) {
|
|
1511
|
+
const pluginsMap = mergePluginTypesToMap(plugins);
|
|
1512
|
+
const html = data.map((node) => serializeNode(node, pluginsMap)).join('');
|
|
1513
|
+
return html;
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
const TEXT_TAGS = {
|
|
1517
|
+
DEL: () => ({ strikethrough: true }),
|
|
1518
|
+
EM: () => ({ italic: true }),
|
|
1519
|
+
I: () => ({ italic: true }),
|
|
1520
|
+
S: () => ({ strikethrough: true }),
|
|
1521
|
+
STRONG: () => ({ bold: true }),
|
|
1522
|
+
U: () => ({ underline: true }),
|
|
1523
|
+
};
|
|
1524
|
+
const deserialize = (el, pluginsMap) => {
|
|
1525
|
+
var _a, _b, _c, _d;
|
|
1526
|
+
if (el.nodeType === 3) {
|
|
1527
|
+
return el.textContent;
|
|
1528
|
+
}
|
|
1529
|
+
else if (el.nodeType !== 1) {
|
|
1530
|
+
return null;
|
|
1531
|
+
}
|
|
1532
|
+
else if (el.nodeName === 'BR') {
|
|
1533
|
+
return '\n';
|
|
1534
|
+
}
|
|
1535
|
+
const { nodeName } = el;
|
|
1536
|
+
let parent = el;
|
|
1537
|
+
let children = Array.from(parent.childNodes)
|
|
1538
|
+
.map((node) => deserialize(node, pluginsMap))
|
|
1539
|
+
.flat();
|
|
1540
|
+
if (children.length === 0) {
|
|
1541
|
+
children = [{ text: '' }];
|
|
1542
|
+
}
|
|
1543
|
+
if (el.nodeName === 'BODY') {
|
|
1544
|
+
return jsx('fragment', {}, children);
|
|
1545
|
+
}
|
|
1546
|
+
if (pluginsMap[nodeName]) {
|
|
1547
|
+
const plugin = pluginsMap[nodeName];
|
|
1548
|
+
if (plugin) {
|
|
1549
|
+
let node = plugin.defineElement();
|
|
1550
|
+
if (typeof ((_b = (_a = plugin.exports) === null || _a === void 0 ? void 0 : _a.html.deserialize) === null || _b === void 0 ? void 0 : _b.parse) === 'function') {
|
|
1551
|
+
const data = (_d = (_c = plugin.exports) === null || _c === void 0 ? void 0 : _c.html.deserialize) === null || _d === void 0 ? void 0 : _d.parse(el);
|
|
1552
|
+
node = Object.assign(Object.assign({}, node), { data });
|
|
1553
|
+
}
|
|
1554
|
+
return jsx('element', node, children);
|
|
1555
|
+
}
|
|
1556
|
+
}
|
|
1557
|
+
if (Text.isTextList(children)) {
|
|
1558
|
+
return jsx('element', pluginsMap.P.defineElement(), children);
|
|
1559
|
+
}
|
|
1560
|
+
if (TEXT_TAGS[nodeName]) {
|
|
1561
|
+
const attrs = TEXT_TAGS[nodeName](el);
|
|
1562
|
+
const textNodes = children.map((child) => {
|
|
1563
|
+
return Text.isText(child) ? jsx('text', attrs, child) : child;
|
|
1564
|
+
});
|
|
1565
|
+
return textNodes;
|
|
1566
|
+
}
|
|
1567
|
+
return children;
|
|
1568
|
+
};
|
|
1569
|
+
function deserializeHtml(htmlString, plugins) {
|
|
1570
|
+
const pluginsMap = mergePluginTypesToMapHMTLNodeName(plugins);
|
|
1571
|
+
const parsedHtml = new DOMParser().parseFromString(htmlString, 'text/html');
|
|
1572
|
+
return deserialize(parsedHtml.body, pluginsMap);
|
|
1573
|
+
}
|
|
1574
|
+
|
|
1575
|
+
const markdown = { deserialize: deserializeMarkdown, serialize: serializeMarkdown };
|
|
1576
|
+
const html = { deserialize: deserializeHtml, serialize: serializeHtml };
|
|
1577
|
+
const yooptaExports = {
|
|
1578
|
+
markdown,
|
|
1579
|
+
html,
|
|
1580
|
+
};
|
|
1581
|
+
|
|
1582
|
+
export { yooptaExports as default, html, markdown };
|