lakelib 0.3.0 → 0.3.2

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/lib/lake.js CHANGED
@@ -171,6 +171,14 @@ var tableMerge = "<svg width=\"24\" height=\"24\" fill=\"none\" viewBox=\"0 0 24
171
171
 
172
172
  var tableSplit = "<svg width=\"24\" height=\"24\" fill=\"none\" viewBox=\"0 0 24 24\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M12.5 10H11v4h1.5v-4Z\" fill=\"#212121\"/><path d=\"M3 6.25A3.25 3.25 0 0 1 6.25 3h11.5A3.25 3.25 0 0 1 21 6.25v11.5A3.25 3.25 0 0 1 17.75 21H6.25A3.25 3.25 0 0 1 3 17.75V6.25ZM6.25 4.5A1.75 1.75 0 0 0 4.5 6.25V7.5H11v-3H6.25Zm13.25 12h-7v3h5.25a1.75 1.75 0 0 0 1.75-1.75V16.5Zm0-10.25a1.75 1.75 0 0 0-1.75-1.75H12.5v3h7V6.25ZM4.5 16.5v1.25c0 .966.784 1.75 1.75 1.75H11v-3H4.5Zm0-1.5h15V9h-15v6Z\" fill=\"#212121\"/></svg>";
173
173
 
174
+ var info = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32\" height=\"32\" fill=\"#000000\" viewBox=\"0 0 256 256\"><path d=\"M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm16-40a8,8,0,0,1-8,8,16,16,0,0,1-16-16V128a8,8,0,0,1,0-16,16,16,0,0,1,16,16v40A8,8,0,0,1,144,176ZM112,84a12,12,0,1,1,12,12A12,12,0,0,1,112,84Z\"></path></svg>";
175
+
176
+ var tip = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32\" height=\"32\" fill=\"#000000\" viewBox=\"0 0 256 256\"><path d=\"M176,232a8,8,0,0,1-8,8H88a8,8,0,0,1,0-16h80A8,8,0,0,1,176,232Zm40-128a87.55,87.55,0,0,1-33.64,69.21A16.24,16.24,0,0,0,176,186v6a16,16,0,0,1-16,16H96a16,16,0,0,1-16-16v-6a16,16,0,0,0-6.23-12.66A87.59,87.59,0,0,1,40,104.49C39.74,56.83,78.26,17.14,125.88,16A88,88,0,0,1,216,104Zm-16,0a72,72,0,0,0-73.74-72c-39,.92-70.47,33.39-70.26,72.39a71.65,71.65,0,0,0,27.64,56.3A32,32,0,0,1,96,186v6h64v-6a32.15,32.15,0,0,1,12.47-25.35A71.65,71.65,0,0,0,200,104Zm-16.11-9.34a57.6,57.6,0,0,0-46.56-46.55,8,8,0,0,0-2.66,15.78c16.57,2.79,30.63,16.85,33.44,33.45A8,8,0,0,0,176,104a9,9,0,0,0,1.35-.11A8,8,0,0,0,183.89,94.66Z\"></path></svg>";
177
+
178
+ var warning = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32\" height=\"32\" fill=\"#000000\" viewBox=\"0 0 256 256\"><path d=\"M236.8,188.09,149.35,36.22h0a24.76,24.76,0,0,0-42.7,0L19.2,188.09a23.51,23.51,0,0,0,0,23.72A24.35,24.35,0,0,0,40.55,224h174.9a24.35,24.35,0,0,0,21.33-12.19A23.51,23.51,0,0,0,236.8,188.09ZM222.93,203.8a8.5,8.5,0,0,1-7.48,4.2H40.55a8.5,8.5,0,0,1-7.48-4.2,7.59,7.59,0,0,1,0-7.72L120.52,44.21a8.75,8.75,0,0,1,15,0l87.45,151.87A7.59,7.59,0,0,1,222.93,203.8ZM120,144V104a8,8,0,0,1,16,0v40a8,8,0,0,1-16,0Zm20,36a12,12,0,1,1-12-12A12,12,0,0,1,140,180Z\"></path></svg>";
179
+
180
+ var danger = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"32\" height=\"32\" fill=\"#000000\" viewBox=\"0 0 256 256\"><path d=\"M120,136V80a8,8,0,0,1,16,0v56a8,8,0,0,1-16,0ZM232,91.55v72.9a15.86,15.86,0,0,1-4.69,11.31l-51.55,51.55A15.86,15.86,0,0,1,164.45,232H91.55a15.86,15.86,0,0,1-11.31-4.69L28.69,175.76A15.86,15.86,0,0,1,24,164.45V91.55a15.86,15.86,0,0,1,4.69-11.31L80.24,28.69A15.86,15.86,0,0,1,91.55,24h72.9a15.86,15.86,0,0,1,11.31,4.69l51.55,51.55A15.86,15.86,0,0,1,232,91.55Zm-16,0L164.45,40H91.55L40,91.55v72.9L91.55,216h72.9L216,164.45ZM128,160a12,12,0,1,0,12,12A12,12,0,0,0,128,160Z\"></path></svg>";
181
+
174
182
  // These icons are sourced from open source projects.
175
183
  //
176
184
  // Fluent Icons by Microsoft (https://fluenticons.co/).
@@ -272,6 +280,11 @@ const icons = new Map([
272
280
  ['tableRow', tableRow],
273
281
  ['tableMerge', tableMerge],
274
282
  ['tableSplit', tableSplit],
283
+ // alerts
284
+ ['info', info],
285
+ ['tip', tip],
286
+ ['warning', warning],
287
+ ['danger', danger],
275
288
  ]);
276
289
 
277
290
  // Returns an array representing a list of the document's elements.
@@ -394,7 +407,7 @@ function hex(value) {
394
407
  const hexString = Number.parseInt(value, 10).toString(16).toLowerCase();
395
408
  return hexString.length > 1 ? hexString : `0${hexString}`;
396
409
  }
