microboard-temp 0.4.107 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/browser.js +68 -452
- package/dist/cjs/index.js +68 -452
- package/dist/cjs/node.js +68 -452
- package/dist/esm/browser.js +68 -452
- package/dist/esm/index.js +68 -452
- package/dist/esm/node.js +68 -452
- package/dist/microboard.css +1 -1
- package/dist/types/Keyboard/HotkeyRegistry.d.ts +13 -0
- package/dist/types/Keyboard/index.d.ts +1 -0
- package/package.json +1 -1
- package/dist/types/public/customWebComponents.d.ts +0 -24
- package/dist/types/public/loadLinkImages.d.ts +0 -0
package/dist/esm/node.js
CHANGED
|
@@ -50134,6 +50134,19 @@ function throttle(func, delay) {
|
|
|
50134
50134
|
};
|
|
50135
50135
|
}
|
|
50136
50136
|
|
|
50137
|
+
// src/Keyboard/HotkeyRegistry.ts
|
|
50138
|
+
var editModeHotkeyRegistry = {};
|
|
50139
|
+
var viewModeHotkeyRegistry = {};
|
|
50140
|
+
var hotkeyNames = {};
|
|
50141
|
+
function registerHotkey({ name, hotkey, hotkeyConfig, boardMode }) {
|
|
50142
|
+
if (boardMode === "edit") {
|
|
50143
|
+
editModeHotkeyRegistry[name] = hotkeyConfig;
|
|
50144
|
+
} else {
|
|
50145
|
+
viewModeHotkeyRegistry[name] = hotkeyConfig;
|
|
50146
|
+
}
|
|
50147
|
+
hotkeyNames[name] = hotkey;
|
|
50148
|
+
}
|
|
50149
|
+
|
|
50137
50150
|
// src/Items/Examples/CardGame/Card/Card.ts
|
|
50138
50151
|
var defaultCardData = {
|
|
50139
50152
|
itemType: "Card",
|
|
@@ -50250,6 +50263,23 @@ registerItem({
|
|
|
50250
50263
|
item: Card,
|
|
50251
50264
|
defaultData: defaultCardData
|
|
50252
50265
|
});
|
|
50266
|
+
registerHotkey({
|
|
50267
|
+
name: "flipCard",
|
|
50268
|
+
hotkey: { key: { button: "KeyF" }, label: { windows: "F", mac: "F" } },
|
|
50269
|
+
boardMode: "edit",
|
|
50270
|
+
hotkeyConfig: {
|
|
50271
|
+
allItemsType: ["Card"],
|
|
50272
|
+
cb: (event, board) => {
|
|
50273
|
+
const cards = board?.selection.items.list();
|
|
50274
|
+
if (!cards) {
|
|
50275
|
+
return;
|
|
50276
|
+
}
|
|
50277
|
+
cards.forEach((card) => {
|
|
50278
|
+
card.toggleIsOpen();
|
|
50279
|
+
});
|
|
50280
|
+
}
|
|
50281
|
+
}
|
|
50282
|
+
});
|
|
50253
50283
|
// src/Items/Examples/CardGame/Deck/Deck.ts
|
|
50254
50284
|
var defaultDeckData = {
|
|
50255
50285
|
itemType: "Deck"
|
|
@@ -51680,10 +51710,11 @@ var hotkeys_default = {
|
|
|
51680
51710
|
|
|
51681
51711
|
// src/Keyboard/isHotkeyPushed.ts
|
|
51682
51712
|
function isHotkeyPushed(hotkey, event) {
|
|
51683
|
-
|
|
51713
|
+
const hotkeys = { ...hotkeys_default, ...hotkeyNames };
|
|
51714
|
+
if (!hotkeys[hotkey]) {
|
|
51684
51715
|
return false;
|
|
51685
51716
|
}
|
|
51686
|
-
const { key } =
|
|
51717
|
+
const { key } = hotkeys[hotkey];
|
|
51687
51718
|
const isControlPushed = event.ctrlKey || event.metaKey;
|
|
51688
51719
|
const isShiftPushed = event.shiftKey;
|
|
51689
51720
|
const isAltPushed = event.altKey;
|
|
@@ -52063,13 +52094,14 @@ function logHotkey(hotkeyConfig, hotkeyName, status, context) {
|
|
|
52063
52094
|
|
|
52064
52095
|
// src/Keyboard/checkHotkeys.ts
|
|
52065
52096
|
function checkHotkeys(hotkeyMap, event, board) {
|
|
52066
|
-
const
|
|
52097
|
+
const fullHotkeysMap = { ...hotkeyMap, ...board.getInterfaceType() === "edit" ? editModeHotkeyRegistry : viewModeHotkeyRegistry };
|
|
52098
|
+
const entries = Object.entries(fullHotkeysMap);
|
|
52067
52099
|
for (const [hotkey, configOrCb] of entries) {
|
|
52068
52100
|
if (isHotkeyPushed(hotkey, event)) {
|
|
52069
52101
|
const context = board.selection.getContext();
|
|
52070
52102
|
if (typeof configOrCb === "function") {
|
|
52071
52103
|
event.preventDefault();
|
|
52072
|
-
configOrCb(event);
|
|
52104
|
+
configOrCb(event, board);
|
|
52073
52105
|
logHotkey(configOrCb, hotkey, "triggered", context);
|
|
52074
52106
|
return true;
|
|
52075
52107
|
}
|
|
@@ -52096,7 +52128,7 @@ function checkHotkeys(hotkeyMap, event, board) {
|
|
|
52096
52128
|
if (preventDefault) {
|
|
52097
52129
|
event.preventDefault();
|
|
52098
52130
|
}
|
|
52099
|
-
cb(event);
|
|
52131
|
+
cb(event, board);
|
|
52100
52132
|
logHotkey(configOrCb, hotkey, "triggered", context);
|
|
52101
52133
|
return true;
|
|
52102
52134
|
}
|
|
@@ -55343,416 +55375,6 @@ class BoardSelection {
|
|
|
55343
55375
|
});
|
|
55344
55376
|
}
|
|
55345
55377
|
}
|
|
55346
|
-
// src/public/customWebComponents.js
|
|
55347
|
-
var customWebComponents_default = `/* eslint-disable max-classes-per-file, @typescript-eslint/no-useless-constructor */
|
|
55348
|
-
class RichTextElement extends HTMLElement {
|
|
55349
|
-
constructor() {
|
|
55350
|
-
super();
|
|
55351
|
-
}
|
|
55352
|
-
}
|
|
55353
|
-
|
|
55354
|
-
class ShapeItemElement extends HTMLElement {
|
|
55355
|
-
constructor() {
|
|
55356
|
-
super();
|
|
55357
|
-
}
|
|
55358
|
-
}
|
|
55359
|
-
|
|
55360
|
-
class StickerElement extends HTMLElement {
|
|
55361
|
-
constructor() {
|
|
55362
|
-
super();
|
|
55363
|
-
}
|
|
55364
|
-
}
|
|
55365
|
-
|
|
55366
|
-
class DrawingElement extends HTMLElement {
|
|
55367
|
-
constructor() {
|
|
55368
|
-
super();
|
|
55369
|
-
}
|
|
55370
|
-
}
|
|
55371
|
-
|
|
55372
|
-
class ConnectorElement extends HTMLElement {
|
|
55373
|
-
constructor() {
|
|
55374
|
-
super();
|
|
55375
|
-
}
|
|
55376
|
-
}
|
|
55377
|
-
|
|
55378
|
-
class FrameItemElement extends HTMLElement {
|
|
55379
|
-
constructor() {
|
|
55380
|
-
super();
|
|
55381
|
-
}
|
|
55382
|
-
}
|
|
55383
|
-
|
|
55384
|
-
class ImageItemElement extends HTMLElement {
|
|
55385
|
-
constructor() {
|
|
55386
|
-
super();
|
|
55387
|
-
}
|
|
55388
|
-
}
|
|
55389
|
-
|
|
55390
|
-
class LinkItemElement extends HTMLElement {
|
|
55391
|
-
constructor() {
|
|
55392
|
-
super();
|
|
55393
|
-
}
|
|
55394
|
-
}
|
|
55395
|
-
|
|
55396
|
-
class AINodeItemElement extends HTMLElement {
|
|
55397
|
-
constructor() {
|
|
55398
|
-
super();
|
|
55399
|
-
}
|
|
55400
|
-
}
|
|
55401
|
-
|
|
55402
|
-
class VideoItemElement extends HTMLElement {
|
|
55403
|
-
constructor() {
|
|
55404
|
-
super();
|
|
55405
|
-
}
|
|
55406
|
-
}
|
|
55407
|
-
|
|
55408
|
-
class CommentElement extends HTMLElement {
|
|
55409
|
-
constructor() {
|
|
55410
|
-
super();
|
|
55411
|
-
}
|
|
55412
|
-
}
|
|
55413
|
-
|
|
55414
|
-
class AudioItemElement extends HTMLElement {
|
|
55415
|
-
constructor() {
|
|
55416
|
-
super();
|
|
55417
|
-
}
|
|
55418
|
-
}
|
|
55419
|
-
|
|
55420
|
-
customElements.define("rich-text", RichTextElement);
|
|
55421
|
-
customElements.define("shape-item", ShapeItemElement);
|
|
55422
|
-
customElements.define("sticker-item", StickerElement);
|
|
55423
|
-
customElements.define("drawing-item", DrawingElement);
|
|
55424
|
-
customElements.define("connector-item", ConnectorElement);
|
|
55425
|
-
customElements.define("frame-item", FrameItemElement);
|
|
55426
|
-
customElements.define("image-item", ImageItemElement);
|
|
55427
|
-
customElements.define("link-item", LinkItemElement);
|
|
55428
|
-
customElements.define("ainode-item", AINodeItemElement);
|
|
55429
|
-
customElements.define("video-item", VideoItemElement);
|
|
55430
|
-
customElements.define("comment-item", CommentElement);
|
|
55431
|
-
customElements.define("audio-item", AudioItemElement);
|
|
55432
|
-
|
|
55433
|
-
document.addEventListener("DOMContentLoaded", () => {
|
|
55434
|
-
const itemsDiv = document.querySelector("#items");
|
|
55435
|
-
if (!itemsDiv) {
|
|
55436
|
-
console.error("ITEMS DIV NOT FOUND!");
|
|
55437
|
-
return;
|
|
55438
|
-
}
|
|
55439
|
-
let isDragging = false;
|
|
55440
|
-
let startX, startY;
|
|
55441
|
-
let translateX = 0;
|
|
55442
|
-
let translateY = 0;
|
|
55443
|
-
let scale = 1;
|
|
55444
|
-
|
|
55445
|
-
itemsDiv.style.transformOrigin = "0 0";
|
|
55446
|
-
document.body.style.cursor = "grab";
|
|
55447
|
-
|
|
55448
|
-
function updateTransform() {
|
|
55449
|
-
itemsDiv.style.transform =
|
|
55450
|
-
"translate(" +
|
|
55451
|
-
translateX +
|
|
55452
|
-
"px, " +
|
|
55453
|
-
translateY +
|
|
55454
|
-
"px) scale(" +
|
|
55455
|
-
scale +
|
|
55456
|
-
")";
|
|
55457
|
-
}
|
|
55458
|
-
|
|
55459
|
-
function handleMouseDown(ev) {
|
|
55460
|
-
isDragging = true;
|
|
55461
|
-
startX = ev.clientX;
|
|
55462
|
-
startY = ev.clientY;
|
|
55463
|
-
itemsDiv.style.cursor = "grabbing";
|
|
55464
|
-
}
|
|
55465
|
-
|
|
55466
|
-
function handleMouseMove(ev) {
|
|
55467
|
-
if (!isDragging) {
|
|
55468
|
-
return;
|
|
55469
|
-
}
|
|
55470
|
-
const dx = ev.clientX - startX;
|
|
55471
|
-
const dy = ev.clientY - startY;
|
|
55472
|
-
startX += dx;
|
|
55473
|
-
startY += dy;
|
|
55474
|
-
translateX += dx;
|
|
55475
|
-
translateY += dy;
|
|
55476
|
-
updateTransform();
|
|
55477
|
-
}
|
|
55478
|
-
|
|
55479
|
-
function handleMouseUp(ev) {
|
|
55480
|
-
if (!isDragging) {
|
|
55481
|
-
return;
|
|
55482
|
-
}
|
|
55483
|
-
isDragging = false;
|
|
55484
|
-
itemsDiv.style.cursor = "grab";
|
|
55485
|
-
}
|
|
55486
|
-
|
|
55487
|
-
function handleWheel(ev) {
|
|
55488
|
-
ev.preventDefault();
|
|
55489
|
-
const factor = ev.deltaY < 0 ? 1.1 : 0.9;
|
|
55490
|
-
translateX = ev.clientX - (ev.clientX - translateX) * factor;
|
|
55491
|
-
translateY = ev.clientY - (ev.clientY - translateY) * factor;
|
|
55492
|
-
scale *= factor;
|
|
55493
|
-
updateTransform();
|
|
55494
|
-
}
|
|
55495
|
-
|
|
55496
|
-
document.addEventListener("mousedown", handleMouseDown);
|
|
55497
|
-
document.addEventListener("mousemove", handleMouseMove);
|
|
55498
|
-
document.addEventListener("mouseup", handleMouseUp);
|
|
55499
|
-
document.addEventListener("wheel", handleWheel, { passive: false });
|
|
55500
|
-
|
|
55501
|
-
const titlePanel = document.createElement("div");
|
|
55502
|
-
titlePanel.style.boxShadow = "0px 10px 16px -3px rgba(20, 21, 26, 0.08)";
|
|
55503
|
-
titlePanel.style.position = "fixed";
|
|
55504
|
-
titlePanel.style.left = "12px";
|
|
55505
|
-
titlePanel.style.top = "12px";
|
|
55506
|
-
titlePanel.style.borderRadius = "12px";
|
|
55507
|
-
titlePanel.style.backgroundColor = "#ffff";
|
|
55508
|
-
titlePanel.style.display = "flex";
|
|
55509
|
-
titlePanel.style.alignItems = "center";
|
|
55510
|
-
titlePanel.style.gap = "8px";
|
|
55511
|
-
titlePanel.style.padding = "0 12px";
|
|
55512
|
-
titlePanel.style.height = "48px";
|
|
55513
|
-
const editButton = document.createElement("button");
|
|
55514
|
-
const editIcon = document.createElementNS(
|
|
55515
|
-
"http://www.w3.org/2000/svg",
|
|
55516
|
-
"svg",
|
|
55517
|
-
);
|
|
55518
|
-
editIcon.setAttribute("width", "13");
|
|
55519
|
-
editIcon.setAttribute("height", "13");
|
|
55520
|
-
editIcon.setAttribute("viewBox", "0 0 13 13");
|
|
55521
|
-
editIcon.setAttribute("fill", "none");
|
|
55522
|
-
editIcon.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
|
55523
|
-
const editIconPath = document.createElementNS(
|
|
55524
|
-
"http://www.w3.org/2000/svg",
|
|
55525
|
-
"path",
|
|
55526
|
-
);
|
|
55527
|
-
editIconPath.setAttribute(
|
|
55528
|
-
"d",
|
|
55529
|
-
"M7.838 0.999902V2.33324H1.33333V11.6666H10.6667V5.1619H12V12.3332C12 12.51 11.9298 12.6796 11.8047 12.8046C11.6797 12.9297 11.5101 12.9999 11.3333 12.9999H0.666667C0.489856 12.9999 0.320286 12.9297 0.195262 12.8046C0.0702379 12.6796 0 12.51 0 12.3332V1.66657C0 1.48976 0.0702379 1.32019 0.195262 1.19516C0.320286 1.07014 0.489856 0.999902 0.666667 0.999902H7.838ZM11.1847 0.872018C11.4453 0.611315 11.868 0.611355 12.1285 0.872108C12.3889 1.1327 12.3889 1.55503 12.1284 1.81553L6.472 7.4719L5.53067 7.4739L5.52933 6.52924L11.1847 0.872018Z",
|
|
55530
|
-
);
|
|
55531
|
-
editIconPath.setAttribute("fill", "#ffff");
|
|
55532
|
-
editIcon.appendChild(editIconPath);
|
|
55533
|
-
editButton.appendChild(editIcon);
|
|
55534
|
-
const editFileText = document.createElement("p");
|
|
55535
|
-
const isSnapshotInIframe =
|
|
55536
|
-
window.parent &&
|
|
55537
|
-
window.parent !== window &&
|
|
55538
|
-
window.parent.location.href.includes("/snapshots/");
|
|
55539
|
-
editFileText.textContent = isSnapshotInIframe ? "Edit copy" : "Edit file";
|
|
55540
|
-
editButton.appendChild(editFileText);
|
|
55541
|
-
|
|
55542
|
-
editButton.style.backgroundColor = "rgba(20, 21, 26, 1)";
|
|
55543
|
-
editButton.style.cursor = "pointer";
|
|
55544
|
-
editButton.style.boxShadow = "0px 1px 2px 0px rgba(20, 21, 26, 0.05)";
|
|
55545
|
-
editButton.style.color = "#ffff";
|
|
55546
|
-
editButton.style.fontSize = "14px";
|
|
55547
|
-
editButton.style.lineHeight = "20px";
|
|
55548
|
-
editButton.style.display = "flex";
|
|
55549
|
-
editButton.style.alignItems = "center";
|
|
55550
|
-
editButton.style.gap = "8px";
|
|
55551
|
-
editButton.style.padding = "8px";
|
|
55552
|
-
editButton.style.borderRadius = "10px";
|
|
55553
|
-
const separator = document.createElement("div");
|
|
55554
|
-
separator.style.borderRight = "1px solid rgba(222, 224, 227, 1)";
|
|
55555
|
-
separator.style.height = "100%";
|
|
55556
|
-
const boardName = document.createElement("div");
|
|
55557
|
-
const fileIcon = document.createElementNS(
|
|
55558
|
-
"http://www.w3.org/2000/svg",
|
|
55559
|
-
"svg",
|
|
55560
|
-
);
|
|
55561
|
-
fileIcon.setAttribute("width", "16");
|
|
55562
|
-
fileIcon.setAttribute("height", "18");
|
|
55563
|
-
fileIcon.setAttribute("viewBox", "0 0 16 18");
|
|
55564
|
-
fileIcon.setAttribute("fill", "none");
|
|
55565
|
-
fileIcon.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
|
55566
|
-
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
55567
|
-
path.setAttribute(
|
|
55568
|
-
"d",
|
|
55569
|
-
"M10.5 2.33341H2.16667V15.6667H13.8333V5.66675H10.5V2.33341ZM0.5 1.49341C0.5 1.03675 0.8725 0.666748 1.3325 0.666748H11.3333L15.5 4.83342V16.4942C15.5008 16.6037 15.48 16.7122 15.4388 16.8136C15.3976 16.915 15.3369 17.0073 15.2601 17.0852C15.1832 17.1631 15.0918 17.2252 14.991 17.2678C14.8902 17.3103 14.7819 17.3327 14.6725 17.3334H1.3275C1.10865 17.3319 0.899181 17.2443 0.744348 17.0897C0.589515 16.935 0.501746 16.7256 0.5 16.5067V1.49341ZM7.16667 8.16675V5.66675H8.83333V8.16675H11.3333V9.83342H8.83333V12.3334H7.16667V9.83342H4.66667V8.16675H7.16667Z",
|
|
55570
|
-
);
|
|
55571
|
-
path.setAttribute("fill", "#696B76");
|
|
55572
|
-
fileIcon.appendChild(path);
|
|
55573
|
-
boardName.appendChild(fileIcon);
|
|
55574
|
-
const boardNameTag = document.querySelector('meta[name="board-name"]');
|
|
55575
|
-
let boardNameStr = "Untitled";
|
|
55576
|
-
if (boardNameTag) {
|
|
55577
|
-
boardNameStr = boardNameTag.getAttribute("content");
|
|
55578
|
-
}
|
|
55579
|
-
const p = document.createElement("p");
|
|
55580
|
-
p.textContent = boardNameStr;
|
|
55581
|
-
p.style.fontSize = "16px";
|
|
55582
|
-
p.style.lineHeight = "24px";
|
|
55583
|
-
boardName.appendChild(p);
|
|
55584
|
-
const cloudIcon = document.createElementNS(
|
|
55585
|
-
"http://www.w3.org/2000/svg",
|
|
55586
|
-
"svg",
|
|
55587
|
-
);
|
|
55588
|
-
cloudIcon.setAttribute("width", "20");
|
|
55589
|
-
cloudIcon.setAttribute("height", "18");
|
|
55590
|
-
cloudIcon.setAttribute("viewBox", "0 0 20 18");
|
|
55591
|
-
cloudIcon.setAttribute("fill", "none");
|
|
55592
|
-
cloudIcon.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
|
55593
|
-
const cloudIconPath = document.createElementNS(
|
|
55594
|
-
"http://www.w3.org/2000/svg",
|
|
55595
|
-
"path",
|
|
55596
|
-
);
|
|
55597
|
-
cloudIconPath.setAttribute(
|
|
55598
|
-
"d",
|
|
55599
|
-
"M2.92711 0.75009L18.8371 16.6601L17.6579 17.8393L15.9796 16.1601C15.401 16.3854 14.7855 16.5007 14.1646 16.5001H5.83128C4.65063 16.5008 3.50782 16.0838 2.60518 15.3227C1.70255 14.5617 1.09833 13.5058 0.89953 12.342C0.700726 11.1782 0.920157 9.98165 1.51897 8.96413C2.11778 7.94662 3.05734 7.17382 4.17128 6.78259C4.13561 6.05854 4.23538 5.3342 4.46544 4.64676L1.74794 1.92842L2.92711 0.75009ZM5.83128 6.50009C5.83128 6.56759 5.83294 6.63592 5.83628 6.70259L5.89461 7.94259L4.72461 8.35426C3.98336 8.6164 3.35857 9.132 2.96052 9.81003C2.56248 10.4881 2.41678 11.2849 2.54916 12.0599C2.68153 12.8349 3.08347 13.5383 3.684 14.0457C4.28453 14.5532 5.04504 14.8322 5.83128 14.8334H14.1646C14.3196 14.8334 14.4721 14.8226 14.6213 14.8026L5.85628 6.03759C5.83961 6.18926 5.83128 6.34342 5.83128 6.50009ZM9.99794 0.666756C10.7878 0.666732 11.5694 0.827112 12.2954 1.13817C13.0214 1.44923 13.6767 1.90449 14.2215 2.47635C14.7664 3.04821 15.1894 3.72476 15.4649 4.46498C15.7405 5.2052 15.8629 5.99367 15.8246 6.78259C16.5167 7.02639 17.1467 7.41945 17.6699 7.93391C18.1931 8.44837 18.5967 9.07163 18.8521 9.75951C19.1076 10.4474 19.2085 11.183 19.1479 11.9143C19.0873 12.6455 18.8665 13.3545 18.5013 13.9909L17.2571 12.7468C17.5023 12.1401 17.5636 11.4747 17.4331 10.8335C17.3027 10.1924 16.9864 9.60375 16.5237 9.14112C16.061 8.67849 15.4723 8.36232 14.8311 8.23202C14.1899 8.10173 13.5245 8.16308 12.9179 8.40842L11.6729 7.16259C12.4071 6.74176 13.2571 6.50009 14.1646 6.50009C14.1646 5.73714 13.9551 4.98884 13.559 4.33679C13.1629 3.68473 12.5953 3.15396 11.9182 2.80235C11.2411 2.45073 10.4805 2.29177 9.71923 2.34281C8.95799 2.39384 8.22538 2.65291 7.60127 3.09176L6.40961 1.90009C7.43392 1.09887 8.69749 0.664571 9.99794 0.666756Z",
|
|
55600
|
-
);
|
|
55601
|
-
cloudIconPath.setAttribute("fill", "#696B76");
|
|
55602
|
-
cloudIcon.appendChild(cloudIconPath);
|
|
55603
|
-
boardName.appendChild(cloudIcon);
|
|
55604
|
-
boardName.style.display = "flex";
|
|
55605
|
-
boardName.style.alignItems = "center";
|
|
55606
|
-
boardName.style.gap = "8px";
|
|
55607
|
-
titlePanel.appendChild(boardName);
|
|
55608
|
-
titlePanel.appendChild(separator);
|
|
55609
|
-
titlePanel.appendChild(editButton);
|
|
55610
|
-
document.body.appendChild(titlePanel);
|
|
55611
|
-
|
|
55612
|
-
editButton.onclick = async () => {
|
|
55613
|
-
editButton.disabled = true;
|
|
55614
|
-
editButton.textContent = "Loading...";
|
|
55615
|
-
|
|
55616
|
-
try {
|
|
55617
|
-
document.removeEventListener("mousedown", handleMouseDown);
|
|
55618
|
-
document.removeEventListener("mousemove", handleMouseMove);
|
|
55619
|
-
document.removeEventListener("mouseup", handleMouseUp);
|
|
55620
|
-
document.removeEventListener("wheel", handleWheel, {
|
|
55621
|
-
passive: false,
|
|
55622
|
-
});
|
|
55623
|
-
translateX = 0;
|
|
55624
|
-
translateY = 0;
|
|
55625
|
-
scale = 1;
|
|
55626
|
-
updateTransform();
|
|
55627
|
-
|
|
55628
|
-
const { initBrowserSettings } = await import(
|
|
55629
|
-
"https://www.unpkg.com/test_package_board@0.0.99/dist/bundle.js"
|
|
55630
|
-
);
|
|
55631
|
-
initBrowserSettings();
|
|
55632
|
-
|
|
55633
|
-
const { createApp } = await import(
|
|
55634
|
-
"https://www.unpkg.com/test_package_board@0.0.99/dist/bundle.js"
|
|
55635
|
-
);
|
|
55636
|
-
|
|
55637
|
-
const app = createApp();
|
|
55638
|
-
window.app = app;
|
|
55639
|
-
const stringed = await app.openAndEditFile();
|
|
55640
|
-
|
|
55641
|
-
if (stringed) {
|
|
55642
|
-
await app.openBoardFromFile();
|
|
55643
|
-
app.getBoard().deserializeHTML(stringed);
|
|
55644
|
-
app.localRender("items");
|
|
55645
|
-
}
|
|
55646
|
-
|
|
55647
|
-
const response = await fetch(
|
|
55648
|
-
"https://www.unpkg.com/test_package_board@0.0.99/dist/bundle.css",
|
|
55649
|
-
);
|
|
55650
|
-
const cssText = await response.text();
|
|
55651
|
-
const styleEl = document.createElement("style");
|
|
55652
|
-
styleEl.textContent = cssText;
|
|
55653
|
-
document.body.appendChild(styleEl);
|
|
55654
|
-
|
|
55655
|
-
const responseSvg = await fetch(
|
|
55656
|
-
"https://www.unpkg.com/test_package_board@0.0.99/dist/sprite.svg",
|
|
55657
|
-
);
|
|
55658
|
-
const svgText = await responseSvg.text();
|
|
55659
|
-
const div = document.createElement("div");
|
|
55660
|
-
div.style.display = "none";
|
|
55661
|
-
div.id = "sprite";
|
|
55662
|
-
div.innerHTML = svgText;
|
|
55663
|
-
document.body.appendChild(div);
|
|
55664
|
-
} finally {
|
|
55665
|
-
editButton.disabled = false;
|
|
55666
|
-
editButton.textContent = "Edit board";
|
|
55667
|
-
}
|
|
55668
|
-
};
|
|
55669
|
-
});
|
|
55670
|
-
`;
|
|
55671
|
-
|
|
55672
|
-
// src/public/index.css
|
|
55673
|
-
var public_default = `@import "https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&display=swap";
|
|
55674
|
-
@import "https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&display=swap";
|
|
55675
|
-
|
|
55676
|
-
/* ../src/index.css */
|
|
55677
|
-
:root {
|
|
55678
|
-
--background-surface-default: rgb(255, 255, 255);
|
|
55679
|
-
--background-button-secondary: rgb(255, 255, 255);
|
|
55680
|
-
--background-button-secondary-hover: rgb(247, 247, 248);
|
|
55681
|
-
--background-badge-purple-disabled: rgb(247, 241, 253);
|
|
55682
|
-
--background-badge-gray: rgb(233, 234, 236);
|
|
55683
|
-
--background-accent-purple: rgb(146, 79, 232);
|
|
55684
|
-
--border-action-normal: rgb(222, 223, 227);
|
|
55685
|
-
--border-action-focus: rgb(146, 79, 232);
|
|
55686
|
-
--border-select-primary: rgb(146, 79, 232);
|
|
55687
|
-
--text-base-primary: rgb(20, 21, 26);
|
|
55688
|
-
--text-base-secondary: rgba(15, 19, 36, 0.6);
|
|
55689
|
-
--text-base-quaternary: rgb(10, 15, 41, 0.25);
|
|
55690
|
-
--text-accent-purple: rgb(152, 89, 233);
|
|
55691
|
-
--icon-base-primary: rgb(20, 21, 26);
|
|
55692
|
-
--icon-base-secondary: rgb(105, 107, 118);
|
|
55693
|
-
--icon-accent-purple: rgb(146, 79, 232);
|
|
55694
|
-
--absolute-position-panel-padding: 12px;
|
|
55695
|
-
}
|
|
55696
|
-
* {
|
|
55697
|
-
box-sizing: border-box;
|
|
55698
|
-
padding: 0;
|
|
55699
|
-
margin: 0;
|
|
55700
|
-
border: none;
|
|
55701
|
-
background: none;
|
|
55702
|
-
font-family: inherit;
|
|
55703
|
-
}
|
|
55704
|
-
html {
|
|
55705
|
-
font-size: 62.5%;
|
|
55706
|
-
}
|
|
55707
|
-
body {
|
|
55708
|
-
color: var(--text-base-primary);
|
|
55709
|
-
font-size: 1.6rem;
|
|
55710
|
-
font-optical-sizing: auto;
|
|
55711
|
-
font-style: normal;
|
|
55712
|
-
font-family: "Manrope", sans-serif;
|
|
55713
|
-
}
|
|
55714
|
-
html,
|
|
55715
|
-
body {
|
|
55716
|
-
overscroll-behavior-x: none;
|
|
55717
|
-
-webkit-user-select: none;
|
|
55718
|
-
}
|
|
55719
|
-
input:-webkit-autofill,
|
|
55720
|
-
input:-webkit-autofill:hover,
|
|
55721
|
-
input:-webkit-autofill:focus,
|
|
55722
|
-
input:-webkit-autofill:active {
|
|
55723
|
-
-webkit-box-shadow: 0 0 0 30px white inset !important;
|
|
55724
|
-
}
|
|
55725
|
-
`;
|
|
55726
|
-
|
|
55727
|
-
// src/public/loadLinkImages.js
|
|
55728
|
-
var loadLinkImages_default = `document.addEventListener("DOMContentLoaded", function () {
|
|
55729
|
-
document.querySelectorAll(".link-object").forEach(linkItem => {
|
|
55730
|
-
const linkImage = linkItem.querySelector(".link-image");
|
|
55731
|
-
const linkContainer = linkItem.querySelector("a");
|
|
55732
|
-
linkImage.onerror = () => {
|
|
55733
|
-
linkImage.onerror = null;
|
|
55734
|
-
linkImage.style.display = "none";
|
|
55735
|
-
const svgNamespace = "http://www.w3.org/2000/svg";
|
|
55736
|
-
const svg = document.createElementNS(svgNamespace, "svg");
|
|
55737
|
-
svg.setAttribute("width", "20");
|
|
55738
|
-
svg.setAttribute("height", "20");
|
|
55739
|
-
svg.setAttribute("viewBox", "0 0 13 14");
|
|
55740
|
-
svg.setAttribute("fill", "none");
|
|
55741
|
-
|
|
55742
|
-
const path = document.createElementNS(svgNamespace, "path");
|
|
55743
|
-
path.setAttribute(
|
|
55744
|
-
"d",
|
|
55745
|
-
"M11.0054 3.414L2.39838 12.021L0.984375 10.607L9.59037 2H2.00538V0H13.0054V11H11.0054V3.414Z",
|
|
55746
|
-
);
|
|
55747
|
-
path.setAttribute("fill", "#924FE8");
|
|
55748
|
-
svg.appendChild(path);
|
|
55749
|
-
|
|
55750
|
-
linkContainer.appendChild(svg);
|
|
55751
|
-
};
|
|
55752
|
-
});
|
|
55753
|
-
});
|
|
55754
|
-
`;
|
|
55755
|
-
|
|
55756
55378
|
// src/Board.ts
|
|
55757
55379
|
class Board {
|
|
55758
55380
|
boardId;
|
|
@@ -56135,47 +55757,29 @@ class Board {
|
|
|
56135
55757
|
return this.copy();
|
|
56136
55758
|
}
|
|
56137
55759
|
serializeHTML() {
|
|
56138
|
-
const customTagsScript = customWebComponents_default;
|
|
56139
|
-
const loadLinksImagesScript = loadLinkImages_default;
|
|
56140
|
-
const css = public_default;
|
|
56141
55760
|
const boardName = this.getName() || this.getBoardId();
|
|
56142
55761
|
const items = this.items.getWholeHTML(conf.documentFactory);
|
|
56143
55762
|
const itemsDiv = `<div id="items">${items}</div>`;
|
|
56144
55763
|
const scripts = `
|
|
56145
|
-
<script type="module"
|
|
56146
|
-
|
|
55764
|
+
<script type="module" src="https://unpkg.com/microboard-ui-temp/dist/customWebComponents.js"></script>
|
|
55765
|
+
<script type="module" src="https://unpkg.com/microboard-ui-temp/dist/controlsHandlers.js"></script>
|
|
55766
|
+
<script type="module" src="https://unpkg.com/microboard-ui-temp/dist/titlePanel.js"></script>
|
|
55767
|
+
<script defer src="https://unpkg.com/microboard-ui-temp/dist/loadLinksImages.js"></script>
|
|
56147
55768
|
`;
|
|
56148
55769
|
const body = `<body style="overflow-x: hidden; overflow-y: hidden;">${itemsDiv}${scripts}</body>`;
|
|
56149
55770
|
const head = `
|
|
56150
|
-
|
|
56151
|
-
|
|
56152
|
-
|
|
56153
|
-
|
|
56154
|
-
|
|
56155
|
-
|
|
56156
|
-
|
|
56157
|
-
|
|
56158
|
-
|
|
56159
|
-
|
|
56160
|
-
|
|
56161
|
-
|
|
56162
|
-
appearance: none;
|
|
56163
|
-
width: 3px;
|
|
56164
|
-
height: 3px
|
|
56165
|
-
}
|
|
56166
|
-
::-webkit-scrollbar-button {
|
|
56167
|
-
display: none;
|
|
56168
|
-
}
|
|
56169
|
-
::-webkit-scrollbar-thumb {
|
|
56170
|
-
display: block;
|
|
56171
|
-
background-color: black;
|
|
56172
|
-
border-radius: 2px;
|
|
56173
|
-
}
|
|
56174
|
-
body {
|
|
56175
|
-
background-color: rgba(200, 200, 200, 0.2);
|
|
56176
|
-
}
|
|
56177
|
-
</style>
|
|
56178
|
-
</head>`.replace(/\t|\n/g, "");
|
|
55771
|
+
<head>
|
|
55772
|
+
<meta charset="utf-8" />
|
|
55773
|
+
<meta name="last-event-order" content="${this.events?.log.getLastIndex()}" />
|
|
55774
|
+
<title>Microboard ${boardName}</title>
|
|
55775
|
+
<link rel="preconnect" href="https://fonts.googleapis.com" />
|
|
55776
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
|
|
55777
|
+
<link
|
|
55778
|
+
href="https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&display=swap"
|
|
55779
|
+
rel="stylesheet"
|
|
55780
|
+
/>
|
|
55781
|
+
<link rel="stylesheet" crossorigin href="https://unpkg.com/microboard-ui-temp/dist/board.css" />
|
|
55782
|
+
</head>`.replace(/\t|\n/g, "");
|
|
56179
55783
|
return `${head}${body}`;
|
|
56180
55784
|
}
|
|
56181
55785
|
deserializeHTMLAndEmit(stringedHTML) {
|
|
@@ -56245,7 +55849,10 @@ class Board {
|
|
|
56245
55849
|
const addItem = (itemData) => {
|
|
56246
55850
|
const item = this.createItem(itemData.id, itemData);
|
|
56247
55851
|
if (item instanceof Connector2) {
|
|
56248
|
-
createdConnectors[itemData.id] = {
|
|
55852
|
+
createdConnectors[itemData.id] = {
|
|
55853
|
+
item,
|
|
55854
|
+
itemData
|
|
55855
|
+
};
|
|
56249
55856
|
}
|
|
56250
55857
|
if ("index" in item && item.index) {
|
|
56251
55858
|
createdGroups[item.getId()] = { item, itemData };
|
|
@@ -56280,10 +55887,16 @@ class Board {
|
|
|
56280
55887
|
for (const itemData of items) {
|
|
56281
55888
|
const item = this.createItem(itemData.id, itemData);
|
|
56282
55889
|
if (item instanceof Connector2) {
|
|
56283
|
-
createdConnectors[itemData.id] = {
|
|
55890
|
+
createdConnectors[itemData.id] = {
|
|
55891
|
+
item,
|
|
55892
|
+
itemData
|
|
55893
|
+
};
|
|
56284
55894
|
}
|
|
56285
55895
|
if ("index" in item && item.index) {
|
|
56286
|
-
createdGroups[item.getId()] = {
|
|
55896
|
+
createdGroups[item.getId()] = {
|
|
55897
|
+
item,
|
|
55898
|
+
itemData
|
|
55899
|
+
};
|
|
56287
55900
|
}
|
|
56288
55901
|
this.index.insert(item);
|
|
56289
55902
|
}
|
|
@@ -59353,6 +58966,7 @@ function initNodeSettings() {
|
|
|
59353
58966
|
// src/node.ts
|
|
59354
58967
|
initNodeSettings();
|
|
59355
58968
|
export {
|
|
58969
|
+
viewModeHotkeyRegistry,
|
|
59356
58970
|
validateRichTextData,
|
|
59357
58971
|
validateItemsMap,
|
|
59358
58972
|
uploadVideoToStorage,
|
|
@@ -59392,6 +59006,7 @@ export {
|
|
|
59392
59006
|
isFiniteNumber,
|
|
59393
59007
|
isControlCharacter,
|
|
59394
59008
|
initI18N,
|
|
59009
|
+
hotkeyNames,
|
|
59395
59010
|
getYouTubeVideoPreview,
|
|
59396
59011
|
getYouTubeThumbnail,
|
|
59397
59012
|
getVideoMetadata,
|
|
@@ -59406,6 +59021,7 @@ export {
|
|
|
59406
59021
|
forceNumberIntoInterval,
|
|
59407
59022
|
fileTosha256,
|
|
59408
59023
|
exportBoardSnapshot,
|
|
59024
|
+
editModeHotkeyRegistry,
|
|
59409
59025
|
decodeHtml,
|
|
59410
59026
|
defaultCursors as cursors,
|
|
59411
59027
|
createVideoItem,
|
package/dist/microboard.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
.microboard-quickAddButton{transform-origin:50%;z-index:2;background-color:#93aff6;border:1px solid #fff;-webkit-border-radius:50%;border-radius:50%;margin:auto;padding:14px;transition:transform .2s,border 0s .2s;position:absolute;transform:translate(-50%,-50%)scale(.25)}.microboard-invisible{display:none}.microboard-quickAddButtonActive{background-color:#924fe8;border:none;transform:translate(-50%,-50%)scale(1)}.microboard-quickAddButton:after{content:"";opacity:1;-webkit-border-radius:50%;border-radius:50%;transition:all .2s .2s;position:absolute;top:0;bottom:0;left:0;right:0;transform:scale(4)}.microboard-quickAddButtonActive:after{opacity:0;transform:none}.microboard-quickAddButton:before{content:"";--quick-add-button-width:17px;--quick-add-button-height:10px;width:var(--quick-add-button-width);height:var(--quick-add-button-height);opacity:0;transform-origin:50%;background:url("data:image/svg+xml;utf8,<svg width=\"var(--quick-add-button-width)\" height=\"var(--quick-add-button-height)\" viewBox=\"0 0 17 10\" fill=\"none\" xmlns=\"http://www.w3.org/2000/svg\"><path d=\"M16.7593 5.00009L10.5339 9.58329L9.68819 8.30677L12.9245 5.83329H0.0415039V4.16663H12.9241L9.68819 1.69341L10.5339 0.416626L16.7593 5.00009Z\" fill=\"white\"/></svg>") no-repeat;transition:opacity .2s;position:absolute;top:35%;left:20%}.microboard-quickAddButtonActive:before{opacity:1}.microboard-quickAddButton.microboard-left:before{rotate:180deg}.microboard-quickAddButton.microboard-right:before{rotate:none}.microboard-quickAddButton.microboard-top:before{rotate:270deg}.microboard-quickAddButton.microboard-bottom:before{rotate:90deg}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type Hotkey, HotkeyConfig, HotkeysMap } from "./types";
|
|
2
|
+
import { Board } from "../Board";
|
|
3
|
+
export declare const editModeHotkeyRegistry: HotkeysMap;
|
|
4
|
+
export declare const viewModeHotkeyRegistry: HotkeysMap;
|
|
5
|
+
export declare const hotkeyNames: Record<string, Hotkey>;
|
|
6
|
+
type RegisterHotkeyArgs = {
|
|
7
|
+
name: string;
|
|
8
|
+
hotkey: Hotkey;
|
|
9
|
+
hotkeyConfig: HotkeyConfig | ((event?: KeyboardEvent, board?: Board) => void);
|
|
10
|
+
boardMode: "view" | "edit";
|
|
11
|
+
};
|
|
12
|
+
export declare function registerHotkey({ name, hotkey, hotkeyConfig, boardMode }: RegisterHotkeyArgs): void;
|
|
13
|
+
export {};
|
|
@@ -14,4 +14,5 @@ export { isHotkeyPushed } from "./isHotkeyPushed";
|
|
|
14
14
|
export * from "./checkHotkeys";
|
|
15
15
|
export { getHotkeyLabel } from "./getHotkeyLabel";
|
|
16
16
|
export { isControlCharacter } from "./isControlCharacter";
|
|
17
|
+
export { editModeHotkeyRegistry, viewModeHotkeyRegistry, hotkeyNames } from "./HotkeyRegistry";
|
|
17
18
|
export type { HotkeysMap } from "./types";
|
package/package.json
CHANGED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
declare class RichTextElement extends HTMLElement {
|
|
2
|
-
}
|
|
3
|
-
declare class ShapeItemElement extends HTMLElement {
|
|
4
|
-
}
|
|
5
|
-
declare class StickerElement extends HTMLElement {
|
|
6
|
-
}
|
|
7
|
-
declare class DrawingElement extends HTMLElement {
|
|
8
|
-
}
|
|
9
|
-
declare class ConnectorElement extends HTMLElement {
|
|
10
|
-
}
|
|
11
|
-
declare class FrameItemElement extends HTMLElement {
|
|
12
|
-
}
|
|
13
|
-
declare class ImageItemElement extends HTMLElement {
|
|
14
|
-
}
|
|
15
|
-
declare class LinkItemElement extends HTMLElement {
|
|
16
|
-
}
|
|
17
|
-
declare class AINodeItemElement extends HTMLElement {
|
|
18
|
-
}
|
|
19
|
-
declare class VideoItemElement extends HTMLElement {
|
|
20
|
-
}
|
|
21
|
-
declare class CommentElement extends HTMLElement {
|
|
22
|
-
}
|
|
23
|
-
declare class AudioItemElement extends HTMLElement {
|
|
24
|
-
}
|