@plait/mind 0.55.1 → 0.56.1
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/esm2022/generators/node-active.generator.mjs +2 -1
- package/esm2022/generators/node-emojis.generator.mjs +2 -1
- package/esm2022/interfaces/element.mjs +2 -6
- package/esm2022/mind-node.component.mjs +16 -30
- package/esm2022/plugins/with-abstract-resize.mjs +11 -9
- package/esm2022/plugins/with-mind-create.mjs +7 -9
- package/esm2022/plugins/with-mind-fragment.mjs +7 -7
- package/esm2022/plugins/with-mind.mjs +5 -2
- package/esm2022/plugins/with-node-image.mjs +5 -5
- package/esm2022/plugins/with-node-resize.mjs +1 -1
- package/esm2022/transforms/index.mjs +4 -3
- package/esm2022/transforms/node.mjs +5 -1
- package/esm2022/utils/abstract/resize.mjs +8 -5
- package/esm2022/utils/clipboard.mjs +4 -4
- package/esm2022/utils/draw/node-dnd.mjs +13 -9
- package/esm2022/utils/mind.mjs +1 -1
- package/esm2022/utils/node/common.mjs +12 -7
- package/esm2022/utils/node/image.mjs +10 -8
- package/fesm2022/plait-mind.mjs +297 -297
- package/fesm2022/plait-mind.mjs.map +1 -1
- package/generators/node-active.generator.d.ts +1 -1
- package/generators/node-emojis.generator.d.ts +1 -0
- package/interfaces/element.d.ts +0 -1
- package/mind-node.component.d.ts +3 -5
- package/package.json +1 -1
- package/transforms/index.d.ts +1 -0
- package/transforms/node.d.ts +1 -0
- package/utils/clipboard.d.ts +2 -2
- package/utils/node/common.d.ts +2 -2
package/fesm2022/plait-mind.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
2
|
import { Component, ChangeDetectionStrategy, NgZone, Directive, Input, HostListener } from '@angular/core';
|
|
3
|
-
import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, PlaitElement, PlaitNode, Path, isNullOrUndefined, PlaitBoard, getSelectedElements, idCreator, Transforms, clearSelectedElement, addSelectedElement, distanceBetweenPointAndRectangle, RectangleClient, depthFirstRecursion, getIsRecursionFunc, drawRoundRectangle, drawLinearPath, drawBezierPath, createG, updateForeignObject, getRectangleByElements,
|
|
3
|
+
import { DefaultThemeColor, ColorfulThemeColor, SoftThemeColor, RetroThemeColor, DarkThemeColor, StarryThemeColor, PlaitElement, PlaitNode, Path, isNullOrUndefined, PlaitBoard, getSelectedElements, idCreator, Transforms, clearSelectedElement, addSelectedElement, distanceBetweenPointAndRectangle, RectangleClient, depthFirstRecursion, getIsRecursionFunc, drawRoundRectangle, drawLinearPath, drawBezierPath, createG, createForeignObject, updateForeignObject, getRectangleByElements, setStrokeLinecap, ACTIVE_STROKE_WIDTH, NODE_TO_PARENT, removeSelectedElement, PlaitHistoryBoard, createText, PlaitPointerType, NODE_TO_INDEX, isMainPointer, toViewBoxPoint, toHostPoint, getHitElementByPoint, distanceBetweenPointAndPoint, CoreTransforms, BOARD_TO_HOST, BoardTransforms, throttleRAF, isContextmenu, temporaryDisableSelection, hotkeys, createClipboardContext, WritableClipboardType, ResizeCursorClass, Point, WritableClipboardOperationType, addClipboardContext, PlaitPluginKey } from '@plait/core';
|
|
4
4
|
import { MindLayoutType, AbstractNode, isIndentedLayout, isHorizontalLayout, isHorizontalLogicLayout, ConnectingPosition, getNonAbstractChildren, isStandardLayout, isLeftLayout, isRightLayout, isVerticalLogicLayout, isTopLayout, isBottomLayout, getCorrectStartEnd, getAbstractLayout, GlobalLayout } from '@plait/layouts';
|
|
5
|
-
import { TEXT_DEFAULT_HEIGHT, buildText, PlaitMarkEditor, MarkTypes, DEFAULT_FONT_SIZE, getTextSize, TextManage
|
|
5
|
+
import { ExitOrigin, TEXT_DEFAULT_HEIGHT, buildText, PlaitMarkEditor, MarkTypes, DEFAULT_FONT_SIZE, getTextSize, TextManage } from '@plait/text';
|
|
6
6
|
import { fromEvent, Subject } from 'rxjs';
|
|
7
|
-
import { getFirstTextEditor, RESIZE_HANDLE_DIAMETER, getRectangleResizeHandleRefs, addElementOfFocusedImage, removeElementOfFocusedImage,
|
|
7
|
+
import { getFirstTextManage, getFirstTextEditor, RESIZE_HANDLE_DIAMETER, getRectangleResizeHandleRefs, addElementOfFocusedImage, ImageGenerator, removeElementOfFocusedImage, Generator, PropertyTransforms, CommonPluginElement, WithTextPluginKey, isDrawingMode, isDndMode, setCreationMode, BoardCreationMode, isExpandHotkey, isTabHotkey, isEnterHotkey, isVirtualKey, isDelete, isSpaceHotkey, getElementOfFocusedImage, acceptImageTypes, buildImage, withResize, getElementsText } from '@plait/common';
|
|
8
8
|
import { Node as Node$1, Path as Path$1 } from 'slate';
|
|
9
9
|
import { pointsOnBezierCurves } from 'points-on-curve';
|
|
10
10
|
import { take, filter } from 'rxjs/operators';
|
|
@@ -479,12 +479,15 @@ const getShapeByElement = (board, element) => {
|
|
|
479
479
|
};
|
|
480
480
|
|
|
481
481
|
function editTopic(element) {
|
|
482
|
-
const
|
|
483
|
-
|
|
482
|
+
const textManage = getFirstTextManage(element);
|
|
483
|
+
textManage?.edit((origin) => {
|
|
484
|
+
if (origin === ExitOrigin.default) {
|
|
485
|
+
}
|
|
486
|
+
});
|
|
484
487
|
}
|
|
485
|
-
const getSelectedMindElements = (board) => {
|
|
486
|
-
const selectedElements =
|
|
487
|
-
return selectedElements;
|
|
488
|
+
const getSelectedMindElements = (board, elements) => {
|
|
489
|
+
const selectedElements = elements?.length ? elements : getSelectedElements(board);
|
|
490
|
+
return selectedElements.filter(value => MindElement.isMindElement(board, value));
|
|
488
491
|
};
|
|
489
492
|
|
|
490
493
|
const TOPIC_COLOR = '#333';
|
|
@@ -1081,15 +1084,17 @@ const adjustNodeToRoot = (board, node) => {
|
|
|
1081
1084
|
|
|
1082
1085
|
const addImageFocus = (board, element) => {
|
|
1083
1086
|
addElementOfFocusedImage(board, element);
|
|
1084
|
-
const
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
+
const commonElementRef = PlaitElement.getElementRef(element);
|
|
1088
|
+
const imageGenerator = commonElementRef.getGenerator(ImageGenerator.key);
|
|
1089
|
+
imageGenerator.componentRef.instance.isFocus = true;
|
|
1090
|
+
imageGenerator.componentRef.instance.cdr.markForCheck();
|
|
1087
1091
|
};
|
|
1088
1092
|
const removeImageFocus = (board, element) => {
|
|
1089
1093
|
removeElementOfFocusedImage(board);
|
|
1090
|
-
const
|
|
1091
|
-
|
|
1092
|
-
|
|
1094
|
+
const commonElementRef = PlaitElement.getElementRef(element);
|
|
1095
|
+
const imageGenerator = commonElementRef.getGenerator(ImageGenerator.key);
|
|
1096
|
+
imageGenerator.componentRef.instance.isFocus = false;
|
|
1097
|
+
imageGenerator.componentRef.instance.cdr.markForCheck();
|
|
1093
1098
|
};
|
|
1094
1099
|
|
|
1095
1100
|
/**
|
|
@@ -1593,17 +1598,90 @@ function drawLink(board, parentNode, node, isHorizontal, needDrawUnderline, defa
|
|
|
1593
1598
|
: drawLogicLink(board, parentNode, node, isHorizontal, defaultStroke, defaultStrokeWidth);
|
|
1594
1599
|
}
|
|
1595
1600
|
|
|
1601
|
+
class EmojiGenerator {
|
|
1602
|
+
constructor(board, viewContainerRef) {
|
|
1603
|
+
this.board = board;
|
|
1604
|
+
this.viewContainerRef = viewContainerRef;
|
|
1605
|
+
this.componentRef = null;
|
|
1606
|
+
}
|
|
1607
|
+
draw(emoji, element) {
|
|
1608
|
+
this.destroy();
|
|
1609
|
+
const componentType = this.board.getPluginOptions(WithMindPluginKey).emojiComponentType;
|
|
1610
|
+
if (!componentType) {
|
|
1611
|
+
throw new Error('can not find emoji component');
|
|
1612
|
+
}
|
|
1613
|
+
this.componentRef = this.viewContainerRef.createComponent(componentType);
|
|
1614
|
+
this.componentRef.instance.emojiItem = emoji;
|
|
1615
|
+
this.componentRef.instance.board = this.board;
|
|
1616
|
+
this.componentRef.instance.element = element;
|
|
1617
|
+
this.componentRef.instance.fontSize = getEmojiFontSize(element);
|
|
1618
|
+
}
|
|
1619
|
+
get nativeElement() {
|
|
1620
|
+
if (this.componentRef) {
|
|
1621
|
+
return this.componentRef.instance.nativeElement;
|
|
1622
|
+
}
|
|
1623
|
+
else {
|
|
1624
|
+
return null;
|
|
1625
|
+
}
|
|
1626
|
+
}
|
|
1627
|
+
destroy() {
|
|
1628
|
+
if (this.componentRef) {
|
|
1629
|
+
this.componentRef.destroy();
|
|
1630
|
+
this.componentRef = null;
|
|
1631
|
+
}
|
|
1632
|
+
}
|
|
1633
|
+
}
|
|
1634
|
+
class NodeEmojisGenerator {
|
|
1635
|
+
static { this.key = 'node-emojis-generator'; }
|
|
1636
|
+
constructor(board, viewContainerRef) {
|
|
1637
|
+
this.board = board;
|
|
1638
|
+
this.viewContainerRef = viewContainerRef;
|
|
1639
|
+
this.emojiGenerators = [];
|
|
1640
|
+
}
|
|
1641
|
+
drawEmojis(element) {
|
|
1642
|
+
this.destroy();
|
|
1643
|
+
if (MindElement.hasEmojis(element)) {
|
|
1644
|
+
this.g = createG();
|
|
1645
|
+
this.g.classList.add('emojis');
|
|
1646
|
+
const foreignRectangle = getEmojiForeignRectangle(this.board, element);
|
|
1647
|
+
const foreignObject = createForeignObject(foreignRectangle.x, foreignRectangle.y, foreignRectangle.width, foreignRectangle.height);
|
|
1648
|
+
this.g.append(foreignObject);
|
|
1649
|
+
const container = document.createElement('div');
|
|
1650
|
+
container.classList.add('node-emojis-container');
|
|
1651
|
+
foreignObject.append(container);
|
|
1652
|
+
this.emojiGenerators = element.data.emojis.map(emojiItem => {
|
|
1653
|
+
const drawer = new EmojiGenerator(this.board, this.viewContainerRef);
|
|
1654
|
+
drawer.draw(emojiItem, element);
|
|
1655
|
+
return drawer;
|
|
1656
|
+
});
|
|
1657
|
+
this.emojiGenerators.forEach(drawer => {
|
|
1658
|
+
container.append(drawer.nativeElement);
|
|
1659
|
+
});
|
|
1660
|
+
return this.g;
|
|
1661
|
+
}
|
|
1662
|
+
return undefined;
|
|
1663
|
+
}
|
|
1664
|
+
destroy() {
|
|
1665
|
+
if (this.g) {
|
|
1666
|
+
this.g.remove();
|
|
1667
|
+
}
|
|
1668
|
+
this.emojiGenerators.forEach(drawer => drawer.destroy());
|
|
1669
|
+
this.emojiGenerators = [];
|
|
1670
|
+
}
|
|
1671
|
+
}
|
|
1672
|
+
|
|
1596
1673
|
const drawFakeDragNode = (board, element, offsetX, offsetY) => {
|
|
1597
|
-
const
|
|
1674
|
+
const ref = PlaitElement.getElementRef(element);
|
|
1675
|
+
const mindNode = MindElement.getNode(element);
|
|
1598
1676
|
const dragFakeNodeG = createG();
|
|
1599
1677
|
dragFakeNodeG.classList.add('dragging', 'fake-node', 'plait-board-attached');
|
|
1600
1678
|
const fakeDraggingNode = {
|
|
1601
|
-
...
|
|
1679
|
+
...mindNode,
|
|
1602
1680
|
children: [],
|
|
1603
|
-
x:
|
|
1604
|
-
y:
|
|
1681
|
+
x: mindNode.x + offsetX,
|
|
1682
|
+
y: mindNode.y + offsetY
|
|
1605
1683
|
};
|
|
1606
|
-
const textRectangle = getTopicRectangleByNode(board,
|
|
1684
|
+
const textRectangle = getTopicRectangleByNode(board, mindNode);
|
|
1607
1685
|
const fakeNodeG = drawRoundRectangleByNode(board, fakeDraggingNode);
|
|
1608
1686
|
const richtextG = getFirstTextManage(element).g.cloneNode(true);
|
|
1609
1687
|
updateForeignObject(richtextG, textRectangle.width, textRectangle.height, textRectangle.x + offsetX, textRectangle.y + offsetY);
|
|
@@ -1611,13 +1689,15 @@ const drawFakeDragNode = (board, element, offsetX, offsetY) => {
|
|
|
1611
1689
|
dragFakeNodeG?.append(richtextG);
|
|
1612
1690
|
// draw emojis
|
|
1613
1691
|
if (MindElement.hasEmojis(element)) {
|
|
1614
|
-
const
|
|
1692
|
+
const nodeEmojisGenerator = ref.getGenerator(NodeEmojisGenerator.key);
|
|
1693
|
+
const fakeEmojisG = nodeEmojisGenerator.g.cloneNode(true);
|
|
1615
1694
|
const foreignRectangle = getEmojiForeignRectangle(board, element);
|
|
1616
1695
|
updateForeignObject(fakeEmojisG, foreignRectangle.width, foreignRectangle.height, foreignRectangle.x + offsetX, foreignRectangle.y + offsetY);
|
|
1617
1696
|
dragFakeNodeG?.append(fakeEmojisG);
|
|
1618
1697
|
}
|
|
1619
1698
|
if (MindElement.hasImage(element)) {
|
|
1620
|
-
const
|
|
1699
|
+
const imageGenerator = ref.getGenerator(ImageGenerator.key);
|
|
1700
|
+
const fakeImageG = imageGenerator.g.cloneNode(true);
|
|
1621
1701
|
const foreignRectangle = getImageForeignRectangle(board, element);
|
|
1622
1702
|
updateForeignObject(fakeImageG, foreignRectangle.width, foreignRectangle.height, foreignRectangle.x + offsetX, foreignRectangle.y + offsetY);
|
|
1623
1703
|
dragFakeNodeG?.append(fakeImageG);
|
|
@@ -1750,6 +1830,148 @@ var AbstractResizeState;
|
|
|
1750
1830
|
AbstractResizeState["end"] = "end";
|
|
1751
1831
|
})(AbstractResizeState || (AbstractResizeState = {}));
|
|
1752
1832
|
|
|
1833
|
+
function drawAbstractIncludedOutline(board, roughSVG, element, activeHandlePosition, resizingLocation) {
|
|
1834
|
+
const abstractIncludedG = createG();
|
|
1835
|
+
const parentElement = MindElement.getParent(element);
|
|
1836
|
+
const nodeLayout = MindQueries.getCorrectLayoutByElement(board, element);
|
|
1837
|
+
const isHorizontal = isHorizontalLayout(nodeLayout);
|
|
1838
|
+
const includedElements = parentElement.children.slice(element.start, element.end + 1);
|
|
1839
|
+
let abstractRectangle = getRectangleByElements(board, includedElements, true);
|
|
1840
|
+
abstractRectangle = RectangleClient.getOutlineRectangle(abstractRectangle, -ABSTRACT_INCLUDED_OUTLINE_OFFSET);
|
|
1841
|
+
if (resizingLocation) {
|
|
1842
|
+
abstractRectangle = getRectangleByResizingLocation(abstractRectangle, resizingLocation, activeHandlePosition, isHorizontal);
|
|
1843
|
+
}
|
|
1844
|
+
const rectangle = drawAbstractRoundRectangle(roughSVG, abstractRectangle.x, abstractRectangle.y, abstractRectangle.x + abstractRectangle.width, abstractRectangle.y + abstractRectangle.height, isHorizontal, {
|
|
1845
|
+
stroke: PRIMARY_COLOR,
|
|
1846
|
+
strokeWidth: 1,
|
|
1847
|
+
fillStyle: 'solid'
|
|
1848
|
+
});
|
|
1849
|
+
const startPlacement = [HorizontalPlacement.center, VerticalPlacement.top];
|
|
1850
|
+
const endPlacement = [HorizontalPlacement.center, VerticalPlacement.bottom];
|
|
1851
|
+
const linkDirection = getLayoutDirection(MindElement.getNode(element), isHorizontal);
|
|
1852
|
+
transformPlacement(startPlacement, linkDirection);
|
|
1853
|
+
transformPlacement(endPlacement, linkDirection);
|
|
1854
|
+
let startCenterPoint = getPointByPlacement(abstractRectangle, startPlacement);
|
|
1855
|
+
let endCenterPoint = getPointByPlacement(abstractRectangle, endPlacement);
|
|
1856
|
+
const startPoint1 = moveXOfPoint(startCenterPoint, -ABSTRACT_HANDLE_LENGTH / 2, linkDirection);
|
|
1857
|
+
const startPoint2 = moveXOfPoint(startCenterPoint, ABSTRACT_HANDLE_LENGTH / 2, linkDirection);
|
|
1858
|
+
const endPoint1 = moveXOfPoint(endCenterPoint, -ABSTRACT_HANDLE_LENGTH / 2, linkDirection);
|
|
1859
|
+
const endPoint2 = moveXOfPoint(endCenterPoint, ABSTRACT_HANDLE_LENGTH / 2, linkDirection);
|
|
1860
|
+
const startHandle = roughSVG.line(startPoint1[0], startPoint1[1], startPoint2[0], startPoint2[1], getHandleOption(activeHandlePosition === AbstractHandlePosition.start));
|
|
1861
|
+
const endHandle = roughSVG.line(endPoint1[0], endPoint1[1], endPoint2[0], endPoint2[1], getHandleOption(activeHandlePosition === AbstractHandlePosition.end));
|
|
1862
|
+
handleBoardClass(board, activeHandlePosition, isHorizontal);
|
|
1863
|
+
setStrokeLinecap(startHandle, 'round');
|
|
1864
|
+
setStrokeLinecap(endHandle, 'round');
|
|
1865
|
+
abstractIncludedG.append(startHandle);
|
|
1866
|
+
abstractIncludedG.append(endHandle);
|
|
1867
|
+
abstractIncludedG.append(rectangle);
|
|
1868
|
+
return abstractIncludedG;
|
|
1869
|
+
}
|
|
1870
|
+
function getHandleOption(isHover) {
|
|
1871
|
+
return isHover
|
|
1872
|
+
? {
|
|
1873
|
+
stroke: PRIMARY_COLOR,
|
|
1874
|
+
strokeWidth: 4,
|
|
1875
|
+
fillStyle: 'solid'
|
|
1876
|
+
}
|
|
1877
|
+
: {
|
|
1878
|
+
stroke: ABSTRACT_HANDLE_COLOR,
|
|
1879
|
+
strokeWidth: 3,
|
|
1880
|
+
fillStyle: 'solid'
|
|
1881
|
+
};
|
|
1882
|
+
}
|
|
1883
|
+
function handleBoardClass(board, activeHandlePosition, isHorizontal) {
|
|
1884
|
+
if (activeHandlePosition) {
|
|
1885
|
+
if (isHorizontal) {
|
|
1886
|
+
PlaitBoard.getBoardContainer(board).classList.add('abstract-resizing-horizontal');
|
|
1887
|
+
}
|
|
1888
|
+
else {
|
|
1889
|
+
PlaitBoard.getBoardContainer(board).classList.add('abstract-resizing-vertical');
|
|
1890
|
+
}
|
|
1891
|
+
}
|
|
1892
|
+
else {
|
|
1893
|
+
PlaitBoard.getBoardContainer(board).classList.remove('abstract-resizing-horizontal');
|
|
1894
|
+
PlaitBoard.getBoardContainer(board).classList.remove('abstract-resizing-vertical');
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
function drawAbstractRoundRectangle(rs, x1, y1, x2, y2, isHorizontal, options) {
|
|
1898
|
+
const width = Math.abs(x1 - x2);
|
|
1899
|
+
const height = Math.abs(y1 - y2);
|
|
1900
|
+
const radius = 5;
|
|
1901
|
+
const handleGap = 4;
|
|
1902
|
+
const handleLength = 10;
|
|
1903
|
+
const handleSpace = handleLength + handleGap * 2;
|
|
1904
|
+
if (isHorizontal) {
|
|
1905
|
+
const handleSideLine = (width - handleSpace - radius * 2) / 2;
|
|
1906
|
+
const sideLine = height - radius * 2;
|
|
1907
|
+
return rs.path(`M${x1 + radius},${y1}
|
|
1908
|
+
l${handleSideLine},0
|
|
1909
|
+
m${handleSpace},0
|
|
1910
|
+
l${handleSideLine},0
|
|
1911
|
+
a${radius},${radius},0,0,1,${radius},${radius}
|
|
1912
|
+
l0,${sideLine}
|
|
1913
|
+
a${radius},${radius},0,0,1,-${radius},${radius}
|
|
1914
|
+
l-${handleSideLine},0
|
|
1915
|
+
m-${handleSpace},0
|
|
1916
|
+
l-${handleSideLine},0
|
|
1917
|
+
a${radius},${radius},0,0,1,-${radius},-${radius}
|
|
1918
|
+
l0,-${sideLine}
|
|
1919
|
+
a${radius},${radius},0,0,1,${radius},-${radius}`, options);
|
|
1920
|
+
}
|
|
1921
|
+
else {
|
|
1922
|
+
const handleSideLine = (height - handleSpace - radius * 2) / 2;
|
|
1923
|
+
const sideLine = width - radius * 2;
|
|
1924
|
+
return rs.path(`M${x1 + radius},${y1}
|
|
1925
|
+
l${sideLine},0
|
|
1926
|
+
a${radius},${radius},0,0,1,${radius},${radius}
|
|
1927
|
+
l0,${handleSideLine}
|
|
1928
|
+
m0,${handleSpace}
|
|
1929
|
+
l0,${handleSideLine}
|
|
1930
|
+
a${radius},${radius},0,0,1,-${radius},${radius}
|
|
1931
|
+
l-${sideLine},0
|
|
1932
|
+
a${radius},${radius},0,0,1,-${radius},-${radius}
|
|
1933
|
+
l0,-${handleSideLine}
|
|
1934
|
+
m0,-${handleSpace}
|
|
1935
|
+
l0,-${handleSideLine}
|
|
1936
|
+
a${radius},${radius},0,0,1,${radius},-${radius}`, options);
|
|
1937
|
+
}
|
|
1938
|
+
}
|
|
1939
|
+
|
|
1940
|
+
class NodeActiveGenerator extends Generator {
|
|
1941
|
+
static { this.key = 'mind-node-active'; }
|
|
1942
|
+
canDraw(element, data) {
|
|
1943
|
+
if (data.selected) {
|
|
1944
|
+
return true;
|
|
1945
|
+
}
|
|
1946
|
+
else {
|
|
1947
|
+
return false;
|
|
1948
|
+
}
|
|
1949
|
+
}
|
|
1950
|
+
draw(element, data) {
|
|
1951
|
+
const activeG = createG();
|
|
1952
|
+
const node = MindElement.getNode(element);
|
|
1953
|
+
const rectangle = getRectangleByNode(node);
|
|
1954
|
+
const strokeWidth = getStrokeWidthByElement(this.board, element);
|
|
1955
|
+
const activeStrokeWidth = ACTIVE_STROKE_WIDTH;
|
|
1956
|
+
const activeRectangle = RectangleClient.inflate(rectangle, activeStrokeWidth);
|
|
1957
|
+
const strokeG = drawRoundRectangle(PlaitBoard.getRoughSVG(this.board), activeRectangle.x, activeRectangle.y, activeRectangle.x + activeRectangle.width, activeRectangle.y + activeRectangle.height, { stroke: PRIMARY_COLOR, strokeWidth: activeStrokeWidth, fill: '' }, true, DefaultNodeStyle.shape.rectangleRadius + (activeStrokeWidth + strokeWidth) / 2);
|
|
1958
|
+
if (AbstractNode.isAbstract(element)) {
|
|
1959
|
+
this.abstractOutlineG = drawAbstractIncludedOutline(this.board, PlaitBoard.getRoughSVG(this.board), element);
|
|
1960
|
+
activeG.append(this.abstractOutlineG);
|
|
1961
|
+
strokeG.classList.add('abstract-element');
|
|
1962
|
+
}
|
|
1963
|
+
activeG.appendChild(strokeG);
|
|
1964
|
+
return activeG;
|
|
1965
|
+
}
|
|
1966
|
+
updateAbstractOutline(element, activeHandlePosition, resizingLocation) {
|
|
1967
|
+
const abstractOutlineG = drawAbstractIncludedOutline(this.board, PlaitBoard.getRoughSVG(this.board), element, activeHandlePosition, resizingLocation);
|
|
1968
|
+
if (this.abstractOutlineG) {
|
|
1969
|
+
this.abstractOutlineG.replaceWith(abstractOutlineG);
|
|
1970
|
+
this.abstractOutlineG = abstractOutlineG;
|
|
1971
|
+
}
|
|
1972
|
+
}
|
|
1973
|
+
}
|
|
1974
|
+
|
|
1753
1975
|
const getRectangleByResizingLocation = (abstractRectangle, location, activeHandlePosition, isHorizontal) => {
|
|
1754
1976
|
if (isHorizontal) {
|
|
1755
1977
|
if (activeHandlePosition === AbstractHandlePosition.start) {
|
|
@@ -1922,14 +2144,16 @@ function handleTouchedAbstract(board, touchedAbstract, endPoint) {
|
|
|
1922
2144
|
return touchedAbstract;
|
|
1923
2145
|
}
|
|
1924
2146
|
if (touchedAbstract) {
|
|
1925
|
-
const
|
|
1926
|
-
|
|
2147
|
+
const ref = PlaitElement.getElementRef(touchedAbstract);
|
|
2148
|
+
const activeGenerator = ref.getGenerator(NodeActiveGenerator.key);
|
|
2149
|
+
activeGenerator.updateAbstractOutline(touchedAbstract);
|
|
1927
2150
|
touchedAbstract = undefined;
|
|
1928
2151
|
}
|
|
1929
2152
|
if (abstract) {
|
|
1930
2153
|
touchedAbstract = abstract;
|
|
1931
|
-
const
|
|
1932
|
-
|
|
2154
|
+
const ref = PlaitElement.getElementRef(touchedAbstract);
|
|
2155
|
+
const activeGenerator = ref.getGenerator(NodeActiveGenerator.key);
|
|
2156
|
+
activeGenerator.updateAbstractOutline(touchedAbstract, touchedHandle);
|
|
1933
2157
|
}
|
|
1934
2158
|
return touchedAbstract;
|
|
1935
2159
|
}
|
|
@@ -2169,10 +2393,6 @@ const MindElement = {
|
|
|
2169
2393
|
},
|
|
2170
2394
|
getEmojis(element) {
|
|
2171
2395
|
return element.data.emojis;
|
|
2172
|
-
},
|
|
2173
|
-
hasMounted(element) {
|
|
2174
|
-
const component = PlaitElement.getComponent(element);
|
|
2175
|
-
return !!component;
|
|
2176
2396
|
}
|
|
2177
2397
|
};
|
|
2178
2398
|
var MindElementShape;
|
|
@@ -2234,77 +2454,6 @@ function drawAbstractLink(board, node, isHorizontal) {
|
|
|
2234
2454
|
return link;
|
|
2235
2455
|
}
|
|
2236
2456
|
|
|
2237
|
-
class EmojiGenerator {
|
|
2238
|
-
constructor(board, viewContainerRef) {
|
|
2239
|
-
this.board = board;
|
|
2240
|
-
this.viewContainerRef = viewContainerRef;
|
|
2241
|
-
this.componentRef = null;
|
|
2242
|
-
}
|
|
2243
|
-
draw(emoji, element) {
|
|
2244
|
-
this.destroy();
|
|
2245
|
-
const componentType = this.board.getPluginOptions(WithMindPluginKey).emojiComponentType;
|
|
2246
|
-
if (!componentType) {
|
|
2247
|
-
throw new Error('can not find emoji component');
|
|
2248
|
-
}
|
|
2249
|
-
this.componentRef = this.viewContainerRef.createComponent(componentType);
|
|
2250
|
-
this.componentRef.instance.emojiItem = emoji;
|
|
2251
|
-
this.componentRef.instance.board = this.board;
|
|
2252
|
-
this.componentRef.instance.element = element;
|
|
2253
|
-
this.componentRef.instance.fontSize = getEmojiFontSize(element);
|
|
2254
|
-
}
|
|
2255
|
-
get nativeElement() {
|
|
2256
|
-
if (this.componentRef) {
|
|
2257
|
-
return this.componentRef.instance.nativeElement;
|
|
2258
|
-
}
|
|
2259
|
-
else {
|
|
2260
|
-
return null;
|
|
2261
|
-
}
|
|
2262
|
-
}
|
|
2263
|
-
destroy() {
|
|
2264
|
-
if (this.componentRef) {
|
|
2265
|
-
this.componentRef.destroy();
|
|
2266
|
-
this.componentRef = null;
|
|
2267
|
-
}
|
|
2268
|
-
}
|
|
2269
|
-
}
|
|
2270
|
-
class NodeEmojisGenerator {
|
|
2271
|
-
constructor(board, viewContainerRef) {
|
|
2272
|
-
this.board = board;
|
|
2273
|
-
this.viewContainerRef = viewContainerRef;
|
|
2274
|
-
this.emojiGenerators = [];
|
|
2275
|
-
}
|
|
2276
|
-
drawEmojis(element) {
|
|
2277
|
-
this.destroy();
|
|
2278
|
-
if (MindElement.hasEmojis(element)) {
|
|
2279
|
-
this.g = createG();
|
|
2280
|
-
this.g.classList.add('emojis');
|
|
2281
|
-
const foreignRectangle = getEmojiForeignRectangle(this.board, element);
|
|
2282
|
-
const foreignObject = createForeignObject(foreignRectangle.x, foreignRectangle.y, foreignRectangle.width, foreignRectangle.height);
|
|
2283
|
-
this.g.append(foreignObject);
|
|
2284
|
-
const container = document.createElement('div');
|
|
2285
|
-
container.classList.add('node-emojis-container');
|
|
2286
|
-
foreignObject.append(container);
|
|
2287
|
-
this.emojiGenerators = element.data.emojis.map(emojiItem => {
|
|
2288
|
-
const drawer = new EmojiGenerator(this.board, this.viewContainerRef);
|
|
2289
|
-
drawer.draw(emojiItem, element);
|
|
2290
|
-
return drawer;
|
|
2291
|
-
});
|
|
2292
|
-
this.emojiGenerators.forEach(drawer => {
|
|
2293
|
-
container.append(drawer.nativeElement);
|
|
2294
|
-
});
|
|
2295
|
-
return this.g;
|
|
2296
|
-
}
|
|
2297
|
-
return undefined;
|
|
2298
|
-
}
|
|
2299
|
-
destroy() {
|
|
2300
|
-
if (this.g) {
|
|
2301
|
-
this.g.remove();
|
|
2302
|
-
}
|
|
2303
|
-
this.emojiGenerators.forEach(drawer => drawer.destroy());
|
|
2304
|
-
this.emojiGenerators = [];
|
|
2305
|
-
}
|
|
2306
|
-
}
|
|
2307
|
-
|
|
2308
2457
|
const setAbstractsByRefs = (board, abstractRefs) => {
|
|
2309
2458
|
abstractRefs.forEach((newProperty, element) => {
|
|
2310
2459
|
const start = element.start + newProperty.start;
|
|
@@ -2454,6 +2603,10 @@ const insertSiblingNode = (board, element) => {
|
|
|
2454
2603
|
insertMindElement(board, element, findNewSiblingNodePath(board, element));
|
|
2455
2604
|
}
|
|
2456
2605
|
};
|
|
2606
|
+
const insertMind = (board, mind) => {
|
|
2607
|
+
Transforms.insertNode(board, mind, [board.children.length]);
|
|
2608
|
+
Transforms.addSelectionWithTemporaryElements(board, [mind]);
|
|
2609
|
+
};
|
|
2457
2610
|
|
|
2458
2611
|
const addEmoji = (board, element, emojiItem) => {
|
|
2459
2612
|
const emojis = element.data.emojis || [];
|
|
@@ -2587,7 +2740,8 @@ const MindTransforms = {
|
|
|
2587
2740
|
removeImage,
|
|
2588
2741
|
setImage,
|
|
2589
2742
|
insertChildNode,
|
|
2590
|
-
insertSiblingNode
|
|
2743
|
+
insertSiblingNode,
|
|
2744
|
+
insertMind
|
|
2591
2745
|
};
|
|
2592
2746
|
|
|
2593
2747
|
class NodePlusGenerator extends Generator {
|
|
@@ -2672,147 +2826,6 @@ class NodePlusGenerator extends Generator {
|
|
|
2672
2826
|
}
|
|
2673
2827
|
}
|
|
2674
2828
|
|
|
2675
|
-
function drawAbstractIncludedOutline(board, roughSVG, element, activeHandlePosition, resizingLocation) {
|
|
2676
|
-
const abstractIncludedG = createG();
|
|
2677
|
-
const parentElement = MindElement.getParent(element);
|
|
2678
|
-
const nodeLayout = MindQueries.getCorrectLayoutByElement(board, element);
|
|
2679
|
-
const isHorizontal = isHorizontalLayout(nodeLayout);
|
|
2680
|
-
const includedElements = parentElement.children.slice(element.start, element.end + 1);
|
|
2681
|
-
let abstractRectangle = getRectangleByElements(board, includedElements, true);
|
|
2682
|
-
abstractRectangle = RectangleClient.getOutlineRectangle(abstractRectangle, -ABSTRACT_INCLUDED_OUTLINE_OFFSET);
|
|
2683
|
-
if (resizingLocation) {
|
|
2684
|
-
abstractRectangle = getRectangleByResizingLocation(abstractRectangle, resizingLocation, activeHandlePosition, isHorizontal);
|
|
2685
|
-
}
|
|
2686
|
-
const rectangle = drawAbstractRoundRectangle(roughSVG, abstractRectangle.x, abstractRectangle.y, abstractRectangle.x + abstractRectangle.width, abstractRectangle.y + abstractRectangle.height, isHorizontal, {
|
|
2687
|
-
stroke: PRIMARY_COLOR,
|
|
2688
|
-
strokeWidth: 1,
|
|
2689
|
-
fillStyle: 'solid'
|
|
2690
|
-
});
|
|
2691
|
-
const startPlacement = [HorizontalPlacement.center, VerticalPlacement.top];
|
|
2692
|
-
const endPlacement = [HorizontalPlacement.center, VerticalPlacement.bottom];
|
|
2693
|
-
const linkDirection = getLayoutDirection(MindElement.getNode(element), isHorizontal);
|
|
2694
|
-
transformPlacement(startPlacement, linkDirection);
|
|
2695
|
-
transformPlacement(endPlacement, linkDirection);
|
|
2696
|
-
let startCenterPoint = getPointByPlacement(abstractRectangle, startPlacement);
|
|
2697
|
-
let endCenterPoint = getPointByPlacement(abstractRectangle, endPlacement);
|
|
2698
|
-
const startPoint1 = moveXOfPoint(startCenterPoint, -ABSTRACT_HANDLE_LENGTH / 2, linkDirection);
|
|
2699
|
-
const startPoint2 = moveXOfPoint(startCenterPoint, ABSTRACT_HANDLE_LENGTH / 2, linkDirection);
|
|
2700
|
-
const endPoint1 = moveXOfPoint(endCenterPoint, -ABSTRACT_HANDLE_LENGTH / 2, linkDirection);
|
|
2701
|
-
const endPoint2 = moveXOfPoint(endCenterPoint, ABSTRACT_HANDLE_LENGTH / 2, linkDirection);
|
|
2702
|
-
const startHandle = roughSVG.line(startPoint1[0], startPoint1[1], startPoint2[0], startPoint2[1], getHandleOption(activeHandlePosition === AbstractHandlePosition.start));
|
|
2703
|
-
const endHandle = roughSVG.line(endPoint1[0], endPoint1[1], endPoint2[0], endPoint2[1], getHandleOption(activeHandlePosition === AbstractHandlePosition.end));
|
|
2704
|
-
handleBoardClass(board, activeHandlePosition, isHorizontal);
|
|
2705
|
-
setStrokeLinecap(startHandle, 'round');
|
|
2706
|
-
setStrokeLinecap(endHandle, 'round');
|
|
2707
|
-
abstractIncludedG.append(startHandle);
|
|
2708
|
-
abstractIncludedG.append(endHandle);
|
|
2709
|
-
abstractIncludedG.append(rectangle);
|
|
2710
|
-
return abstractIncludedG;
|
|
2711
|
-
}
|
|
2712
|
-
function getHandleOption(isHover) {
|
|
2713
|
-
return isHover
|
|
2714
|
-
? {
|
|
2715
|
-
stroke: PRIMARY_COLOR,
|
|
2716
|
-
strokeWidth: 4,
|
|
2717
|
-
fillStyle: 'solid'
|
|
2718
|
-
}
|
|
2719
|
-
: {
|
|
2720
|
-
stroke: ABSTRACT_HANDLE_COLOR,
|
|
2721
|
-
strokeWidth: 3,
|
|
2722
|
-
fillStyle: 'solid'
|
|
2723
|
-
};
|
|
2724
|
-
}
|
|
2725
|
-
function handleBoardClass(board, activeHandlePosition, isHorizontal) {
|
|
2726
|
-
if (activeHandlePosition) {
|
|
2727
|
-
if (isHorizontal) {
|
|
2728
|
-
PlaitBoard.getBoardContainer(board).classList.add('abstract-resizing-horizontal');
|
|
2729
|
-
}
|
|
2730
|
-
else {
|
|
2731
|
-
PlaitBoard.getBoardContainer(board).classList.add('abstract-resizing-vertical');
|
|
2732
|
-
}
|
|
2733
|
-
}
|
|
2734
|
-
else {
|
|
2735
|
-
PlaitBoard.getBoardContainer(board).classList.remove('abstract-resizing-horizontal');
|
|
2736
|
-
PlaitBoard.getBoardContainer(board).classList.remove('abstract-resizing-vertical');
|
|
2737
|
-
}
|
|
2738
|
-
}
|
|
2739
|
-
function drawAbstractRoundRectangle(rs, x1, y1, x2, y2, isHorizontal, options) {
|
|
2740
|
-
const width = Math.abs(x1 - x2);
|
|
2741
|
-
const height = Math.abs(y1 - y2);
|
|
2742
|
-
const radius = 5;
|
|
2743
|
-
const handleGap = 4;
|
|
2744
|
-
const handleLength = 10;
|
|
2745
|
-
const handleSpace = handleLength + handleGap * 2;
|
|
2746
|
-
if (isHorizontal) {
|
|
2747
|
-
const handleSideLine = (width - handleSpace - radius * 2) / 2;
|
|
2748
|
-
const sideLine = height - radius * 2;
|
|
2749
|
-
return rs.path(`M${x1 + radius},${y1}
|
|
2750
|
-
l${handleSideLine},0
|
|
2751
|
-
m${handleSpace},0
|
|
2752
|
-
l${handleSideLine},0
|
|
2753
|
-
a${radius},${radius},0,0,1,${radius},${radius}
|
|
2754
|
-
l0,${sideLine}
|
|
2755
|
-
a${radius},${radius},0,0,1,-${radius},${radius}
|
|
2756
|
-
l-${handleSideLine},0
|
|
2757
|
-
m-${handleSpace},0
|
|
2758
|
-
l-${handleSideLine},0
|
|
2759
|
-
a${radius},${radius},0,0,1,-${radius},-${radius}
|
|
2760
|
-
l0,-${sideLine}
|
|
2761
|
-
a${radius},${radius},0,0,1,${radius},-${radius}`, options);
|
|
2762
|
-
}
|
|
2763
|
-
else {
|
|
2764
|
-
const handleSideLine = (height - handleSpace - radius * 2) / 2;
|
|
2765
|
-
const sideLine = width - radius * 2;
|
|
2766
|
-
return rs.path(`M${x1 + radius},${y1}
|
|
2767
|
-
l${sideLine},0
|
|
2768
|
-
a${radius},${radius},0,0,1,${radius},${radius}
|
|
2769
|
-
l0,${handleSideLine}
|
|
2770
|
-
m0,${handleSpace}
|
|
2771
|
-
l0,${handleSideLine}
|
|
2772
|
-
a${radius},${radius},0,0,1,-${radius},${radius}
|
|
2773
|
-
l-${sideLine},0
|
|
2774
|
-
a${radius},${radius},0,0,1,-${radius},-${radius}
|
|
2775
|
-
l0,-${handleSideLine}
|
|
2776
|
-
m0,-${handleSpace}
|
|
2777
|
-
l0,-${handleSideLine}
|
|
2778
|
-
a${radius},${radius},0,0,1,${radius},-${radius}`, options);
|
|
2779
|
-
}
|
|
2780
|
-
}
|
|
2781
|
-
|
|
2782
|
-
class NodeActiveGenerator extends Generator {
|
|
2783
|
-
canDraw(element, data) {
|
|
2784
|
-
if (data.selected) {
|
|
2785
|
-
return true;
|
|
2786
|
-
}
|
|
2787
|
-
else {
|
|
2788
|
-
return false;
|
|
2789
|
-
}
|
|
2790
|
-
}
|
|
2791
|
-
draw(element, data) {
|
|
2792
|
-
const activeG = createG();
|
|
2793
|
-
const node = MindElement.getNode(element);
|
|
2794
|
-
const rectangle = getRectangleByNode(node);
|
|
2795
|
-
const strokeWidth = getStrokeWidthByElement(this.board, element);
|
|
2796
|
-
const activeStrokeWidth = ACTIVE_STROKE_WIDTH;
|
|
2797
|
-
const activeRectangle = RectangleClient.inflate(rectangle, activeStrokeWidth);
|
|
2798
|
-
const strokeG = drawRoundRectangle(PlaitBoard.getRoughSVG(this.board), activeRectangle.x, activeRectangle.y, activeRectangle.x + activeRectangle.width, activeRectangle.y + activeRectangle.height, { stroke: PRIMARY_COLOR, strokeWidth: activeStrokeWidth, fill: '' }, true, DefaultNodeStyle.shape.rectangleRadius + (activeStrokeWidth + strokeWidth) / 2);
|
|
2799
|
-
if (AbstractNode.isAbstract(element)) {
|
|
2800
|
-
this.abstractOutlineG = drawAbstractIncludedOutline(this.board, PlaitBoard.getRoughSVG(this.board), element);
|
|
2801
|
-
activeG.append(this.abstractOutlineG);
|
|
2802
|
-
strokeG.classList.add('abstract-element');
|
|
2803
|
-
}
|
|
2804
|
-
activeG.appendChild(strokeG);
|
|
2805
|
-
return activeG;
|
|
2806
|
-
}
|
|
2807
|
-
updateAbstractOutline(element, activeHandlePosition, resizingLocation) {
|
|
2808
|
-
const abstractOutlineG = drawAbstractIncludedOutline(this.board, PlaitBoard.getRoughSVG(this.board), element, activeHandlePosition, resizingLocation);
|
|
2809
|
-
if (this.abstractOutlineG) {
|
|
2810
|
-
this.abstractOutlineG.replaceWith(abstractOutlineG);
|
|
2811
|
-
this.abstractOutlineG = abstractOutlineG;
|
|
2812
|
-
}
|
|
2813
|
-
}
|
|
2814
|
-
}
|
|
2815
|
-
|
|
2816
2829
|
class CollapseGenerator extends Generator {
|
|
2817
2830
|
canDraw(element) {
|
|
2818
2831
|
if (element.children.length && !PlaitMind.isMind(element)) {
|
|
@@ -2928,16 +2941,15 @@ class MindNodeComponent extends CommonPluginElement {
|
|
|
2928
2941
|
get textManage() {
|
|
2929
2942
|
return this.getTextManages()[0];
|
|
2930
2943
|
}
|
|
2931
|
-
constructor(
|
|
2932
|
-
super(
|
|
2933
|
-
this.cdr = cdr;
|
|
2944
|
+
constructor() {
|
|
2945
|
+
super();
|
|
2934
2946
|
this.shapeG = null;
|
|
2935
2947
|
this.destroy$ = new Subject();
|
|
2936
2948
|
this.trackBy = (index, node) => {
|
|
2937
2949
|
return node.origin.id;
|
|
2938
2950
|
};
|
|
2939
2951
|
}
|
|
2940
|
-
|
|
2952
|
+
initializeGenerator() {
|
|
2941
2953
|
this.nodeShapeGenerator = new NodeShapeGenerator(this.board);
|
|
2942
2954
|
this.nodeEmojisGenerator = new NodeEmojisGenerator(this.board, this.viewContainerRef);
|
|
2943
2955
|
this.activeGenerator = new NodeActiveGenerator(this.board);
|
|
@@ -2978,10 +2990,13 @@ class MindNodeComponent extends CommonPluginElement {
|
|
|
2978
2990
|
}
|
|
2979
2991
|
});
|
|
2980
2992
|
this.initializeTextManages([textManage]);
|
|
2993
|
+
this.getRef().addGenerator(NodeActiveGenerator.key, this.activeGenerator);
|
|
2994
|
+
this.getRef().addGenerator(NodeEmojisGenerator.key, this.nodeEmojisGenerator);
|
|
2995
|
+
this.getRef().addGenerator(ImageGenerator.key, this.imageGenerator);
|
|
2981
2996
|
}
|
|
2982
2997
|
ngOnInit() {
|
|
2983
2998
|
super.ngOnInit();
|
|
2984
|
-
this.
|
|
2999
|
+
this.initializeGenerator();
|
|
2985
3000
|
this.node = MindElement.getNode(this.element);
|
|
2986
3001
|
this.index = NODE_TO_INDEX.get(this.element) || 0;
|
|
2987
3002
|
this.roughSVG = PlaitBoard.getRoughSVG(this.board);
|
|
@@ -2989,8 +3004,7 @@ class MindNodeComponent extends CommonPluginElement {
|
|
|
2989
3004
|
this.drawLink();
|
|
2990
3005
|
this.drawTopic();
|
|
2991
3006
|
this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), {
|
|
2992
|
-
selected: this.selected
|
|
2993
|
-
isEditing: this.textManage.isEditing
|
|
3007
|
+
selected: this.selected
|
|
2994
3008
|
});
|
|
2995
3009
|
this.drawEmojis();
|
|
2996
3010
|
this.drawExtend();
|
|
@@ -3000,14 +3014,14 @@ class MindNodeComponent extends CommonPluginElement {
|
|
|
3000
3014
|
}
|
|
3001
3015
|
}
|
|
3002
3016
|
onContextChanged(value, previous) {
|
|
3017
|
+
this.initializeWeakMap();
|
|
3003
3018
|
const newNode = MindElement.getNode(value.element);
|
|
3004
3019
|
const isEqualNode = RectangleClient.isEqual(this.node, newNode);
|
|
3005
3020
|
this.node = newNode;
|
|
3006
3021
|
const isChangeTheme = this.board.operations.find(op => op.type === 'set_theme');
|
|
3007
3022
|
if (!isEqualNode || value.element !== previous.element || isChangeTheme) {
|
|
3008
3023
|
this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), {
|
|
3009
|
-
selected: this.selected
|
|
3010
|
-
isEditing: this.textManage.isEditing
|
|
3024
|
+
selected: this.selected
|
|
3011
3025
|
});
|
|
3012
3026
|
this.nodeShapeGenerator.processDrawing(this.element, this.getElementG(), { node: this.node });
|
|
3013
3027
|
this.drawLink();
|
|
@@ -3029,8 +3043,7 @@ class MindNodeComponent extends CommonPluginElement {
|
|
|
3029
3043
|
const hasSameParent = value.parent === previous.parent;
|
|
3030
3044
|
if (!hasSameSelected) {
|
|
3031
3045
|
this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), {
|
|
3032
|
-
selected: this.selected
|
|
3033
|
-
isEditing: this.textManage.isEditing
|
|
3046
|
+
selected: this.selected
|
|
3034
3047
|
});
|
|
3035
3048
|
}
|
|
3036
3049
|
if (!hasSameParent) {
|
|
@@ -3085,23 +3098,8 @@ class MindNodeComponent extends CommonPluginElement {
|
|
|
3085
3098
|
this.textManage.updateText(this.element.data.topic);
|
|
3086
3099
|
this.textManage.updateRectangle();
|
|
3087
3100
|
}
|
|
3088
|
-
editTopic() {
|
|
3089
|
-
this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), {
|
|
3090
|
-
selected: this.selected,
|
|
3091
|
-
isEditing: true
|
|
3092
|
-
});
|
|
3093
|
-
this.textManage.edit((origin) => {
|
|
3094
|
-
if (origin === ExitOrigin.default) {
|
|
3095
|
-
this.activeGenerator.processDrawing(this.element, PlaitBoard.getElementActiveHost(this.board), {
|
|
3096
|
-
selected: this.selected,
|
|
3097
|
-
isEditing: false
|
|
3098
|
-
});
|
|
3099
|
-
}
|
|
3100
|
-
});
|
|
3101
|
-
}
|
|
3102
3101
|
ngOnDestroy() {
|
|
3103
3102
|
super.ngOnDestroy();
|
|
3104
|
-
this.textManage.destroy();
|
|
3105
3103
|
this.nodeEmojisGenerator.destroy();
|
|
3106
3104
|
this.imageGenerator.destroy();
|
|
3107
3105
|
this.activeGenerator.destroy();
|
|
@@ -3110,8 +3108,9 @@ class MindNodeComponent extends CommonPluginElement {
|
|
|
3110
3108
|
if (ELEMENT_TO_NODE.get(this.element) === this.node) {
|
|
3111
3109
|
ELEMENT_TO_NODE.delete(this.element);
|
|
3112
3110
|
}
|
|
3111
|
+
this.destroyTextManages();
|
|
3113
3112
|
}
|
|
3114
|
-
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: MindNodeComponent, deps: [
|
|
3113
|
+
static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: MindNodeComponent, deps: [], target: i0.ɵɵFactoryTarget.Component }); }
|
|
3115
3114
|
static { this.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "17.2.4", type: MindNodeComponent, isStandalone: true, selector: "plait-mind-node", usesInheritance: true, ngImport: i0, template: ``, isInline: true, changeDetection: i0.ChangeDetectionStrategy.OnPush }); }
|
|
3116
3115
|
}
|
|
3117
3116
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImport: i0, type: MindNodeComponent, decorators: [{
|
|
@@ -3122,7 +3121,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.2.4", ngImpor
|
|
|
3122
3121
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
3123
3122
|
standalone: true
|
|
3124
3123
|
}]
|
|
3125
|
-
}], ctorParameters: () => [
|
|
3124
|
+
}], ctorParameters: () => [] });
|
|
3126
3125
|
|
|
3127
3126
|
class PlaitMindComponent extends MindNodeComponent {
|
|
3128
3127
|
ngOnInit() {
|
|
@@ -3369,11 +3368,9 @@ const withAbstract = (board) => {
|
|
|
3369
3368
|
if (abstractHandlePosition && activeAbstractElement) {
|
|
3370
3369
|
// prevent text from being selected
|
|
3371
3370
|
event.preventDefault();
|
|
3372
|
-
const abstractComponent = PlaitElement.getComponent(activeAbstractElement);
|
|
3373
|
-
const element = abstractComponent.element;
|
|
3374
3371
|
const nodeLayout = MindQueries.getCorrectLayoutByElement(board, activeAbstractElement);
|
|
3375
3372
|
const isHorizontal = isHorizontalLayout(nodeLayout);
|
|
3376
|
-
const parentElement = MindElement.getParent(
|
|
3373
|
+
const parentElement = MindElement.getParent(activeAbstractElement);
|
|
3377
3374
|
let children = parentElement.children;
|
|
3378
3375
|
const parentLayout = MindQueries.getLayoutByElement(parentElement);
|
|
3379
3376
|
if (isStandardLayout(parentLayout)) {
|
|
@@ -3391,7 +3388,7 @@ const withAbstract = (board) => {
|
|
|
3391
3388
|
}
|
|
3392
3389
|
const resizingLocation = isHorizontal ? endPoint[1] : endPoint[0];
|
|
3393
3390
|
const parent = MindElement.getNode(parentElement);
|
|
3394
|
-
const scope = getLocationScope(board, abstractHandlePosition, children,
|
|
3391
|
+
const scope = getLocationScope(board, abstractHandlePosition, children, activeAbstractElement, parent, isHorizontal);
|
|
3395
3392
|
const location = Math.min(scope.max, Math.max(scope.min, resizingLocation));
|
|
3396
3393
|
let locationIndex = findLocationLeftIndex(board, children, location, isHorizontal);
|
|
3397
3394
|
const isPropertyUnchanged = (abstractHandlePosition === AbstractHandlePosition.start &&
|
|
@@ -3403,7 +3400,7 @@ const withAbstract = (board) => {
|
|
|
3403
3400
|
else {
|
|
3404
3401
|
if (isStandardLayout(parent.layout)) {
|
|
3405
3402
|
const rightNodeCount = parent.origin.rightNodeCount;
|
|
3406
|
-
let start =
|
|
3403
|
+
let start = activeAbstractElement.start;
|
|
3407
3404
|
if (start >= rightNodeCount) {
|
|
3408
3405
|
locationIndex += rightNodeCount;
|
|
3409
3406
|
}
|
|
@@ -3411,7 +3408,9 @@ const withAbstract = (board) => {
|
|
|
3411
3408
|
newProperty =
|
|
3412
3409
|
abstractHandlePosition === AbstractHandlePosition.start ? { start: locationIndex + 1 } : { end: locationIndex };
|
|
3413
3410
|
}
|
|
3414
|
-
|
|
3411
|
+
const ref = PlaitElement.getElementRef(activeAbstractElement);
|
|
3412
|
+
const activeGenerator = ref.getGenerator(NodeActiveGenerator.key);
|
|
3413
|
+
activeGenerator.updateAbstractOutline(activeAbstractElement, abstractHandlePosition, location);
|
|
3415
3414
|
}
|
|
3416
3415
|
pointerMove(event);
|
|
3417
3416
|
};
|
|
@@ -3427,8 +3426,9 @@ const withAbstract = (board) => {
|
|
|
3427
3426
|
Transforms.setNode(board, newProperty, path);
|
|
3428
3427
|
}
|
|
3429
3428
|
else {
|
|
3430
|
-
const
|
|
3431
|
-
|
|
3429
|
+
const ref = PlaitElement.getElementRef(activeAbstractElement);
|
|
3430
|
+
const activeGenerator = ref.getGenerator(NodeActiveGenerator.key);
|
|
3431
|
+
activeGenerator.updateAbstractOutline(activeAbstractElement);
|
|
3432
3432
|
}
|
|
3433
3433
|
activeAbstractElement = undefined;
|
|
3434
3434
|
}
|
|
@@ -3455,9 +3455,7 @@ const withCreateMind = (board) => {
|
|
|
3455
3455
|
if (!PlaitBoard.isReadonly(board) && movingPoint && isDrawingMode(board) && isMindPointer) {
|
|
3456
3456
|
movingPoint = toViewBoxPoint(board, toHostPoint(board, movingPoint[0], movingPoint[1]));
|
|
3457
3457
|
const emptyMind = createEmptyMind(newBoard, movingPoint);
|
|
3458
|
-
|
|
3459
|
-
clearSelectedElement(board);
|
|
3460
|
-
addSelectedElement(board, emptyMind);
|
|
3458
|
+
MindTransforms.insertMind(board, emptyMind);
|
|
3461
3459
|
BoardTransforms.updatePointerType(board, PlaitPointerType.selection);
|
|
3462
3460
|
return;
|
|
3463
3461
|
}
|
|
@@ -3516,13 +3514,12 @@ const withCreateMind = (board) => {
|
|
|
3516
3514
|
};
|
|
3517
3515
|
newBoard.pointerUp = (event) => {
|
|
3518
3516
|
if (emptyMind) {
|
|
3519
|
-
|
|
3520
|
-
clearSelectedElement(board);
|
|
3521
|
-
addSelectedElement(board, emptyMind);
|
|
3517
|
+
MindTransforms.insertMind(board, emptyMind);
|
|
3522
3518
|
BoardTransforms.updatePointerType(board, PlaitPointerType.selection);
|
|
3523
3519
|
emptyMind = null;
|
|
3520
|
+
destroy();
|
|
3521
|
+
return;
|
|
3524
3522
|
}
|
|
3525
|
-
destroy();
|
|
3526
3523
|
pointerUp(event);
|
|
3527
3524
|
};
|
|
3528
3525
|
board.keyDown = (event) => {
|
|
@@ -3710,12 +3707,12 @@ const withNodeImage = (board) => {
|
|
|
3710
3707
|
}
|
|
3711
3708
|
globalPointerUp(event);
|
|
3712
3709
|
};
|
|
3713
|
-
board.buildFragment = (clipboardContext, rectangle,
|
|
3710
|
+
board.buildFragment = (clipboardContext, rectangle, operationType, originData) => {
|
|
3714
3711
|
const selectedImageElement = getElementOfFocusedImage(board);
|
|
3715
3712
|
if (selectedImageElement) {
|
|
3716
3713
|
clipboardContext = createClipboardContext(WritableClipboardType.medias, [selectedImageElement.data.image], '');
|
|
3717
3714
|
}
|
|
3718
|
-
return buildFragment(clipboardContext, rectangle,
|
|
3715
|
+
return buildFragment(clipboardContext, rectangle, operationType, originData);
|
|
3719
3716
|
};
|
|
3720
3717
|
board.deleteFragment = (elements) => {
|
|
3721
3718
|
const selectedImageElement = getElementOfFocusedImage(board);
|
|
@@ -3724,7 +3721,7 @@ const withNodeImage = (board) => {
|
|
|
3724
3721
|
}
|
|
3725
3722
|
deleteFragment(elements);
|
|
3726
3723
|
};
|
|
3727
|
-
board.insertFragment = (clipboardData, targetPoint) => {
|
|
3724
|
+
board.insertFragment = (clipboardData, targetPoint, operationType) => {
|
|
3728
3725
|
const selectedElements = getSelectedElements(board);
|
|
3729
3726
|
const isSelectedImage = !!getElementOfFocusedImage(board);
|
|
3730
3727
|
const isSingleSelection = selectedElements.length === 1 && MindElement.isMindElement(board, selectedElements[0]);
|
|
@@ -3746,7 +3743,7 @@ const withNodeImage = (board) => {
|
|
|
3746
3743
|
return;
|
|
3747
3744
|
}
|
|
3748
3745
|
}
|
|
3749
|
-
insertFragment(clipboardData, targetPoint);
|
|
3746
|
+
insertFragment(clipboardData, targetPoint, operationType);
|
|
3750
3747
|
};
|
|
3751
3748
|
return board;
|
|
3752
3749
|
};
|
|
@@ -3897,7 +3894,7 @@ const buildClipboardData = (board, selectedElements, startPoint) => {
|
|
|
3897
3894
|
});
|
|
3898
3895
|
return result;
|
|
3899
3896
|
};
|
|
3900
|
-
const insertClipboardData = (board, elements, targetPoint) => {
|
|
3897
|
+
const insertClipboardData = (board, elements, targetPoint, operationType) => {
|
|
3901
3898
|
let newElement, path;
|
|
3902
3899
|
const selectedElements = getSelectedElements(board);
|
|
3903
3900
|
let newELements = [];
|
|
@@ -3907,7 +3904,7 @@ const insertClipboardData = (board, elements, targetPoint) => {
|
|
|
3907
3904
|
const nonAbstractChildrenLength = targetParent && getNonAbstractChildren(targetParent).length;
|
|
3908
3905
|
elements.forEach((item, index) => {
|
|
3909
3906
|
newElement = copyNewNode(item);
|
|
3910
|
-
if (hasTargetParent) {
|
|
3907
|
+
if (hasTargetParent && operationType !== WritableClipboardOperationType.duplicate) {
|
|
3911
3908
|
if (item.isRoot) {
|
|
3912
3909
|
newElement = adjustRootToNode(board, newElement);
|
|
3913
3910
|
const styles = PlaitMind.isMind(targetParent) ? { fontFamily: BRANCH_FONT_FAMILY } : { fontFamily: DEFAULT_FONT_FAMILY };
|
|
@@ -3977,8 +3974,8 @@ const withMindFragment = (baseBoard) => {
|
|
|
3977
3974
|
firstLevelElements = null;
|
|
3978
3975
|
}
|
|
3979
3976
|
};
|
|
3980
|
-
board.buildFragment = (clipboardContext, rectangle,
|
|
3981
|
-
const targetMindElements = getSelectedMindElements(board);
|
|
3977
|
+
board.buildFragment = (clipboardContext, rectangle, operationType, originData) => {
|
|
3978
|
+
const targetMindElements = getSelectedMindElements(board, originData);
|
|
3982
3979
|
const firstLevelElements = getFirstLevelElement(targetMindElements);
|
|
3983
3980
|
if (firstLevelElements.length) {
|
|
3984
3981
|
const elements = buildClipboardData(board, firstLevelElements, rectangle ? [rectangle.x, rectangle.y] : [0, 0]);
|
|
@@ -3994,13 +3991,13 @@ const withMindFragment = (baseBoard) => {
|
|
|
3994
3991
|
});
|
|
3995
3992
|
}
|
|
3996
3993
|
}
|
|
3997
|
-
return buildFragment(clipboardContext, rectangle,
|
|
3994
|
+
return buildFragment(clipboardContext, rectangle, operationType, originData);
|
|
3998
3995
|
};
|
|
3999
|
-
board.insertFragment = (clipboardData, targetPoint) => {
|
|
3996
|
+
board.insertFragment = (clipboardData, targetPoint, operationType) => {
|
|
4000
3997
|
if (clipboardData?.elements?.length) {
|
|
4001
3998
|
const mindElements = clipboardData.elements?.filter(value => MindElement.isMindElement(board, value));
|
|
4002
3999
|
if (mindElements && mindElements.length > 0) {
|
|
4003
|
-
insertClipboardData(board, mindElements, targetPoint);
|
|
4000
|
+
insertClipboardData(board, mindElements, targetPoint, operationType);
|
|
4004
4001
|
}
|
|
4005
4002
|
}
|
|
4006
4003
|
if (clipboardData?.text) {
|
|
@@ -4010,7 +4007,7 @@ const withMindFragment = (baseBoard) => {
|
|
|
4010
4007
|
return;
|
|
4011
4008
|
}
|
|
4012
4009
|
}
|
|
4013
|
-
insertFragment(clipboardData, targetPoint);
|
|
4010
|
+
insertFragment(clipboardData, targetPoint, operationType);
|
|
4014
4011
|
};
|
|
4015
4012
|
return board;
|
|
4016
4013
|
};
|
|
@@ -4066,6 +4063,9 @@ const withMind = (baseBoard) => {
|
|
|
4066
4063
|
}
|
|
4067
4064
|
};
|
|
4068
4065
|
board.getRectangle = element => {
|
|
4066
|
+
if (!PlaitElement.hasMounted(element)) {
|
|
4067
|
+
console.error('mind element has not been mounted');
|
|
4068
|
+
}
|
|
4069
4069
|
if (MindElement.isMindElement(board, element)) {
|
|
4070
4070
|
return getRectangleByNode(MindElement.getNode(element));
|
|
4071
4071
|
}
|