@plohoj/html-editor 0.0.6 → 0.1.0

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 CHANGED
@@ -1,5 +1,73 @@
1
- import { throttleTime, mergeMap, distinctUntilChanged, switchMap, debounceTime, filter, map, take, tap, shareReplay, connect, takeUntil } from 'rxjs/operators';
2
- import { Observable, concat, defer, EMPTY, of, merge, fromEvent, pipe, from, tap as tap$1, share, NEVER, takeUntil as takeUntil$1, ignoreElements, ReplaySubject } from 'rxjs';
1
+ import { mergeMap, EMPTY, merge, connect, filter, takeUntil, Observable, concat, defer, throttleTime, distinctUntilChanged, switchMap, of, debounceTime, map, take, fromEvent, tap, shareReplay, share, NEVER, ignoreElements, ReplaySubject } from 'rxjs';
2
+ import { __rest } from 'tslib';
3
+
4
+ function assuredArray(values) {
5
+ if (values instanceof Array) {
6
+ return values;
7
+ }
8
+ if (values) {
9
+ return [values];
10
+ }
11
+ return [];
12
+ }
13
+ function mergeMapAddedElements(projectOrOptions, options) {
14
+ // #region Options parsing
15
+ let project;
16
+ let stableOptions;
17
+ if (typeof projectOrOptions === 'function') {
18
+ project = projectOrOptions;
19
+ stableOptions = options || {};
20
+ }
21
+ else {
22
+ project = projectOrOptions.project;
23
+ stableOptions = projectOrOptions;
24
+ }
25
+ const { takeUntil: takeUntilOption = 'removed' } = stableOptions;
26
+ // #endregion
27
+ if (takeUntilOption === 'always') {
28
+ return source$ => source$.pipe(mergeMap(changes => {
29
+ const added = assuredArray(changes.added);
30
+ if (added.length === 0) {
31
+ return EMPTY;
32
+ }
33
+ const addedObservers = added.map(project);
34
+ return merge(...addedObservers);
35
+ }));
36
+ }
37
+ return source$ => source$.pipe(connect(connectedSource$ => connectedSource$.pipe(mergeMap(changes => {
38
+ const added = assuredArray(changes.added);
39
+ if (added.length === 0) {
40
+ return EMPTY;
41
+ }
42
+ const addedObservers = added.map(addedElement => {
43
+ let takeUntil$;
44
+ if (takeUntilOption === 'removed') {
45
+ takeUntil$ = connectedSource$.pipe(filter(connectedChanges => connectedChanges.removed instanceof Array
46
+ ? connectedChanges.removed.indexOf(addedElement) !== -1
47
+ : connectedChanges.removed === addedElement));
48
+ }
49
+ else {
50
+ let wasRemoved = false;
51
+ takeUntil$ = connectedSource$.pipe(filter(connectedChanges => {
52
+ if (!wasRemoved) {
53
+ wasRemoved = connectedChanges.removed instanceof Array
54
+ ? connectedChanges.removed.indexOf(addedElement) !== -1
55
+ : connectedChanges.removed === addedElement;
56
+ }
57
+ if (wasRemoved) {
58
+ const hasTarget = connectedChanges.target instanceof Array
59
+ ? connectedChanges.target.indexOf(addedElement) !== -1
60
+ : connectedChanges.target === addedElement;
61
+ return hasTarget;
62
+ }
63
+ return false;
64
+ }));
65
+ }
66
+ return project(addedElement).pipe(takeUntil(takeUntil$));
67
+ });
68
+ return merge(...addedObservers);
69
+ }))));
70
+ }
3
71
 
