microboard-temp 0.4.5 → 0.4.7
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 +590 -120
- package/dist/cjs/index.js +590 -120
- package/dist/cjs/node.js +590 -120
- package/dist/esm/browser.js +591 -121
- package/dist/esm/index.js +591 -121
- package/dist/esm/node.js +591 -121
- package/dist/types/BoardOperations.d.ts +7 -1
- package/dist/types/Items/AINode/AINode.d.ts +2 -1
- package/dist/types/Items/BaseItem/BaseItem.d.ts +1 -0
- package/dist/types/Items/Comment/Comment.d.ts +1 -0
- package/dist/types/Items/Curve/Curve.d.ts +2 -0
- package/dist/types/Items/Line/Line.d.ts +1 -0
- package/dist/types/Items/RichText/CanvasText/LayoutBlockNodes.d.ts +2 -1
- package/dist/types/Items/RichText/CanvasText/Render.d.ts +61 -0
- package/dist/types/Items/RichText/Editor/BlockNode.d.ts +5 -11
- package/dist/types/Items/RichText/editorHelpers/common/getAreAllChildrenEmpty.d.ts +2 -1
- package/dist/types/Items/RichText/setNodeStyles.d.ts +2 -2
- package/dist/types/Items/Shape/Shape.d.ts +1 -0
- package/dist/types/Selection/QuickAddButtons/quickAddHelpers.d.ts +1 -1
- package/dist/types/Selection/Selection.d.ts +3 -3
- package/dist/types/SpatialIndex/SpacialIndex.d.ts +3 -3
- package/dist/types/public/customWebComponents.d.ts +24 -0
- package/dist/types/public/loadLinkImages.d.ts +0 -0
- package/package.json +19 -19
package/dist/esm/node.js
CHANGED
|
@@ -2251,6 +2251,9 @@ class Line {
|
|
|
2251
2251
|
getStartPoint() {
|
|
2252
2252
|
return this.start;
|
|
2253
2253
|
}
|
|
2254
|
+
getEndPoint() {
|
|
2255
|
+
return this.end;
|
|
2256
|
+
}
|
|
2254
2257
|
getLength() {
|
|
2255
2258
|
const { start, end } = this;
|
|
2256
2259
|
const deltaX = end.x - start.x;
|
|
@@ -3848,6 +3851,9 @@ class QuadraticBezier extends BaseCurve {
|
|
|
3848
3851
|
getStartPoint() {
|
|
3849
3852
|
return this.start;
|
|
3850
3853
|
}
|
|
3854
|
+
getEndPoint() {
|
|
3855
|
+
return this.end;
|
|
3856
|
+
}
|
|
3851
3857
|
moveToStart(ctx) {
|
|
3852
3858
|
ctx.moveTo(this.start.x, this.start.y);
|
|
3853
3859
|
}
|
|
@@ -3891,6 +3897,9 @@ class CubicBezier extends BaseCurve {
|
|
|
3891
3897
|
getStartPoint() {
|
|
3892
3898
|
return this.start;
|
|
3893
3899
|
}
|
|
3900
|
+
getEndPoint() {
|
|
3901
|
+
return this.end;
|
|
3902
|
+
}
|
|
3894
3903
|
moveToStart(ctx) {
|
|
3895
3904
|
ctx.moveTo(this.start.x, this.start.y);
|
|
3896
3905
|
}
|
|
@@ -7993,25 +8002,33 @@ class TransformationCommand {
|
|
|
7993
8002
|
x: 1 / op2.x,
|
|
7994
8003
|
y: 1 / op2.y
|
|
7995
8004
|
};
|
|
8005
|
+
} else {
|
|
8006
|
+
reverseOp = {
|
|
8007
|
+
...op2,
|
|
8008
|
+
x: 1,
|
|
8009
|
+
y: 1
|
|
8010
|
+
};
|
|
7996
8011
|
}
|
|
7997
8012
|
return { item: currTrans, operation: reverseOp };
|
|
7998
8013
|
});
|
|
7999
8014
|
}
|
|
8000
8015
|
case "locked": {
|
|
8016
|
+
const op2 = this.operation;
|
|
8001
8017
|
return mapItemsByOperation(this.transformation, () => {
|
|
8002
8018
|
return {
|
|
8003
|
-
...
|
|
8004
|
-
item: [...
|
|
8019
|
+
...op2,
|
|
8020
|
+
item: [...op2.item],
|
|
8005
8021
|
method: "unlocked",
|
|
8006
8022
|
locked: false
|
|
8007
8023
|
};
|
|
8008
8024
|
});
|
|
8009
8025
|
}
|
|
8010
8026
|
case "unlocked": {
|
|
8027
|
+
const op2 = this.operation;
|
|
8011
8028
|
return mapItemsByOperation(this.transformation, () => {
|
|
8012
8029
|
return {
|
|
8013
|
-
...
|
|
8014
|
-
item: [...
|
|
8030
|
+
...op2,
|
|
8031
|
+
item: [...op2.item],
|
|
8015
8032
|
method: "locked",
|
|
8016
8033
|
locked: true
|
|
8017
8034
|
};
|
|
@@ -9622,6 +9639,13 @@ var tagByType = {
|
|
|
9622
9639
|
Comment: "comment-item",
|
|
9623
9640
|
Group: ""
|
|
9624
9641
|
};
|
|
9642
|
+
var headingTagsMap = {
|
|
9643
|
+
h1: "heading_one",
|
|
9644
|
+
h2: "heading_two",
|
|
9645
|
+
h3: "heading_three",
|
|
9646
|
+
h4: "heading_four",
|
|
9647
|
+
h5: "heading_five"
|
|
9648
|
+
};
|
|
9625
9649
|
var parsersHTML = {
|
|
9626
9650
|
"sticker-item": parseHTMLSticker,
|
|
9627
9651
|
"shape-item": parseHTMLShape,
|
|
@@ -9646,12 +9670,12 @@ function getTransformationData(el) {
|
|
|
9646
9670
|
if (transformMatch) {
|
|
9647
9671
|
const [, translateX, translateY, scaleX, scaleY] = transformMatch.map(Number);
|
|
9648
9672
|
const matrix = new Matrix2(translateX, translateY, scaleX, scaleY);
|
|
9649
|
-
return { ...matrix, rotate: 0 };
|
|
9673
|
+
return { ...matrix, rotate: 0, isLocked: false };
|
|
9650
9674
|
}
|
|
9651
|
-
return { ...new Matrix2, rotate: 0 };
|
|
9675
|
+
return { ...new Matrix2, rotate: 0, isLocked: false };
|
|
9652
9676
|
}
|
|
9653
9677
|
function parseHTMLRichText(el, options) {
|
|
9654
|
-
const parseNode = (node) => {
|
|
9678
|
+
const parseNode = (node, nestingLevel = 1) => {
|
|
9655
9679
|
const isLinkNode = node.tagName.toLowerCase() === "a";
|
|
9656
9680
|
if (node.tagName.toLowerCase() === "span" || isLinkNode && node.children.length === 0) {
|
|
9657
9681
|
const isSingleSpace = node.textContent?.length === 1 && node.textContent?.trim() === "";
|
|
@@ -9674,7 +9698,7 @@ function parseHTMLRichText(el, options) {
|
|
|
9674
9698
|
superscript: false
|
|
9675
9699
|
};
|
|
9676
9700
|
}
|
|
9677
|
-
const children2 = Array.from(node.children).map((child) => parseNode(child));
|
|
9701
|
+
const children2 = Array.from(node.children).map((child) => parseNode(child, nestingLevel + 1));
|
|
9678
9702
|
const tagName = node.tagName.toLowerCase();
|
|
9679
9703
|
const extractCommonProps = () => ({
|
|
9680
9704
|
horisontalAlignment: node.style.textAlign || "left",
|
|
@@ -9682,23 +9706,19 @@ function parseHTMLRichText(el, options) {
|
|
|
9682
9706
|
paddingBottom: parseFloat(node.style.paddingBottom) || undefined
|
|
9683
9707
|
});
|
|
9684
9708
|
switch (tagName) {
|
|
9685
|
-
case "blockquote":
|
|
9686
|
-
return {
|
|
9687
|
-
type: "block-quote",
|
|
9688
|
-
...extractCommonProps(),
|
|
9689
|
-
children: children2
|
|
9690
|
-
};
|
|
9691
9709
|
case "ul":
|
|
9692
9710
|
return {
|
|
9693
9711
|
type: "ul_list",
|
|
9694
9712
|
...extractCommonProps(),
|
|
9695
|
-
children: children2
|
|
9713
|
+
children: children2,
|
|
9714
|
+
listLevel: nestingLevel
|
|
9696
9715
|
};
|
|
9697
9716
|
case "ol":
|
|
9698
9717
|
return {
|
|
9699
9718
|
type: "ol_list",
|
|
9700
9719
|
...extractCommonProps(),
|
|
9701
|
-
children: children2
|
|
9720
|
+
children: children2,
|
|
9721
|
+
listLevel: nestingLevel
|
|
9702
9722
|
};
|
|
9703
9723
|
case "li":
|
|
9704
9724
|
return {
|
|
@@ -9720,11 +9740,9 @@ function parseHTMLRichText(el, options) {
|
|
|
9720
9740
|
case "h2":
|
|
9721
9741
|
case "h3":
|
|
9722
9742
|
case "h4":
|
|
9723
|
-
case "h5":
|
|
9724
|
-
case "h6": {
|
|
9725
|
-
const headingType = `heading_${["one", "two", "three", "four", "five", "six"][parseInt(tagName[1]) - 1]}`;
|
|
9743
|
+
case "h5": {
|
|
9726
9744
|
return {
|
|
9727
|
-
type:
|
|
9745
|
+
type: headingTagsMap[tagName],
|
|
9728
9746
|
...extractCommonProps(),
|
|
9729
9747
|
children: children2
|
|
9730
9748
|
};
|
|
@@ -9928,6 +9946,7 @@ function parseHTMLConnector(el) {
|
|
|
9928
9946
|
...endPointType === "FixedConnector" ? { segment: startSegment, tangent: endTangent } : {}
|
|
9929
9947
|
};
|
|
9930
9948
|
const connectorData = {
|
|
9949
|
+
middlePoint: null,
|
|
9931
9950
|
id: el.id,
|
|
9932
9951
|
itemType: "Connector",
|
|
9933
9952
|
transformation,
|
|
@@ -9988,6 +10007,7 @@ function parseHTMLDrawing(el) {
|
|
|
9988
10007
|
}
|
|
9989
10008
|
function parseHTMLAINode(el) {
|
|
9990
10009
|
const aiNodeData = {
|
|
10010
|
+
threadDirection: 3,
|
|
9991
10011
|
id: el.id,
|
|
9992
10012
|
itemType: "AINode",
|
|
9993
10013
|
parentNodeId: el.getAttribute("parent-node-id") || undefined,
|
|
@@ -10321,17 +10341,18 @@ function getBlockNode(data, maxWidth, isFrame, listData, listMark, newLine = fal
|
|
|
10321
10341
|
break;
|
|
10322
10342
|
default:
|
|
10323
10343
|
if ("text" in child && typeof child.text === "string") {
|
|
10324
|
-
const
|
|
10344
|
+
const textNode = child;
|
|
10345
|
+
const fontScale2 = (textNode.fontSize === "auto" ? 14 : textNode.fontSize ?? 14) / 14;
|
|
10325
10346
|
handleTextNode({
|
|
10326
10347
|
isFrame,
|
|
10327
|
-
child,
|
|
10348
|
+
child: textNode,
|
|
10328
10349
|
node,
|
|
10329
10350
|
maxWidth,
|
|
10330
10351
|
paddingTop: i === 0 ? 16 * (data.paddingTop || 0) : 0,
|
|
10331
10352
|
marginLeft: (listData ? fontScale2 * 16 : 0) + (listData?.level || 0) * fontScale2 * 24,
|
|
10332
10353
|
newLine: i === 0 ? newLine : false,
|
|
10333
10354
|
listMark: i === 0 ? listMark : undefined,
|
|
10334
|
-
link:
|
|
10355
|
+
link: textNode.link
|
|
10335
10356
|
});
|
|
10336
10357
|
} else {
|
|
10337
10358
|
const blockNode = getBlockNode(child, maxWidth, isFrame, listData, i === 0 ? listMark : undefined, true);
|
|
@@ -10375,7 +10396,8 @@ function getTextNode(data) {
|
|
|
10375
10396
|
type: "text",
|
|
10376
10397
|
text,
|
|
10377
10398
|
style: getTextStyle(data),
|
|
10378
|
-
blocks: []
|
|
10399
|
+
blocks: [],
|
|
10400
|
+
newLine: false
|
|
10379
10401
|
};
|
|
10380
10402
|
return node;
|
|
10381
10403
|
}
|
|
@@ -10621,7 +10643,7 @@ function setBlockNodeCoordinates(blockNode) {
|
|
|
10621
10643
|
}
|
|
10622
10644
|
lineBottom += maxFontSize * lineHeight;
|
|
10623
10645
|
leading = maxFontSize * lineHeight - maxFontSize;
|
|
10624
|
-
yOffset = lineBottom - leading / 2 - highestBlock
|
|
10646
|
+
yOffset = lineBottom - leading / 2 - (highestBlock?.measure.descent || 0);
|
|
10625
10647
|
for (const block of line) {
|
|
10626
10648
|
block.y = yOffset;
|
|
10627
10649
|
}
|
|
@@ -10645,7 +10667,7 @@ function getTextBlock({
|
|
|
10645
10667
|
x: 0,
|
|
10646
10668
|
y: 0,
|
|
10647
10669
|
measure,
|
|
10648
|
-
fontSize: style.fontSize,
|
|
10670
|
+
fontSize: style.fontSize === "auto" ? 14 : style.fontSize,
|
|
10649
10671
|
paddingTop,
|
|
10650
10672
|
marginLeft,
|
|
10651
10673
|
listMark,
|
|
@@ -11203,7 +11225,7 @@ function handleListMerge(editor) {
|
|
|
11203
11225
|
return false;
|
|
11204
11226
|
}
|
|
11205
11227
|
const [textNode, textNodePath] = Editor.node(editor, anchor.path);
|
|
11206
|
-
if (!textNode || textNode.type !== "text" ||
|
|
11228
|
+
if (!textNode || Editor.isEditor(textNode) || textNode.type !== "text" || !("text" in textNode) || !isCursorAtStartOfFirstChild(editor, textNodePath)) {
|
|
11207
11229
|
return false;
|
|
11208
11230
|
}
|
|
11209
11231
|
const paragraphPath = Path4.parent(textNodePath);
|
|
@@ -11213,12 +11235,12 @@ function handleListMerge(editor) {
|
|
|
11213
11235
|
}
|
|
11214
11236
|
const listItemPath = Path4.parent(paragraphPath);
|
|
11215
11237
|
const [listItem] = Editor.node(editor, listItemPath);
|
|
11216
|
-
if (!listItem || listItem.type !== "list_item") {
|
|
11238
|
+
if (!listItem || Editor.isEditor(listItem) || listItem.type !== "list_item") {
|
|
11217
11239
|
return false;
|
|
11218
11240
|
}
|
|
11219
11241
|
const listPath = Path4.parent(listItemPath);
|
|
11220
11242
|
const [list] = Editor.node(editor, listPath);
|
|
11221
|
-
if (!list || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
11243
|
+
if (!list || Editor.isEditor(list) || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
11222
11244
|
return false;
|
|
11223
11245
|
}
|
|
11224
11246
|
const listItemIndex = listItemPath[listItemPath.length - 1];
|
|
@@ -11252,6 +11274,9 @@ function handleListMerge(editor) {
|
|
|
11252
11274
|
} else {
|
|
11253
11275
|
const previousItemPath = Path4.previous(listItemPath);
|
|
11254
11276
|
const [previousItem] = Editor.node(editor, previousItemPath);
|
|
11277
|
+
if ("text" in previousItem) {
|
|
11278
|
+
return false;
|
|
11279
|
+
}
|
|
11255
11280
|
currentListItemChildren.forEach((childNode, index) => {
|
|
11256
11281
|
const copiedNode = structuredClone(childNode);
|
|
11257
11282
|
copiedNode.paddingTop = 0;
|
|
@@ -11283,7 +11308,18 @@ function createParagraphNode(text, editor, horisontalAlignment) {
|
|
|
11283
11308
|
const marks = Editor2.marks(editor) || {};
|
|
11284
11309
|
const pargaraph = {
|
|
11285
11310
|
type: "paragraph",
|
|
11286
|
-
children: [{
|
|
11311
|
+
children: [{
|
|
11312
|
+
type: "text",
|
|
11313
|
+
text,
|
|
11314
|
+
...marks,
|
|
11315
|
+
bold: false,
|
|
11316
|
+
italic: false,
|
|
11317
|
+
underline: false,
|
|
11318
|
+
overline: false,
|
|
11319
|
+
"line-through": false,
|
|
11320
|
+
subscript: false,
|
|
11321
|
+
superscript: false
|
|
11322
|
+
}]
|
|
11287
11323
|
};
|
|
11288
11324
|
if (horisontalAlignment) {
|
|
11289
11325
|
pargaraph.horisontalAlignment = horisontalAlignment;
|
|
@@ -11337,6 +11373,9 @@ function handleSplitListItem(editor) {
|
|
|
11337
11373
|
if (isBlockEmpty && isOnlyChildParagraph) {
|
|
11338
11374
|
const listItemIndex = listItemPath[listItemPath.length - 1];
|
|
11339
11375
|
const [parentList, parentListPath] = Editor3.parent(editor, listItemPath);
|
|
11376
|
+
if (Editor3.isEditor(parentList) || parentList.type !== "ol_list" && parentList.type !== "ul_list") {
|
|
11377
|
+
return false;
|
|
11378
|
+
}
|
|
11340
11379
|
const listType = parentList.type;
|
|
11341
11380
|
Editor3.withoutNormalizing(editor, () => {
|
|
11342
11381
|
const nextPath = Path5.next(parentListPath);
|
|
@@ -11361,6 +11400,9 @@ function handleSplitListItem(editor) {
|
|
|
11361
11400
|
match: (n, path2) => path2[path2.length - 1] >= listItemIndex
|
|
11362
11401
|
});
|
|
11363
11402
|
const [updatedParentList] = Editor3.node(editor, parentListPath);
|
|
11403
|
+
if (Editor3.isEditor(updatedParentList)) {
|
|
11404
|
+
return false;
|
|
11405
|
+
}
|
|
11364
11406
|
if (getAreAllChildrenEmpty(updatedParentList)) {
|
|
11365
11407
|
Transforms2.removeNodes(editor, { at: parentListPath });
|
|
11366
11408
|
}
|
|
@@ -11392,7 +11434,7 @@ import { Transforms as Transforms4 } from "slate";
|
|
|
11392
11434
|
import { Editor as Editor4, Transforms as Transforms3 } from "slate";
|
|
11393
11435
|
function clearAllTextNodes(editor) {
|
|
11394
11436
|
for (const [node, path2] of Editor4.nodes(editor, {
|
|
11395
|
-
match: (n) => n.type === "text"
|
|
11437
|
+
match: (n) => !Editor4.isEditor(n) && n.type === "text"
|
|
11396
11438
|
})) {
|
|
11397
11439
|
Transforms3.removeNodes(editor, { at: path2 });
|
|
11398
11440
|
Transforms3.setNodes(editor, { ...node, text: "" }, { at: path2 });
|
|
@@ -11427,7 +11469,7 @@ function handleWrapIntoNestedList(editor) {
|
|
|
11427
11469
|
}
|
|
11428
11470
|
const { anchor } = selection;
|
|
11429
11471
|
const [textNode, textNodePath] = Editor5.node(editor, anchor.path);
|
|
11430
|
-
if (!textNode || textNode.type !== "text" ||
|
|
11472
|
+
if (!textNode || Editor5.isEditor(textNode) || textNode.type !== "text" || !("text" in textNode) || !isCursorAtStartOfFirstChild(editor, textNodePath)) {
|
|
11431
11473
|
return false;
|
|
11432
11474
|
}
|
|
11433
11475
|
const paragraphPath = Path6.parent(textNodePath);
|
|
@@ -11437,12 +11479,12 @@ function handleWrapIntoNestedList(editor) {
|
|
|
11437
11479
|
}
|
|
11438
11480
|
const listItemPath = Path6.parent(paragraphPath);
|
|
11439
11481
|
const [listItem] = Editor5.node(editor, listItemPath);
|
|
11440
|
-
if (!listItem || listItem.type !== "list_item") {
|
|
11482
|
+
if (!listItem || Editor5.isEditor(listItem) || listItem.type !== "list_item") {
|
|
11441
11483
|
return false;
|
|
11442
11484
|
}
|
|
11443
11485
|
const listPath = Path6.parent(listItemPath);
|
|
11444
11486
|
const [list] = Editor5.node(editor, listPath);
|
|
11445
|
-
if (!list || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
11487
|
+
if (!list || Editor5.isEditor(list) || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
11446
11488
|
return false;
|
|
11447
11489
|
}
|
|
11448
11490
|
Transforms5.wrapNodes(editor, { type: "list_item", children: [] }, { at: paragraphPath });
|
|
@@ -11465,19 +11507,19 @@ function wrapIntoList(editor, targetListType, location) {
|
|
|
11465
11507
|
}
|
|
11466
11508
|
|
|
11467
11509
|
// src/Items/RichText/editorHelpers/lists/toggleListTypeForSelection.ts
|
|
11468
|
-
import { Editor as Editor7, Element as Element2, Path as Path8,
|
|
11510
|
+
import { Editor as Editor7, Element as Element2, Path as Path8, Transforms as Transforms7 } from "slate";
|
|
11469
11511
|
|
|
11470
11512
|
// src/Items/RichText/editorHelpers/lists/getBlockParentList.ts
|
|
11471
11513
|
import { Editor as Editor6, Path as Path7 } from "slate";
|
|
11472
11514
|
function getBlockParentList(editor, blockPath) {
|
|
11473
11515
|
const listItemPath = Path7.parent(blockPath);
|
|
11474
11516
|
const [listItem] = Editor6.node(editor, listItemPath);
|
|
11475
|
-
if (!listItem || listItem.type !== "list_item") {
|
|
11517
|
+
if (!listItem || Editor6.isEditor(listItem) || listItem.type !== "list_item") {
|
|
11476
11518
|
return null;
|
|
11477
11519
|
}
|
|
11478
11520
|
const listPath = Path7.parent(listItemPath);
|
|
11479
11521
|
const [list] = Editor6.node(editor, listPath);
|
|
11480
|
-
if (!list || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
11522
|
+
if (!list || Editor6.isEditor(listItem) || "type" in list && list.type !== "ol_list" && list.type !== "ul_list") {
|
|
11481
11523
|
return null;
|
|
11482
11524
|
}
|
|
11483
11525
|
return [list, listPath];
|
|
@@ -11490,17 +11532,16 @@ function toggleListTypeForSelection(editor, targetListType) {
|
|
|
11490
11532
|
return false;
|
|
11491
11533
|
}
|
|
11492
11534
|
Editor7.withoutNormalizing(editor, () => {
|
|
11493
|
-
const [start, end] = Range4.edges(selection);
|
|
11494
|
-
const commonAncestorPath = Path8.common(start.path, end.path);
|
|
11495
11535
|
const nodes = Array.from(Editor7.nodes(editor, {
|
|
11496
11536
|
at: selection,
|
|
11497
11537
|
mode: "lowest",
|
|
11498
|
-
match: (n) => Editor7.isBlock(editor, n)
|
|
11538
|
+
match: (n) => !Editor7.isEditor(n) && n.type !== "text" && Editor7.isBlock(editor, n)
|
|
11499
11539
|
}));
|
|
11500
11540
|
const nodesWithLists = {};
|
|
11501
11541
|
const unwrapCandidates = [];
|
|
11502
11542
|
nodes.forEach(([node, path2]) => {
|
|
11503
11543
|
const parentList = getBlockParentList(editor, path2);
|
|
11544
|
+
node = node;
|
|
11504
11545
|
if (parentList) {
|
|
11505
11546
|
unwrapCandidates.push(node);
|
|
11506
11547
|
if (!nodesWithLists[parentList[1].length]) {
|
|
@@ -11610,7 +11651,7 @@ function toggleListType(editor, targetListType, shouldWrap = true) {
|
|
|
11610
11651
|
Editor8.withoutNormalizing(editor, () => {
|
|
11611
11652
|
const { anchor } = selection;
|
|
11612
11653
|
const [textNode, textNodePath] = Editor8.node(editor, anchor.path);
|
|
11613
|
-
if (!textNode || textNode.type !== "text" ||
|
|
11654
|
+
if (!textNode || Editor8.isEditor(textNode) || textNode.type !== "text" || !("text" in textNode)) {
|
|
11614
11655
|
result = false;
|
|
11615
11656
|
return;
|
|
11616
11657
|
}
|
|
@@ -11622,7 +11663,7 @@ function toggleListType(editor, targetListType, shouldWrap = true) {
|
|
|
11622
11663
|
}
|
|
11623
11664
|
const listItemPath = Path9.parent(paragraphPath);
|
|
11624
11665
|
const [listItem] = Editor8.node(editor, listItemPath);
|
|
11625
|
-
if (!listItem || listItem.type !== "list_item") {
|
|
11666
|
+
if (!listItem || Editor8.isEditor(listItem) || listItem.type !== "list_item") {
|
|
11626
11667
|
if (shouldWrap) {
|
|
11627
11668
|
wrapIntoList(editor, targetListType, selection);
|
|
11628
11669
|
return;
|
|
@@ -11632,7 +11673,7 @@ function toggleListType(editor, targetListType, shouldWrap = true) {
|
|
|
11632
11673
|
}
|
|
11633
11674
|
const listPath = Path9.parent(listItemPath);
|
|
11634
11675
|
const [list] = Editor8.node(editor, listPath);
|
|
11635
|
-
if (!list || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
11676
|
+
if (!list || Editor8.isEditor(list) || list.type !== "ol_list" && list.type !== "ul_list") {
|
|
11636
11677
|
if (shouldWrap) {
|
|
11637
11678
|
wrapIntoList(editor, targetListType, selection);
|
|
11638
11679
|
return;
|
|
@@ -11714,7 +11755,7 @@ function getListTypeAtSelectionStart(editor) {
|
|
|
11714
11755
|
const startPoint = Range6.start(selection);
|
|
11715
11756
|
const listEntry = Editor10.above(editor, {
|
|
11716
11757
|
at: startPoint,
|
|
11717
|
-
match: (n) => n.type === "ol_list" || n.type === "ul_list"
|
|
11758
|
+
match: (n) => !Editor10.isEditor(n) && (n.type === "ol_list" || n.type === "ul_list")
|
|
11718
11759
|
});
|
|
11719
11760
|
if (listEntry) {
|
|
11720
11761
|
const [listNode] = listEntry;
|
|
@@ -11737,11 +11778,11 @@ var setLink = (editor, link, selection) => {
|
|
|
11737
11778
|
const format = link ? "rgba(71, 120, 245, 1)" : "rgb(20, 21, 26)";
|
|
11738
11779
|
Editor11.addMark(editor, "fontColor", format);
|
|
11739
11780
|
for (const [node, path2] of Editor11.nodes(editor, {
|
|
11740
|
-
match: (n) => n.type === "text"
|
|
11781
|
+
match: (n) => !Editor11.isEditor(n) && n.type === "text"
|
|
11741
11782
|
})) {
|
|
11742
11783
|
const nodeRange = Editor11.range(editor, path2);
|
|
11743
11784
|
Transforms10.select(editor, nodeRange);
|
|
11744
|
-
Transforms10.setNodes(editor, { link }, { split: false, match: (n) => n.type === "text" });
|
|
11785
|
+
Transforms10.setNodes(editor, { link }, { split: false, match: (n) => !Editor11.isEditor(n) && n.type === "text" });
|
|
11745
11786
|
}
|
|
11746
11787
|
};
|
|
11747
11788
|
|
|
@@ -19579,7 +19620,9 @@ function setNodeChildrenStyles({
|
|
|
19579
19620
|
}) {
|
|
19580
19621
|
let fontStyles = conf.DEFAULT_TEXT_STYLES;
|
|
19581
19622
|
if (editor) {
|
|
19582
|
-
|
|
19623
|
+
const marks = Editor15.marks(editor);
|
|
19624
|
+
const fontSize = marks?.fontSize ? marks.fontSize === "auto" ? conf.DEFAULT_TEXT_STYLES.fontSize : marks.fontSize : conf.DEFAULT_TEXT_STYLES.fontSize;
|
|
19625
|
+
fontStyles = marks ? { ...conf.DEFAULT_TEXT_STYLES, ...marks, fontSize } : conf.DEFAULT_TEXT_STYLES;
|
|
19583
19626
|
}
|
|
19584
19627
|
switch (node2.type) {
|
|
19585
19628
|
case "heading_one":
|
|
@@ -19629,6 +19672,9 @@ function setNodeStyles({
|
|
|
19629
19672
|
editor,
|
|
19630
19673
|
horisontalAlignment
|
|
19631
19674
|
}) {
|
|
19675
|
+
if (node2.type === "list_item") {
|
|
19676
|
+
return;
|
|
19677
|
+
}
|
|
19632
19678
|
if (node2.type === "ol_list" || node2.type === "ul_list") {
|
|
19633
19679
|
node2.listLevel = listLevel;
|
|
19634
19680
|
for (const listItem of node2.children) {
|
|
@@ -19779,9 +19825,10 @@ class MarkdownProcessor {
|
|
|
19779
19825
|
} else {
|
|
19780
19826
|
const lastParagraphPath = this.getText().length - 1;
|
|
19781
19827
|
const lastParagraph = this.getText()[lastParagraphPath];
|
|
19828
|
+
const lastParagraphText = lastParagraph.children[lastParagraph.children.length - 1];
|
|
19782
19829
|
const insertLocation = {
|
|
19783
19830
|
path: [lastParagraphPath, lastParagraph.children.length - 1],
|
|
19784
|
-
offset:
|
|
19831
|
+
offset: lastParagraphText.text.length
|
|
19785
19832
|
};
|
|
19786
19833
|
Transforms12.insertText(this.editor, combinedText, {
|
|
19787
19834
|
at: insertLocation
|
|
@@ -19846,7 +19893,7 @@ function getFirstSelectionLink(editor, selection) {
|
|
|
19846
19893
|
}
|
|
19847
19894
|
for (const [node2] of Editor19.nodes(editor, {
|
|
19848
19895
|
at: selection,
|
|
19849
|
-
match: (n) => !!n.link
|
|
19896
|
+
match: (n) => ("link" in n) && !!n.link
|
|
19850
19897
|
})) {
|
|
19851
19898
|
return node2.link;
|
|
19852
19899
|
}
|
|
@@ -20796,14 +20843,6 @@ class RichTextCommand {
|
|
|
20796
20843
|
fontColor: this.board.items.getById(id)?.getRichText()?.getFontColor() || conf.DEFAULT_TEXT_STYLES.fontColor
|
|
20797
20844
|
}
|
|
20798
20845
|
}));
|
|
20799
|
-
case "setBlockType":
|
|
20800
|
-
return items.map((id) => ({
|
|
20801
|
-
item: id,
|
|
20802
|
-
operation: {
|
|
20803
|
-
...this.operation,
|
|
20804
|
-
type: this.board.items.getById(id)?.getRichText()?.getBlockType() || "paragraph"
|
|
20805
|
-
}
|
|
20806
|
-
}));
|
|
20807
20846
|
case "setFontStyle":
|
|
20808
20847
|
return items.map((id) => ({
|
|
20809
20848
|
item: id,
|
|
@@ -20906,7 +20945,8 @@ class RichTextGroupCommand {
|
|
|
20906
20945
|
class: "RichText",
|
|
20907
20946
|
method: "edit",
|
|
20908
20947
|
item: [richText.getId() ?? ""],
|
|
20909
|
-
ops
|
|
20948
|
+
ops,
|
|
20949
|
+
selection: null
|
|
20910
20950
|
}
|
|
20911
20951
|
});
|
|
20912
20952
|
}
|
|
@@ -20923,7 +20963,8 @@ class RichTextGroupCommand {
|
|
|
20923
20963
|
class: "RichText",
|
|
20924
20964
|
method: "edit",
|
|
20925
20965
|
item: [richText.getId() ?? ""],
|
|
20926
|
-
ops: ops.map((op) => Operation2.inverse(op)).reverse()
|
|
20966
|
+
ops: ops.map((op) => Operation2.inverse(op)).reverse(),
|
|
20967
|
+
selection: null
|
|
20927
20968
|
}
|
|
20928
20969
|
});
|
|
20929
20970
|
}
|
|
@@ -21572,6 +21613,9 @@ class Comment2 {
|
|
|
21572
21613
|
const anchor = this.anchor.copy();
|
|
21573
21614
|
return new Mbr(anchor.x, anchor.y, anchor.x, anchor.y);
|
|
21574
21615
|
}
|
|
21616
|
+
getPathMbr() {
|
|
21617
|
+
return this.getMbr();
|
|
21618
|
+
}
|
|
21575
21619
|
getNearestEdgePointTo(point3) {
|
|
21576
21620
|
return this.anchor;
|
|
21577
21621
|
}
|
|
@@ -22059,6 +22103,9 @@ class BaseItem extends Mbr {
|
|
|
22059
22103
|
onRemove() {
|
|
22060
22104
|
this.onRemoveCallbacks.forEach((cb) => cb());
|
|
22061
22105
|
}
|
|
22106
|
+
getPathMbr() {
|
|
22107
|
+
return this.getMbr().copy();
|
|
22108
|
+
}
|
|
22062
22109
|
render(context) {}
|
|
22063
22110
|
renderHTML(documentFactory) {
|
|
22064
22111
|
return documentFactory.createElement("div");
|
|
@@ -22584,7 +22631,10 @@ class RichText extends BaseItem {
|
|
|
22584
22631
|
}
|
|
22585
22632
|
getFontSize() {
|
|
22586
22633
|
const marks = this.editor.getSelectionMarks();
|
|
22587
|
-
|
|
22634
|
+
let fontSize = marks?.fontSize ?? this.initialTextStyles.fontSize;
|
|
22635
|
+
if (fontSize === "auto") {
|
|
22636
|
+
fontSize = this.initialTextStyles.fontSize;
|
|
22637
|
+
}
|
|
22588
22638
|
if (this.autoSize) {
|
|
22589
22639
|
return fontSize * this.autoSizeScale;
|
|
22590
22640
|
}
|
|
@@ -22602,7 +22652,7 @@ class RichText extends BaseItem {
|
|
|
22602
22652
|
for (const [node2] of textNodes) {
|
|
22603
22653
|
const fontSize = node2.fontSize || node2 && node2.fontSize;
|
|
22604
22654
|
if (fontSize) {
|
|
22605
|
-
fontSizes.push(fontSize);
|
|
22655
|
+
fontSizes.push(fontSize === "auto" ? this.initialTextStyles.fontSize : fontSize);
|
|
22606
22656
|
}
|
|
22607
22657
|
}
|
|
22608
22658
|
if (fontSizes.length > 0) {
|
|
@@ -22615,7 +22665,7 @@ class RichText extends BaseItem {
|
|
|
22615
22665
|
return marks?.fontHighlight ?? this.initialTextStyles.fontHighlight;
|
|
22616
22666
|
}
|
|
22617
22667
|
getBlockType() {
|
|
22618
|
-
const blockNode = getSelectedBlockNode(this.editor);
|
|
22668
|
+
const blockNode = getSelectedBlockNode(this.editor.editor);
|
|
22619
22669
|
return blockNode ? blockNode.type : "paragraph";
|
|
22620
22670
|
}
|
|
22621
22671
|
getHorisontalAlignment() {
|
|
@@ -22646,16 +22696,18 @@ class RichText extends BaseItem {
|
|
|
22646
22696
|
const refMbr = new Mbr(domMbr.left, domMbr.top, domMbr.right, domMbr.bottom);
|
|
22647
22697
|
if (refMbr.isInside(point3) && (conf.documentFactory.caretPositionFromPoint || conf.documentFactory.caretRangeFromPoint)) {
|
|
22648
22698
|
const domRange = conf.documentFactory.caretPositionFromPoint ? conf.documentFactory.caretPositionFromPoint(point3.x, point3.y) : conf.documentFactory.caretRangeFromPoint(point3.x, point3.y);
|
|
22649
|
-
|
|
22650
|
-
|
|
22651
|
-
|
|
22652
|
-
|
|
22653
|
-
|
|
22654
|
-
|
|
22655
|
-
|
|
22656
|
-
|
|
22657
|
-
|
|
22658
|
-
|
|
22699
|
+
if (domRange) {
|
|
22700
|
+
const textNode = conf.documentFactory.caretPositionFromPoint ? domRange.offsetNode : domRange.startContainer;
|
|
22701
|
+
const offset = conf.documentFactory.caretPositionFromPoint ? domRange.offset : domRange.startOffset;
|
|
22702
|
+
const slatePoint = conf.reactEditorToSlatePoint(this.editor.editor, textNode, offset, {
|
|
22703
|
+
exactMatch: false,
|
|
22704
|
+
suppressThrow: false
|
|
22705
|
+
});
|
|
22706
|
+
if (slatePoint) {
|
|
22707
|
+
const nRange = { anchor: slatePoint, focus: slatePoint };
|
|
22708
|
+
this.editorTransforms.select(this.editor.editor, nRange);
|
|
22709
|
+
conf.reactEditorFocus(this.editor.editor);
|
|
22710
|
+
}
|
|
22659
22711
|
}
|
|
22660
22712
|
} else {
|
|
22661
22713
|
if (!(conf.documentFactory.caretPositionFromPoint || conf.documentFactory.caretRangeFromPoint)) {
|
|
@@ -39864,6 +39916,9 @@ class Shape extends BaseItem {
|
|
|
39864
39916
|
getMbr() {
|
|
39865
39917
|
return this.mbr.copy();
|
|
39866
39918
|
}
|
|
39919
|
+
getPathMbr() {
|
|
39920
|
+
return this.getPath().getMbr();
|
|
39921
|
+
}
|
|
39867
39922
|
getNearestEdgePointTo(point5) {
|
|
39868
39923
|
return this.path.getNearestEdgePointTo(point5);
|
|
39869
39924
|
}
|
|
@@ -45644,13 +45699,8 @@ function createCanvasDrawer(board) {
|
|
|
45644
45699
|
// src/Selection/QuickAddButtons/quickAddHelpers.ts
|
|
45645
45700
|
function getControlPointData(item, index2, isRichText = false) {
|
|
45646
45701
|
const itemScale = isRichText ? { x: 1, y: 1 } : item.transformation.getScale();
|
|
45647
|
-
const width2 = item.
|
|
45648
|
-
let height3;
|
|
45649
|
-
if (item.itemType === "Shape" && index2 !== 2 && index2 !== 3) {
|
|
45650
|
-
height3 = item.getPath().getMbr().getHeight();
|
|
45651
|
-
} else {
|
|
45652
|
-
height3 = item.getMbr().getHeight();
|
|
45653
|
-
}
|
|
45702
|
+
const width2 = item.getPathMbr().getWidth();
|
|
45703
|
+
let height3 = item.getPathMbr().getHeight();
|
|
45654
45704
|
const adjMapScaled = {
|
|
45655
45705
|
0: { x: 0, y: height3 / 2 / itemScale.y },
|
|
45656
45706
|
1: {
|
|
@@ -45683,7 +45733,7 @@ function quickAddItem(board, type, connector) {
|
|
|
45683
45733
|
optionalItem = new Sticker(board);
|
|
45684
45734
|
break;
|
|
45685
45735
|
case "AINode":
|
|
45686
|
-
optionalItem = createAINode2(board, startPoint?.item?.getId()
|
|
45736
|
+
optionalItem = createAINode2(board, 3, "item" in startPoint ? startPoint?.item?.getId() : undefined);
|
|
45687
45737
|
break;
|
|
45688
45738
|
}
|
|
45689
45739
|
let itemMbr = optionalItem.getMbr();
|
|
@@ -45710,20 +45760,25 @@ function quickAddItem(board, type, connector) {
|
|
|
45710
45760
|
if ("text" in guarded && guarded.itemType !== "AINode" && guarded.itemType !== "RichText") {
|
|
45711
45761
|
delete guarded.text;
|
|
45712
45762
|
}
|
|
45763
|
+
if (!itemData.transformation) {
|
|
45764
|
+
itemData.transformation = new DefaultTransformationData;
|
|
45765
|
+
}
|
|
45713
45766
|
itemData.transformation.translateX = endPoint.x;
|
|
45714
45767
|
itemData.transformation.translateY = endPoint.y;
|
|
45715
45768
|
const lines = connector.lines.getSegments();
|
|
45716
45769
|
const lastLine = lines[lines.length - 1];
|
|
45717
|
-
|
|
45770
|
+
const lastLineStart = lastLine.getStartPoint();
|
|
45771
|
+
const lastLineEnd = lastLine.getEndPoint();
|
|
45772
|
+
let dir2 = getDirection(lastLineStart, lastLineEnd);
|
|
45773
|
+
const firstLineStart = lines[0].getEndPoint();
|
|
45718
45774
|
if (!dir2) {
|
|
45719
|
-
const
|
|
45720
|
-
const
|
|
45721
|
-
const yDiff = Math.abs(firstLine.start.y - lastLine.end.y);
|
|
45775
|
+
const xDiff = Math.abs(firstLineStart.x - lastLineEnd.x);
|
|
45776
|
+
const yDiff = Math.abs(firstLineStart.y - lastLineEnd.y);
|
|
45722
45777
|
dir2 = xDiff > yDiff ? "horizontal" : "vertical";
|
|
45723
45778
|
}
|
|
45724
45779
|
let dirIndex = -1;
|
|
45725
45780
|
if (dir2 === "vertical") {
|
|
45726
|
-
if (
|
|
45781
|
+
if (firstLineStart.y > lastLineEnd.y) {
|
|
45727
45782
|
itemData.transformation.translateX -= itemMbr.getWidth() / 2;
|
|
45728
45783
|
itemData.transformation.translateY -= itemMbr.getHeight();
|
|
45729
45784
|
dirIndex = 3;
|
|
@@ -45732,7 +45787,7 @@ function quickAddItem(board, type, connector) {
|
|
|
45732
45787
|
dirIndex = 2;
|
|
45733
45788
|
}
|
|
45734
45789
|
} else if (dir2 === "horizontal") {
|
|
45735
|
-
if (
|
|
45790
|
+
if (firstLineStart.x > lastLineEnd.x) {
|
|
45736
45791
|
itemData.transformation.translateX -= itemMbr.getWidth();
|
|
45737
45792
|
itemData.transformation.translateY -= itemMbr.getHeight() / 2;
|
|
45738
45793
|
dirIndex = 1;
|
|
@@ -45754,7 +45809,7 @@ function quickAddItem(board, type, connector) {
|
|
|
45754
45809
|
connector.setEndPoint(newEndPoint);
|
|
45755
45810
|
board.selection.removeAll();
|
|
45756
45811
|
board.selection.add(added);
|
|
45757
|
-
if (added
|
|
45812
|
+
if (added instanceof RichText || added instanceof AINode) {
|
|
45758
45813
|
const text5 = added.getRichText();
|
|
45759
45814
|
text5.editor.setMaxWidth(text5.editor.maxWidth || 600);
|
|
45760
45815
|
board.selection.editText();
|
|
@@ -45762,7 +45817,7 @@ function quickAddItem(board, type, connector) {
|
|
|
45762
45817
|
board.selection.setContext("EditUnderPointer");
|
|
45763
45818
|
}
|
|
45764
45819
|
}
|
|
45765
|
-
function createAINode2(board,
|
|
45820
|
+
function createAINode2(board, directionIndex, parentNodeId) {
|
|
45766
45821
|
const node2 = new AINode(board, true, parentNodeId, undefined, directionIndex);
|
|
45767
45822
|
const nodeRichText = node2.getRichText();
|
|
45768
45823
|
nodeRichText.applyMaxWidth(600);
|
|
@@ -45796,17 +45851,17 @@ function getQuickAddButtons(selection, board) {
|
|
|
45796
45851
|
let quickAddItems = undefined;
|
|
45797
45852
|
function calculateQuickAddPosition(index2, selectedItem, connectorStartPoint) {
|
|
45798
45853
|
const connectorStorage = new SessionStorage;
|
|
45799
|
-
const currMbr = selectedItem.
|
|
45854
|
+
const currMbr = selectedItem.getPathMbr();
|
|
45800
45855
|
const selectedItemData = selectedItem.serialize();
|
|
45801
|
-
const width2 =
|
|
45802
|
-
const height3 =
|
|
45856
|
+
const width2 = currMbr.getWidth();
|
|
45857
|
+
const height3 = currMbr.getHeight();
|
|
45803
45858
|
let offsetX = width2;
|
|
45804
45859
|
let offsetY = height3;
|
|
45805
45860
|
let newWidth = width2;
|
|
45806
45861
|
let newHeight = height3;
|
|
45807
45862
|
let itemData;
|
|
45808
45863
|
if (selectedItem.itemType === "AINode" || selectedItem.itemType === "RichText") {
|
|
45809
|
-
const item = selectedItem.itemType === "AINode" ? createAINode2(board, selectedItem.getId()
|
|
45864
|
+
const item = selectedItem.itemType === "AINode" ? createAINode2(board, index2, selectedItem.getId()) : createRichText2(board);
|
|
45810
45865
|
newWidth = item.getMbr().getWidth();
|
|
45811
45866
|
newHeight = item.getMbr().getHeight();
|
|
45812
45867
|
itemData = item.serialize();
|
|
@@ -45855,9 +45910,9 @@ function getQuickAddButtons(selection, board) {
|
|
|
45855
45910
|
const endPoints = getQuickButtonsPositions(newMbr);
|
|
45856
45911
|
const reverseIndexMap = { 0: 1, 1: 0, 2: 3, 3: 2 };
|
|
45857
45912
|
const connectorEndPoint = endPoints?.positions[reverseIndexMap[index2]] || new Point;
|
|
45858
|
-
const fontSize = selectedItem
|
|
45913
|
+
const fontSize = selectedItem instanceof RichText ? selectedItem.getFontSize() : 14;
|
|
45859
45914
|
const newItem = board.createItem(board.getNewItemId(), newItemData);
|
|
45860
|
-
if (newItem
|
|
45915
|
+
if (newItem instanceof RichText) {
|
|
45861
45916
|
const storage = new SessionStorage;
|
|
45862
45917
|
storage.setFontSize("RichText", fontSize);
|
|
45863
45918
|
newItem.editor.selectWholeText();
|
|
@@ -45870,6 +45925,10 @@ function getQuickAddButtons(selection, board) {
|
|
|
45870
45925
|
const scaleX = newItemMbr.getWidth() / 100;
|
|
45871
45926
|
const scaleY = newItemMbr.getHeight() / 100;
|
|
45872
45927
|
shapeData.transformation = {
|
|
45928
|
+
isLocked: false,
|
|
45929
|
+
rotate: 0,
|
|
45930
|
+
translateX: 0,
|
|
45931
|
+
translateY: 0,
|
|
45873
45932
|
...newItemData.transformation,
|
|
45874
45933
|
scaleX,
|
|
45875
45934
|
scaleY
|
|
@@ -45926,7 +45985,7 @@ function getQuickAddButtons(selection, board) {
|
|
|
45926
45985
|
}
|
|
45927
45986
|
let pathCenter;
|
|
45928
45987
|
if (single.itemType === "Shape") {
|
|
45929
|
-
pathCenter = single.
|
|
45988
|
+
pathCenter = single.getPathMbr().getCenter();
|
|
45930
45989
|
}
|
|
45931
45990
|
const center = itemMbr.getCenter();
|
|
45932
45991
|
const width2 = itemMbr.getWidth();
|
|
@@ -50295,7 +50354,7 @@ class Presence {
|
|
|
50295
50354
|
};
|
|
50296
50355
|
});
|
|
50297
50356
|
ctx2.restore();
|
|
50298
|
-
this.pointerAnimationId = safeRequestAnimationFrame(renderLoop);
|
|
50357
|
+
this.pointerAnimationId = safeRequestAnimationFrame(renderLoop) || null;
|
|
50299
50358
|
};
|
|
50300
50359
|
renderLoop();
|
|
50301
50360
|
}
|
|
@@ -51595,7 +51654,7 @@ class SpatialIndex {
|
|
|
51595
51654
|
return this.itemsIndex.getRectsEnclosedOrCrossedBy(new Mbr(left, top, right, bottom));
|
|
51596
51655
|
}
|
|
51597
51656
|
getComments() {
|
|
51598
|
-
return this.itemsArray.filter((item) => item instanceof
|
|
51657
|
+
return this.itemsArray.filter((item) => item instanceof Comment2);
|
|
51599
51658
|
}
|
|
51600
51659
|
getMbr() {
|
|
51601
51660
|
return this.Mbr;
|
|
@@ -51719,10 +51778,10 @@ class Items {
|
|
|
51719
51778
|
}
|
|
51720
51779
|
const { nearest } = enclosed.reduce((acc, item) => {
|
|
51721
51780
|
const area = item.getMbr().getHeight() * item.getMbr().getWidth();
|
|
51722
|
-
if (item
|
|
51781
|
+
if (item instanceof Drawing && !item.isPointNearLine(this.pointer.point)) {
|
|
51723
51782
|
return acc;
|
|
51724
51783
|
}
|
|
51725
|
-
const isItemTransparent = item
|
|
51784
|
+
const isItemTransparent = item instanceof Shape && item?.getBackgroundColor() === "none";
|
|
51726
51785
|
const itemZIndex = this.getZIndex(item);
|
|
51727
51786
|
const accZIndex = this.getZIndex(acc.nearest);
|
|
51728
51787
|
if (itemZIndex > accZIndex && (!isItemTransparent || area === acc.area) || area < acc.area) {
|
|
@@ -51753,7 +51812,7 @@ class Items {
|
|
|
51753
51812
|
}
|
|
51754
51813
|
getLinkedConnectorsById(id) {
|
|
51755
51814
|
return this.listAll().filter((item) => {
|
|
51756
|
-
if (item
|
|
51815
|
+
if (!(item instanceof Connector2)) {
|
|
51757
51816
|
return false;
|
|
51758
51817
|
}
|
|
51759
51818
|
const { startItem, endItem } = item.getConnectedItems();
|
|
@@ -51768,7 +51827,7 @@ class Items {
|
|
|
51768
51827
|
return [];
|
|
51769
51828
|
}
|
|
51770
51829
|
return this.listAll().filter((item) => {
|
|
51771
|
-
if (item
|
|
51830
|
+
if (!(item instanceof Connector2) || !item.isConnected()) {
|
|
51772
51831
|
return false;
|
|
51773
51832
|
}
|
|
51774
51833
|
const { startItem, endItem } = item.getConnectedItems();
|
|
@@ -51943,7 +52002,7 @@ class SelectionItems {
|
|
|
51943
52002
|
return ids;
|
|
51944
52003
|
}
|
|
51945
52004
|
getSingle() {
|
|
51946
|
-
return this.isSingle() ? this.items.values().next().value : null;
|
|
52005
|
+
return this.isSingle() ? this.items.values().next().value || null : null;
|
|
51947
52006
|
}
|
|
51948
52007
|
listByIds(itemIdList) {
|
|
51949
52008
|
return itemIdList.map((id) => this.items.get(id)).filter((item) => item !== undefined);
|
|
@@ -51991,7 +52050,7 @@ class ConnectorTransformer extends Tool {
|
|
|
51991
52050
|
getConnector(items) {
|
|
51992
52051
|
if (items.isSingle()) {
|
|
51993
52052
|
const connector = items.getSingle();
|
|
51994
|
-
if (connector
|
|
52053
|
+
if (connector instanceof Connector2) {
|
|
51995
52054
|
return connector;
|
|
51996
52055
|
}
|
|
51997
52056
|
}
|
|
@@ -53461,10 +53520,10 @@ class BoardSelection {
|
|
|
53461
53520
|
}
|
|
53462
53521
|
copiedItemsMap[item.getId()] = { ...serializedData, zIndex };
|
|
53463
53522
|
}
|
|
53464
|
-
copy(skipImageBlobCopy
|
|
53523
|
+
copy(skipImageBlobCopy) {
|
|
53465
53524
|
const copiedItemsMap = {};
|
|
53466
53525
|
const single = this.items.getSingle();
|
|
53467
|
-
if (!skipImageBlobCopy && single && single
|
|
53526
|
+
if (!skipImageBlobCopy && single && single instanceof ImageItem) {
|
|
53468
53527
|
this.handleItemCopy(single, copiedItemsMap);
|
|
53469
53528
|
return { imageElement: single.image, imageData: copiedItemsMap };
|
|
53470
53529
|
}
|
|
@@ -53489,7 +53548,7 @@ class BoardSelection {
|
|
|
53489
53548
|
return copiedItemsMap;
|
|
53490
53549
|
}
|
|
53491
53550
|
cut() {
|
|
53492
|
-
const items = this.copy();
|
|
53551
|
+
const items = this.copy(true);
|
|
53493
53552
|
this.removeFromBoard();
|
|
53494
53553
|
return items;
|
|
53495
53554
|
}
|
|
@@ -53640,7 +53699,7 @@ class BoardSelection {
|
|
|
53640
53699
|
});
|
|
53641
53700
|
Object.values(selectedMap).forEach((val) => {
|
|
53642
53701
|
const parentFrame = this.board.items.getById(val.item.parent);
|
|
53643
|
-
const isParentFrame = parentFrame
|
|
53702
|
+
const isParentFrame = parentFrame instanceof Frame;
|
|
53644
53703
|
const parentFrameId = isParentFrame ? parentFrame.getId() : null;
|
|
53645
53704
|
if (val.nested) {
|
|
53646
53705
|
const isRemoveChildFromFrame = Object.values(selectedMap).some((val2) => val2.nested && val2.nested.getId() !== parentFrameId);
|
|
@@ -53655,7 +53714,7 @@ class BoardSelection {
|
|
|
53655
53714
|
console.warn(`Didnt find frame with id ${val.item.parent}`);
|
|
53656
53715
|
}
|
|
53657
53716
|
}
|
|
53658
|
-
if (val.item
|
|
53717
|
+
if (val.item instanceof Frame && checkFrames) {
|
|
53659
53718
|
const currFrame = val.item;
|
|
53660
53719
|
const currMbr = currFrame.getMbr();
|
|
53661
53720
|
const children = val.item.getChildrenIds().map((childId) => this.board.items.getById(childId)).filter((item) => !!item);
|
|
@@ -54063,12 +54122,6 @@ class BoardSelection {
|
|
|
54063
54122
|
text5.setEditorFocus(this.context);
|
|
54064
54123
|
}
|
|
54065
54124
|
}
|
|
54066
|
-
getMediaStorageIds() {
|
|
54067
|
-
return this.items.list().filter((item) => {
|
|
54068
|
-
const shouldClearStorageUsage = item.itemType === "Image" || item.itemType === "Video" && item.getIsStorageUrl() || item.itemType === "Audio" && item.getIsStorageUrl();
|
|
54069
|
-
return shouldClearStorageUsage;
|
|
54070
|
-
}).map((item) => item.getStorageId());
|
|
54071
|
-
}
|
|
54072
54125
|
removeFromBoard() {
|
|
54073
54126
|
const isLocked = this.items.list().some((item) => item.transformation.isLocked);
|
|
54074
54127
|
if (isLocked) {
|
|
@@ -54083,7 +54136,6 @@ class BoardSelection {
|
|
|
54083
54136
|
const connectors = itemIds.flatMap((id) => {
|
|
54084
54137
|
return this.board.items.getLinkedConnectorsById(id);
|
|
54085
54138
|
}).map((connector) => connector.getId());
|
|
54086
|
-
conf.hooks.beforeMediaRemove(this.getMediaStorageIds(), this.board.getBoardId());
|
|
54087
54139
|
this.emit({
|
|
54088
54140
|
class: "Board",
|
|
54089
54141
|
method: "remove",
|
|
@@ -54120,7 +54172,15 @@ class BoardSelection {
|
|
|
54120
54172
|
this.board.sendToBack(this.items.list());
|
|
54121
54173
|
}
|
|
54122
54174
|
async duplicate() {
|
|
54123
|
-
const mediaIds =
|
|
54175
|
+
const mediaIds = [];
|
|
54176
|
+
this.items.list().forEach((item) => {
|
|
54177
|
+
if ("getStorageId" in item) {
|
|
54178
|
+
const storageId = item.getStorageId();
|
|
54179
|
+
if (storageId) {
|
|
54180
|
+
mediaIds.push(storageId);
|
|
54181
|
+
}
|
|
54182
|
+
}
|
|
54183
|
+
});
|
|
54124
54184
|
const canDuplicate = mediaIds.length ? await conf.hooks.beforeMediaUpload(mediaIds, this.board.getBoardId()) : true;
|
|
54125
54185
|
if (!canDuplicate) {
|
|
54126
54186
|
return;
|
|
@@ -54188,7 +54248,7 @@ class BoardSelection {
|
|
|
54188
54248
|
}
|
|
54189
54249
|
}
|
|
54190
54250
|
const contextItems = [];
|
|
54191
|
-
if (single && single
|
|
54251
|
+
if (single && single instanceof AINode) {
|
|
54192
54252
|
const contextItemsIds = single.getContextItems();
|
|
54193
54253
|
if (contextItemsIds.length) {
|
|
54194
54254
|
const newContextItems = this.board.items.listAll().filter((item) => contextItemsIds.includes(item.getId()));
|
|
@@ -54210,7 +54270,7 @@ class BoardSelection {
|
|
|
54210
54270
|
}
|
|
54211
54271
|
}
|
|
54212
54272
|
contextItems.forEach((item) => {
|
|
54213
|
-
if (item
|
|
54273
|
+
if (item instanceof AINode) {
|
|
54214
54274
|
const path2 = item.getPath();
|
|
54215
54275
|
path2.setBorderColor(CONTEXT_NODE_HIGHLIGHT_COLOR);
|
|
54216
54276
|
path2.setBorderWidth(2);
|
|
@@ -54225,6 +54285,416 @@ class BoardSelection {
|
|
|
54225
54285
|
});
|
|
54226
54286
|
}
|
|
54227
54287
|
}
|
|
54288
|
+
// src/public/customWebComponents.js
|
|
54289
|
+
var customWebComponents_default = `/* eslint-disable max-classes-per-file, @typescript-eslint/no-useless-constructor */
|
|
54290
|
+
class RichTextElement extends HTMLElement {
|
|
54291
|
+
constructor() {
|
|
54292
|
+
super();
|
|
54293
|
+
}
|
|
54294
|
+
}
|
|
54295
|
+
|
|
54296
|
+
class ShapeItemElement extends HTMLElement {
|
|
54297
|
+
constructor() {
|
|
54298
|
+
super();
|
|
54299
|
+
}
|
|
54300
|
+
}
|
|
54301
|
+
|
|
54302
|
+
class StickerElement extends HTMLElement {
|
|
54303
|
+
constructor() {
|
|
54304
|
+
super();
|
|
54305
|
+
}
|
|
54306
|
+
}
|
|
54307
|
+
|
|
54308
|
+
class DrawingElement extends HTMLElement {
|
|
54309
|
+
constructor() {
|
|
54310
|
+
super();
|
|
54311
|
+
}
|
|
54312
|
+
}
|
|
54313
|
+
|
|
54314
|
+
class ConnectorElement extends HTMLElement {
|
|
54315
|
+
constructor() {
|
|
54316
|
+
super();
|
|
54317
|
+
}
|
|
54318
|
+
}
|
|
54319
|
+
|
|
54320
|
+
class FrameItemElement extends HTMLElement {
|
|
54321
|
+
constructor() {
|
|
54322
|
+
super();
|
|
54323
|
+
}
|
|
54324
|
+
}
|
|
54325
|
+
|
|
54326
|
+
class ImageItemElement extends HTMLElement {
|
|
54327
|
+
constructor() {
|
|
54328
|
+
super();
|
|
54329
|
+
}
|
|
54330
|
+
}
|
|
54331
|
+
|
|
54332
|
+
class LinkItemElement extends HTMLElement {
|
|
54333
|
+
constructor() {
|
|
54334
|
+
super();
|
|
54335
|
+
}
|
|
54336
|
+
}
|
|
54337
|
+
|
|
54338
|
+
class AINodeItemElement extends HTMLElement {
|
|
54339
|
+
constructor() {
|
|
54340
|
+
super();
|
|
54341
|
+
}
|
|
54342
|
+
}
|
|
54343
|
+
|
|
54344
|
+
class VideoItemElement extends HTMLElement {
|
|
54345
|
+
constructor() {
|
|
54346
|
+
super();
|
|
54347
|
+
}
|
|
54348
|
+
}
|
|
54349
|
+
|
|
54350
|
+
class CommentElement extends HTMLElement {
|
|
54351
|
+
constructor() {
|
|
54352
|
+
super();
|
|
54353
|
+
}
|
|
54354
|
+
}
|
|
54355
|
+
|
|
54356
|
+
class AudioItemElement extends HTMLElement {
|
|
54357
|
+
constructor() {
|
|
54358
|
+
super();
|
|
54359
|
+
}
|
|
54360
|
+
}
|
|
54361
|
+
|
|
54362
|
+
customElements.define("rich-text", RichTextElement);
|
|
54363
|
+
customElements.define("shape-item", ShapeItemElement);
|
|
54364
|
+
customElements.define("sticker-item", StickerElement);
|
|
54365
|
+
customElements.define("drawing-item", DrawingElement);
|
|
54366
|
+
customElements.define("connector-item", ConnectorElement);
|
|
54367
|
+
customElements.define("frame-item", FrameItemElement);
|
|
54368
|
+
customElements.define("image-item", ImageItemElement);
|
|
54369
|
+
customElements.define("link-item", LinkItemElement);
|
|
54370
|
+
customElements.define("ainode-item", AINodeItemElement);
|
|
54371
|
+
customElements.define("video-item", VideoItemElement);
|
|
54372
|
+
customElements.define("comment-item", CommentElement);
|
|
54373
|
+
customElements.define("audio-item", AudioItemElement);
|
|
54374
|
+
|
|
54375
|
+
document.addEventListener("DOMContentLoaded", () => {
|
|
54376
|
+
const itemsDiv = document.querySelector("#items");
|
|
54377
|
+
if (!itemsDiv) {
|
|
54378
|
+
console.error("ITEMS DIV NOT FOUND!");
|
|
54379
|
+
return;
|
|
54380
|
+
}
|
|
54381
|
+
let isDragging = false;
|
|
54382
|
+
let startX, startY;
|
|
54383
|
+
let translateX = 0;
|
|
54384
|
+
let translateY = 0;
|
|
54385
|
+
let scale = 1;
|
|
54386
|
+
|
|
54387
|
+
itemsDiv.style.transformOrigin = "0 0";
|
|
54388
|
+
document.body.style.cursor = "grab";
|
|
54389
|
+
|
|
54390
|
+
function updateTransform() {
|
|
54391
|
+
itemsDiv.style.transform =
|
|
54392
|
+
"translate(" +
|
|
54393
|
+
translateX +
|
|
54394
|
+
"px, " +
|
|
54395
|
+
translateY +
|
|
54396
|
+
"px) scale(" +
|
|
54397
|
+
scale +
|
|
54398
|
+
")";
|
|
54399
|
+
}
|
|
54400
|
+
|
|
54401
|
+
function handleMouseDown(ev) {
|
|
54402
|
+
isDragging = true;
|
|
54403
|
+
startX = ev.clientX;
|
|
54404
|
+
startY = ev.clientY;
|
|
54405
|
+
itemsDiv.style.cursor = "grabbing";
|
|
54406
|
+
}
|
|
54407
|
+
|
|
54408
|
+
function handleMouseMove(ev) {
|
|
54409
|
+
if (!isDragging) {
|
|
54410
|
+
return;
|
|
54411
|
+
}
|
|
54412
|
+
const dx = ev.clientX - startX;
|
|
54413
|
+
const dy = ev.clientY - startY;
|
|
54414
|
+
startX += dx;
|
|
54415
|
+
startY += dy;
|
|
54416
|
+
translateX += dx;
|
|
54417
|
+
translateY += dy;
|
|
54418
|
+
updateTransform();
|
|
54419
|
+
}
|
|
54420
|
+
|
|
54421
|
+
function handleMouseUp(ev) {
|
|
54422
|
+
if (!isDragging) {
|
|
54423
|
+
return;
|
|
54424
|
+
}
|
|
54425
|
+
isDragging = false;
|
|
54426
|
+
itemsDiv.style.cursor = "grab";
|
|
54427
|
+
}
|
|
54428
|
+
|
|
54429
|
+
function handleWheel(ev) {
|
|
54430
|
+
ev.preventDefault();
|
|
54431
|
+
const factor = ev.deltaY < 0 ? 1.1 : 0.9;
|
|
54432
|
+
translateX = ev.clientX - (ev.clientX - translateX) * factor;
|
|
54433
|
+
translateY = ev.clientY - (ev.clientY - translateY) * factor;
|
|
54434
|
+
scale *= factor;
|
|
54435
|
+
updateTransform();
|
|
54436
|
+
}
|
|
54437
|
+
|
|
54438
|
+
document.addEventListener("mousedown", handleMouseDown);
|
|
54439
|
+
document.addEventListener("mousemove", handleMouseMove);
|
|
54440
|
+
document.addEventListener("mouseup", handleMouseUp);
|
|
54441
|
+
document.addEventListener("wheel", handleWheel, { passive: false });
|
|
54442
|
+
|
|
54443
|
+
const titlePanel = document.createElement("div");
|
|
54444
|
+
titlePanel.style.boxShadow = "0px 10px 16px -3px rgba(20, 21, 26, 0.08)";
|
|
54445
|
+
titlePanel.style.position = "fixed";
|
|
54446
|
+
titlePanel.style.left = "12px";
|
|
54447
|
+
titlePanel.style.top = "12px";
|
|
54448
|
+
titlePanel.style.borderRadius = "12px";
|
|
54449
|
+
titlePanel.style.backgroundColor = "#ffff";
|
|
54450
|
+
titlePanel.style.display = "flex";
|
|
54451
|
+
titlePanel.style.alignItems = "center";
|
|
54452
|
+
titlePanel.style.gap = "8px";
|
|
54453
|
+
titlePanel.style.padding = "0 12px";
|
|
54454
|
+
titlePanel.style.height = "48px";
|
|
54455
|
+
const editButton = document.createElement("button");
|
|
54456
|
+
const editIcon = document.createElementNS(
|
|
54457
|
+
"http://www.w3.org/2000/svg",
|
|
54458
|
+
"svg",
|
|
54459
|
+
);
|
|
54460
|
+
editIcon.setAttribute("width", "13");
|
|
54461
|
+
editIcon.setAttribute("height", "13");
|
|
54462
|
+
editIcon.setAttribute("viewBox", "0 0 13 13");
|
|
54463
|
+
editIcon.setAttribute("fill", "none");
|
|
54464
|
+
editIcon.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
|
54465
|
+
const editIconPath = document.createElementNS(
|
|
54466
|
+
"http://www.w3.org/2000/svg",
|
|
54467
|
+
"path",
|
|
54468
|
+
);
|
|
54469
|
+
editIconPath.setAttribute(
|
|
54470
|
+
"d",
|
|
54471
|
+
"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",
|
|
54472
|
+
);
|
|
54473
|
+
editIconPath.setAttribute("fill", "#ffff");
|
|
54474
|
+
editIcon.appendChild(editIconPath);
|
|
54475
|
+
editButton.appendChild(editIcon);
|
|
54476
|
+
const editFileText = document.createElement("p");
|
|
54477
|
+
const isSnapshotInIframe =
|
|
54478
|
+
window.parent &&
|
|
54479
|
+
window.parent !== window &&
|
|
54480
|
+
window.parent.location.href.includes("/snapshots/");
|
|
54481
|
+
editFileText.textContent = isSnapshotInIframe ? "Edit copy" : "Edit file";
|
|
54482
|
+
editButton.appendChild(editFileText);
|
|
54483
|
+
|
|
54484
|
+
editButton.style.backgroundColor = "rgba(20, 21, 26, 1)";
|
|
54485
|
+
editButton.style.cursor = "pointer";
|
|
54486
|
+
editButton.style.boxShadow = "0px 1px 2px 0px rgba(20, 21, 26, 0.05)";
|
|
54487
|
+
editButton.style.color = "#ffff";
|
|
54488
|
+
editButton.style.fontSize = "14px";
|
|
54489
|
+
editButton.style.lineHeight = "20px";
|
|
54490
|
+
editButton.style.display = "flex";
|
|
54491
|
+
editButton.style.alignItems = "center";
|
|
54492
|
+
editButton.style.gap = "8px";
|
|
54493
|
+
editButton.style.padding = "8px";
|
|
54494
|
+
editButton.style.borderRadius = "10px";
|
|
54495
|
+
const separator = document.createElement("div");
|
|
54496
|
+
separator.style.borderRight = "1px solid rgba(222, 224, 227, 1)";
|
|
54497
|
+
separator.style.height = "100%";
|
|
54498
|
+
const boardName = document.createElement("div");
|
|
54499
|
+
const fileIcon = document.createElementNS(
|
|
54500
|
+
"http://www.w3.org/2000/svg",
|
|
54501
|
+
"svg",
|
|
54502
|
+
);
|
|
54503
|
+
fileIcon.setAttribute("width", "16");
|
|
54504
|
+
fileIcon.setAttribute("height", "18");
|
|
54505
|
+
fileIcon.setAttribute("viewBox", "0 0 16 18");
|
|
54506
|
+
fileIcon.setAttribute("fill", "none");
|
|
54507
|
+
fileIcon.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
|
54508
|
+
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
54509
|
+
path.setAttribute(
|
|
54510
|
+
"d",
|
|
54511
|
+
"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",
|
|
54512
|
+
);
|
|
54513
|
+
path.setAttribute("fill", "#696B76");
|
|
54514
|
+
fileIcon.appendChild(path);
|
|
54515
|
+
boardName.appendChild(fileIcon);
|
|
54516
|
+
const boardNameTag = document.querySelector('meta[name="board-name"]');
|
|
54517
|
+
let boardNameStr = "Untitled";
|
|
54518
|
+
if (boardNameTag) {
|
|
54519
|
+
boardNameStr = boardNameTag.getAttribute("content");
|
|
54520
|
+
}
|
|
54521
|
+
const p = document.createElement("p");
|
|
54522
|
+
p.textContent = boardNameStr;
|
|
54523
|
+
p.style.fontSize = "16px";
|
|
54524
|
+
p.style.lineHeight = "24px";
|
|
54525
|
+
boardName.appendChild(p);
|
|
54526
|
+
const cloudIcon = document.createElementNS(
|
|
54527
|
+
"http://www.w3.org/2000/svg",
|
|
54528
|
+
"svg",
|
|
54529
|
+
);
|
|
54530
|
+
cloudIcon.setAttribute("width", "20");
|
|
54531
|
+
cloudIcon.setAttribute("height", "18");
|
|
54532
|
+
cloudIcon.setAttribute("viewBox", "0 0 20 18");
|
|
54533
|
+
cloudIcon.setAttribute("fill", "none");
|
|
54534
|
+
cloudIcon.setAttribute("xmlns", "http://www.w3.org/2000/svg");
|
|
54535
|
+
const cloudIconPath = document.createElementNS(
|
|
54536
|
+
"http://www.w3.org/2000/svg",
|
|
54537
|
+
"path",
|
|
54538
|
+
);
|
|
54539
|
+
cloudIconPath.setAttribute(
|
|
54540
|
+
"d",
|
|
54541
|
+
"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",
|
|
54542
|
+
);
|
|
54543
|
+
cloudIconPath.setAttribute("fill", "#696B76");
|
|
54544
|
+
cloudIcon.appendChild(cloudIconPath);
|
|
54545
|
+
boardName.appendChild(cloudIcon);
|
|
54546
|
+
boardName.style.display = "flex";
|
|
54547
|
+
boardName.style.alignItems = "center";
|
|
54548
|
+
boardName.style.gap = "8px";
|
|
54549
|
+
titlePanel.appendChild(boardName);
|
|
54550
|
+
titlePanel.appendChild(separator);
|
|
54551
|
+
titlePanel.appendChild(editButton);
|
|
54552
|
+
document.body.appendChild(titlePanel);
|
|
54553
|
+
|
|
54554
|
+
editButton.onclick = async () => {
|
|
54555
|
+
editButton.disabled = true;
|
|
54556
|
+
editButton.textContent = "Loading...";
|
|
54557
|
+
|
|
54558
|
+
try {
|
|
54559
|
+
document.removeEventListener("mousedown", handleMouseDown);
|
|
54560
|
+
document.removeEventListener("mousemove", handleMouseMove);
|
|
54561
|
+
document.removeEventListener("mouseup", handleMouseUp);
|
|
54562
|
+
document.removeEventListener("wheel", handleWheel, {
|
|
54563
|
+
passive: false,
|
|
54564
|
+
});
|
|
54565
|
+
translateX = 0;
|
|
54566
|
+
translateY = 0;
|
|
54567
|
+
scale = 1;
|
|
54568
|
+
updateTransform();
|
|
54569
|
+
|
|
54570
|
+
const { initBrowserSettings } = await import(
|
|
54571
|
+
"https://www.unpkg.com/test_package_board@0.0.99/dist/bundle.js"
|
|
54572
|
+
);
|
|
54573
|
+
initBrowserSettings();
|
|
54574
|
+
|
|
54575
|
+
const { createApp } = await import(
|
|
54576
|
+
"https://www.unpkg.com/test_package_board@0.0.99/dist/bundle.js"
|
|
54577
|
+
);
|
|
54578
|
+
|
|
54579
|
+
const app = createApp();
|
|
54580
|
+
window.app = app;
|
|
54581
|
+
const stringed = await app.openAndEditFile();
|
|
54582
|
+
|
|
54583
|
+
if (stringed) {
|
|
54584
|
+
await app.openBoardFromFile();
|
|
54585
|
+
app.getBoard().deserializeHTML(stringed);
|
|
54586
|
+
app.localRender("items");
|
|
54587
|
+
}
|
|
54588
|
+
|
|
54589
|
+
const response = await fetch(
|
|
54590
|
+
"https://www.unpkg.com/test_package_board@0.0.99/dist/bundle.css",
|
|
54591
|
+
);
|
|
54592
|
+
const cssText = await response.text();
|
|
54593
|
+
const styleEl = document.createElement("style");
|
|
54594
|
+
styleEl.textContent = cssText;
|
|
54595
|
+
document.body.appendChild(styleEl);
|
|
54596
|
+
|
|
54597
|
+
const responseSvg = await fetch(
|
|
54598
|
+
"https://www.unpkg.com/test_package_board@0.0.99/dist/sprite.svg",
|
|
54599
|
+
);
|
|
54600
|
+
const svgText = await responseSvg.text();
|
|
54601
|
+
const div = document.createElement("div");
|
|
54602
|
+
div.style.display = "none";
|
|
54603
|
+
div.id = "sprite";
|
|
54604
|
+
div.innerHTML = svgText;
|
|
54605
|
+
document.body.appendChild(div);
|
|
54606
|
+
} finally {
|
|
54607
|
+
editButton.disabled = false;
|
|
54608
|
+
editButton.textContent = "Edit board";
|
|
54609
|
+
}
|
|
54610
|
+
};
|
|
54611
|
+
});
|
|
54612
|
+
`;
|
|
54613
|
+
|
|
54614
|
+
// src/public/loadLinkImages.js
|
|
54615
|
+
var loadLinkImages_default = `document.addEventListener("DOMContentLoaded", function () {
|
|
54616
|
+
document.querySelectorAll(".link-object").forEach(linkItem => {
|
|
54617
|
+
const linkImage = linkItem.querySelector(".link-image");
|
|
54618
|
+
const linkContainer = linkItem.querySelector("a");
|
|
54619
|
+
linkImage.onerror = () => {
|
|
54620
|
+
linkImage.onerror = null;
|
|
54621
|
+
linkImage.style.display = "none";
|
|
54622
|
+
const svgNamespace = "http://www.w3.org/2000/svg";
|
|
54623
|
+
const svg = document.createElementNS(svgNamespace, "svg");
|
|
54624
|
+
svg.setAttribute("width", "20");
|
|
54625
|
+
svg.setAttribute("height", "20");
|
|
54626
|
+
svg.setAttribute("viewBox", "0 0 13 14");
|
|
54627
|
+
svg.setAttribute("fill", "none");
|
|
54628
|
+
|
|
54629
|
+
const path = document.createElementNS(svgNamespace, "path");
|
|
54630
|
+
path.setAttribute(
|
|
54631
|
+
"d",
|
|
54632
|
+
"M11.0054 3.414L2.39838 12.021L0.984375 10.607L9.59037 2H2.00538V0H13.0054V11H11.0054V3.414Z",
|
|
54633
|
+
);
|
|
54634
|
+
path.setAttribute("fill", "#924FE8");
|
|
54635
|
+
svg.appendChild(path);
|
|
54636
|
+
|
|
54637
|
+
linkContainer.appendChild(svg);
|
|
54638
|
+
};
|
|
54639
|
+
});
|
|
54640
|
+
});
|
|
54641
|
+
`;
|
|
54642
|
+
|
|
54643
|
+
// src/public/index.css
|
|
54644
|
+
var public_default = `@import "https://fonts.googleapis.com/css2?family=Manrope:wght@200..800&display=swap";
|
|
54645
|
+
@import "https://fonts.googleapis.com/css2?family=Open+Sans:wght@400;700&display=swap";
|
|
54646
|
+
|
|
54647
|
+
/* ../src/index.css */
|
|
54648
|
+
:root {
|
|
54649
|
+
--background-surface-default: rgb(255, 255, 255);
|
|
54650
|
+
--background-button-secondary: rgb(255, 255, 255);
|
|
54651
|
+
--background-button-secondary-hover: rgb(247, 247, 248);
|
|
54652
|
+
--background-badge-purple-disabled: rgb(247, 241, 253);
|
|
54653
|
+
--background-badge-gray: rgb(233, 234, 236);
|
|
54654
|
+
--background-accent-purple: rgb(146, 79, 232);
|
|
54655
|
+
--border-action-normal: rgb(222, 223, 227);
|
|
54656
|
+
--border-action-focus: rgb(146, 79, 232);
|
|
54657
|
+
--border-select-primary: rgb(146, 79, 232);
|
|
54658
|
+
--text-base-primary: rgb(20, 21, 26);
|
|
54659
|
+
--text-base-secondary: rgba(15, 19, 36, 0.6);
|
|
54660
|
+
--text-base-quaternary: rgb(10, 15, 41, 0.25);
|
|
54661
|
+
--text-accent-purple: rgb(152, 89, 233);
|
|
54662
|
+
--icon-base-primary: rgb(20, 21, 26);
|
|
54663
|
+
--icon-base-secondary: rgb(105, 107, 118);
|
|
54664
|
+
--icon-accent-purple: rgb(146, 79, 232);
|
|
54665
|
+
--absolute-position-panel-padding: 12px;
|
|
54666
|
+
}
|
|
54667
|
+
* {
|
|
54668
|
+
box-sizing: border-box;
|
|
54669
|
+
padding: 0;
|
|
54670
|
+
margin: 0;
|
|
54671
|
+
border: none;
|
|
54672
|
+
background: none;
|
|
54673
|
+
font-family: inherit;
|
|
54674
|
+
}
|
|
54675
|
+
html {
|
|
54676
|
+
font-size: 62.5%;
|
|
54677
|
+
}
|
|
54678
|
+
body {
|
|
54679
|
+
color: var(--text-base-primary);
|
|
54680
|
+
font-size: 1.6rem;
|
|
54681
|
+
font-optical-sizing: auto;
|
|
54682
|
+
font-style: normal;
|
|
54683
|
+
font-family: "Manrope", sans-serif;
|
|
54684
|
+
}
|
|
54685
|
+
html,
|
|
54686
|
+
body {
|
|
54687
|
+
overscroll-behavior-x: none;
|
|
54688
|
+
-webkit-user-select: none;
|
|
54689
|
+
}
|
|
54690
|
+
input:-webkit-autofill,
|
|
54691
|
+
input:-webkit-autofill:hover,
|
|
54692
|
+
input:-webkit-autofill:focus,
|
|
54693
|
+
input:-webkit-autofill:active {
|
|
54694
|
+
-webkit-box-shadow: 0 0 0 30px white inset !important;
|
|
54695
|
+
}
|
|
54696
|
+
`;
|
|
54697
|
+
|
|
54228
54698
|
// src/Board.ts
|
|
54229
54699
|
class Board {
|
|
54230
54700
|
boardId;
|
|
@@ -54607,9 +55077,9 @@ class Board {
|
|
|
54607
55077
|
return this.copy();
|
|
54608
55078
|
}
|
|
54609
55079
|
serializeHTML() {
|
|
54610
|
-
const customTagsScript =
|
|
54611
|
-
const loadLinksImagesScript =
|
|
54612
|
-
const css =
|
|
55080
|
+
const customTagsScript = customWebComponents_default;
|
|
55081
|
+
const loadLinksImagesScript = loadLinkImages_default;
|
|
55082
|
+
const css = public_default;
|
|
54613
55083
|
const boardName = this.getName() || this.getBoardId();
|
|
54614
55084
|
const items = this.items.getWholeHTML(conf.documentFactory);
|
|
54615
55085
|
const itemsDiv = `<div id="items">${items}</div>`;
|