397
- // Converts colors in RGB or RGBA format to hex format.
410
+ // Converts a color in RGB or RGBA format to hex format.
398
411
  function toHex(value) {
399
412
  return value.replace(/rgba?\s*\(\s*(\d+)\s*,\s*(\d+)\s*,\s*(\d+)\s*(?:,\s*([\d.]+)\s*)?\)/ig, (match, p1, p2, p3, p4) => {
400
413
  if (p4 === undefined) {
@@ -424,10 +437,10 @@ function debug(...data) {
424
437
  // value is an array which include types and listeners.
425
438
  const eventData = {};
426
439
  let lastNodeId = 0;
427
- // The Nodes class represents collections of nodes.
440
+ // The Nodes interface represents a collection of the document's nodes.
428
441
  class Nodes {
429
442
  constructor(node) {
430
- node = node !== null && node !== void 0 ? node : [];
443
+ node = node !== null && node !== undefined ? node : [];
431
444
  this.nodeList = Array.isArray(node) ? node : [node];
432
445
  for (let i = 0; i < this.nodeList.length; i++) {
433
446
  // lakeId is an expando for preserving node ID.
@@ -438,12 +451,12 @@ class Nodes {
438
451
  }
439
452
  this.length = this.nodeList.length;
440
453
  }
441
- // Returns node ID at the first index.
454
+ // The unique ID of the first node.
442
455
  get id() {
443
456
  const node = this.get(0);
444
457
  return node.lakeId;
445
458
  }
446
- // Returns node name at the first index.
459
+ // The name of the first node.
447
460
  get name() {
448
461
  if (this.length === 0) {
449
462
  return '';
@@ -451,7 +464,7 @@ class Nodes {
451
464
  const node = this.get(0);
452
465
  return node.nodeName.toLowerCase();
453
466
  }
454
- // Returns a boolean value indicating whether the node is an element.
467
+ // A boolean value indicating whether the first node is an element.
455
468
  get isElement() {
456
469
  if (this.length === 0) {
457
470
  return false;
@@ -459,7 +472,7 @@ class Nodes {
459
472
  const node = this.get(0);
460
473
  return node.nodeType === Node.ELEMENT_NODE;
461
474
  }
462
- // Returns a boolean value indicating whether the node is a text node.
475
+ // A boolean value indicating whether the first node is a text.
463
476
  get isText() {
464
477
  if (this.length === 0) {
465
478
  return false;
@@ -467,65 +480,65 @@ class Nodes {
467
480
  const node = this.get(0);
468
481
  return node.nodeType === Node.TEXT_NODE;
469
482
  }
470
- // Returns a boolean value indicating whether the node is a block element.
483
+ // A boolean value indicating whether the first node is a block.
471
484
  get isBlock() {
472
485
  if (this.length === 0) {
473
486
  return false;
474
487
  }
475
488
  return blockTagNames.has(this.name);
476
489
  }
477
- // Returns a boolean value indicating whether the node is a mark element.
490
+ // A boolean value indicating whether the first node is a mark.
478
491
  get isMark() {
479
492
  if (this.length === 0) {
480
493
  return false;
481
494
  }
482
495
  return markTagNames.has(this.name);
483
496
  }
484
- // Returns a boolean value indicating whether the node is a void element.
497
+ // A boolean value indicating whether the first node is a void element that cannot have any child nodes.
485
498
  get isVoid() {
486
499
  if (this.length === 0) {
487
500
  return false;
488
501
  }
489
502
  return voidTagNames.has(this.name);
490
503
  }
491
- // Returns a boolean value indicating whether the node is a heading element.
504
+ // A boolean value indicating whether the first node is a heading.
492
505
  get isHeading() {
493
506
  if (this.length === 0) {
494
507
  return false;
495
508
  }
496
509
  return headingTagNames.has(this.name);
497
510
  }
498
- // Returns a boolean value indicating whether the node is a list element.
511
+ // A boolean value indicating whether the first node is a list.
499
512
  get isList() {
500
513
  if (this.length === 0) {
501
514
  return false;
502
515
  }
503
516
  return listTagNames.has(this.name);
504
517
  }
505
- // Returns a boolean value indicating whether the node is a table element.
518
+ // A boolean value indicating whether the first node is a table.
506
519
  get isTable() {
507
520
  if (this.length === 0) {
508
521
  return false;
509
522
  }
510
523
  return tableTagNames.has(this.name);
511
524
  }
512
- // Returns a boolean value indicating whether the node is a bookmark element.
525
+ // A boolean value indicating whether the first node is a bookmark element.
513
526
  get isBookmark() {
514
527
  return this.name === 'lake-bookmark';
515
528
  }
516
- // Returns a boolean value indicating whether the node is a box element.
529
+ // A boolean value indicating whether the first node is a box element.
517
530
  get isBox() {
518
531
  return this.name === 'lake-box';
519
532
  }
520
- // Returns a boolean value indicating whether the node is a inline box element.
533
+ // A boolean value indicating whether the first node is an inline box element.
521
534
  get isInlineBox() {
522
535
  return this.isBox && this.attr('type') === 'inline';
523
536
  }
524
- // Returns a boolean value indicating whether the node is a block box element.
537
+ // A boolean value indicating whether the first node is a block box element.
525
538
  get isBlockBox() {
526
539
  return this.isBox && this.attr('type') === 'block';
527
540
  }
528
- // Returns a boolean value indicating whether the element is a root element of contenteditable area.
541
+ // A boolean value indicating whether the first node is a contenteditable element where users can edit the content.
529
542
  get isContainer() {
530
543
  if (this.length === 0) {
531
544
  return false;
@@ -533,15 +546,15 @@ class Nodes {
533
546
  const node = this.get(0);
534
547
  return this.isElement && node.getAttribute('contenteditable') === 'true';
535
548
  }
536
- // Returns a boolean value indicating whether the node is ouside the container.
549
+ // A boolean value indicating whether the first node does not have an ancestor element which contenteditable attribute is true.
537
550
  get isOutside() {
538
551
  return this.closest('[contenteditable="true"]').length === 0;
539
552
  }
540
- // Returns a boolean value indicating whether the node is inside the container.
553
+ // A boolean value indicating whether the first node has an ancestor element which contenteditable attribute is true.
541
554
  get isInside() {
542
555
  return !this.isOutside && !this.isContainer;
543
556
  }
544
- // Returns a boolean value indicating whether the node is a top element inside the container.
557
+ // A boolean value indicating whether the first node's parent element is an element which contenteditable attribute is true.
545
558
  get isTopInside() {
546
559
  if (this.length === 0) {
547
560
  return false;
@@ -552,7 +565,7 @@ class Nodes {
552
565
  }
553
566
  return this.isInside && parentNode.isContainer;
554
567
  }
555
- // Returns a boolean value indicating whether the node is editable.
568
+ // A boolean value indicating whether the first node is editable.
556
569
  get isContentEditable() {
557
570
  if (this.length === 0) {
558
571
  return false;
@@ -570,11 +583,11 @@ class Nodes {
570
583
  const element = this.get(0);
571
584
  return element.isContentEditable;
572
585
  }
573
- // Returns a boolean value indicating whether the node is indivisible.
586
+ // A boolean value indicating whether the first node is indivisible.
574
587
  get isIndivisible() {
575
588
  return this.isContainer || this.isTable;
576
589
  }
577
- // Returns a boolean value indicating whether the node is empty.
590
+ // A boolean value indicating whether the first node is empty.
578
591
  get isEmpty() {
579
592
  if (this.isBox) {
580
593
  return false;
@@ -594,20 +607,20 @@ class Nodes {
594
607
  }
595
608
  return true;
596
609
  }
597
- // Gets a native node at the specified index.
610
+ // Returns a native node at the specified index.
598
611
  get(index) {
599
612
  return this.nodeList[index];
600
613
  }
601
- // Gets all native nodes
614
+ // Returns all native nodes.
602
615
  getAll() {
603
616
  return this.nodeList;
604
617
  }
605
- // Reduces the nodes of a Nodes object to the one at the specified index.
618
+ // Returns a new Nodes object that includes only the node at the specified index.
606
619
  eq(index) {
607
620
  const node = this.get(index);
608
621
  return new Nodes(node);
609
622
  }
610
- // Iterates over a Nodes object, executing a function for each node.
623
+ // Executes a provided function once for each node.
611
624
  each(callback) {
612
625
  const nodes = this.getAll();
613
626
  for (let i = 0; i < nodes.length; i++) {
@@ -617,7 +630,7 @@ class Nodes {
617
630
  }
618
631
  return this;
619
632
  }
620
- // Iterates over a Nodes object, executing a function for each element.
633
+ // Executes a provided function once for each element.
621
634
  eachElement(callback) {
622
635
  const nodes = this.getAll();
623
636
  for (let i = 0; i < nodes.length; i++) {
@@ -629,12 +642,12 @@ class Nodes {
629
642
  }
630
643
  return this;
631
644
  }
632
- // Reverses the nodes of a Nodes object.
645
+ // Returns a new Nodes object with the nodes in reversed order.
633
646
  reverse() {
634
647
  const nodes = this.getAll().reverse();
635
648
  return new Nodes(nodes);
636
649
  }
637
- // Tests whether the element would be selected by the specified CSS selector.
650
+ // Tests whether the first node would be selected by the specified CSS selector.
638
651
  matches(selector) {
639
652
  if (!this.isElement) {
640
653
  return false;
@@ -642,24 +655,21 @@ class Nodes {
642
655
  const element = this.get(0);
643
656
  return element.matches(selector);
644
657
  }
645
- // Returns a boolean value indicating whether a node is a descendant of a given node, that is the node itself,
646
- // one of its direct children (childNodes), one of the children's direct children, and so on.
658
+ // Returns a boolean value indicating whether the first node is a descendant of a given node,
659
+ // that is the first node itself, one of its direct children (childNodes), one of the children's direct children, and so on.
647
660
  contains(otherNode) {
648
- if (otherNode instanceof Nodes) {
649
- otherNode = otherNode.get(0);
650
- }
651
661
  const element = this.get(0);
652
- return element.contains(otherNode);
662
+ return element.contains(otherNode.get(0));
653
663
  }
654
- // Returns a boolean value indicating whether the node and the target node are siblings.
655
- isSibling(target) {
664
+ // Returns a boolean value indicating whether the first node and a given node are siblings.
665
+ isSibling(otherNode) {
656
666
  if (this.length === 0) {
657
667
  return false;
658
668
  }
659
669
  const parent = this.get(0).parentNode;
660
- return parent && parent === target.parent().get(0);
670
+ return parent && parent === otherNode.parent().get(0);
661
671
  }
662
- // Returns the descendants of the first element which are selected by the specified CSS selector.
672
+ // Returns the descendants of the first node that match the specified CSS selector or node path.
663
673
  find(selector) {
664
674
  if (typeof selector === 'string') {
665
675
  const element = this.get(0);
@@ -675,8 +685,7 @@ class Nodes {
675
685
  }
676
686
  return node;
677
687
  }
678
- // Traverses the first node and its parents (heading toward the document root)
679
- // until it finds a element that matches the specified CSS selector.
688
+ // Traverses the first node and its parents (heading toward the document root) until it finds an element that matches the specified CSS selector.
680
689
  closest(selector) {
681
690
  if (this.isText) {
682
691
  const element = this.get(0).parentNode;
@@ -721,7 +730,7 @@ class Nodes {
721
730
  }
722
731
  return block;
723
732
  }
724
- // Traverses the first node and its parents until it finds a root element which has contenteditable="true" attribute.
733
+ // Traverses the first node and its parents until it finds a div element which contenteditable attribute is true.
725
734
  closestContainer() {
726
735
  return this.closest('div[contenteditable="true"]');
727
736
  }
@@ -751,12 +760,12 @@ class Nodes {
751
760
  const node = this.get(0);
752
761
  return new Nodes(node.nextSibling);
753
762
  }
754
- // Returns the first child of the first element.
763
+ // Returns the first child of the first node.
755
764
  first() {
756
765
  const element = this.get(0);
757
766
  return new Nodes(element.firstChild);
758
767
  }
759
- // Returns the last child of the first element.
768
+ // Returns the last child of the first node.
760
769
  last() {
761
770
  const element = this.get(0);
762
771
  return new Nodes(element.lastChild);
@@ -771,7 +780,7 @@ class Nodes {
771
780
  }
772
781
  return i;
773
782
  }
774
- // Returns a path of the first element.
783
+ // Returns the path of the first node.
775
784
  path() {
776
785
  const path = [];
777
786
  let node = this.eq(0);
@@ -791,7 +800,7 @@ class Nodes {
791
800
  }
792
801
  return path.reverse();
793
802
  }
794
- // Returns a list of child nodes of the first element.
803
+ // Returns a list which contains all of the child nodes of the first node.
795
804
  children() {
796
805
  const childList = [];
797
806
  let child = this.first();
@@ -801,7 +810,7 @@ class Nodes {
801
810
  }
802
811
  return childList;
803
812
  }
804
- // Returns a node generator that iterates over the descendants of the first element.
813
+ // Returns a generator that iterates over the descendants of the first node.
805
814
  *getWalker() {
806
815
  function* iterate(node) {
807
816
  if (node.isBox) {
@@ -819,7 +828,7 @@ class Nodes {
819
828
  yield node;
820
829
  }
821
830
  }
822
- // Attaches an event listener for the elements.
831
+ // Sets up an event listener for each element.
823
832
  on(type, listener) {
824
833
  return this.eachElement(element => {
825
834
  element.addEventListener(type, listener, false);
@@ -833,12 +842,12 @@ class Nodes {
833
842
  });
834
843
  });
835
844
  }
836
- // Removes event handlers that were attached with .on() method.
845
+ // Removes event listeners previously registered with on() method.
837
846
  off(type, listener) {
838
847
  return this.eachElement(element => {
839
848
  var _a;
840
849
  const elementId = element.lakeId;
841
- const eventItems = (_a = eventData[elementId]) !== null && _a !== void 0 ? _a : [];
850
+ const eventItems = (_a = eventData[elementId]) !== null && _a !== undefined ? _a : [];
842
851
  for (let i = 0; i < eventItems.length; i++) {
843
852
  const item = eventItems[i];
844
853
  if (!type || type === item.type && (!listener || listener === item.listener)) {
@@ -852,40 +861,41 @@ class Nodes {
852
861
  eventData[elementId] = eventItems.filter((item) => item.type !== '');
853
862
  });
854
863
  }
855
- // Executes all event listeners attached to the Nodes object for the given event type.
864
+ // Executes all event listeners attached to all nodes for the given event type.
856
865
  emit(type, event) {
857
866
  return this.eachElement(element => {
858
867
  const elementId = element.lakeId;
859
868
  const eventItems = eventData[elementId];
860
869
  for (const item of eventItems) {
861
870
  if (item.type === type) {
862
- item.listener(event !== null && event !== void 0 ? event : new Event(type));
871
+ item.listener(event !== null && event !== undefined ? event : new Event(type));
863
872
  }
864
873
  }
865
874
  });
866
875
  }
867
- // Gets all event listeners attached to the Nodes object.
876
+ // Returns all event listeners attached to the node at the specified index.
868
877
  getEventListeners(index) {
869
878
  const elementId = this.get(index).lakeId;
870
879
  return eventData[elementId];
871
880
  }
872
- // Sets focus on the specified element, if it can be focused.
881
+ // Sets focus on the specified node, if it can be focused.
873
882
  focus() {
874
883
  const element = this.get(0);
875
884
  element.focus();
876
885
  return this;
877
886
  }
878
- // Removes focus from the specified element.
887
+ // Removes focus from the specified node.
879
888
  blur() {
880
889
  const element = this.get(0);
881
890
  element.blur();
882
891
  return this;
883
892
  }
884
- // Returns a duplicate of the first node.
893
+ // Returns a copy of the first node. If deep is true, the copy also includes the node's descendants.
885
894
  clone(deep = false) {
886
895
  const node = this.get(0);
887
896
  return new Nodes(node.cloneNode(deep));
888
897
  }
898
+ // Returns a boolean value indicating whether the first node has the specified attribute or not.
889
899
  hasAttr(attributeName) {
890
900
  const element = this.get(0);
891
901
  return element.hasAttribute(attributeName);
@@ -900,21 +910,24 @@ class Nodes {
900
910
  }
901
911
  if (value === undefined) {
902
912
  const element = this.get(0);
903
- return (_a = element.getAttribute(attributeName)) !== null && _a !== void 0 ? _a : '';
913
+ return (_a = element.getAttribute(attributeName)) !== null && _a !== undefined ? _a : '';
904
914
  }
905
915
  return this.eachElement(element => {
906
916
  element.setAttribute(attributeName, value);
907
917
  });
908
918
  }
919
+ // Removes the attribute with the specified name from every element.
909
920
  removeAttr(attributeName) {
910
921
  return this.eachElement(element => {
911
922
  element.removeAttribute(attributeName);
912
923
  });
913
924
  }
925
+ // Returns a boolean value indicating whether the first node has the specified class or not.
914
926
  hasClass(className) {
915
927
  const element = this.get(0);
916
928
  return inString(element.className, className, ' ');
917
929
  }
930
+ // Adds the given class to every element.
918
931
  addClass(className) {
919
932
  if (Array.isArray(className)) {
920
933
  for (const name of className) {
@@ -929,6 +942,7 @@ class Nodes {
929
942
  element.classList.add(className);
930
943
  });
931
944
  }
945
+ // Removes the given class from every element.
932
946
  removeClass(className) {
933
947
  if (Array.isArray(className)) {
934
948
  for (const name of className) {
@@ -946,6 +960,8 @@ class Nodes {
946
960
  }
947
961
  });
948
962
  }
963
+ // Returns the value of the given CSS property of the first node,
964
+ // after applying active stylesheets and resolving any basic computation this value may contain.
949
965
  computedCSS(propertyName) {
950
966
  const element = this.get(0);
951
967
  return getCSS(element, propertyName);
@@ -968,26 +984,28 @@ class Nodes {
968
984
  }
969
985
  });
970
986
  }
971
- // Returns the width of of the first element.
987
+ // Returns the width of of the first node.
972
988
  width() {
973
989
  const element = this.get(0);
974
990
  return element.offsetWidth;
975
991
  }
976
- // Returns the interior width of the first element, which does not include padding.
992
+ // Returns the interior width of the first node, which does not include padding.
977
993
  innerWidth() {
978
994
  const paddingLeft = Number.parseInt(this.computedCSS('padding-left'), 10) || 0;
979
995
  const paddingRight = Number.parseInt(this.computedCSS('padding-right'), 10) || 0;
980
996
  return this.width() - paddingLeft - paddingRight;
981
997
  }
982
- // Returns the height of of the first element.
998
+ // Returns the height of of the first node.
983
999
  height() {
984
1000
  const element = this.get(0);
985
1001
  return element.offsetHeight;
986
1002
  }
1003
+ // Displays all nodes.
987
1004
  show(displayType = 'block') {
988
1005
  this.css('display', displayType);
989
1006
  return this;
990
1007
  }
1008
+ // Hides all nodes.
991
1009
  hide() {
992
1010
  this.css('display', 'none');
993
1011
  return this;
@@ -1006,7 +1024,7 @@ class Nodes {
1006
1024
  if (value === undefined) {
1007
1025
  const node = this.get(0);
1008
1026
  if (this.isText) {
1009
- return (_a = node.nodeValue) !== null && _a !== void 0 ? _a : '';
1027
+ return (_a = node.nodeValue) !== null && _a !== undefined ? _a : '';
1010
1028
  }
1011
1029
  const element = node;
1012
1030
  // https://developer.mozilla.org/en-US/docs/Web/API/HTMLElement/innerText
@@ -1025,16 +1043,17 @@ class Nodes {
1025
1043
  element.value = value;
1026
1044
  });
1027
1045
  }
1046
+ // Returns the HTML string describing the first node including its descendants.
1028
1047
  outerHTML() {
1029
1048
  const element = this.get(0);
1030
1049
  return element.outerHTML;
1031
1050
  }
1032
- // Removes all child nodes of each element.
1051
+ // Removes all child nodes for each element.
1033
1052
  empty() {
1034
1053
  this.html('');
1035
1054
  return this;
1036
1055
  }
1037
- // Inserts the specified content to the beginning of the first element.
1056
+ // Inserts the specified content just inside the first node, before its first child.
1038
1057
  prepend(content) {
1039
1058
  const element = this.get(0);
1040
1059
  if (typeof content === 'string') {
@@ -1060,7 +1079,7 @@ class Nodes {
1060
1079
  }
1061
1080
  return this;
1062
1081
  }
1063
- // Inserts the specified content to the end of the first element.
1082
+ // Inserts the specified content just inside the first node, after its last child.
1064
1083
  append(content) {
1065
1084
  const element = this.get(0);
1066
1085
  if (typeof content === 'string') {
@@ -1124,7 +1143,7 @@ class Nodes {
1124
1143
  }
1125
1144
  return this;
1126
1145
  }
1127
- // Replaces the first node with the provided new content.
1146
+ // Replaces the first node with the given new content.
1128
1147
  replaceWith(newContent) {
1129
1148
  const node = this.get(0);
1130
1149
  if (!node.parentNode) {
@@ -1140,9 +1159,7 @@ class Nodes {
1140
1159
  node.parentNode.replaceChild(target, node);
1141
1160
  return this;
1142
1161
  }
1143
- // Removes each node from the DOM.
1144
- // keepChildren parameter:
1145
- // A boolean value; true only removes each node and keeps all descended nodes; false removes the descendants; if omitted, it defaults to false.
1162
+ // Removes all nodes from the DOM.
1146
1163
  remove(keepChildren = false) {
1147
1164
  this.each(node => {
1148
1165
  if (!node.parentNode) {
@@ -1160,7 +1177,7 @@ class Nodes {
1160
1177
  });
1161
1178
  return this;
1162
1179
  }
1163
- // Breaks the first text node into two nodes at the specified offset, keeping both nodes in the tree as siblings.
1180
+ // Splits the first node, which must be a text node, into two nodes at the specified offset, keeping both as siblings in the tree.
1164
1181
  splitText(offset) {
1165
1182
  if (!this.isText) {
1166
1183
  return new Nodes();
@@ -1169,7 +1186,7 @@ class Nodes {
1169
1186
  const newNode = node.splitText(offset);
1170
1187
  return new Nodes(newNode);
1171
1188
  }
1172
- // Returns information of the first node.
1189
+ // Returns information about the first node, which is used for debugging.
1173
1190
  toString() {
1174
1191
  if (this.length === 0) {
1175
1192
  return '';
@@ -1181,13 +1198,13 @@ class Nodes {
1181
1198
  }
1182
1199
  return `node (${node.lakeId}): ${nodeValue}`;
1183
1200
  }
1184
- // Prints information of the first node.
1201
+ // Prints information about the first node, which is used for debugging.
1185
1202
  info() {
1186
1203
  debug(this.toString());
1187
1204
  }
1188
1205
  }
1189
1206
 
1190
- // Returns an object representing a list of the document's elements.
1207
+ // Returns a Nodes object representing a list of the document's nodes.
1191
1208
  function query(content) {
1192
1209
  if (content instanceof Nodes) {
1193
1210
  return content;
@@ -1205,10 +1222,10 @@ const characterMap = new Map([
1205
1222
  ]);
1206
1223
  // Converts all of the reserved characters in the specified string to HTML entities.
1207
1224
  function encode(value) {
1208
- return value.replace(/[&<>"\xA0]/g, match => { var _a; return (_a = characterMap.get(match)) !== null && _a !== void 0 ? _a : ''; });
1225
+ return value.replace(/[&<>"\xA0]/g, match => { var _a; return (_a = characterMap.get(match)) !== null && _a !== undefined ? _a : ''; });
1209
1226
  }
1210
1227
 
1211
- // The template function is a tag function for converting all of the reserved characters in the specified string to HTML entities.
1228
+ // A tag function for converting all of the reserved characters in the specified string to HTML entities.
1212
1229
  function template(strings, ...keys) {
1213
1230
  let content = strings[0];
1214
1231
  for (let i = 0; i < keys.length; i++) {
@@ -1225,16 +1242,16 @@ function template(strings, ...keys) {
1225
1242
  return content;
1226
1243
  }
1227
1244
 
1228
- // The Fragment class represents a minimal document object that has no parent.
1245
+ // The Fragment interface represents a minimal document object that has no parent.
1229
1246
  class Fragment {
1230
1247
  constructor(fragment) {
1231
- this.fragment = fragment !== null && fragment !== void 0 ? fragment : document.createDocumentFragment();
1248
+ this.fragment = fragment !== null && fragment !== undefined ? fragment : document.createDocumentFragment();
1232
1249
  }
1233
- // Gets a native fragment.
1250
+ // Returns a native DocumentFragment object from the fragment.
1234
1251
  get() {
1235
1252
  return this.fragment;
1236
1253
  }
1237
- // Returns the descendants of the fragment which are selected by the specified CSS selector.
1254
+ // Returns the descendants of the fragment that match the specified CSS selector.
1238
1255
  find(selector) {
1239
1256
  const nodeList = [];
1240
1257
  let child = new Nodes(this.fragment.firstChild);
@@ -1251,49 +1268,49 @@ class Fragment {
1251
1268
  }
1252
1269
  return new Nodes(nodeList);
1253
1270
  }
1254
- // Inserts the specified node as the last child.
1255
- append(node) {
1256
- query(node).each(nativeNode => {
1271
+ // Inserts the specified content just inside the fragment, after its last child.
1272
+ append(content) {
1273
+ query(content).each(nativeNode => {
1257
1274
  this.fragment.appendChild(nativeNode);
1258
1275
  });
1259
1276
  }
1260
1277
  }
1261
1278
 
1262
- // The Range class represents a fragment of a document that can contain nodes and parts of text nodes.
1279
+ // The Range interface represents a fragment of a document that can contain nodes and parts of text nodes.
1263
1280
  class Range {
1264
1281
  constructor(range) {
1265
- this.range = range !== null && range !== void 0 ? range : document.createRange();
1282
+ this.range = range !== null && range !== undefined ? range : document.createRange();
1266
1283
  }
1267
- // Returns a node within which the range starts.
1284
+ // A node within which the range starts.
1268
1285
  get startNode() {
1269
1286
  return new Nodes(this.range.startContainer);
1270
1287
  }
1271
- // Returns a number representing where in the startNode the range starts.
1288
+ // A number representing where in the startNode the range starts.
1272
1289
  get startOffset() {
1273
1290
  return this.range.startOffset;
1274
1291
  }
1275
- // Returns a node within which the range ends.
1292
+ // A node within which the range ends.
1276
1293
  get endNode() {
1277
1294
  return new Nodes(this.range.endContainer);
1278
1295
  }
1279
- // Returns a number representing where in the endNode the range ends.
1296
+ // A number representing where in the endNode the range ends.
1280
1297
  get endOffset() {
1281
1298
  return this.range.endOffset;
1282
1299
  }
1283
- // Returns the closest node that contains both the startNode and endNode.
1300
+ // The deepest — or furthest down the document tree — node that contains both boundary points of the range.
1284
1301
  get commonAncestor() {
1285
1302
  return new Nodes(this.range.commonAncestorContainer);
1286
1303
  }
1287
- // Returns a boolean value indicating whether the range's start and end points are at the same position.
1304
+ // A boolean value indicating whether the range's start and end points are at the same position.
1288
1305
  get isCollapsed() {
1289
1306
  return this.range.collapsed;
1290
1307
  }
1291
- // Returns a boolean value indicating whether the range's start point is in the box.
1308
+ // A boolean value indicating whether the range's start point is in a box.
1292
1309
  get isBox() {
1293
1310
  const boxNode = this.commonAncestor.closest('lake-box');
1294
1311
  return boxNode.length > 0;
1295
1312
  }
1296
- // Returns a boolean value indicating whether the range's common ancestor node is in the start strip of the box.
1313
+ // A boolean value indicating whether the commonAncestor is in the start position of a box.
1297
1314
  // case 1: <lake-box><span class="lake-box-strip">|</span><div class="lake-box-container"></div> ...
1298
1315
  // case 2: <lake-box><span class="lake-box-strip"></span>|<div class="lake-box-container"></div> ...
1299
1316
  // case 3: <lake-box>|<span class="lake-box-strip"></span><div class="lake-box-container"></div> ...
@@ -1305,7 +1322,7 @@ class Range {
1305
1322
  const boxContainer = boxNode.find('.lake-box-container');
1306
1323
  return this.compareBeforeNode(boxContainer) >= 0;
1307
1324
  }
1308
- // Returns a boolean value indicating whether the range's common ancestor node is in the center of the box.
1325
+ // A boolean value indicating whether the commonAncestor is in the center position of a box.
1309
1326
  // case 1: ... <div class="lake-box-container"><div>|</div></div> ...
1310
1327
  // case 2: ... <div class="lake-box-container"><div></div>|</div> ...
1311
1328
  get isBoxCenter() {
@@ -1318,7 +1335,7 @@ class Range {
1318
1335
  // case: ... <div class="lake-box-container">|<div></div></div> ...
1319
1336
  return this.isCollapsed && this.startNode.get(0) === boxContainer.get(0) && this.startOffset === 0;
1320
1337
  }
1321
- // Returns a boolean value indicating whether the range's common ancestor node is in the end strip of the box.
1338
+ // A boolean value indicating whether commonAncestor is in the end position of a box.
1322
1339
  // case 1: ... <div class="lake-box-container"></div><span class="lake-box-strip">|</span></lake-box>
1323
1340
  // case 2: ... <div class="lake-box-container"></div>|<span class="lake-box-strip"></span></lake-box>
1324
1341
  // case 3: ... <div class="lake-box-container"></div><span class="lake-box-strip"></span>|</lake-box>
@@ -1330,7 +1347,7 @@ class Range {
1330
1347
  const boxContainer = boxNode.find('.lake-box-container');
1331
1348
  return this.compareAfterNode(boxContainer) <= 0;
1332
1349
  }
1333
- // Returns a boolean value indicating whether the range's common ancestor node is inside the container of the box.
1350
+ // A boolean value indicating whether commonAncestor is inside the container of a box.
1334
1351
  // case 1: ... <div class="lake-box-container"><div>|</div></div> ...
1335
1352
  // case 2: ... <div class="lake-box-container"><div></div>|</div> ...
1336
1353
  get isInsideBox() {
@@ -1348,7 +1365,7 @@ class Range {
1348
1365
  }
1349
1366
  return this.compareBeforeNode(boxContainer) < 0 && this.compareAfterNode(boxContainer) > 0;
1350
1367
  }
1351
- // Returns a boolean value indicating whether the range is inoperative.
1368
+ // A boolean value indicating whether the range is inoperative.
1352
1369
  get isInoperative() {
1353
1370
  if (this.commonAncestor.isOutside) {
1354
1371
  return true;
@@ -1362,7 +1379,7 @@ class Range {
1362
1379
  }
1363
1380
  return false;
1364
1381
  }
1365
- // Gets a native range.
1382
+ // Returns a native Range object from the range.
1366
1383
  get() {
1367
1384
  return this.range;
1368
1385
  }
@@ -1419,11 +1436,13 @@ class Range {
1419
1436
  height: height > 0 ? height : 1,
1420
1437
  });
1421
1438
  }
1422
- // Returns 1 if the point is before the range, 0 if the point is in the range, and 1 if the point is after the range.
1439
+ // Returns -1, 0, or 1 depending on whether the specified node is before, the same as, or after the range.
1440
+ // −1 if the point is before the range. 0 if the point is in the range. 1 if the point is after the range.
1423
1441
  comparePoint(node, offset) {
1424
1442
  return this.range.comparePoint(node.get(0), offset);
1425
1443
  }
1426
1444
  // Returns -1, 0, or 1 depending on whether the beginning of the specified node is before, the same as, or after the range.
1445
+ // −1 if the beginning of the node is before the range. 0 if the beginning of the node is in the range. 1 if the beginning of the node is after the range.
1427
1446
  compareBeforeNode(node) {
1428
1447
  const targetRange = new Range();
1429
1448
  if (node.isText) {
@@ -1436,11 +1455,12 @@ class Range {
1436
1455
  return this.comparePoint(targetRange.startNode, targetRange.startOffset);
1437
1456
  }
1438
1457
  // Returns -1, 0, or 1 depending on whether the end of the specified node is before, the same as, or after the range.
1458
+ // −1 if the end of the node is before the range. 0 if the end of the node is in the range. 1 if the end of the node is after the range.
1439
1459
  compareAfterNode(node) {
1440
1460
  var _a;
1441
1461
  const targetRange = new Range();
1442
1462
  if (node.isText) {
1443
- const nodeValue = (_a = node.get(0).nodeValue) !== null && _a !== void 0 ? _a : '';
1463
+ const nodeValue = (_a = node.get(0).nodeValue) !== null && _a !== undefined ? _a : '';
1444
1464
  targetRange.setStart(node, nodeValue.length);
1445
1465
  }
1446
1466
  else {
@@ -1449,7 +1469,7 @@ class Range {
1449
1469
  targetRange.collapseToStart();
1450
1470
  return this.comparePoint(targetRange.startNode, targetRange.startOffset);
1451
1471
  }
1452
- // Indicates whether a specified node is part of the range or intersects the range.
1472
+ // Returns a boolean value indicating whether the specified node is part of the range or intersects the range.
1453
1473
  intersectsNode(node) {
1454
1474
  return this.range.intersectsNode(node.get(0));
1455
1475
  }
@@ -1457,11 +1477,11 @@ class Range {
1457
1477
  setStart(node, offset) {
1458
1478
  this.range.setStart(node.get(0), offset);
1459
1479
  }
1460
- // Sets the start position of the range before a node.
1480
+ // Sets the start position of the range to the beginning of the specified node.
1461
1481
  setStartBefore(node) {
1462
1482
  this.range.setStartBefore(node.get(0));
1463
1483
  }
1464
- // Sets the start position of the range after a node.
1484
+ // Sets the start position of the range to the end of the specified node.
1465
1485
  setStartAfter(node) {
1466
1486
  this.range.setStartAfter(node.get(0));
1467
1487
  }
@@ -1469,19 +1489,19 @@ class Range {
1469
1489
  setEnd(node, offset) {
1470
1490
  this.range.setEnd(node.get(0), offset);
1471
1491
  }
1472
- // Sets the end position of the range before a node.
1492
+ // Sets the end position of the range to the beginning of the specified node.
1473
1493
  setEndBefore(node) {
1474
1494
  this.range.setEndBefore(node.get(0));
1475
1495
  }
1476
- // Sets the end position of the range after a node.
1496
+ // Sets the end position of the range to the end of the specified node.
1477
1497
  setEndAfter(node) {
1478
1498
  this.range.setEndAfter(node.get(0));
1479
1499
  }
1480
- // Collapses the range to the start of it.
1500
+ // Collapses the range to its start.
1481
1501
  collapseToStart() {
1482
1502
  this.range.collapse(true);
1483
1503
  }
1484
- // Collapses the range to the end of it.
1504
+ // Collapses the range to its end.
1485
1505
  collapseToEnd() {
1486
1506
  this.range.collapse(false);
1487
1507
  }
@@ -1493,7 +1513,7 @@ class Range {
1493
1513
  selectNodeContents(node) {
1494
1514
  this.range.selectNodeContents(node.get(0));
1495
1515
  }
1496
- // Sets the range to the center position of the box.
1516
+ // Collapses the range to the center position of the specified box.
1497
1517
  selectBox(boxNode) {
1498
1518
  const boxContainer = boxNode.find('.lake-box-container');
1499
1519
  if (boxContainer.length === 0) {
@@ -1502,7 +1522,7 @@ class Range {
1502
1522
  this.setStart(boxContainer, 0);
1503
1523
  this.collapseToStart();
1504
1524
  }
1505
- // Sets the range to the start position of the box.
1525
+ // Collapses the range to the start position of the specified box.
1506
1526
  selectBoxStart(boxNode) {
1507
1527
  const boxStrip = boxNode.find('.lake-box-strip');
1508
1528
  if (boxStrip.length === 0) {
@@ -1511,7 +1531,7 @@ class Range {
1511
1531
  this.selectNodeContents(boxStrip.eq(0));
1512
1532
  this.collapseToStart();
1513
1533
  }
1514
- // Sets the range to the start position of the box.
1534
+ // Collapses the range to the end position of the specified box.
1515
1535
  selectBoxEnd(boxNode) {
1516
1536
  const boxStrip = boxNode.find('.lake-box-strip');
1517
1537
  if (boxStrip.length === 0) {
@@ -1520,7 +1540,7 @@ class Range {
1520
1540
  this.selectNodeContents(boxStrip.eq(1));
1521
1541
  this.collapseToStart();
1522
1542
  }
1523
- // Collapses the range and sets the range to the beginning of the contents of the specified node.
1543
+ // Collapses the range to the deepest point at the beginning of the contents of the specified node.
1524
1544
  shrinkBefore(node) {
1525
1545
  if (node.isBox) {
1526
1546
  this.selectBoxStart(node);
@@ -1544,7 +1564,7 @@ class Range {
1544
1564
  }
1545
1565
  this.collapseToStart();
1546
1566
  }
1547
- // Collapses the range and sets the range to the end of the contents of the specified node.
1567
+ // Collapses the range to the deepest point at the end of the contents of the specified node.
1548
1568
  shrinkAfter(node) {
1549
1569
  if (node.isBox) {
1550
1570
  this.selectBoxEnd(node);
@@ -1570,7 +1590,7 @@ class Range {
1570
1590
  this.collapseToEnd();
1571
1591
  this.adjustBr();
1572
1592
  }
1573
- // Reduces the boundary of the range.
1593
+ // Sets the start and end positions of the range to the deepest start position and end position of the contents of the specified node.
1574
1594
  // <div>[<p><strong>foo</strong></p>]</div>
1575
1595
  // to
1576
1596
  // <div><p><strong>[foo]</strong></p></div>
@@ -1593,7 +1613,7 @@ class Range {
1593
1613
  this.setEnd(child, child.children().length);
1594
1614
  }
1595
1615
  }
1596
- // Relocates the start and end points of the range for the box.
1616
+ // Relocates the start and end positions of the range for boxes.
1597
1617
  adjustBox() {
1598
1618
  const startBoxNode = this.startNode.closest('lake-box');
1599
1619
  if (startBoxNode.length > 0) {
@@ -1618,7 +1638,7 @@ class Range {
1618
1638
  }
1619
1639
  }
1620
1640
  }
1621
- // Relocates the beginning or end position of the range for table.
1641
+ // Relocates the start and end positions of the range for tables.
1622
1642
  adjustTable() {
1623
1643
  const startTable = this.startNode.closest('table');
1624
1644
  const endTable = this.endNode.closest('table');
@@ -1632,7 +1652,7 @@ class Range {
1632
1652
  this.shrink();
1633
1653
  }
1634
1654
  }
1635
- // Relocates the start point of the range for the block.
1655
+ // Relocates the start and end positions of the range for blocks.
1636
1656
  // case 1:
1637
1657
  // <p>foo</p>|<p>bar</p>
1638
1658
  // to
@@ -1666,16 +1686,16 @@ class Range {
1666
1686
  this.shrinkBefore(nextBlock);
1667
1687
  }
1668
1688
  }
1669
- // Relocates the start and end points of the range.
1689
+ // Relocates the start and end positions of the range for boxes, tables, and blocks.
1670
1690
  adjust() {
1671
1691
  this.adjustBox();
1672
1692
  this.adjustTable();
1673
1693
  this.adjustBlock();
1674
1694
  }
1675
- // Relocates the start and end points of the range for <br /> element.
1695
+ // Relocates the start and end positions of the range for <br /> elements.
1676
1696
  // In composition mode (e.g., when a user starts entering a Chinese character using a Pinyin IME),
1677
- // uncompleted text is inserted if the caret is positioned behind a <br> tag.
1678
- // To fix this bug, the caret needs to be moved to the front of the <br> tag.
1697
+ // uncompleted text is inserted if the cursor is positioned behind a <br> tag.
1698
+ // To fix this bug, the cursor needs to be moved to the front of the <br> tag.
1679
1699
  adjustBr() {
1680
1700
  if (!this.isCollapsed) {
1681
1701
  return;
@@ -1687,7 +1707,7 @@ class Range {
1687
1707
  this.collapseToStart();
1688
1708
  }
1689
1709
  }
1690
- // Returns the previous node of the beginning point of the range.
1710
+ // Returns the node immediately preceding the start position of the range.
1691
1711
  getPrevNode() {
1692
1712
  let prevNode;
1693
1713
  if (this.startNode.isText) {
@@ -1701,9 +1721,9 @@ class Range {
1701
1721
  else {
1702
1722
  prevNode = this.startNode.children()[this.startOffset - 1];
1703
1723
  }
1704
- return prevNode !== null && prevNode !== void 0 ? prevNode : new Nodes();
1724
+ return prevNode !== null && prevNode !== undefined ? prevNode : new Nodes();
1705
1725
  }
1706
- // Returns the next node of the beginning point of the range.
1726
+ // Returns the node immediately following the end position of the range.
1707
1727
  getNextNode() {
1708
1728
  let nextNode;
1709
1729
  if (this.endNode.isText) {
@@ -1717,9 +1737,9 @@ class Range {
1717
1737
  else {
1718
1738
  nextNode = this.endNode.children()[this.endOffset];
1719
1739
  }
1720
- return nextNode !== null && nextNode !== void 0 ? nextNode : new Nodes();
1740
+ return nextNode !== null && nextNode !== undefined ? nextNode : new Nodes();
1721
1741
  }
1722
- // Returns target boxes relating to the range.
1742
+ // Returns the boxes contained within or intersected by the range.
1723
1743
  getBoxes() {
1724
1744
  if (this.isCollapsed) {
1725
1745
  const startBox = this.startNode.closest('lake-box');
@@ -1735,7 +1755,7 @@ class Range {
1735
1755
  }
1736
1756
  return nodeList;
1737
1757
  }
1738
- // Returns target blocks relating to the range.
1758
+ // Returns the blocks contained within or intersected by the range.
1739
1759
  getBlocks() {
1740
1760
  if (this.isCollapsed) {
1741
1761
  const startBlock = this.startNode.closestOperableBlock();
@@ -1774,7 +1794,7 @@ class Range {
1774
1794
  }
1775
1795
  return blocks;
1776
1796
  }
1777
- // Returns target marks and text nodes relating to the range.
1797
+ // Returns the marks and text nodes contained within or intersected by the range.
1778
1798
  getMarks(hasText = false) {
1779
1799
  const marks = [];
1780
1800
  if (this.commonAncestor.isText && hasText) {
@@ -1806,7 +1826,7 @@ class Range {
1806
1826
  }
1807
1827
  return marks;
1808
1828
  }
1809
- // Returns the text of the start part of the closest block divided into two parts by the start point of the range.
1829
+ // Returns the text from the start position of the closest block to the start position of the range.
1810
1830
  // "<p>one<anchor />two<focus />three</p>" returns "one".
1811
1831
  getStartText() {
1812
1832
  const node = this.startNode;
@@ -1829,7 +1849,7 @@ class Range {
1829
1849
  }
1830
1850
  return text;
1831
1851
  }
1832
- // Returns the text of the end part of the closest block divided into two parts by the end point of the range.
1852
+ // Returns the text from the end position of the range to the end position of the closest block.
1833
1853
  // "<p>one<anchor />two<focus />three</p>" returns "three".
1834
1854
  getEndText() {
1835
1855
  const node = this.endNode;
@@ -1852,9 +1872,9 @@ class Range {
1852
1872
  }
1853
1873
  return text;
1854
1874
  }
1855
- // Returns a new text range from the specified character to the beginning of the current range.
1875
+ // Returns a new range from the specified character to the start position of the range.
1856
1876
  // The specified character must be preceded by a whitespace or be at the beginning of a paragraph,
1857
- // without being adjacent to other characters. If these conditions are not met, it returns null.
1877
+ // without being adjacent to other characters. It will return null if not.
1858
1878
  getCharacterRange(character) {
1859
1879
  const newRange = this.clone();
1860
1880
  newRange.shrink();
@@ -1891,15 +1911,15 @@ class Range {
1891
1911
  }
1892
1912
  return newRange;
1893
1913
  }
1894
- // Returns a range object with boundary points identical to the cloned range.
1914
+ // Returns a copy of the range.
1895
1915
  clone() {
1896
1916
  return new Range(this.range.cloneRange());
1897
1917
  }
1898
- // Returns a document fragment copying the nodes included in the range.
1918
+ // Returns a DocumentFragment object copying the nodes included in the range.
1899
1919
  cloneContents() {
1900
1920
  return this.range.cloneContents();
1901
1921
  }
1902
- // Prints information of the range.
1922
+ // Prints information about the range, which is used for debugging.
1903
1923
  info() {
1904
1924
  debug('--- range information ---');
1905
1925
  debug('start node:', this.startNode.toString(), ', offset:', this.startOffset);
@@ -2589,7 +2609,7 @@ const toolbarItems = [
2589
2609
  const currentValues = [];
2590
2610
  for (const item of activeItems) {
2591
2611
  if (item.node.isMark) {
2592
- const name = (_a = tagPluginNameMap.get(item.name)) !== null && _a !== void 0 ? _a : item.name;
2612
+ const name = (_a = tagPluginNameMap.get(item.name)) !== null && _a !== undefined ? _a : item.name;
2593
2613
  currentValues.push(name);
2594
2614
  }
2595
2615
  }
@@ -2834,7 +2854,7 @@ function uploadFile(config) {
2834
2854
  return box;
2835
2855
  }
2836
2856
 
2837
- // The Button class represents a UI component activated by a user. Once activated, it then performs an action.
2857
+ // The Button interface represents a UI component clicked by a user. Once clicked, it then performs an action.
2838
2858
  class Button {
2839
2859
  constructor(config) {
2840
2860
  this.config = config;
@@ -2849,6 +2869,7 @@ class Button {
2849
2869
  this.node.attr('tabindex', config.tabIndex.toString());
2850
2870
  }
2851
2871
  }
2872
+ // Renders the button.
2852
2873
  render() {
2853
2874
  const config = this.config;
2854
2875
  const buttonNode = this.node;
@@ -2908,7 +2929,7 @@ function modifierText(value, userAgent) {
2908
2929
  if (typeof window === 'undefined') {
2909
2930
  return value;
2910
2931
  }
2911
- userAgent = userAgent !== null && userAgent !== void 0 ? userAgent : navigator.userAgent;
2932
+ userAgent = userAgent !== null && userAgent !== undefined ? userAgent : navigator.userAgent;
2912
2933
  const isMac = userAgent.indexOf('Mac OS X') >= 0;
2913
2934
  const modText = isMac ? '⌘' : 'Ctrl';
2914
2935
  return value.replace(/(^|\+|\s)mod(\+|\s|$)/g, `$1${modText}$2`);
@@ -2990,6 +3011,14 @@ var enUS = {
2990
3011
  checklistDesc: 'Create a checklist',
2991
3012
  table: 'Table',
2992
3013
  tableDesc: 'Insert a table',
3014
+ infoAlert: 'Info alert',
3015
+ infoAlertDesc: 'Create an info alert',
3016
+ tipAlert: 'Tip alert',
3017
+ tipAlertDesc: 'Create a tip alert',
3018
+ warningAlert: 'Warning alert',
3019
+ warningAlertDesc: 'Create a warning alert',
3020
+ dangerAlert: 'Danger alert',
3021
+ dangerAlertDesc: 'Create a danger alert',
2993
3022
  hr: 'Horizontal line',
2994
3023
  hrDesc: 'Insert a horizontal line',
2995
3024
  codeBlock: 'Code block',
@@ -3151,6 +3180,14 @@ var zhCN = {
3151
3180
  checklistDesc: '创建任务列表',
3152
3181
  table: '表格',
3153
3182
  tableDesc: '插入表格',
3183
+ infoAlert: '信息块',
3184
+ infoAlertDesc: '创建信息块',
3185
+ tipAlert: '提示块',
3186
+ tipAlertDesc: '创建提示块',
3187
+ warningAlert: '警告块',
3188
+ warningAlertDesc: '创建警告块',
3189
+ dangerAlert: '危险警告块',
3190
+ dangerAlertDesc: '创建危险警告块',
3154
3191
  hr: '分割线',
3155
3192
  hrDesc: '插入分割线',
3156
3193
  codeBlock: '代码块',
@@ -3312,6 +3349,14 @@ var ja = {
3312
3349
  checklistDesc: 'チェックリストを作成',
3313
3350
  table: 'テーブル',
3314
3351
  tableDesc: 'テーブルを挿入',
3352
+ infoAlert: '情報ブロック',
3353
+ infoAlertDesc: '情報ブロックを作成',
3354
+ tipAlert: 'ヒントブロック',
3355
+ tipAlertDesc: 'ヒントブロックを作成',
3356
+ warningAlert: '警告ブロック',
3357
+ warningAlertDesc: '警告ブロックを作成',
3358
+ dangerAlert: '危険ブロック',
3359
+ dangerAlertDesc: '危険ブロックを作成',
3315
3360
  hr: '区切り線',
3316
3361
  hrDesc: '水平線を挿入',
3317
3362
  codeBlock: 'コードブロック',
@@ -3473,6 +3518,14 @@ var ko = {
3473
3518
  checklistDesc: '체크리스트를 작성',
3474
3519
  table: '표',
3475
3520
  tableDesc: '표를 삽입',
3521
+ infoAlert: '정보 블록',
3522
+ infoAlertDesc: '정보 블록을 작성',
3523
+ tipAlert: '팁 블록',
3524
+ tipAlertDesc: '팁 블록을 작성',
3525
+ warningAlert: '경고 블록',
3526
+ warningAlertDesc: '경고 블록을 작성',
3527
+ dangerAlert: '위험 블록',
3528
+ dangerAlertDesc: '위험 블록을 작성',
3476
3529
  hr: '구분선',
3477
3530
  hrDesc: '구분선을 삽입',
3478
3531
  codeBlock: '코드 블록',
@@ -3587,7 +3640,7 @@ const loadAllLocales = () => locales.forEach(loadLocale);
3587
3640
  const i18nObject = (locale) => i18nObject$1(locale, loadedLocales[locale], loadedFormatters[locale]);
3588
3641
  loadAllLocales();
3589
3642
 
3590
- // The Dropdown class represents a UI component that provides a menu of options.
3643
+ // The Dropdown interface represents a UI component that provides a menu of options.
3591
3644
  class Dropdown {
3592
3645
  constructor(config) {
3593
3646
  this.clickListener = (event) => {
@@ -3812,10 +3865,11 @@ class Dropdown {
3812
3865
  document.removeEventListener('click', this.clickListener);
3813
3866
  window.removeEventListener('resize', this.resizeListener);
3814
3867
  }
3868
+ // Renders the dropdown.
3815
3869
  render() {
3816
3870
  var _a, _b;
3817
3871
  const config = this.config;
3818
- const defaultValue = (_a = config.defaultValue) !== null && _a !== void 0 ? _a : '';
3872
+ const defaultValue = (_a = config.defaultValue) !== null && _a !== undefined ? _a : '';
3819
3873
  const titleNode = this.node.find('.lake-dropdown-title');
3820
3874
  if (!config.downIcon) {
3821
3875
  titleNode.addClass('lake-dropdown-title-no-down');
@@ -3840,7 +3894,7 @@ class Dropdown {
3840
3894
  Dropdown.setValue(this.node, [defaultValue]);
3841
3895
  if (textNode.length > 0) {
3842
3896
  const menuMap = Dropdown.getMenuMap(config.menuItems, this.locale);
3843
- textNode.text((_b = menuMap.get(defaultValue)) !== null && _b !== void 0 ? _b : defaultValue);
3897
+ textNode.text((_b = menuMap.get(defaultValue)) !== null && _b !== undefined ? _b : defaultValue);
3844
3898
  }
3845
3899
  if (config.menuType === 'color') {
3846
3900
  this.updateColorAccent(titleNode, defaultValue);
@@ -3894,6 +3948,7 @@ class Dropdown {
3894
3948
  this.showMenu();
3895
3949
  });
3896
3950
  }
3951
+ // Destroys the dropdown.
3897
3952
  unmount() {
3898
3953
  this.hideMenu();
3899
3954
  this.menuNode.remove();
@@ -3926,7 +3981,7 @@ const toolbarItemMap = new Map();
3926
3981
  for (const item of toolbarItems) {
3927
3982
  toolbarItemMap.set(item.name, item);
3928
3983
  }
3929
- // The Toolbar class represents a button group used to execute commands.
3984
+ // The Toolbar interface provides properties and methods for rendering and manipulating the toolbar.
3930
3985
  class Toolbar {
3931
3986
  constructor(config) {
3932
3987
  this.placement = 'top';
@@ -4032,7 +4087,7 @@ class Toolbar {
4032
4087
  }
4033
4088
  });
4034
4089
  }
4035
- // Updates state of each item such as disabled, selected.
4090
+ // Update the state of each item in the toolbar, such as whether it is selected, disabled.
4036
4091
  updateState(state = {
4037
4092
  activeItems: [],
4038
4093
  }) {
@@ -4093,7 +4148,7 @@ class Toolbar {
4093
4148
  if (textNode.length > 0) {
4094
4149
  const key = selectedValues[0] || item.defaultValue || '';
4095
4150
  const menuMap = this.allMenuMap.get(item.name);
4096
- const text = (_a = (menuMap && menuMap.get(key))) !== null && _a !== void 0 ? _a : key;
4151
+ const text = (_a = (menuMap && menuMap.get(key))) !== null && _a !== undefined ? _a : key;
4097
4152
  textNode.text(text);
4098
4153
  }
4099
4154
  }
@@ -4238,10 +4293,12 @@ class FloatingToolbar extends Toolbar {
4238
4293
  }
4239
4294
  }
4240
4295
 
4241
- // The Box class represents an embedded content, which is used to enhance editing capability.
4296
+ // The Box interface represents an embedded content, which is used to enhance editing capability.
4242
4297
  class Box {
4243
4298
  constructor(node) {
4299
+ // Managing events.
4244
4300
  this.event = new EventEmitter();
4301
+ // A toolbar for the box.
4245
4302
  this.toolbar = null;
4246
4303
  if (typeof node === 'string') {
4247
4304
  const component = boxes.get(node);
@@ -4320,19 +4377,19 @@ class Box {
4320
4377
  set value(value) {
4321
4378
  this.node.attr('value', toBase64(JSON.stringify(value)));
4322
4379
  }
4323
- updateValue(valueKey, valueValue) {
4380
+ updateValue(keyName, keyValue) {
4324
4381
  const value = this.value;
4325
- if (typeof valueKey === 'string') {
4326
- value[valueKey] = valueValue;
4382
+ if (typeof keyName === 'string') {
4383
+ value[keyName] = keyValue;
4327
4384
  }
4328
4385
  else {
4329
- for (const key of Object.keys(valueKey)) {
4330
- value[key] = valueKey[key];
4386
+ for (const key of Object.keys(keyName)) {
4387
+ value[key] = keyName[key];
4331
4388
  }
4332
4389
  }
4333
4390
  this.value = value;
4334
4391
  }
4335
- // Returns an instance of the editor that includes the box.
4392
+ // Returns an instance of the editor containing the box.
4336
4393
  getEditor() {
4337
4394
  const container = this.node.closest('div[contenteditable]');
4338
4395
  const editor = container.length > 0 ? editors.get(container.id) : undefined;
@@ -4341,10 +4398,21 @@ class Box {
4341
4398
  }
4342
4399
  return editor;
4343
4400
  }
4344
- // Returns the container node of the box.
4401
+ // Returns the container of the box.
4345
4402
  getContainer() {
4346
4403
  return this.node.find('.lake-box-container');
4347
4404
  }
4405
+ // Returns the HTML string contained within the box.
4406
+ getHTML() {
4407
+ const component = boxes.get(this.name);
4408
+ if (component === undefined) {
4409
+ return '';
4410
+ }
4411
+ if (component.html === undefined) {
4412
+ return this.node.outerHTML();
4413
+ }
4414
+ return component.html(this);
4415
+ }
4348
4416
  // Sets a floating toolbar for the box.
4349
4417
  setToolbar(items) {
4350
4418
  const editor = this.getEditor();
@@ -4387,7 +4455,7 @@ class Box {
4387
4455
  }
4388
4456
  debug(`Box "${this.name}" (id: ${this.node.id}) rendered`);
4389
4457
  }
4390
- // Destroys a rendered box.
4458
+ // Destroys the box.
4391
4459
  unmount() {
4392
4460
  this.event.emit('blur');
4393
4461
  this.event.emit('beforeunmount');
@@ -4395,17 +4463,6 @@ class Box {
4395
4463
  this.node.empty();
4396
4464
  debug(`Box "${this.name}" (id: ${this.node.id}) unmounted`);
4397
4465
  }
4398
- // Returns a HTML string of the box.
4399
- getHTML() {
4400
- const component = boxes.get(this.name);
4401
- if (component === undefined) {
4402
- return '';
4403
- }
4404
- if (component.html === undefined) {
4405
- return this.node.outerHTML();
4406
- }
4407
- return component.html(this);
4408
- }
4409
4466
  }
4410
4467
 
4411
4468
  const blockAttributeRules = {
@@ -4528,7 +4585,7 @@ function parseStyle(styleValue) {
4528
4585
  return properties;
4529
4586
  }
4530
4587
 
4531
- // The HTMLParser class provides the ability to parse HTML source code by specified rules.
4588
+ // The HTMLParser interface provides the ability to parse an HTML string by specified rules.
4532
4589
  class HTMLParser {
4533
4590
  constructor(content, rules = getElementRules()) {
4534
4591
  this.rules = rules;
@@ -4539,7 +4596,7 @@ class HTMLParser {
4539
4596
  this.source = content;
4540
4597
  }
4541
4598
  }
4542
- // Parses HTML string and returns the resulting body element.
4599
+ // Parses the given HTML string and returns the body element from the result.
4543
4600
  parseHTML(html) {
4544
4601
  const parser = new DOMParser();
4545
4602
  const doc = parser.parseFromString(html, 'text/html');
@@ -4646,7 +4703,7 @@ class HTMLParser {
4646
4703
  }
4647
4704
  return nodeValue;
4648
4705
  }
4649
- // Returns the result as HTML format.
4706
+ // Returns an HTML string.
4650
4707
  getHTML() {
4651
4708
  const rules = this.rules;
4652
4709
  function* iterate(node) {
@@ -4684,7 +4741,7 @@ class HTMLParser {
4684
4741
  }
4685
4742
  return html.trim();
4686
4743
  }
4687
- // Returns a document fragment.
4744
+ // Returns a DocumentFragment object.
4688
4745
  getFragment() {
4689
4746
  const html = this.getHTML();
4690
4747
  const body = this.parseHTML(html);
@@ -4699,11 +4756,12 @@ class HTMLParser {
4699
4756
  }
4700
4757
  }
4701
4758
 
4702
- // The TextParser class provides the ability to parse a text into an HTML string or DocumentFragment object.
4759
+ // The TextParser interface provides the ability to parse a text.
4703
4760
  class TextParser {
4704
4761
  constructor(content) {
4705
4762
  this.content = content;
4706
4763
  }
4764
+ // Returns an HTML string.
4707
4765
  getHTML() {
4708
4766
  let html = this.content;
4709
4767
  html = html.replace(/ {2}/g, ' \xA0');
@@ -4715,6 +4773,7 @@ class TextParser {
4715
4773
  html = html.replace(/[\r\n]/g, '</p><p>');
4716
4774
  return html;
4717
4775
  }
4776
+ // Returns a DocumentFragment object.
4718
4777
  getFragment() {
4719
4778
  const htmlParser = new HTMLParser(this.getHTML());
4720
4779
  return htmlParser.getFragment();
@@ -4728,8 +4787,7 @@ function insertNode(range, node) {
4728
4787
  nativeRange.setEndAfter(nativeNode);
4729
4788
  nativeRange.collapse(false);
4730
4789
  }
4731
- // Either the method inserts a bookmark into the current position of the collapsed range
4732
- // or the method inserts a pair of bookmarks into the beginning and the end of the range.
4790
+ // Inserts a bookmark at the cursor position or a pair of bookmarks at the beginning and end of the range.
4733
4791
  // case 1: foo<lake-bookmark type="focus" />bar
4734
4792
  // case 2: <lake-bookmark type="anchor" />foo<lake-bookmark type="focus" />
4735
4793
  // case 3: foo<lake-box type="inline" name="image" focus="start"></lake-box>bar
@@ -4855,7 +4913,7 @@ function removeAndNormalizeNode(node, range) {
4855
4913
  node.remove();
4856
4914
  }
4857
4915
  }
4858
- // Changes the specified range to the range represented by the bookmark.
4916
+ // Changes the specified range to a range represented by the bookmark.
4859
4917
  function toBookmark(range, bookmark) {
4860
4918
  const anchor = bookmark.anchor;
4861
4919
  const focus = bookmark.focus;
@@ -5165,7 +5223,7 @@ function getDeepElement(element) {
5165
5223
 
5166
5224
  // Appends a list of nodes to the specified element.
5167
5225
  function wrapNodeList(nodeList, wrapper) {
5168
- wrapper = wrapper !== null && wrapper !== void 0 ? wrapper : query('<p />');
5226
+ wrapper = wrapper !== null && wrapper !== undefined ? wrapper : query('<p />');
5169
5227
  if (nodeList.length === 0) {
5170
5228
  return wrapper;
5171
5229
  }
@@ -5833,7 +5891,7 @@ function removeBox(range) {
5833
5891
  return box;
5834
5892
  }
5835
5893
 
5836
- var version = "0.3.0";
5894
+ var version = "0.3.2";
5837
5895
 
5838
5896
  // Converts the custom HTML tags to the special tags that can not be parsed by browser.
5839
5897
  function denormalizeValue(value) {
@@ -6415,7 +6473,7 @@ function insertSiblings(previousSibling, morphedNode, nextSibling) {
6415
6473
  const node = stack.pop();
6416
6474
  added.push(node); // push added preceding siblings on in order and insert
6417
6475
  if (node) {
6418
- (_a = morphedNode.parentElement) === null || _a === void 0 ? void 0 : _a.insertBefore(node, morphedNode);
6476
+ (_a = morphedNode.parentElement) === null || _a === undefined ? undefined : _a.insertBefore(node, morphedNode);
6419
6477
  }
6420
6478
  }
6421
6479
  added.push(morphedNode);
@@ -6428,7 +6486,7 @@ function insertSiblings(previousSibling, morphedNode, nextSibling) {
6428
6486
  while (stack.length > 0) {
6429
6487
  const node = stack.pop();
6430
6488
  if (node) {
6431
- (_b = morphedNode.parentElement) === null || _b === void 0 ? void 0 : _b.insertBefore(node, morphedNode.nextSibling);
6489
+ (_b = morphedNode.parentElement) === null || _b === undefined ? undefined : _b.insertBefore(node, morphedNode.nextSibling);
6432
6490
  }
6433
6491
  }
6434
6492
  return added;
@@ -6542,7 +6600,7 @@ function morphOldNodeTo(oldNode, newContent, ctx) {
6542
6600
  return oldNode;
6543
6601
  if (ctx.callbacks.beforeNodeAdded(newContent) === false)
6544
6602
  return oldNode;
6545
- (_a = oldNode.parentElement) === null || _a === void 0 ? void 0 : _a.replaceChild(newContent, oldNode);
6603
+ (_a = oldNode.parentElement) === null || _a === undefined ? undefined : _a.replaceChild(newContent, oldNode);
6546
6604
  ctx.callbacks.afterNodeAdded(newContent);
6547
6605
  ctx.callbacks.afterNodeRemoved(oldNode);
6548
6606
  return newContent;
@@ -6648,8 +6706,8 @@ function morphNormalizedContent(oldNode, normalizedNewContent, ctx) {
6648
6706
  // into either side of the best match
6649
6707
  const bestMatch = findBestNodeMatch(normalizedNewContent, oldNode, ctx);
6650
6708
  // stash the siblings that will need to be inserted on either side of the best match
6651
- const previousSibling = bestMatch === null || bestMatch === void 0 ? void 0 : bestMatch.previousSibling;
6652
- const nextSibling = bestMatch === null || bestMatch === void 0 ? void 0 : bestMatch.nextSibling;
6709
+ const previousSibling = bestMatch === null || bestMatch === undefined ? undefined : bestMatch.previousSibling;
6710
+ const nextSibling = bestMatch === null || bestMatch === undefined ? undefined : bestMatch.nextSibling;
6653
6711
  // morph it
6654
6712
  const morphedNode = morphOldNodeTo(oldNode, bestMatch, ctx);
6655
6713
  if (bestMatch) {
@@ -6831,9 +6889,9 @@ class History {
6831
6889
  }
6832
6890
  save(options = {}) {
6833
6891
  var _a, _b, _c;
6834
- const inputType = (_a = options.inputType) !== null && _a !== void 0 ? _a : '';
6835
- const update = (_b = options.update) !== null && _b !== void 0 ? _b : false;
6836
- const emitEvent = (_c = options.emitEvent) !== null && _c !== void 0 ? _c : true;
6892
+ const inputType = (_a = options.inputType) !== null && _a !== undefined ? _a : '';
6893
+ const update = (_b = options.update) !== null && _b !== undefined ? _b : false;
6894
+ const emitEvent = (_c = options.emitEvent) !== null && _c !== undefined ? _c : true;
6837
6895
  if (!this.canSave) {
6838
6896
  return;
6839
6897
  }
@@ -7005,20 +7063,29 @@ const defaultConfig = {
7005
7063
  slash: false,
7006
7064
  mention: false,
7007
7065
  };
7066
+ // The Editor interface provides properties and methods for rendering and manipulating the editor.
7008
7067
  class Editor {
7009
7068
  constructor(config) {
7069
+ // A string that has not yet been saved to the history.
7010
7070
  this.unsavedInputData = '';
7071
+ // The number of input event calls before saving to the history.
7011
7072
  this.unsavedInputCount = 0;
7073
+ // The state of the current selection.
7012
7074
  this.state = {
7013
7075
  activeItems: [],
7014
7076
  disabledNameMap: new Map(),
7015
7077
  selectedNameMap: new Map(),
7016
7078
  selectedValuesMap: new Map(),
7017
7079
  };
7080
+ // The functions for unmounting plugins.
7018
7081
  this.unmountPluginMap = new Map();
7019
- this.isComposing = false;
7082
+ // Managing events.
7020
7083
  this.event = new EventEmitter();
7084
+ // Managing the box components.
7021
7085
  this.box = Editor.box;
7086
+ // Indicating whether a user is entering a character using a text composition system such as an Input Method Editor (IME).
7087
+ this.isComposing = false;
7088
+ // A pop-up component which is currently displayed, such as LinkPopup, MentionMenu, and SlashMenu.
7022
7089
  this.popup = null;
7023
7090
  this.copyListener = event => {
7024
7091
  const range = this.selection.getCurrentRange();
@@ -7242,7 +7309,7 @@ class Editor {
7242
7309
  }
7243
7310
  const inputType = event instanceof CompositionEvent ? 'insertText' : event.inputType;
7244
7311
  if (inputType === 'insertText') {
7245
- const inputData = (_a = event.data) !== null && _a !== void 0 ? _a : '';
7312
+ const inputData = (_a = event.data) !== null && _a !== undefined ? _a : '';
7246
7313
  if (inputData.length > 1) {
7247
7314
  this.history.save({
7248
7315
  inputType: 'insertText',
@@ -7310,7 +7377,7 @@ class Editor {
7310
7377
  }
7311
7378
  this.emitStateChangeEvent();
7312
7379
  this.togglePlaceholderClass(value);
7313
- this.scrollToCaret();
7380
+ this.scrollToCursor();
7314
7381
  this.event.emit('change', value);
7315
7382
  };
7316
7383
  this.history.event.on('undo', value => {
@@ -7332,19 +7399,22 @@ class Editor {
7332
7399
  }
7333
7400
  });
7334
7401
  }
7335
- // Returns a boolean value indicating whether the editor is focused.
7336
- get hasFocus() {
7337
- const activeElement = document.activeElement;
7338
- if (!activeElement) {
7339
- return false;
7340
- }
7341
- return query(activeElement).closest('.lake-container').get(0) === this.container.get(0);
7342
- }
7343
7402
  // Returns translation functions for the specified language.
7344
7403
  get locale() {
7345
7404
  return i18nObject(this.config.lang);
7346
7405
  }
7347
- // Fixes wrong content, especially empty tag.
7406
+ // Sets the default config for the specified plugin.
7407
+ setPluginConfig(name, config) {
7408
+ if (typeof this.config[name] !== 'object') {
7409
+ this.config[name] = {};
7410
+ }
7411
+ for (const key of Object.keys(config)) {
7412
+ if (this.config[name][key] === undefined) {
7413
+ this.config[name][key] = config[key];
7414
+ }
7415
+ }
7416
+ }
7417
+ // Fixes incorrect content, such as adding paragraphs for void elements or removing empty tags.
7348
7418
  fixContent() {
7349
7419
  const range = this.selection.range;
7350
7420
  const cellNode = range.commonAncestor.closest('td');
@@ -7379,17 +7449,6 @@ class Editor {
7379
7449
  range.adjustBr();
7380
7450
  return changed;
7381
7451
  }
7382
- // Sets default config for a plugin.
7383
- setPluginConfig(name, config) {
7384
- if (typeof this.config[name] !== 'object') {
7385
- this.config[name] = {};
7386
- }
7387
- for (const key of Object.keys(config)) {
7388
- if (this.config[name][key] === undefined) {
7389
- this.config[name][key] = config[key];
7390
- }
7391
- }
7392
- }
7393
7452
  // Renders all boxes that haven't been rendered yet.
7394
7453
  renderBoxes() {
7395
7454
  this.removeBoxGarbage();
@@ -7404,34 +7463,22 @@ class Editor {
7404
7463
  box.render();
7405
7464
  });
7406
7465
  }
7407
- // Sets focus on the editor.
7408
- focus() {
7409
- const range = this.selection.range;
7410
- if (this.container.contains(range.commonAncestor) && range.isBox) {
7411
- return;
7412
- }
7413
- this.container.focus();
7414
- }
7415
- // Removes focus from the editor.
7416
- blur() {
7417
- this.container.blur();
7418
- }
7419
- // Scrolls to the caret or the range of the selection.
7420
- scrollToCaret() {
7466
+ // Scrolls to the cursor.
7467
+ scrollToCursor() {
7421
7468
  const range = this.selection.range;
7422
7469
  if (range.isBox) {
7423
7470
  return;
7424
7471
  }
7425
- // Creates an artificial caret that is the same size as the caret at the current caret position.
7472
+ // Creates an artificial cursor that is the same size as the cursor at the current cursor position.
7426
7473
  const rangeRect = range.getRect();
7427
7474
  if (rangeRect.x === 0 || rangeRect.y === 0) {
7428
7475
  return;
7429
7476
  }
7430
7477
  const containerRect = this.container.get(0).getBoundingClientRect();
7431
- const artificialCaret = query('<div class="lake-artificial-caret" />');
7478
+ const artificialCursor = query('<div class="lake-artificial-cursor" />');
7432
7479
  const left = rangeRect.x - containerRect.x;
7433
7480
  const top = rangeRect.y - containerRect.y;
7434
- artificialCaret.css({
7481
+ artificialCursor.css({
7435
7482
  position: 'absolute',
7436
7483
  top: `${top}px`,
7437
7484
  left: `${left}px`,
@@ -7440,14 +7487,34 @@ class Editor {
7440
7487
  // background: 'red',
7441
7488
  'z-index': '-1',
7442
7489
  });
7443
- this.overlayContainer.find('.lake-artificial-caret').remove();
7444
- this.overlayContainer.append(artificialCaret);
7445
- scrollToNode(artificialCaret, {
7490
+ this.overlayContainer.find('.lake-artificial-cursor').remove();
7491
+ this.overlayContainer.append(artificialCursor);
7492
+ scrollToNode(artificialCursor, {
7446
7493
  behavior: 'instant',
7447
7494
  block: 'nearest',
7448
7495
  inline: 'nearest',
7449
7496
  });
7450
- artificialCaret.remove();
7497
+ artificialCursor.remove();
7498
+ }
7499
+ // Checks whether the editor has focus.
7500
+ hasFocus() {
7501
+ const activeElement = document.activeElement;
7502
+ if (!activeElement) {
7503
+ return false;
7504
+ }
7505
+ return query(activeElement).closest('.lake-container').get(0) === this.container.get(0);
7506
+ }
7507
+ // Sets focus on the editor.
7508
+ focus() {
7509
+ const range = this.selection.range;
7510
+ if (this.container.contains(range.commonAncestor) && range.isBox) {
7511
+ return;
7512
+ }
7513
+ this.container.focus();
7514
+ }
7515
+ // Removes focus from the editor.
7516
+ blur() {
7517
+ this.container.blur();
7451
7518
  }
7452
7519
  // Sets the specified content to the editor.
7453
7520
  setValue(value) {
@@ -7467,7 +7534,7 @@ class Editor {
7467
7534
  value = denormalizeValue(value);
7468
7535
  return value;
7469
7536
  }
7470
- // Renders an editor area and sets default content to it.
7537
+ // Renders an editing area and sets default content to it.
7471
7538
  render() {
7472
7539
  const value = normalizeValue(this.config.value);
7473
7540
  const htmlParser = new HTMLParser(value);
@@ -7534,8 +7601,11 @@ class Editor {
7534
7601
  }
7535
7602
  }
7536
7603
  }
7604
+ // the current version of Lake.
7537
7605
  Editor.version = version;
7606
+ // Managing the box components.
7538
7607
  Editor.box = new BoxManager();
7608
+ // Managing the plugins.
7539
7609
  Editor.plugin = new Plugin();
7540
7610
 
7541
7611
  var copy = (editor) => {
@@ -9403,7 +9473,7 @@ class LinkPopup {
9403
9473
  }
9404
9474
  // Writes the specified text to the system clipboard
9405
9475
  writeClipboardText(text) {
9406
- return __awaiter(this, void 0, void 0, function* () {
9476
+ return __awaiter(this, undefined, undefined, function* () {
9407
9477
  let error = false;
9408
9478
  try {
9409
9479
  if (window.LAKE_TEST) {
@@ -9925,7 +9995,7 @@ var codeBlockBox = {
9925
9995
  });
9926
9996
  const codeEditor = new EditorView({
9927
9997
  parent: codeBlockNativeNode,
9928
- doc: (_a = boxValue.code) !== null && _a !== void 0 ? _a : '',
9998
+ doc: (_a = boxValue.code) !== null && _a !== undefined ? _a : '',
9929
9999
  extensions: [
9930
10000
  EditorState.readOnly.of(editor.readonly),
9931
10001
  EditorView.editable.of(!editor.readonly),
@@ -10277,7 +10347,7 @@ function renderFloatingToolbar(box) {
10277
10347
  }
10278
10348
  // Loads an image and get its width and height.
10279
10349
  function getImageInfo(url) {
10280
- return __awaiter(this, void 0, void 0, function* () {
10350
+ return __awaiter(this, undefined, undefined, function* () {
10281
10351
  const node = query('<img />');
10282
10352
  node.css({
10283
10353
  position: 'absolute',
@@ -10467,7 +10537,7 @@ function renderCaption(box) {
10467
10537
  }
10468
10538
  // Displays error icon and filename.
10469
10539
  function renderError$1(box) {
10470
- return __awaiter(this, void 0, void 0, function* () {
10540
+ return __awaiter(this, undefined, undefined, function* () {
10471
10541
  const editor = box.getEditor();
10472
10542
  const boxContainer = box.getContainer();
10473
10543
  const value = box.value;
@@ -10510,7 +10580,7 @@ function renderError$1(box) {
10510
10580
  }
10511
10581
  // Displays an image with uplaoding progress.
10512
10582
  function renderUploading(box) {
10513
- return __awaiter(this, void 0, void 0, function* () {
10583
+ return __awaiter(this, undefined, undefined, function* () {
10514
10584
  const editor = box.getEditor();
10515
10585
  const boxContainer = box.getContainer();
10516
10586
  const value = box.value;
@@ -10580,7 +10650,7 @@ function renderUploading(box) {
10580
10650
  }
10581
10651
  // Displays an image that can be previewed or removed.
10582
10652
  function renderDone(box) {
10583
- return __awaiter(this, void 0, void 0, function* () {
10653
+ return __awaiter(this, undefined, undefined, function* () {
10584
10654
  const editor = box.getEditor();
10585
10655
  const boxContainer = box.getContainer();
10586
10656
  const value = box.value;
@@ -10973,7 +11043,7 @@ function setFloatingToolbar(box) {
10973
11043
  box.setToolbar(items);
10974
11044
  }
10975
11045
  function appendContent(rootNode, box) {
10976
- return __awaiter(this, void 0, void 0, function* () {
11046
+ return __awaiter(this, undefined, undefined, function* () {
10977
11047
  const value = box.value;
10978
11048
  const infoNode = query(template `
10979
11049
  <div class="lake-file-info">
@@ -11462,7 +11532,7 @@ class MentionMenu extends Menu {
11462
11532
  const itemNode = query(template `
11463
11533
  <li>
11464
11534
  <div class="lake-mention-avatar"></div>
11465
- <div class="lake-mention-nickname">${(_a = item.nickname) !== null && _a !== void 0 ? _a : item.name}</div>
11535
+ <div class="lake-mention-nickname">${(_a = item.nickname) !== null && _a !== undefined ? _a : item.name}</div>
11466
11536
  <div class="lake-mention-name">(${item.name})</div>
11467
11537
  </li>
11468
11538
  `);
@@ -11484,7 +11554,7 @@ class MentionMenu extends Menu {
11484
11554
  keyword = keyword.toLowerCase();
11485
11555
  const items = [];
11486
11556
  for (const item of this.items) {
11487
- const nickname = (_a = item.nickname) !== null && _a !== void 0 ? _a : item.name;
11557
+ const nickname = (_a = item.nickname) !== null && _a !== undefined ? _a : item.name;
11488
11558
  if (item.name.toLowerCase().indexOf(keyword) >= 0 ||
11489
11559
  nickname.toLowerCase().indexOf(keyword) >= 0 ||
11490
11560
  nickname.replace(/\s+/g, '').indexOf(keyword) >= 0) {
@@ -11506,7 +11576,7 @@ var mentionBox = {
11506
11576
  const url = getProfileUrl ? getProfileUrl(value) : '#';
11507
11577
  const boxContainer = box.getContainer();
11508
11578
  const rootNode = query(template `
11509
- <div class="lake-mention"><a href="${url}">@${(_a = value.nickname) !== null && _a !== void 0 ? _a : value.name}</a></div>
11579
+ <div class="lake-mention"><a href="${url}">@${(_a = value.nickname) !== null && _a !== undefined ? _a : value.name}</a></div>
11510
11580
  `);
11511
11581
  boxContainer.empty();
11512
11582
  boxContainer.append(rootNode);
@@ -11709,7 +11779,7 @@ const blockItemListForSpaceKey = [
11709
11779
  var _a;
11710
11780
  return [
11711
11781
  'heading',
11712
- (_a = headingTypeMap.get(results[0])) !== null && _a !== void 0 ? _a : 'h6',
11782
+ (_a = headingTypeMap.get(results[0])) !== null && _a !== undefined ? _a : 'h6',
11713
11783
  ];
11714
11784
  },
11715
11785
  },
@@ -11784,7 +11854,7 @@ const blockItemListForEnterKey = [
11784
11854
  return [
11785
11855
  'codeBlock',
11786
11856
  {
11787
- lang: (_a = shortLangTypeMap.get(results[1])) !== null && _a !== void 0 ? _a : results[1],
11857
+ lang: (_a = shortLangTypeMap.get(results[1])) !== null && _a !== undefined ? _a : results[1],
11788
11858
  },
11789
11859
  ];
11790
11860
  },
@@ -12627,7 +12697,7 @@ var escapeKey = (editor) => {
12627
12697
  selection.sync();
12628
12698
  return;
12629
12699
  }
12630
- if (editor.hasFocus) {
12700
+ if (editor.hasFocus()) {
12631
12701
  event.preventDefault();
12632
12702
  editor.blur();
12633
12703
  }
@@ -12755,6 +12825,46 @@ const slashItems = [
12755
12825
  editor.command.execute(value);
12756
12826
  },
12757
12827
  },
12828
+ {
12829
+ name: 'infoAlert',
12830
+ type: 'button',
12831
+ icon: icons.get('info'),
12832
+ title: locale => locale.slash.infoAlert(),
12833
+ description: locale => locale.slash.infoAlertDesc(),
12834
+ onClick: editor => {
12835
+ editor.command.execute('blockQuote', 'info');
12836
+ },
12837
+ },
12838
+ {
12839
+ name: 'tipAlert',
12840
+ type: 'button',
12841
+ icon: icons.get('tip'),
12842
+ title: locale => locale.slash.tipAlert(),
12843
+ description: locale => locale.slash.tipAlertDesc(),
12844
+ onClick: editor => {
12845
+ editor.command.execute('blockQuote', 'tip');
12846
+ },
12847
+ },
12848
+ {
12849
+ name: 'warningAlert',
12850
+ type: 'button',
12851
+ icon: icons.get('warning'),
12852
+ title: locale => locale.slash.warningAlert(),
12853
+ description: locale => locale.slash.warningAlertDesc(),
12854
+ onClick: editor => {
12855
+ editor.command.execute('blockQuote', 'warning');
12856
+ },
12857
+ },
12858
+ {
12859
+ name: 'dangerAlert',
12860
+ type: 'button',
12861
+ icon: icons.get('danger'),
12862
+ title: locale => locale.slash.dangerAlert(),
12863
+ description: locale => locale.slash.dangerAlertDesc(),
12864
+ onClick: editor => {
12865
+ editor.command.execute('blockQuote', 'danger');
12866
+ },
12867
+ },
12758
12868
  {
12759
12869
  name: 'hr',
12760
12870
  type: 'button',
@@ -12908,6 +13018,10 @@ const defaultItems = [
12908
13018
  'bulletedList',
12909
13019
  'checklist',
12910
13020
  'table',
13021
+ 'infoAlert',
13022
+ 'tipAlert',
13023
+ 'warningAlert',
13024
+ 'dangerAlert',
12911
13025
  'hr',
12912
13026
  ];
12913
13027
  function getKeyword(block) {