4
72
  function trueStub() {
5
73
  return true;
@@ -8,9 +76,7 @@ function falseStub() {
8
76
  return false;
9
77
  }
10
78
 
11
- /**
12
- * Converts the callback of the MutationObserver class to an Rx event stream
13
- */
79
+ /** Converts the callback of the {@link MutationObserver} class to an Rx event stream */
14
80
  function observeElementMutation(node, options) {
15
81
  return new Observable(subscriber => {
16
82
  const mutationObserver = new MutationObserver(mutation => subscriber.next(mutation));
@@ -19,18 +85,36 @@ function observeElementMutation(node, options) {
19
85
  });
20
86
  }
21
87
 
22
- /**
23
- * Returns change (addition and deletion) of element that match selectors, like an Rx stream.
24
- */
25
- function observeQuerySelector(query, options = {}) {
26
- const { parent = document.documentElement, asRemovedWhen, filter = trueStub, } = options;
88
+ function observeQuerySelector(queryOrOptions, projectOrOptions, options) {
89
+ // #region Options parsing
90
+ let query;
91
+ let project;
92
+ let stableOptions;
93
+ if (typeof queryOrOptions === 'string') {
94
+ query = queryOrOptions;
95
+ if (typeof projectOrOptions === 'function') {
96
+ project = projectOrOptions;
97
+ stableOptions = options || {};
98
+ }
99
+ else {
100
+ stableOptions = projectOrOptions || {};
101
+ project = projectOrOptions === null || projectOrOptions === void 0 ? void 0 : projectOrOptions.project;
102
+ }
103
+ }
104
+ else {
105
+ stableOptions = queryOrOptions;
106
+ query = queryOrOptions.query;
107
+ project = queryOrOptions === null || queryOrOptions === void 0 ? void 0 : queryOrOptions.project;
108
+ }
109
+ const { parent = document.documentElement, asRemovedWhen, filter = trueStub, has, tap } = stableOptions, restOfStableOptions = __rest(stableOptions, ["parent", "asRemovedWhen", "filter", "has", "tap"]);
110
+ // #endregion
27
111
  let targetElement;
28
112
  function checkChanges() {
29
113
  const querySelectedElements = parent.querySelectorAll(query);
30
114
  let filteredSelectedElement;
31
115
  const changes = {};
32
116
  for (const querySelectedElement of querySelectedElements) {
33
- if (options.has && !querySelectedElement.querySelector(options.has)) {
117
+ if (has && !querySelectedElement.querySelector(has)) {
34
118
  continue;
35
119
  }
36
120
  if (!filter(querySelectedElement)) {
@@ -47,12 +131,14 @@ function observeQuerySelector(query, options = {}) {
47
131
  }
48
132
  if (filteredSelectedElement) {
49
133
  changes.added = filteredSelectedElement;
134
+ tap === null || tap === void 0 ? void 0 : tap(filteredSelectedElement);
50
135
  }
51
136
  changes.target = filteredSelectedElement;
52
137
  targetElement = filteredSelectedElement;
53
138
  return of(changes);
54
139
  }
55
140
  const observeQuerySelector$ = concat(defer(() => checkChanges()), observeElementMutation(parent, { subtree: true, childList: true }).pipe(throttleTime(0, undefined, { leading: true, trailing: true }), mergeMap(checkChanges)));
141
+ let observeQuerySelectorWithRemovedWhen$ = observeQuerySelector$;
56
142
  if (asRemovedWhen) {
57
143
  const removedObserver$ = defer(() => {
58
144
  if (!targetElement) {
@@ -64,38 +150,60 @@ function observeQuerySelector(query, options = {}) {
64
150
  targetElement = undefined;
65
151
  return of(changes);
66
152
  });
67
- const observeQuerySelectorWithRemovedWhen$ = asRemovedWhen.pipe(distinctUntilChanged(), switchMap(asRemoved => asRemoved ? removedObserver$ : observeQuerySelector$));
68
- return observeQuerySelectorWithRemovedWhen$;
153
+ observeQuerySelectorWithRemovedWhen$ = asRemovedWhen.pipe(distinctUntilChanged(), switchMap(asRemoved => asRemoved ? removedObserver$ : observeQuerySelector$));
69
154
  }
70
- return observeQuerySelector$;
71
- }
72
-
73
- /**
74
- * Awaiting only one element to match the selector and returns it as an Rx stream.
75
- * The stream ends after one element is found / added.
76
- */
77
- function awaitElement(query, options = {}) {
78
- return observeQuerySelector(query, options)
79
- .pipe(debounceTime(options.debounceTime || 0, options.debounceScheduler), filter(changes => !!changes.target), map(changes => changes.target), take(1));
155
+ if (project) {
156
+ return observeQuerySelectorWithRemovedWhen$.pipe(mergeMapAddedElements(Object.assign({ project }, restOfStableOptions)));
157
+ }
158
+ return observeQuerySelectorWithRemovedWhen$;
80
159
  }
81
160
 
82
- function randomFromArray(array, from = 0, to = array.length) {
83
- if (to < 0) {
84
- to = array.length + to;
161
+ function awaitElement(queryOrOptions, options) {
162
+ // #region Options parsing
163
+ let query;
164
+ let stableOptions;
165
+ if (typeof queryOrOptions === 'string') {
166
+ query = queryOrOptions;
167
+ stableOptions = options || {};
85
168
  }
86
- return array[Math.floor(Math.random() * (to - from)) + from];
169
+ else {
170
+ stableOptions = queryOrOptions;
171
+ query = queryOrOptions.query;
172
+ }
173
+ // #endregion
174
+ return observeQuerySelector(query, stableOptions).pipe(debounceTime(stableOptions.debounceTime || 0, stableOptions.debounceScheduler), filter(changes => !!changes.target), map(changes => changes.target), take(1));
87
175
  }
88
176
 
89
- /** Returns changes (additions and deletions) of elements that match selectors, like an Rx stream. */
90
- function observeQuerySelectorAll(query, options = {}) {
91
- const { parent = document.documentElement, asRemovedWhen, filter = trueStub, } = options;
177
+ function observeQuerySelectorAll(queryOrOptions, projectOrOptions, options) {
178
+ // #region Options parsing
179
+ let query;
180
+ let project;
181
+ let stableOptions;
182
+ if (typeof queryOrOptions === 'string') {
183
+ query = queryOrOptions;
184
+ if (typeof projectOrOptions === 'function') {
185
+ project = projectOrOptions;
186
+ stableOptions = options || {};
187
+ }
188
+ else {
189
+ stableOptions = projectOrOptions || {};
190
+ project = projectOrOptions === null || projectOrOptions === void 0 ? void 0 : projectOrOptions.project;
191
+ }
192
+ }
193
+ else {
194
+ stableOptions = queryOrOptions;
195
+ query = queryOrOptions.query;
196
+ project = queryOrOptions === null || queryOrOptions === void 0 ? void 0 : queryOrOptions.project;
197
+ }
198
+ const { parent = document.documentElement, asRemovedWhen, filter = trueStub, has, tap } = stableOptions, restOfStableOptions = __rest(stableOptions, ["parent", "asRemovedWhen", "filter", "has", "tap"]);
199
+ // #endregion
92
200
  const targetElements = new Set();
93
201
  function checkChanges() {
94
202
  const addedElements = new Set();
95
203
  const targetElementsDiff = new Set(targetElements);
96
204
  const querySelectedElements = new Set(parent.querySelectorAll(query));
97
205
  for (const querySelectedElement of querySelectedElements) {
98
- if (options.has && !querySelectedElement.querySelector(options.has)) {
206
+ if (has && !querySelectedElement.querySelector(has)) {
99
207
  continue;
100
208
  }
101
209
  if (!filter(querySelectedElement)) {
@@ -117,6 +225,7 @@ function observeQuerySelectorAll(query, options = {}) {
117
225
  }
118
226
  for (const addedElement of addedElements) {
119
227
  targetElements.add(addedElement);
228
+ tap === null || tap === void 0 ? void 0 : tap(addedElement);
120
229
  }
121
230
  const changes = {
122
231
  target: [...targetElements.values()],
@@ -125,7 +234,8 @@ function observeQuerySelectorAll(query, options = {}) {
125
234
  };
126
235
  return of(changes);
127
236
  }
128
- let observeQuerySelectorAll$ = concat(defer(() => checkChanges()), observeElementMutation(parent, { subtree: true, childList: true }).pipe(throttleTime(0, undefined, { leading: true, trailing: true }), mergeMap(checkChanges)));
237
+ const observeQuerySelectorAll$ = concat(defer(() => checkChanges()), observeElementMutation(parent, { subtree: true, childList: true }).pipe(throttleTime(0, undefined, { leading: true, trailing: true }), mergeMap(checkChanges)));
238
+ let observeQuerySelectorAllWithRemovedWhen$ = observeQuerySelectorAll$;
129
239
  if (asRemovedWhen) {
130
240
  const removedObserver$ = defer(() => {
131
241
  if (targetElements.size === 0) {
@@ -139,28 +249,58 @@ function observeQuerySelectorAll(query, options = {}) {
139
249
  targetElements.clear();
140
250
  return of(changes);
141
251
  });
142
- const observeQuerySelectorAllWithRemovedWhen$ = asRemovedWhen.pipe(distinctUntilChanged(), switchMap(asRemoved => asRemoved ? removedObserver$ : observeQuerySelectorAll$));
143
- return observeQuerySelectorAllWithRemovedWhen$;
252
+ observeQuerySelectorAllWithRemovedWhen$ = asRemovedWhen.pipe(distinctUntilChanged(), switchMap(asRemoved => asRemoved ? removedObserver$ : observeQuerySelectorAll$));
253
+ }
254
+ if (project) {
255
+ return observeQuerySelectorAllWithRemovedWhen$.pipe(mergeMapAddedElements(Object.assign({ project }, restOfStableOptions)));
144
256
  }
145
- return observeQuerySelectorAll$;
257
+ return observeQuerySelectorAllWithRemovedWhen$;
146
258
  }
147
259
 
148
- /**
149
- * Awaiting Expects at least one element to match the selector and returns it as an Rx stream.
150
- * If there are more than 1 elements, it will return a random one.
151
- * The stream ends after the elements are found / added.
152
- */
153
- function awaitRandomElement(query, options = {}) {
154
- return observeQuerySelectorAll(query, options)
155
- .pipe(debounceTime(options.debounceTime || 0, options.debounceScheduler), filter(changes => changes.target.length > 0), map(changes => randomFromArray(changes.target)), take(1));
260
+ function awaitElements(queryOrOptions, options) {
261
+ // #region Options parsing
262
+ let query;
263
+ let stableOptions;
264
+ if (typeof queryOrOptions === 'string') {
265
+ query = queryOrOptions;
266
+ stableOptions = options || {};
267
+ }
268
+ else {
269
+ stableOptions = queryOrOptions;
270
+ query = queryOrOptions.query;
271
+ }
272
+ // #endregion
273
+ return observeQuerySelectorAll(query, stableOptions).pipe(debounceTime(stableOptions.debounceTime || 0, stableOptions.debounceScheduler), filter(changes => !!changes.target), map(changes => changes.target), take(1));
274
+ }
275
+
276
+ function randomFromArray(array, from = 0, to = array.length) {
277
+ if (to < 0) {
278
+ to = array.length + to;
279
+ }
280
+ return array[Math.floor(Math.random() * (to - from)) + from];
281
+ }
282
+
283
+ function awaitRandomElement(queryOrOptions, options) {
284
+ // #region Options parsing
285
+ let query;
286
+ let stableOptions;
287
+ if (typeof queryOrOptions === 'string') {
288
+ query = queryOrOptions;
289
+ stableOptions = options || {};
290
+ }
291
+ else {
292
+ stableOptions = queryOrOptions;
293
+ query = queryOrOptions.query;
294
+ }
295
+ // #endregion
296
+ return observeQuerySelectorAll(query, stableOptions).pipe(debounceTime(stableOptions.debounceTime || 0, stableOptions.debounceScheduler), filter(changes => changes.target.length > 0), map(changes => randomFromArray(changes.target)), take(1));
156
297
  }
157
298
 
158
299
  function observePressedKeyboardButtons(options = {}) {
159
300
  const target = options.target || window;
160
301
  const set = new Set();
161
302
  const addKey$ = merge(fromEvent(target, 'keydown'), fromEvent(target, 'keypress')).pipe(filter((event) => !set.has(event.key)), tap((event) => set.add(event.key)));
162
- const keyRemove$ = fromEvent(target, 'keyup')
163
- .pipe(filter((event) => set.has(event.key)), tap((event) => set.delete(event.key)));
303
+ const keyRemove$ = fromEvent(target, 'keyup').pipe(filter((event) => set.has(event.key)), tap((event) => set.delete(event.key)));
164
304
  return merge(addKey$, keyRemove$).pipe(map(() => set));
165
305
  }
166
306
 
@@ -191,8 +331,89 @@ const urlChange$ = new Observable(subscriber$ => {
191
331
  };
192
332
  }).pipe(distinctUntilChanged(), shareReplay(1));
193
333
 
334
+ function mergeMapByCondition(conditionOrOptions, project, options) {
335
+ // #region Options parsing
336
+ let stableOptions;
337
+ let conditionFn;
338
+ let stableProject;
339
+ if ('condition' in conditionOrOptions) {
340
+ stableOptions = conditionOrOptions;
341
+ conditionFn = conditionOrOptions.condition;
342
+ stableProject = conditionOrOptions.project;
343
+ }
344
+ else {
345
+ conditionFn = conditionOrOptions;
346
+ stableOptions = options || {};
347
+ stableProject = project;
348
+ }
349
+ const { takeFor = 'new', takeUntil: takeUntilOption = 'fail', } = stableOptions;
350
+ // #endregion
351
+ let isPrevConditionPass = false;
352
+ return source$ => source$.pipe(map(source => ({ source, isConditionPassed: conditionFn(source) })), connect(connectedSource$ => {
353
+ let takeUntil$;
354
+ if (takeUntilOption === 'fail') {
355
+ takeUntil$ = connectedSource$.pipe(filter(({ isConditionPassed }) => isConditionPassed));
356
+ }
357
+ else if (takeUntilOption === 'pass') {
358
+ let wasFailed = false;
359
+ takeUntil$ = connectedSource$.pipe(filter(({ isConditionPassed }) => {
360
+ if (isConditionPassed) {
361
+ if (wasFailed) {
362
+ return true;
363
+ }
364
+ }
365
+ else {
366
+ wasFailed = true;
367
+ }
368
+ return false;
369
+ }));
370
+ }
371
+ return connectedSource$.pipe(mergeMap(({ source, isConditionPassed }) => {
372
+ if (isConditionPassed) {
373
+ const isCreateNewProject = takeFor === 'all' || !isPrevConditionPass;
374
+ isPrevConditionPass = true;
375
+ if (isCreateNewProject) {
376
+ if (!stableProject) {
377
+ return of(source);
378
+ }
379
+ let project$ = stableProject(source);
380
+ if (takeUntil$) {
381
+ project$ = project$.pipe(takeUntil(takeUntil$));
382
+ }
383
+ return project$;
384
+ }
385
+ }
386
+ else {
387
+ isPrevConditionPass = false;
388
+ }
389
+ return EMPTY;
390
+ }));
391
+ }));
392
+ }
393
+
394
+ function getStringConditionFunction(condition) {
395
+ return typeof condition === 'function' ? condition : (value) => condition.test(value);
396
+ }
397
+ function mergeMapStringCondition(conditionOrOptions, project, options) {
398
+ if ('condition' in conditionOrOptions) {
399
+ return mergeMapByCondition(Object.assign(Object.assign({}, conditionOrOptions), { condition: getStringConditionFunction(conditionOrOptions.condition) }));
400
+ }
401
+ else {
402
+ return mergeMapByCondition(Object.assign(Object.assign({}, options), { condition: getStringConditionFunction(conditionOrOptions), project }));
403
+ }
404
+ }
405
+
406
+ function observeUrlChanges(options = {}) {
407
+ return urlChange$.pipe(mergeMapStringCondition(Object.assign(Object.assign({}, options), { condition: options.condition || (() => true) })));
408
+ }
409
+
194
410
  function clickElementImmediately(element) {
195
- element.dispatchEvent(new MouseEvent('click', { bubbles: true }));
411
+ if ('click' in element) {
412
+ element.click();
413
+ }
414
+ else {
415
+ element.dispatchEvent(new MouseEvent('click', { bubbles: true }));
416
+ }
196
417
  console.log(`Click: `, element);
197
418
  }
198
419
  function clickElement(element) {
@@ -200,73 +421,34 @@ function clickElement(element) {
200
421
  clickElementImmediately(element);
201
422
  }
202
423
  else {
203
- return pipe(tap((element) => clickElementImmediately(element)));
424
+ return tap((element) => clickElementImmediately(element));
204
425
  }
205
426
  }
206
427
 
207
- function assuredArray(values) {
208
- if (values instanceof Array) {
209
- return values;
428
+ function focusElementImmediately(element) {
429
+ if ('focus' in element) {
430
+ element.focus();
210
431
  }
211
- if (values) {
212
- return [values];
432
+ else {
433
+ element.dispatchEvent(new FocusEvent('focus'));
434
+ element.dispatchEvent(new FocusEvent('focusin', { bubbles: true }));
213
435
  }
214
- return [];
436
+ console.log(`Focus: `, element);
215
437
  }
216
- function mergeMapAddedElements(projectOrOptions, options) {
217
- const project = typeof projectOrOptions === 'function'
218
- ? projectOrOptions
219
- : (element) => of(element);
220
- options = typeof projectOrOptions === 'object' ? projectOrOptions : options;
221
- const { isTakeUntilRemoved = false } = options || {};
222
- if (!isTakeUntilRemoved) {
223
- return source$ => source$.pipe(mergeMap(changes => {
224
- const added = assuredArray(changes.added);
225
- if (added.length === 0) {
226
- return EMPTY;
227
- }
228
- const addedObservers = added.map(project);
229
- return merge(...addedObservers);
230
- }));
231
- }
232
- return source$ => source$.pipe(connect(connectedSource$ => connectedSource$.pipe(mergeMap(changes => {
233
- const added = assuredArray(changes.added);
234
- if (added.length === 0) {
235
- return EMPTY;
236
- }
237
- const addedObservers = added.map(addedElement => from(project(addedElement)).pipe(takeUntil(connectedSource$.pipe(filter(changes => {
238
- if (changes.removed instanceof Array) {
239
- return changes.removed.indexOf(addedElement) != -1;
240
- }
241
- else {
242
- return changes.removed === addedElement;
243
- }
244
- })))));
245
- return merge(...addedObservers);
246
- }))));
247
- }
248
-
249
- /** The operator creates a separate stream when the source string is validated. */
250
- function mergeMapStringToggle(condition, project, options) {
251
- const mapConditionFn = typeof condition === 'function' ? condition : (url) => condition.test(url);
252
- let urlMatchToggler;
253
- if (typeof project === 'function') {
254
- urlMatchToggler = (isUrlMatch) => isUrlMatch ? from(project()) : EMPTY;
438
+ function focusElement(element) {
439
+ if (element) {
440
+ focusElementImmediately(element);
255
441
  }
256
442
  else {
257
- urlMatchToggler = (isUrlMatch) => isUrlMatch ? from(project) : EMPTY;
443
+ return tap((element) => focusElementImmediately(element));
258
444
  }
259
- const mergeOperator = (options === null || options === void 0 ? void 0 : options.isTakeUntilToggle)
260
- ? switchMap(urlMatchToggler)
261
- : mergeMap(urlMatchToggler);
262
- return pipe(map(mapConditionFn), distinctUntilChanged(), mergeOperator);
263
445
  }
264
446
 
265
447
  function removeElement() {
266
- return pipe(tap((element) => {
448
+ return tap((element) => {
267
449
  element.remove();
268
450
  console.log(`Remove: `, element);
269
- }));
451
+ });
270
452
  }
271
453
 
272
454
  function restoreHistory(options) {
@@ -274,7 +456,7 @@ function restoreHistory(options) {
274
456
  let hasStory = false;
275
457
  const observeCancel$ = options.cancelRestore
276
458
  ? defer(() => options.cancelRestore())
277
- .pipe(tap$1(() => {
459
+ .pipe(tap(() => {
278
460
  if (hasStory) {
279
461
  options.removeStory();
280
462
  }
@@ -288,10 +470,10 @@ function restoreHistory(options) {
288
470
  hasStory = true;
289
471
  let rested$ = of(story);
290
472
  if (options.cancelRestore) {
291
- rested$ = rested$.pipe(takeUntil$1(observeCancel$));
473
+ rested$ = rested$.pipe(takeUntil(observeCancel$));
292
474
  }
293
475
  return rested$;
294
- }), source$.pipe(tap$1((data) => {
476
+ }), source$.pipe(tap((data) => {
295
477
  options.setStory(data);
296
478
  hasStory = true;
297
479
  })));
@@ -302,12 +484,12 @@ function restoreHistory(options) {
302
484
  function setInputValueImmediately(element, value) {
303
485
  element.value = value;
304
486
  element.focus();
305
- element.dispatchEvent(new Event('input', { target: element }));
487
+ element.dispatchEvent(new Event('input'));
306
488
  console.log(`Set value: `, { element, value });
307
489
  }
308
490
  function setInputValue(elementOrValue, value) {
309
491
  if (typeof elementOrValue === 'string') {
310
- return pipe(tap((element) => setInputValueImmediately(element, elementOrValue)));
492
+ return tap((element) => setInputValueImmediately(element, elementOrValue));
311
493
  }
312
494
  else {
313
495
  setInputValueImmediately(elementOrValue, value);
@@ -349,6 +531,7 @@ function findRecursively(obj, options = {}) {
349
531
  const needSeen = new Set([{
350
532
  value: obj,
351
533
  depth: 0,
534
+ path: '',
352
535
  }]);
353
536
  const { matcher = falseStub, filter = trueStub, continueAfterGetterError = trueStub, stop = falseStub, minDepth = 1, maxDepth = Infinity, } = options;
354
537
  const pathRegExpCheck = options.pathRegExp
@@ -368,7 +551,7 @@ function findRecursively(obj, options = {}) {
368
551
  if (seenPathsForValue) {
369
552
  // TODO windows or document
370
553
  // TODO List of visited objects, but with the wrong path
371
- const hasCircularPath = seenPathsForValue.some(path => options.path && (path === null || path === void 0 ? void 0 : path.includes(options.path)));
554
+ const hasCircularPath = seenPathsForValue.some(path => options.path.includes(path));
372
555
  if (hasCircularPath) {
373
556
  return;
374
557
  }
@@ -415,12 +598,12 @@ function findRecursively(obj, options = {}) {
415
598
  const incrementalDepth = depth + 1;
416
599
  needSeen.delete(iterator.value);
417
600
  if (value instanceof Array) {
418
- iterateArrayLike(value.entries(), (fieldIndex) => `${path || ''}[${fieldIndex}]`, incrementalDepth);
601
+ iterateArrayLike(value.entries(), (fieldIndex) => `${path}[${fieldIndex}]`, incrementalDepth);
419
602
  }
420
- if (value instanceof Map) {
421
- iterateArrayLike(value.entries(), (fieldIndex) => `${path || ''}{${fieldIndex}}`, incrementalDepth);
603
+ else if (value instanceof Map) {
604
+ iterateArrayLike(value.entries(), (fieldIndex) => `${path}{${fieldIndex}}`, incrementalDepth);
422
605
  }
423
- if (value instanceof Set) {
606
+ else if (value instanceof Set) {
424
607
  for (const [fieldIndex, fieldValue] of [...value].entries()) {
425
608
  checkForNeedSeen({
426
609
  field: fieldValue,
@@ -467,5 +650,5 @@ function findRecursively(obj, options = {}) {
467
650
  return searched;
468
651
  }
469
652
 
470
- export { awaitElement, awaitRandomElement, clickElement, composeRestoreHistory, findRecursively, mergeMapAddedElements, mergeMapStringToggle, observeElementMutation, observePressedKeyboardButtons, observeQuerySelector, observeQuerySelectorAll, randomFromArray, removeElement, restoreHistory, setInputValue, urlChange$ };
653
+ export { awaitElement, awaitElements, awaitRandomElement, clickElement, composeRestoreHistory, findRecursively, focusElement, mergeMapAddedElements, mergeMapByCondition, mergeMapStringCondition, observeElementMutation, observePressedKeyboardButtons, observeQuerySelector, observeQuerySelectorAll, observeUrlChanges, randomFromArray, removeElement, restoreHistory, setInputValue, urlChange$ };
471
654
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
package/package.json CHANGED
@@ -1,24 +1,25 @@
1
- {
2
- "name": "@plohoj/html-editor",
3
- "version": "0.0.6",
4
- "description": "html-editor it's a tool for helping modification html elements",
5
- "repository": {
6
- "type": "git",
7
- "url": "git+https://github.com/plohoj/html-editor.git"
8
- },
9
- "scripts": {
10
- "build": "rollup --config"
11
- },
12
- "author": "Plokhikh Alexandr",
13
- "license": "ISC",
14
- "module": "./dist/index.js",
15
- "types": "./src/index.ts",
16
- "dependencies": {
17
- "rxjs": "^7.0.0"
18
- },
19
- "devDependencies": {
20
- "rollup": "^2.60.2",
21
- "rollup-plugin-typescript2": "^0.31.1",
22
- "typescript": "^4.5.2"
23
- }
24
- }
1
+ {
2
+ "name": "@plohoj/html-editor",
3
+ "version": "0.1.0",
4
+ "description": "html-editor it's a tool for helping modification html elements",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git+https://github.com/plohoj/html-editor.git"
8
+ },
9
+ "scripts": {
10
+ "build": "rollup --config"
11
+ },
12
+ "author": "Plokhikh Alexandr",
13
+ "license": "ISC",
14
+ "module": "./dist/index.js",
15
+ "types": "./src/index.ts",
16
+ "type": "module",
17
+ "dependencies": {
18
+ "rxjs": "^7.0.0"
19
+ },
20
+ "devDependencies": {
21
+ "rollup": "^3.9.1",
22
+ "rollup-plugin-typescript2": "^0.34.1",
23
+ "typescript": "^4.9.4"
24
+ }
25
+ }