@threadlabs/looma 0.1.17 → 0.1.18
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/README.md +2 -1
- package/dist/{chunk-OY4D3W4U.js → chunk-DTQVRGVL.js} +29 -29
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/looma.cjs.js +1 -1
- package/dist/cjs/ui-context-menu.cjs.entry.js +5 -2
- package/dist/collection/components/ui-context-menu/ui-context-menu.css +4 -0
- package/dist/collection/components/ui-context-menu/ui-context-menu.js +6 -2
- package/dist/components/ui-context-menu.js +1 -1
- package/dist/esm/loader.js +1 -1
- package/dist/esm/looma.js +1 -1
- package/dist/esm/ui-context-menu.entry.js +5 -2
- package/dist/index.cjs +6 -3
- package/dist/index.js +2 -2
- package/dist/looma/looma.esm.js +1 -1
- package/dist/looma/p-063f5a89.entry.js +1 -0
- package/dist/types/components/ui-context-menu/ui-context-menu.d.ts +3 -0
- package/dist/{ui-affordance-scope.entry-X7DTKJGL.js → ui-affordance-scope.entry-2W7ZKAGK.js} +1 -1
- package/dist/{ui-avatar-group.entry-MC34FKAN.js → ui-avatar-group.entry-SE5JG2FT.js} +1 -1
- package/dist/{ui-avatar.entry-OKRQWTQV.js → ui-avatar.entry-46JDI25A.js} +1 -1
- package/dist/{ui-badge.entry-RI7JB7KV.js → ui-badge.entry-U7G3MEC5.js} +1 -1
- package/dist/{ui-button.entry-PFO5TTPN.js → ui-button.entry-DELD6KMH.js} +1 -1
- package/dist/{ui-checkbox.entry-UHFWVISP.js → ui-checkbox.entry-ZUG2P642.js} +1 -1
- package/dist/{ui-context-menu.entry-AIXB6U5D.js → ui-context-menu.entry-L4HTK3PV.js} +6 -3
- package/dist/{ui-dialog.entry-LPREQH2T.js → ui-dialog.entry-TQPYD2YI.js} +1 -1
- package/dist/{ui-disclosure.entry-7XCUIYVZ.js → ui-disclosure.entry-23TII4YU.js} +1 -1
- package/dist/{ui-floating-action-button.entry-5PNIMUAW.js → ui-floating-action-button.entry-FOQYAFJI.js} +1 -1
- package/dist/{ui-form-field.entry-77YW46SM.js → ui-form-field.entry-SCPG4STY.js} +1 -1
- package/dist/{ui-icon-button.entry-4AD6ALPQ.js → ui-icon-button.entry-U45ZVAC3.js} +1 -1
- package/dist/{ui-input.entry-E7E6QDTV.js → ui-input.entry-3AIA3G4C.js} +1 -1
- package/dist/{ui-menu-item.entry-H3HFLUB6.js → ui-menu-item.entry-3QO5TG2J.js} +1 -1
- package/dist/{ui-menu.entry-UAKZU4HG.js → ui-menu.entry-JACWGDDG.js} +1 -1
- package/dist/{ui-popover.entry-GVQKX26B.js → ui-popover.entry-2XP4H3S2.js} +1 -1
- package/dist/{ui-radio-group.entry-MNSR6UEE.js → ui-radio-group.entry-73IKFMDK.js} +1 -1
- package/dist/{ui-radio.entry-6D4WTI5E.js → ui-radio.entry-INJVXUKE.js} +1 -1
- package/dist/{ui-search-result-row.entry-J2TILUH2.js → ui-search-result-row.entry-4J732TDC.js} +1 -1
- package/dist/{ui-search-shell.entry-FSWHEZQF.js → ui-search-shell.entry-3C2WRVE2.js} +1 -1
- package/dist/{ui-select.entry-JRCYYNNW.js → ui-select.entry-3ZLDGAKX.js} +1 -1
- package/dist/{ui-switch.entry-YZWMNRP2.js → ui-switch.entry-5MJRLR2P.js} +1 -1
- package/dist/{ui-tabs.entry-F2Y344JY.js → ui-tabs.entry-F5H7OPBO.js} +1 -1
- package/dist/{ui-textarea.entry-3EZCUUAK.js → ui-textarea.entry-BNJ375JB.js} +1 -1
- package/dist/{ui-toast-region.entry-BTV4AW3I.js → ui-toast-region.entry-ZUIPJ2JH.js} +1 -1
- package/dist/{ui-tooltip.entry-U644CF5U.js → ui-tooltip.entry-DZ4RMF35.js} +1 -1
- package/dist/{ui-top-bar.entry-FGGOREQR.js → ui-top-bar.entry-VKRXIUU6.js} +1 -1
- package/dist/{ui-tree-item.entry-XVMHEONY.js → ui-tree-item.entry-NFUQ45OL.js} +1 -1
- package/dist/{ui-tree.entry-4R7DYGAM.js → ui-tree.entry-H4CWDYI6.js} +1 -1
- package/editor/{chunk-RTHHTPWK.js → chunk-3QMBK3XZ.js} +245 -41
- package/editor/{chunk-OHD4OS32.js → chunk-OXFYYLUC.js} +632 -236
- package/editor/{chunk-CX4QDKSV.js → chunk-ZOUKEZ77.js} +21 -1
- package/editor/extensions/index.d.ts +49 -1
- package/editor/extensions/index.js +15 -3
- package/editor/index.d.ts +3 -2
- package/editor/index.js +16 -4
- package/editor/ui.d.ts +9 -1
- package/editor/ui.js +2 -2
- package/editor.css +170 -0
- package/package.json +1 -1
- package/styles.css +1 -7
- package/vue/editor/index.d.ts +103 -4
- package/vue/editor/index.js +137 -63
- package/dist/looma/p-ba01f45d.entry.js +0 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
|
+
MAX_MENTION_RESULT_LIMIT,
|
|
2
3
|
TABLE_CELL_BACKGROUND_OPTIONS
|
|
3
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-ZOUKEZ77.js";
|
|
4
5
|
|
|
5
6
|
// src/table-context-menu.ts
|
|
6
7
|
import {
|
|
@@ -479,12 +480,215 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
479
480
|
}
|
|
480
481
|
}
|
|
481
482
|
|
|
483
|
+
// src/mention-menu.ts
|
|
484
|
+
import { getVisualViewportRect as getVisualViewportRect2 } from "@threadlabs/looma/core";
|
|
485
|
+
var TAG4 = "ui-editor-mention-menu";
|
|
486
|
+
var MOBILE_BREAKPOINT = 768;
|
|
487
|
+
var MENU_HEIGHT_ESTIMATE = 320;
|
|
488
|
+
var MENU_WIDTH = 320;
|
|
489
|
+
var OFFSET = 8;
|
|
490
|
+
function finiteCoordinate(value) {
|
|
491
|
+
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
492
|
+
}
|
|
493
|
+
function normalizeAnchorRect(value) {
|
|
494
|
+
if (!value || typeof value !== "object") return null;
|
|
495
|
+
const rect = value;
|
|
496
|
+
const x = finiteCoordinate(rect.x);
|
|
497
|
+
const y = finiteCoordinate(rect.y);
|
|
498
|
+
const width = finiteCoordinate(rect.width);
|
|
499
|
+
const height = finiteCoordinate(rect.height);
|
|
500
|
+
const left = finiteCoordinate(rect.left) ?? x;
|
|
501
|
+
const top = finiteCoordinate(rect.top) ?? y;
|
|
502
|
+
const right = finiteCoordinate(rect.right) ?? (left !== null && width !== null ? left + width : null);
|
|
503
|
+
const bottom = finiteCoordinate(rect.bottom) ?? (top !== null && height !== null ? top + height : null);
|
|
504
|
+
return left === null || top === null || right === null || bottom === null ? null : { left, top, right, bottom };
|
|
505
|
+
}
|
|
506
|
+
function escapeHtml(value) {
|
|
507
|
+
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
508
|
+
}
|
|
509
|
+
function dispatchMenuEvent(element, name, detail) {
|
|
510
|
+
element.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));
|
|
511
|
+
}
|
|
512
|
+
if (typeof HTMLElement !== "undefined") {
|
|
513
|
+
class UIEditorMentionMenuElement extends HTMLElement {
|
|
514
|
+
#open = false;
|
|
515
|
+
#query = "";
|
|
516
|
+
#items = [];
|
|
517
|
+
#selectedIndex = 0;
|
|
518
|
+
#loading = false;
|
|
519
|
+
#anchorRect = null;
|
|
520
|
+
#normalizedAnchorRect = null;
|
|
521
|
+
get open() {
|
|
522
|
+
return this.#open;
|
|
523
|
+
}
|
|
524
|
+
set open(value) {
|
|
525
|
+
this.#open = Boolean(value);
|
|
526
|
+
this.render();
|
|
527
|
+
}
|
|
528
|
+
get query() {
|
|
529
|
+
return this.#query;
|
|
530
|
+
}
|
|
531
|
+
set query(value) {
|
|
532
|
+
this.#query = typeof value === "string" ? value : "";
|
|
533
|
+
this.render();
|
|
534
|
+
}
|
|
535
|
+
get items() {
|
|
536
|
+
return this.#items;
|
|
537
|
+
}
|
|
538
|
+
set items(value) {
|
|
539
|
+
this.#items = Array.isArray(value) ? value.slice(0, MAX_MENTION_RESULT_LIMIT) : [];
|
|
540
|
+
if (this.#selectedIndex >= this.#items.length) this.#selectedIndex = 0;
|
|
541
|
+
this.render();
|
|
542
|
+
}
|
|
543
|
+
get selectedIndex() {
|
|
544
|
+
return this.#selectedIndex;
|
|
545
|
+
}
|
|
546
|
+
set selectedIndex(value) {
|
|
547
|
+
this.#selectedIndex = Number.isFinite(value) ? Math.max(0, value) : 0;
|
|
548
|
+
this.render();
|
|
549
|
+
}
|
|
550
|
+
get loading() {
|
|
551
|
+
return this.#loading;
|
|
552
|
+
}
|
|
553
|
+
set loading(value) {
|
|
554
|
+
this.#loading = Boolean(value);
|
|
555
|
+
this.render();
|
|
556
|
+
}
|
|
557
|
+
get anchorRect() {
|
|
558
|
+
return this.#anchorRect;
|
|
559
|
+
}
|
|
560
|
+
set anchorRect(value) {
|
|
561
|
+
const normalized = normalizeAnchorRect(value);
|
|
562
|
+
this.#anchorRect = normalized ? value : null;
|
|
563
|
+
this.#normalizedAnchorRect = normalized;
|
|
564
|
+
this.render();
|
|
565
|
+
}
|
|
566
|
+
connectedCallback() {
|
|
567
|
+
this.setAttribute("role", "listbox");
|
|
568
|
+
this.setAttribute("aria-label", "Mention a person");
|
|
569
|
+
this.addEventListener("mousedown", this.onMouseDown);
|
|
570
|
+
this.addEventListener("click", this.onClick);
|
|
571
|
+
this.addEventListener("mouseover", this.onMouseOver);
|
|
572
|
+
window.addEventListener("resize", this.onViewportChange);
|
|
573
|
+
window.addEventListener("scroll", this.onViewportChange, true);
|
|
574
|
+
window.visualViewport?.addEventListener("resize", this.onViewportChange);
|
|
575
|
+
window.visualViewport?.addEventListener("scroll", this.onViewportChange);
|
|
576
|
+
this.render();
|
|
577
|
+
}
|
|
578
|
+
disconnectedCallback() {
|
|
579
|
+
this.removeEventListener("mousedown", this.onMouseDown);
|
|
580
|
+
this.removeEventListener("click", this.onClick);
|
|
581
|
+
this.removeEventListener("mouseover", this.onMouseOver);
|
|
582
|
+
window.removeEventListener("resize", this.onViewportChange);
|
|
583
|
+
window.removeEventListener("scroll", this.onViewportChange, true);
|
|
584
|
+
window.visualViewport?.removeEventListener("resize", this.onViewportChange);
|
|
585
|
+
window.visualViewport?.removeEventListener("scroll", this.onViewportChange);
|
|
586
|
+
}
|
|
587
|
+
onMouseDown = (event) => event.preventDefault();
|
|
588
|
+
onClick = (event) => {
|
|
589
|
+
const target = event.target.closest("[data-index]");
|
|
590
|
+
const index = Number.parseInt(target?.dataset.index ?? "", 10);
|
|
591
|
+
if (Number.isFinite(index)) {
|
|
592
|
+
dispatchMenuEvent(
|
|
593
|
+
this,
|
|
594
|
+
"looma-editor-mention-menu-select",
|
|
595
|
+
{ index }
|
|
596
|
+
);
|
|
597
|
+
}
|
|
598
|
+
};
|
|
599
|
+
onMouseOver = (event) => {
|
|
600
|
+
const target = event.target.closest("[data-index]");
|
|
601
|
+
const index = Number.parseInt(target?.dataset.index ?? "", 10);
|
|
602
|
+
if (!Number.isFinite(index) || index === this.#selectedIndex) return;
|
|
603
|
+
this.#selectedIndex = index;
|
|
604
|
+
dispatchMenuEvent(
|
|
605
|
+
this,
|
|
606
|
+
"looma-editor-mention-menu-highlight",
|
|
607
|
+
{ index }
|
|
608
|
+
);
|
|
609
|
+
this.render();
|
|
610
|
+
};
|
|
611
|
+
onViewportChange = () => {
|
|
612
|
+
if (this.#open) this.applyHostPosition();
|
|
613
|
+
};
|
|
614
|
+
applyHostPosition() {
|
|
615
|
+
const rect = this.#normalizedAnchorRect;
|
|
616
|
+
if (!rect) {
|
|
617
|
+
this.style.display = "none";
|
|
618
|
+
return;
|
|
619
|
+
}
|
|
620
|
+
const viewport = getVisualViewportRect2(window);
|
|
621
|
+
this.style.display = "block";
|
|
622
|
+
this.style.position = "fixed";
|
|
623
|
+
this.style.zIndex = "500";
|
|
624
|
+
if (window.innerWidth < MOBILE_BREAKPOINT) {
|
|
625
|
+
const toolbarReserve = 56;
|
|
626
|
+
const height = Math.min(MENU_HEIGHT_ESTIMATE, Math.max(0, viewport.height - toolbarReserve));
|
|
627
|
+
this.style.left = `${viewport.left}px`;
|
|
628
|
+
this.style.top = `${viewport.top + viewport.height - height - toolbarReserve}px`;
|
|
629
|
+
this.style.right = "";
|
|
630
|
+
this.style.bottom = "";
|
|
631
|
+
this.style.width = `${viewport.width}px`;
|
|
632
|
+
this.style.maxHeight = `${height}px`;
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
635
|
+
const spaceBelow = viewport.bottom - rect.bottom - OFFSET;
|
|
636
|
+
const spaceAbove = rect.top - viewport.top - OFFSET;
|
|
637
|
+
const top = spaceBelow >= MENU_HEIGHT_ESTIMATE || spaceBelow >= spaceAbove ? rect.bottom + OFFSET : rect.top - OFFSET - MENU_HEIGHT_ESTIMATE;
|
|
638
|
+
const left = Math.max(
|
|
639
|
+
viewport.left + 8,
|
|
640
|
+
Math.min(rect.left, viewport.right - MENU_WIDTH - 8)
|
|
641
|
+
);
|
|
642
|
+
this.style.top = `${Math.max(viewport.top + 8, top)}px`;
|
|
643
|
+
this.style.left = `${left}px`;
|
|
644
|
+
this.style.right = "";
|
|
645
|
+
this.style.bottom = "";
|
|
646
|
+
this.style.width = `${MENU_WIDTH}px`;
|
|
647
|
+
this.style.maxHeight = "";
|
|
648
|
+
}
|
|
649
|
+
render() {
|
|
650
|
+
const visible = this.#open && (this.#loading || this.#items.length > 0) && this.#normalizedAnchorRect;
|
|
651
|
+
this.hidden = !visible;
|
|
652
|
+
if (!visible) return;
|
|
653
|
+
this.applyHostPosition();
|
|
654
|
+
const optionIdPrefix = this.id || TAG4;
|
|
655
|
+
const selectedId = `${optionIdPrefix}-option-${this.#selectedIndex}`;
|
|
656
|
+
this.setAttribute("aria-busy", this.#loading ? "true" : "false");
|
|
657
|
+
if (this.#items.length > 0) this.setAttribute("aria-activedescendant", selectedId);
|
|
658
|
+
else this.removeAttribute("aria-activedescendant");
|
|
659
|
+
const items = this.#items.map((item, index) => {
|
|
660
|
+
const selected = index === this.#selectedIndex;
|
|
661
|
+
return [
|
|
662
|
+
`<li id="${optionIdPrefix}-option-${index}" class="ui-editor-mention-menu__item${selected ? " ui-editor-mention-menu__item--active" : ""}"`,
|
|
663
|
+
` role="option" aria-selected="${selected}" data-index="${index}">`,
|
|
664
|
+
`<span class="ui-editor-mention-menu__avatar" aria-hidden="true">${escapeHtml(item.initials ?? item.label.slice(0, 2).toUpperCase())}</span>`,
|
|
665
|
+
`<span class="ui-editor-mention-menu__body">`,
|
|
666
|
+
`<span class="ui-editor-mention-menu__label">${escapeHtml(item.label)}</span>`,
|
|
667
|
+
item.detail ? `<span class="ui-editor-mention-menu__detail">${escapeHtml(item.detail)}</span>` : "",
|
|
668
|
+
`</span></li>`
|
|
669
|
+
].join("");
|
|
670
|
+
}).join("");
|
|
671
|
+
this.innerHTML = [
|
|
672
|
+
`<div class="ui-editor-mention-menu">`,
|
|
673
|
+
`<div class="ui-editor-mention-menu__header">`,
|
|
674
|
+
`<span>People</span><span class="ui-editor-mention-menu__hint">Type after @ to search</span>`,
|
|
675
|
+
`</div>`,
|
|
676
|
+
this.#loading && this.#items.length === 0 ? `<div class="ui-editor-mention-menu__loading" role="status">Searching\u2026</div>` : `<ul class="ui-editor-mention-menu__list" role="presentation">${items}</ul>`,
|
|
677
|
+
`</div>`
|
|
678
|
+
].join("");
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
if (typeof window !== "undefined" && !customElements.get(TAG4)) {
|
|
682
|
+
customElements.define(TAG4, UIEditorMentionMenuElement);
|
|
683
|
+
}
|
|
684
|
+
}
|
|
685
|
+
|
|
482
686
|
// src/table-overlay.ts
|
|
483
687
|
import {
|
|
484
688
|
createProximityCoordinator,
|
|
485
689
|
loomaIconMarkup as loomaIconMarkup3
|
|
486
690
|
} from "@threadlabs/looma/core";
|
|
487
|
-
var
|
|
691
|
+
var TAG5 = "ui-editor-table-overlay";
|
|
488
692
|
var DEFAULT_ROWS = 3;
|
|
489
693
|
var DEFAULT_COLS = 3;
|
|
490
694
|
function sameNumbers(left, right) {
|
|
@@ -789,37 +993,37 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
789
993
|
this.#proximity?.refresh();
|
|
790
994
|
}
|
|
791
995
|
}
|
|
792
|
-
if (typeof window !== "undefined" && !customElements.get(
|
|
793
|
-
customElements.define(
|
|
996
|
+
if (typeof window !== "undefined" && !customElements.get(TAG5)) {
|
|
997
|
+
customElements.define(TAG5, UIEditorTableOverlayElement);
|
|
794
998
|
}
|
|
795
999
|
}
|
|
796
1000
|
|
|
797
1001
|
// src/slash-menu.ts
|
|
798
1002
|
import {
|
|
799
|
-
getVisualViewportRect as
|
|
1003
|
+
getVisualViewportRect as getVisualViewportRect3,
|
|
800
1004
|
loomaIconMarkup as loomaIconMarkup4
|
|
801
1005
|
} from "@threadlabs/looma/core";
|
|
802
|
-
var
|
|
803
|
-
var
|
|
804
|
-
var
|
|
805
|
-
var
|
|
806
|
-
var
|
|
807
|
-
function
|
|
1006
|
+
var TAG6 = "ui-editor-slash-menu";
|
|
1007
|
+
var MOBILE_BREAKPOINT2 = 768;
|
|
1008
|
+
var MENU_HEIGHT_ESTIMATE2 = 320;
|
|
1009
|
+
var MENU_WIDTH2 = 280;
|
|
1010
|
+
var OFFSET2 = 8;
|
|
1011
|
+
function finiteCoordinate2(value) {
|
|
808
1012
|
return typeof value === "number" && Number.isFinite(value) ? value : null;
|
|
809
1013
|
}
|
|
810
|
-
function
|
|
1014
|
+
function normalizeAnchorRect2(value) {
|
|
811
1015
|
if (!value || typeof value !== "object") {
|
|
812
1016
|
return null;
|
|
813
1017
|
}
|
|
814
1018
|
const rect = value;
|
|
815
|
-
const x =
|
|
816
|
-
const y =
|
|
817
|
-
const width =
|
|
818
|
-
const height =
|
|
819
|
-
const left =
|
|
820
|
-
const top =
|
|
821
|
-
const right =
|
|
822
|
-
const bottom =
|
|
1019
|
+
const x = finiteCoordinate2(rect.x);
|
|
1020
|
+
const y = finiteCoordinate2(rect.y);
|
|
1021
|
+
const width = finiteCoordinate2(rect.width);
|
|
1022
|
+
const height = finiteCoordinate2(rect.height);
|
|
1023
|
+
const left = finiteCoordinate2(rect.left) ?? x;
|
|
1024
|
+
const top = finiteCoordinate2(rect.top) ?? y;
|
|
1025
|
+
const right = finiteCoordinate2(rect.right) ?? (left !== null && width !== null ? left + width : null);
|
|
1026
|
+
const bottom = finiteCoordinate2(rect.bottom) ?? (top !== null && height !== null ? top + height : null);
|
|
823
1027
|
if (left === null || top === null || right === null || bottom === null) {
|
|
824
1028
|
return null;
|
|
825
1029
|
}
|
|
@@ -834,7 +1038,7 @@ function dispatchSlashMenuEvent(element, name, detail) {
|
|
|
834
1038
|
})
|
|
835
1039
|
);
|
|
836
1040
|
}
|
|
837
|
-
function
|
|
1041
|
+
function escapeHtml2(value) {
|
|
838
1042
|
return value.replaceAll("&", "&").replaceAll("<", "<").replaceAll(">", ">").replaceAll('"', """).replaceAll("'", "'");
|
|
839
1043
|
}
|
|
840
1044
|
if (typeof HTMLElement !== "undefined") {
|
|
@@ -877,7 +1081,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
877
1081
|
return this.#anchorRect;
|
|
878
1082
|
}
|
|
879
1083
|
set anchorRect(value) {
|
|
880
|
-
const normalized =
|
|
1084
|
+
const normalized = normalizeAnchorRect2(value);
|
|
881
1085
|
this.#anchorRect = normalized ? value : null;
|
|
882
1086
|
this.#normalizedAnchorRect = normalized;
|
|
883
1087
|
this.render();
|
|
@@ -947,16 +1151,16 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
947
1151
|
this.style.display = "none";
|
|
948
1152
|
return;
|
|
949
1153
|
}
|
|
950
|
-
const viewport =
|
|
1154
|
+
const viewport = getVisualViewportRect3(window);
|
|
951
1155
|
const viewportWidth = viewport.width;
|
|
952
1156
|
const viewportHeight = viewport.height;
|
|
953
1157
|
this.style.display = "block";
|
|
954
1158
|
this.style.position = "fixed";
|
|
955
1159
|
this.style.zIndex = "500";
|
|
956
|
-
if (window.innerWidth <
|
|
1160
|
+
if (window.innerWidth < MOBILE_BREAKPOINT2) {
|
|
957
1161
|
const toolbarReserve = 56;
|
|
958
1162
|
const menuHeight = Math.min(
|
|
959
|
-
|
|
1163
|
+
MENU_HEIGHT_ESTIMATE2,
|
|
960
1164
|
Math.max(0, viewportHeight - toolbarReserve)
|
|
961
1165
|
);
|
|
962
1166
|
this.style.left = `${viewport.left}px`;
|
|
@@ -968,16 +1172,16 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
968
1172
|
return;
|
|
969
1173
|
}
|
|
970
1174
|
let top;
|
|
971
|
-
const spaceBelow = viewport.bottom - rect.bottom -
|
|
972
|
-
const spaceAbove = rect.top - viewport.top -
|
|
973
|
-
if (spaceBelow >=
|
|
974
|
-
top = rect.bottom +
|
|
1175
|
+
const spaceBelow = viewport.bottom - rect.bottom - OFFSET2;
|
|
1176
|
+
const spaceAbove = rect.top - viewport.top - OFFSET2;
|
|
1177
|
+
if (spaceBelow >= MENU_HEIGHT_ESTIMATE2 || spaceBelow >= spaceAbove) {
|
|
1178
|
+
top = rect.bottom + OFFSET2;
|
|
975
1179
|
} else {
|
|
976
|
-
top = rect.top -
|
|
1180
|
+
top = rect.top - OFFSET2 - MENU_HEIGHT_ESTIMATE2;
|
|
977
1181
|
}
|
|
978
1182
|
let left = rect.left;
|
|
979
|
-
if (left +
|
|
980
|
-
left = viewport.right -
|
|
1183
|
+
if (left + MENU_WIDTH2 > viewport.right - 8) {
|
|
1184
|
+
left = viewport.right - MENU_WIDTH2 - 8;
|
|
981
1185
|
}
|
|
982
1186
|
if (left < viewport.left + 8) {
|
|
983
1187
|
left = viewport.left + 8;
|
|
@@ -986,7 +1190,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
986
1190
|
this.style.left = `${left}px`;
|
|
987
1191
|
this.style.right = "";
|
|
988
1192
|
this.style.bottom = "";
|
|
989
|
-
this.style.width = `${
|
|
1193
|
+
this.style.width = `${MENU_WIDTH2}px`;
|
|
990
1194
|
this.style.maxHeight = "";
|
|
991
1195
|
}
|
|
992
1196
|
render() {
|
|
@@ -1008,8 +1212,8 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1008
1212
|
`>`,
|
|
1009
1213
|
`<span class="ui-editor-slash-menu__icon" aria-hidden="true">${loomaIconMarkup4(item.icon)}</span>`,
|
|
1010
1214
|
`<span class="ui-editor-slash-menu__body">`,
|
|
1011
|
-
`<span class="ui-editor-slash-menu__title">${
|
|
1012
|
-
`<span class="ui-editor-slash-menu__description">${
|
|
1215
|
+
`<span class="ui-editor-slash-menu__title">${escapeHtml2(item.title)}</span>`,
|
|
1216
|
+
`<span class="ui-editor-slash-menu__description">${escapeHtml2(item.description)}</span>`,
|
|
1013
1217
|
`</span>`,
|
|
1014
1218
|
`</li>`
|
|
1015
1219
|
].join("");
|
|
@@ -1018,7 +1222,7 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1018
1222
|
`<div class="ui-editor-slash-menu">`,
|
|
1019
1223
|
`<div class="ui-editor-slash-menu__header" aria-hidden="true">`,
|
|
1020
1224
|
`<span class="ui-editor-slash-menu__header-label">Insert</span>`,
|
|
1021
|
-
query ? `<span class="ui-editor-slash-menu__header-query">${
|
|
1225
|
+
query ? `<span class="ui-editor-slash-menu__header-query">${escapeHtml2(query)}</span>` : "",
|
|
1022
1226
|
`</div>`,
|
|
1023
1227
|
`<ul class="ui-editor-slash-menu__list" role="presentation">${items}</ul>`,
|
|
1024
1228
|
`<div class="ui-editor-slash-menu__footer" aria-hidden="true">`,
|
|
@@ -1028,13 +1232,13 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1028
1232
|
].join("");
|
|
1029
1233
|
}
|
|
1030
1234
|
}
|
|
1031
|
-
if (typeof window !== "undefined" && !customElements.get(
|
|
1032
|
-
customElements.define(
|
|
1235
|
+
if (typeof window !== "undefined" && !customElements.get(TAG6)) {
|
|
1236
|
+
customElements.define(TAG6, UIEditorSlashMenuElement);
|
|
1033
1237
|
}
|
|
1034
1238
|
}
|
|
1035
1239
|
|
|
1036
1240
|
// src/toolbar.ts
|
|
1037
|
-
var
|
|
1241
|
+
var TAG7 = "ui-editor-toolbar";
|
|
1038
1242
|
if (typeof HTMLElement !== "undefined") {
|
|
1039
1243
|
class UIEditorToolbarElement extends HTMLElement {
|
|
1040
1244
|
connectedCallback() {
|
|
@@ -1046,8 +1250,8 @@ if (typeof HTMLElement !== "undefined") {
|
|
|
1046
1250
|
}
|
|
1047
1251
|
}
|
|
1048
1252
|
}
|
|
1049
|
-
if (typeof window !== "undefined" && !customElements.get(
|
|
1050
|
-
customElements.define(
|
|
1253
|
+
if (typeof window !== "undefined" && !customElements.get(TAG7)) {
|
|
1254
|
+
customElements.define(TAG7, UIEditorToolbarElement);
|
|
1051
1255
|
}
|
|
1052
1256
|
}
|
|
1053
1257
|
|