microboard-ui-temp 0.3.5 → 0.3.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/{chunk-bdkn78st.js → chunk-c47kwavk.js} +1715 -1698
- package/dist/example.html +1 -1
- package/dist/index.html +1 -1
- package/dist/index.js +1715 -1698
- package/dist/spa.js +1715 -1698
- package/package.json +2 -2
|
@@ -228592,43 +228592,25 @@ var __getProtoOf2 = Object.getPrototypeOf;
|
|
|
228592
228592
|
var __defProp2 = Object.defineProperty;
|
|
228593
228593
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
228594
228594
|
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
228595
|
-
function __accessProp(key) {
|
|
228596
|
-
return this[key];
|
|
228597
|
-
}
|
|
228598
|
-
var __toESMCache_node;
|
|
228599
|
-
var __toESMCache_esm;
|
|
228600
228595
|
var __toESM2 = (mod2, isNodeMode, target) => {
|
|
228601
|
-
var canCache = mod2 != null && typeof mod2 === "object";
|
|
228602
|
-
if (canCache) {
|
|
228603
|
-
var cache2 = isNodeMode ? __toESMCache_node ??= new WeakMap : __toESMCache_esm ??= new WeakMap;
|
|
228604
|
-
var cached = cache2.get(mod2);
|
|
228605
|
-
if (cached)
|
|
228606
|
-
return cached;
|
|
228607
|
-
}
|
|
228608
228596
|
target = mod2 != null ? __create2(__getProtoOf2(mod2)) : {};
|
|
228609
228597
|
const to = isNodeMode || !mod2 || !mod2.__esModule ? __defProp2(target, "default", { value: mod2, enumerable: true }) : target;
|
|
228610
228598
|
for (let key of __getOwnPropNames2(mod2))
|
|
228611
228599
|
if (!__hasOwnProp2.call(to, key))
|
|
228612
228600
|
__defProp2(to, key, {
|
|
228613
|
-
get:
|
|
228601
|
+
get: () => mod2[key],
|
|
228614
228602
|
enumerable: true
|
|
228615
228603
|
});
|
|
228616
|
-
if (canCache)
|
|
228617
|
-
cache2.set(mod2, to);
|
|
228618
228604
|
return to;
|
|
228619
228605
|
};
|
|
228620
228606
|
var __commonJS2 = (cb, mod2) => () => (mod2 || cb((mod2 = { exports: {} }).exports, mod2), mod2.exports);
|
|
228621
|
-
var __returnValue = (v) => v;
|
|
228622
|
-
function __exportSetter(name, newValue) {
|
|
228623
|
-
this[name] = __returnValue.bind(null, newValue);
|
|
228624
|
-
}
|
|
228625
228607
|
var __export2 = (target, all) => {
|
|
228626
228608
|
for (var name in all)
|
|
228627
228609
|
__defProp2(target, name, {
|
|
228628
228610
|
get: all[name],
|
|
228629
228611
|
enumerable: true,
|
|
228630
228612
|
configurable: true,
|
|
228631
|
-
set:
|
|
228613
|
+
set: (newValue) => all[name] = () => newValue
|
|
228632
228614
|
});
|
|
228633
228615
|
};
|
|
228634
228616
|
var __require2 = /* @__PURE__ */ ((x) => __require)(function(x) {
|
|
@@ -228641,13 +228623,13 @@ var require_extend = __commonJS2((exports2, module2) => {
|
|
|
228641
228623
|
var toStr2 = Object.prototype.toString;
|
|
228642
228624
|
var defineProperty = Object.defineProperty;
|
|
228643
228625
|
var gOPD = Object.getOwnPropertyDescriptor;
|
|
228644
|
-
var isArray = function
|
|
228626
|
+
var isArray = function isArray(arr2) {
|
|
228645
228627
|
if (typeof Array.isArray === "function") {
|
|
228646
228628
|
return Array.isArray(arr2);
|
|
228647
228629
|
}
|
|
228648
228630
|
return toStr2.call(arr2) === "[object Array]";
|
|
228649
228631
|
};
|
|
228650
|
-
var isPlainObject22 = function
|
|
228632
|
+
var isPlainObject22 = function isPlainObject(obj) {
|
|
228651
228633
|
if (!obj || toStr2.call(obj) !== "[object Object]") {
|
|
228652
228634
|
return false;
|
|
228653
228635
|
}
|
|
@@ -228660,7 +228642,7 @@ var require_extend = __commonJS2((exports2, module2) => {
|
|
|
228660
228642
|
for (key in obj) {}
|
|
228661
228643
|
return typeof key === "undefined" || hasOwn.call(obj, key);
|
|
228662
228644
|
};
|
|
228663
|
-
var setProperty = function
|
|
228645
|
+
var setProperty = function setProperty(target, options2) {
|
|
228664
228646
|
if (defineProperty && options2.name === "__proto__") {
|
|
228665
228647
|
defineProperty(target, options2.name, {
|
|
228666
228648
|
enumerable: true,
|
|
@@ -228672,7 +228654,7 @@ var require_extend = __commonJS2((exports2, module2) => {
|
|
|
228672
228654
|
target[options2.name] = options2.newValue;
|
|
228673
228655
|
}
|
|
228674
228656
|
};
|
|
228675
|
-
var getProperty = function
|
|
228657
|
+
var getProperty = function getProperty(obj, name) {
|
|
228676
228658
|
if (name === "__proto__") {
|
|
228677
228659
|
if (!hasOwn.call(obj, name)) {
|
|
228678
228660
|
return;
|
|
@@ -229366,7 +229348,7 @@ function safeRequestAnimationFrame(callback) {
|
|
|
229366
229348
|
if (typeof requestAnimationFrame === "function") {
|
|
229367
229349
|
return requestAnimationFrame(callback);
|
|
229368
229350
|
} else {
|
|
229369
|
-
callback
|
|
229351
|
+
setTimeout(callback, 0);
|
|
229370
229352
|
}
|
|
229371
229353
|
}
|
|
229372
229354
|
function isFiniteNumber(value) {
|
|
@@ -229741,205 +229723,6 @@ class Mbr {
|
|
|
229741
229723
|
}
|
|
229742
229724
|
}
|
|
229743
229725
|
}
|
|
229744
|
-
function updateRects(board, ref, mbr, verticalOffset, horizontalOffset, fit = "contextPanel") {
|
|
229745
|
-
const { selection, camera } = board;
|
|
229746
|
-
const panel = ref.current;
|
|
229747
|
-
const selectionMbr = mbr ?? selection.getMbr();
|
|
229748
|
-
const selectionItems = selection.items;
|
|
229749
|
-
const richTextSelection = selectionItems.getSingle() instanceof RichText ? selectionItems.list()[0] : undefined;
|
|
229750
|
-
if (panel && selectionMbr) {
|
|
229751
|
-
if (fit === "contextPanel") {
|
|
229752
|
-
const panelRect = getContextPanelRect(selectionMbr, camera, panel, !!richTextSelection, horizontalOffset, verticalOffset);
|
|
229753
|
-
return panelRect;
|
|
229754
|
-
}
|
|
229755
|
-
if (fit === "linkToBtn") {
|
|
229756
|
-
if (!mbr) {
|
|
229757
|
-
return null;
|
|
229758
|
-
}
|
|
229759
|
-
const panelRect = fitLinkToBtn(selectionMbr.getTransformed(camera.getMatrix()), camera.window.getMbr(), Mbr.fromDomRect(panel.getBoundingClientRect()), verticalOffset, horizontalOffset);
|
|
229760
|
-
return panelRect;
|
|
229761
|
-
}
|
|
229762
|
-
if (fit === "comment") {
|
|
229763
|
-
if (!mbr) {
|
|
229764
|
-
return null;
|
|
229765
|
-
}
|
|
229766
|
-
const panelRect = fitComment(selectionMbr.getTransformed(camera.getMatrix()), Mbr.fromDomRect(panel.getBoundingClientRect()), verticalOffset, horizontalOffset);
|
|
229767
|
-
return panelRect;
|
|
229768
|
-
}
|
|
229769
|
-
if (fit === "threadPanel") {
|
|
229770
|
-
if (!mbr) {
|
|
229771
|
-
return null;
|
|
229772
|
-
}
|
|
229773
|
-
const panelRect = fitThreadPanel(selectionMbr.getTransformed(camera.getMatrix()), camera.window.getMbr(), Mbr.fromDomRect(panel.getBoundingClientRect()), verticalOffset, horizontalOffset);
|
|
229774
|
-
return panelRect;
|
|
229775
|
-
}
|
|
229776
|
-
if (fit === "boardMenu") {
|
|
229777
|
-
if (!mbr) {
|
|
229778
|
-
return null;
|
|
229779
|
-
}
|
|
229780
|
-
const panelRect = fitBoardMenu(selectionMbr.getTransformed(camera.getMatrix()), camera.window.getMbr(), Mbr.fromDomRect(panel.getBoundingClientRect()), verticalOffset, horizontalOffset);
|
|
229781
|
-
return panelRect;
|
|
229782
|
-
}
|
|
229783
|
-
if (fit === "hyperLink") {
|
|
229784
|
-
if (!mbr) {
|
|
229785
|
-
return null;
|
|
229786
|
-
}
|
|
229787
|
-
const panelRect = fitHyperLink(selectionMbr.getTransformed(camera.getMatrix()), Mbr.fromDomRect(panel.getBoundingClientRect()), camera.window.getMbr(), verticalOffset);
|
|
229788
|
-
return panelRect;
|
|
229789
|
-
}
|
|
229790
|
-
}
|
|
229791
|
-
return null;
|
|
229792
|
-
}
|
|
229793
|
-
function getContextPanelRect(selectionMbr, camera, panel, toLeft, horizontalOffset, verticalOffset) {
|
|
229794
|
-
const transformedMbr = selectionMbr.getTransformed(camera.getMatrix());
|
|
229795
|
-
const windowMbr = camera.window.getMbr();
|
|
229796
|
-
const panelRectFromDom = Mbr.fromDomRect(panel.getBoundingClientRect());
|
|
229797
|
-
const panelRect = toLeft ? fitContextPanelToLeft(transformedMbr, windowMbr, panelRectFromDom, verticalOffset, horizontalOffset) : fitContextPanelToCenter(transformedMbr, windowMbr, panelRectFromDom, verticalOffset, horizontalOffset);
|
|
229798
|
-
return panelRect;
|
|
229799
|
-
}
|
|
229800
|
-
function fitContextPanelToLeft(selectionMbr, view, panel, verticalOffset = 40, horizontalOffset = 80) {
|
|
229801
|
-
const panelHeight = panel.getHeight();
|
|
229802
|
-
const panelWidth = panel.getWidth();
|
|
229803
|
-
const newPanel = new Mbr;
|
|
229804
|
-
const topSpace = selectionMbr.top - view.top;
|
|
229805
|
-
const hasEnoughTopSpace = topSpace >= panelHeight + verticalOffset;
|
|
229806
|
-
if (hasEnoughTopSpace) {
|
|
229807
|
-
newPanel.top = selectionMbr.top - panelHeight - verticalOffset;
|
|
229808
|
-
if (newPanel.top < view.top) {
|
|
229809
|
-
newPanel.top = view.top + verticalOffset;
|
|
229810
|
-
}
|
|
229811
|
-
} else {
|
|
229812
|
-
const usePanelTop = panel.top > 1 && panel.top > selectionMbr.top + verticalOffset;
|
|
229813
|
-
newPanel.top = usePanelTop ? panel.top : selectionMbr.bottom + verticalOffset;
|
|
229814
|
-
const isOverflowingBottom = newPanel.top + panelHeight > view.bottom;
|
|
229815
|
-
const isLargeOffsetForRichText = newPanel.top >= selectionMbr.bottom + verticalOffset * 2;
|
|
229816
|
-
if (isOverflowingBottom || isLargeOffsetForRichText) {
|
|
229817
|
-
newPanel.top = selectionMbr.bottom - (panelHeight + verticalOffset);
|
|
229818
|
-
}
|
|
229819
|
-
}
|
|
229820
|
-
newPanel.bottom = newPanel.top + panelHeight;
|
|
229821
|
-
fitContextPanelInViewRect(newPanel, view, verticalOffset);
|
|
229822
|
-
const itemMbr = selectionMbr.getMbr();
|
|
229823
|
-
newPanel.left = itemMbr.left;
|
|
229824
|
-
adjustPanelHorizontal(newPanel, panelWidth, view, horizontalOffset);
|
|
229825
|
-
return newPanel;
|
|
229826
|
-
}
|
|
229827
|
-
function fitContextPanelToCenter(selectionMbr, view, panel, verticalOffset = 40, horizontalOffset = 80) {
|
|
229828
|
-
const panelHeight = panel.getHeight();
|
|
229829
|
-
const panelWidth = panel.getWidth();
|
|
229830
|
-
const newPanel = new Mbr;
|
|
229831
|
-
const topSpace = selectionMbr.top - view.top;
|
|
229832
|
-
const bottomSpace = view.bottom - selectionMbr.bottom;
|
|
229833
|
-
const shouldPlaceAbove = topSpace > bottomSpace - panelHeight;
|
|
229834
|
-
if (shouldPlaceAbove) {
|
|
229835
|
-
newPanel.top = selectionMbr.top - panelHeight - verticalOffset;
|
|
229836
|
-
if (newPanel.top < view.top) {
|
|
229837
|
-
newPanel.top = view.top + verticalOffset;
|
|
229838
|
-
}
|
|
229839
|
-
} else {
|
|
229840
|
-
newPanel.top = selectionMbr.bottom + verticalOffset;
|
|
229841
|
-
const isOverflowingBottom = newPanel.top + panelHeight > view.bottom;
|
|
229842
|
-
const isLargeOffsetForRichText = newPanel.top >= selectionMbr.bottom + verticalOffset * 2;
|
|
229843
|
-
if (isOverflowingBottom || isLargeOffsetForRichText) {
|
|
229844
|
-
newPanel.top = selectionMbr.bottom - (panelHeight + verticalOffset);
|
|
229845
|
-
}
|
|
229846
|
-
}
|
|
229847
|
-
newPanel.bottom = newPanel.top + panelHeight;
|
|
229848
|
-
fitContextPanelInViewRect(newPanel, view, verticalOffset);
|
|
229849
|
-
const itemCenter = selectionMbr.getCenter();
|
|
229850
|
-
newPanel.left = itemCenter.x - panelWidth / 2;
|
|
229851
|
-
adjustPanelHorizontal(newPanel, panelWidth, view, horizontalOffset);
|
|
229852
|
-
return newPanel;
|
|
229853
|
-
}
|
|
229854
|
-
function adjustPanelHorizontal(newPanel, panelWidth, view, horizontalOffset) {
|
|
229855
|
-
newPanel.right = newPanel.left + panelWidth;
|
|
229856
|
-
if (newPanel.left < view.left + horizontalOffset) {
|
|
229857
|
-
newPanel.left = view.left + horizontalOffset;
|
|
229858
|
-
} else if (newPanel.right + horizontalOffset > view.right) {
|
|
229859
|
-
newPanel.left = view.right - (panelWidth + horizontalOffset);
|
|
229860
|
-
}
|
|
229861
|
-
newPanel.right = newPanel.left + panelWidth;
|
|
229862
|
-
}
|
|
229863
|
-
function fitContextPanelInViewRect(panel, view, verticalOffset) {
|
|
229864
|
-
const panelHeight = panel.getHeight();
|
|
229865
|
-
if (panel.top <= view.top + verticalOffset) {
|
|
229866
|
-
panel.top = view.top + 2 * verticalOffset;
|
|
229867
|
-
panel.bottom = panel.top + panelHeight;
|
|
229868
|
-
}
|
|
229869
|
-
if (panel.bottom >= view.bottom - verticalOffset) {
|
|
229870
|
-
panel.bottom = view.bottom - 2 * verticalOffset;
|
|
229871
|
-
panel.top = panel.bottom - panelHeight;
|
|
229872
|
-
}
|
|
229873
|
-
}
|
|
229874
|
-
function fitLinkToBtn(itemMbr, view, panel, verticalOffset = -2, horizontalOffset = -2) {
|
|
229875
|
-
const panelHeight = panel.getHeight();
|
|
229876
|
-
const newPanel = new Mbr;
|
|
229877
|
-
newPanel.top = itemMbr.top - panelHeight - verticalOffset;
|
|
229878
|
-
newPanel.top = newPanel.top + panelHeight;
|
|
229879
|
-
newPanel.bottom = newPanel.top + panelHeight * 2;
|
|
229880
|
-
const panelWidth = panel.getWidth();
|
|
229881
|
-
newPanel.left = itemMbr.right - panelWidth + horizontalOffset;
|
|
229882
|
-
return newPanel;
|
|
229883
|
-
}
|
|
229884
|
-
function fitHyperLink(linkMbr, panel, view, offset = 20) {
|
|
229885
|
-
const panelHeight = panel.getHeight();
|
|
229886
|
-
const newPanel = new Mbr;
|
|
229887
|
-
newPanel.top = linkMbr.bottom;
|
|
229888
|
-
newPanel.bottom = panelHeight + newPanel.top;
|
|
229889
|
-
const panelWidth = panel.getWidth();
|
|
229890
|
-
newPanel.left = linkMbr.left;
|
|
229891
|
-
newPanel.right = newPanel.left + panelWidth;
|
|
229892
|
-
return newPanel;
|
|
229893
|
-
}
|
|
229894
|
-
function fitComment(anchor, panel, verticalOffset = 0, horizontalOffset = 0) {
|
|
229895
|
-
const panelHeight = panel.getHeight();
|
|
229896
|
-
const newPanel = new Mbr;
|
|
229897
|
-
newPanel.top = anchor.top - panelHeight - verticalOffset;
|
|
229898
|
-
newPanel.bottom = newPanel.top + panelHeight;
|
|
229899
|
-
const panelWidth = panel.getWidth();
|
|
229900
|
-
newPanel.left = anchor.left - panelWidth / 2 - horizontalOffset;
|
|
229901
|
-
newPanel.right = newPanel.left + panelWidth;
|
|
229902
|
-
return newPanel;
|
|
229903
|
-
}
|
|
229904
|
-
function fitBoardMenu(anchor, view, panel, verticalOffset = 20, horizontalOffset = 20) {
|
|
229905
|
-
const panelHeight = panel.getHeight();
|
|
229906
|
-
const panelWidth = panel.getWidth();
|
|
229907
|
-
const newPanel = new Mbr;
|
|
229908
|
-
newPanel.top = anchor.top;
|
|
229909
|
-
newPanel.bottom = newPanel.top + panelHeight;
|
|
229910
|
-
if (newPanel.bottom > view.bottom - verticalOffset) {
|
|
229911
|
-
newPanel.bottom = view.bottom - verticalOffset;
|
|
229912
|
-
newPanel.top = newPanel.bottom - panelHeight;
|
|
229913
|
-
}
|
|
229914
|
-
newPanel.left = anchor.left;
|
|
229915
|
-
newPanel.right = newPanel.left + panelWidth;
|
|
229916
|
-
if (newPanel.right > view.right - horizontalOffset) {
|
|
229917
|
-
newPanel.right = view.right - horizontalOffset;
|
|
229918
|
-
newPanel.left = newPanel.right - panelWidth;
|
|
229919
|
-
}
|
|
229920
|
-
return newPanel;
|
|
229921
|
-
}
|
|
229922
|
-
function fitThreadPanel(anchor, view, panel, verticalOffset = 50, horizontalOffset = 50) {
|
|
229923
|
-
const panelHeight = panel.getHeight();
|
|
229924
|
-
const panelWidth = panel.getWidth();
|
|
229925
|
-
const newPanel = new Mbr;
|
|
229926
|
-
newPanel.top = anchor.top - panelHeight / 2;
|
|
229927
|
-
if (newPanel.top < view.top + verticalOffset) {
|
|
229928
|
-
newPanel.top = view.top + verticalOffset;
|
|
229929
|
-
}
|
|
229930
|
-
newPanel.bottom = newPanel.top + panelHeight;
|
|
229931
|
-
if (newPanel.bottom > view.bottom - verticalOffset) {
|
|
229932
|
-
newPanel.bottom = view.bottom - verticalOffset;
|
|
229933
|
-
newPanel.top = newPanel.bottom - panelHeight;
|
|
229934
|
-
}
|
|
229935
|
-
newPanel.left = anchor.left;
|
|
229936
|
-
newPanel.right = newPanel.left + panelWidth;
|
|
229937
|
-
if (newPanel.right > view.right - horizontalOffset) {
|
|
229938
|
-
newPanel.right = anchor.right;
|
|
229939
|
-
newPanel.left = newPanel.right - panelWidth;
|
|
229940
|
-
}
|
|
229941
|
-
return newPanel;
|
|
229942
|
-
}
|
|
229943
229726
|
function getLinesRelationType(lineA, lineB) {
|
|
229944
229727
|
let denominator = (lineB.end.y - lineB.start.y) * (lineA.end.x - lineA.start.x) - (lineB.end.x - lineB.start.x) * (lineA.end.y - lineA.start.y);
|
|
229945
229728
|
if (denominator === Infinity || denominator === -Infinity) {
|
|
@@ -231857,6 +231640,229 @@ class Arc {
|
|
|
231857
231640
|
return new Arc(this.center.copy(), this.radiusX, this.radiusY, this.startAngle, this.endAngle, this.clockwise);
|
|
231858
231641
|
}
|
|
231859
231642
|
}
|
|
231643
|
+
var _sessionStorage;
|
|
231644
|
+
if (typeof window !== "undefined" && window.sessionStorage) {
|
|
231645
|
+
_sessionStorage = window.sessionStorage;
|
|
231646
|
+
} else {
|
|
231647
|
+
|
|
231648
|
+
class NodeStoragePolyfill {
|
|
231649
|
+
_store = {};
|
|
231650
|
+
clear() {
|
|
231651
|
+
this._store = {};
|
|
231652
|
+
}
|
|
231653
|
+
getItem(key) {
|
|
231654
|
+
return Object.prototype.hasOwnProperty.call(this._store, key) ? this._store[key] : null;
|
|
231655
|
+
}
|
|
231656
|
+
key(index) {
|
|
231657
|
+
const keys = Object.keys(this._store);
|
|
231658
|
+
return keys[index] ?? null;
|
|
231659
|
+
}
|
|
231660
|
+
removeItem(key) {
|
|
231661
|
+
delete this._store[key];
|
|
231662
|
+
}
|
|
231663
|
+
setItem(key, value) {
|
|
231664
|
+
this._store[key] = value;
|
|
231665
|
+
}
|
|
231666
|
+
get length() {
|
|
231667
|
+
return Object.keys(this._store).length;
|
|
231668
|
+
}
|
|
231669
|
+
}
|
|
231670
|
+
_sessionStorage = new NodeStoragePolyfill;
|
|
231671
|
+
}
|
|
231672
|
+
|
|
231673
|
+
class SessionStorage {
|
|
231674
|
+
set(key, value) {
|
|
231675
|
+
const boardId = this.getBoardId() || "";
|
|
231676
|
+
_sessionStorage.setItem(boardId + "_" + key, JSON.stringify(value));
|
|
231677
|
+
}
|
|
231678
|
+
get(key) {
|
|
231679
|
+
const boardId = this.getBoardId() || "";
|
|
231680
|
+
const item = _sessionStorage.getItem(boardId + "_" + key);
|
|
231681
|
+
if (!item || item === "undefined") {
|
|
231682
|
+
return;
|
|
231683
|
+
}
|
|
231684
|
+
return JSON.parse(item);
|
|
231685
|
+
}
|
|
231686
|
+
remove(key) {
|
|
231687
|
+
const boardId = this.getBoardId() || "";
|
|
231688
|
+
_sessionStorage.removeItem(boardId + "_" + key);
|
|
231689
|
+
}
|
|
231690
|
+
setConnectorStrokeStyle(color) {
|
|
231691
|
+
this.set(`connectorStrokeStyle`, color);
|
|
231692
|
+
}
|
|
231693
|
+
getConnectorStrokeStyle() {
|
|
231694
|
+
return this.get("connectorStrokeStyle");
|
|
231695
|
+
}
|
|
231696
|
+
setConnectorLineWidth(width) {
|
|
231697
|
+
this.set(`connectorLineWidth`, width);
|
|
231698
|
+
}
|
|
231699
|
+
getConnectorLineWidth() {
|
|
231700
|
+
return this.get("connectorLineWidth");
|
|
231701
|
+
}
|
|
231702
|
+
setConnectorFillColor(color) {
|
|
231703
|
+
this.set(`connectorFillColor`, color);
|
|
231704
|
+
}
|
|
231705
|
+
getConnectorFillColor() {
|
|
231706
|
+
return this.get("connectorFillColor");
|
|
231707
|
+
}
|
|
231708
|
+
setConnectorPointer(type, edge) {
|
|
231709
|
+
this.set(`connector${edge.charAt(0).toUpperCase() + edge.slice(1)}Pointer`, type);
|
|
231710
|
+
}
|
|
231711
|
+
getConnectorPointer(edge) {
|
|
231712
|
+
return this.get(`connector${edge.charAt(0).toUpperCase() + edge.slice(1)}Pointer`);
|
|
231713
|
+
}
|
|
231714
|
+
setConnectorLineStyle(type) {
|
|
231715
|
+
this.set("connectorLineStyle", type);
|
|
231716
|
+
}
|
|
231717
|
+
getConnectorLineStyle() {
|
|
231718
|
+
return this.get("connectorLineStyle");
|
|
231719
|
+
}
|
|
231720
|
+
setShapeData(data) {
|
|
231721
|
+
this.set("lastShapeData", data);
|
|
231722
|
+
}
|
|
231723
|
+
getShapeData() {
|
|
231724
|
+
return this.get("lastShapeData");
|
|
231725
|
+
}
|
|
231726
|
+
setStickerData(data) {
|
|
231727
|
+
this.set("lastSticker", data);
|
|
231728
|
+
}
|
|
231729
|
+
getStickerData() {
|
|
231730
|
+
return this.get("lastSticker");
|
|
231731
|
+
}
|
|
231732
|
+
setShapeWidth(width) {
|
|
231733
|
+
this.set("shapeWidth", width);
|
|
231734
|
+
}
|
|
231735
|
+
getShapeWidth() {
|
|
231736
|
+
return this.get("shapeWidth");
|
|
231737
|
+
}
|
|
231738
|
+
setShapeHeight(height) {
|
|
231739
|
+
this.set("shapeHeight", height);
|
|
231740
|
+
}
|
|
231741
|
+
getShapeHeight() {
|
|
231742
|
+
return this.get("shapeHeight");
|
|
231743
|
+
}
|
|
231744
|
+
setImageDimensions(dimension) {
|
|
231745
|
+
this.set("imageDimensions", dimension);
|
|
231746
|
+
}
|
|
231747
|
+
getImageDimensions() {
|
|
231748
|
+
return this.get("imageDimensions");
|
|
231749
|
+
}
|
|
231750
|
+
setFontSize(itemType, size2) {
|
|
231751
|
+
this.set(`fontSize_${itemType}`, size2);
|
|
231752
|
+
}
|
|
231753
|
+
getFontSize(itemType) {
|
|
231754
|
+
return this.get(`fontSize_${itemType}`);
|
|
231755
|
+
}
|
|
231756
|
+
setFontStyles(itemType, styles) {
|
|
231757
|
+
this.set(`fontStyles_${itemType}`, styles);
|
|
231758
|
+
}
|
|
231759
|
+
getFontStyles(itemType) {
|
|
231760
|
+
return this.get(`fontStyles_${itemType}`);
|
|
231761
|
+
}
|
|
231762
|
+
setFontColor(itemType, color) {
|
|
231763
|
+
this.set(`fontColor_${itemType}`, color);
|
|
231764
|
+
}
|
|
231765
|
+
getFontColor(itemType) {
|
|
231766
|
+
return this.get(`fontColor_${itemType}`);
|
|
231767
|
+
}
|
|
231768
|
+
setFontHighlight(itemType, highlightColor) {
|
|
231769
|
+
this.set(`fontHighlightColor_${itemType}`, highlightColor);
|
|
231770
|
+
}
|
|
231771
|
+
getFontHighlight(itemType) {
|
|
231772
|
+
return this.get(`fontHighlightColor_${itemType}`);
|
|
231773
|
+
}
|
|
231774
|
+
setHorizontalAlignment(itemType, horizontalAlignment) {
|
|
231775
|
+
this.set(`fontHorizontalAlignment_${itemType}`, horizontalAlignment);
|
|
231776
|
+
}
|
|
231777
|
+
getHorizontalAlignment(itemType) {
|
|
231778
|
+
return this.get(`fontHorizontalAlignment_${itemType}`);
|
|
231779
|
+
}
|
|
231780
|
+
setVerticalAlignment(itemType, verticalAlignment) {
|
|
231781
|
+
this.set(`fontVerticalAlignment_${itemType}`, verticalAlignment);
|
|
231782
|
+
}
|
|
231783
|
+
getVerticalAlignment(itemType) {
|
|
231784
|
+
return this.get(`fontVerticalAlignment_${itemType}`);
|
|
231785
|
+
}
|
|
231786
|
+
setLastAIRequest(request) {
|
|
231787
|
+
_sessionStorage.setItem("lastAIRequest", request);
|
|
231788
|
+
}
|
|
231789
|
+
getLastAIRequest() {
|
|
231790
|
+
return _sessionStorage.getItem("lastAIRequest");
|
|
231791
|
+
}
|
|
231792
|
+
removeLastAIRequest() {
|
|
231793
|
+
_sessionStorage.removeItem("lastAIRequest");
|
|
231794
|
+
}
|
|
231795
|
+
clear() {
|
|
231796
|
+
_sessionStorage.clear();
|
|
231797
|
+
}
|
|
231798
|
+
getBoardId() {
|
|
231799
|
+
if (typeof window === "undefined") {
|
|
231800
|
+
return;
|
|
231801
|
+
}
|
|
231802
|
+
return window.location.href.split("/").pop()?.split("?")[0];
|
|
231803
|
+
}
|
|
231804
|
+
}
|
|
231805
|
+
var tempStorage = new SessionStorage;
|
|
231806
|
+
function getTranslationFromHTML(el) {
|
|
231807
|
+
const transform = el.style.transform;
|
|
231808
|
+
const translateMatch = transform.match(/translate\(([^)]+)\)/);
|
|
231809
|
+
const [translateX, translateY] = translateMatch ? translateMatch[1].split(",").map((value) => parseFloat(value)) : [0, 0];
|
|
231810
|
+
return [translateX, translateY];
|
|
231811
|
+
}
|
|
231812
|
+
function getScaleFromHTML(el) {
|
|
231813
|
+
const transform = el.style.transform;
|
|
231814
|
+
const scaleMatch = transform.match(/scale\(([^)]+)\)/);
|
|
231815
|
+
const [scaleX, scaleY] = scaleMatch ? scaleMatch[1].split(",").map((value) => parseFloat(value)) : [1, 1];
|
|
231816
|
+
return [scaleX, scaleY];
|
|
231817
|
+
}
|
|
231818
|
+
function translateElementBy(el, x, y) {
|
|
231819
|
+
const [exX, exY] = getTranslationFromHTML(el);
|
|
231820
|
+
const [newX, newY] = [exX + x, exY + y];
|
|
231821
|
+
const [scaleX, scaleY] = getScaleFromHTML(el);
|
|
231822
|
+
el.style.transform = `translate(${newX}px, ${newY}px) scale(${scaleX}, ${scaleY})`;
|
|
231823
|
+
return el;
|
|
231824
|
+
}
|
|
231825
|
+
function scaleElementBy(el, scaleX, scaleY) {
|
|
231826
|
+
const [currentScaleX, currentScaleY] = getScaleFromHTML(el);
|
|
231827
|
+
const [newScaleX, newScaleY] = [
|
|
231828
|
+
currentScaleX * scaleX,
|
|
231829
|
+
currentScaleY * scaleY
|
|
231830
|
+
];
|
|
231831
|
+
const [translateX, translateY] = getTranslationFromHTML(el);
|
|
231832
|
+
el.style.transform = `translate(${translateX}px, ${translateY}px) scale(${newScaleX}, ${newScaleY})`;
|
|
231833
|
+
return el;
|
|
231834
|
+
}
|
|
231835
|
+
function resetElementScale(el) {
|
|
231836
|
+
const [x, y] = getTranslationFromHTML(el);
|
|
231837
|
+
el.style.transform = `translate(${x}px, ${y}px) scale(1, 1)`;
|
|
231838
|
+
return el;
|
|
231839
|
+
}
|
|
231840
|
+
function positionRelatively(toPosition, positionBy, padding2 = 0) {
|
|
231841
|
+
const [translateX, translateY] = getTranslationFromHTML(toPosition);
|
|
231842
|
+
const [frameX, frameY] = getTranslationFromHTML(positionBy);
|
|
231843
|
+
const [dx, dy] = [translateX - frameX, translateY - frameY];
|
|
231844
|
+
const verticalAlignment = toPosition.getAttribute("data-vertical-alignment");
|
|
231845
|
+
const horizontalAlignment = toPosition.getAttribute("data-vertical-alignment");
|
|
231846
|
+
let paddingX = padding2;
|
|
231847
|
+
let paddingY = padding2;
|
|
231848
|
+
if (verticalAlignment && verticalAlignment === "bottom") {
|
|
231849
|
+
paddingY = -padding2;
|
|
231850
|
+
}
|
|
231851
|
+
if (horizontalAlignment && horizontalAlignment === "right") {
|
|
231852
|
+
paddingX = -padding2;
|
|
231853
|
+
}
|
|
231854
|
+
const [scaleX, scaleY] = getScaleFromHTML(toPosition);
|
|
231855
|
+
toPosition.style.transform = `translate(${dx + paddingX}px, ${dy + paddingY}px) scale(${scaleX}, ${scaleY})`;
|
|
231856
|
+
return toPosition;
|
|
231857
|
+
}
|
|
231858
|
+
function positionAbsolutely(toPosition, positionBy) {
|
|
231859
|
+
const [translateX, translateY] = getTranslationFromHTML(toPosition);
|
|
231860
|
+
const [frameX, frameY] = getTranslationFromHTML(positionBy);
|
|
231861
|
+
const [dx, dy] = [translateX + frameX, translateY + frameY];
|
|
231862
|
+
const [scaleX, scaleY] = getScaleFromHTML(toPosition);
|
|
231863
|
+
toPosition.style.transform = `translate(${dx}px, ${dy}px) scale(${scaleX}, ${scaleY})`;
|
|
231864
|
+
return toPosition;
|
|
231865
|
+
}
|
|
231860
231866
|
|
|
231861
231867
|
class BrowserDocumentFactory {
|
|
231862
231868
|
createElement(tagName) {
|
|
@@ -232032,6 +232038,151 @@ class MockPath2D {
|
|
|
232032
232038
|
}
|
|
232033
232039
|
}
|
|
232034
232040
|
|
|
232041
|
+
class Matrix2 {
|
|
232042
|
+
translateX;
|
|
232043
|
+
translateY;
|
|
232044
|
+
scaleX;
|
|
232045
|
+
scaleY;
|
|
232046
|
+
shearX;
|
|
232047
|
+
shearY;
|
|
232048
|
+
constructor(translateX = 0, translateY = 0, scaleX = 1, scaleY = 1, shearX = 0, shearY = 0) {
|
|
232049
|
+
this.translateX = translateX;
|
|
232050
|
+
this.translateY = translateY;
|
|
232051
|
+
this.scaleX = scaleX;
|
|
232052
|
+
this.scaleY = scaleY;
|
|
232053
|
+
this.shearX = shearX;
|
|
232054
|
+
this.shearY = shearY;
|
|
232055
|
+
this.translateX = toFiniteNumber(translateX);
|
|
232056
|
+
this.translateY = toFiniteNumber(translateY);
|
|
232057
|
+
this.scaleX = toFiniteNumber(scaleX, 1);
|
|
232058
|
+
this.scaleY = toFiniteNumber(scaleY, 1);
|
|
232059
|
+
this.shearX = toFiniteNumber(shearX);
|
|
232060
|
+
this.shearY = toFiniteNumber(shearY);
|
|
232061
|
+
}
|
|
232062
|
+
translate(x, y) {
|
|
232063
|
+
this.translateX += x;
|
|
232064
|
+
this.translateY += y;
|
|
232065
|
+
}
|
|
232066
|
+
scale(x, y) {
|
|
232067
|
+
this.scaleX = this.scaleX * x;
|
|
232068
|
+
this.scaleY = this.scaleY * y;
|
|
232069
|
+
}
|
|
232070
|
+
multiplyByMatrix(matrix) {
|
|
232071
|
+
const { translateX, translateY, scaleX, scaleY, shearX, shearY } = this;
|
|
232072
|
+
this.translateX = scaleX * matrix.translateX + shearX * matrix.translateY + translateX;
|
|
232073
|
+
this.translateY = shearY * matrix.translateX + scaleY * matrix.translateY + translateY;
|
|
232074
|
+
this.scaleX = scaleX * matrix.scaleX + shearX * matrix.shearY;
|
|
232075
|
+
this.scaleY = shearY * matrix.shearX + scaleY * matrix.scaleY;
|
|
232076
|
+
this.shearX = scaleX * matrix.shearX + shearX * matrix.scaleY;
|
|
232077
|
+
this.shearY = shearY * matrix.scaleX + scaleY * matrix.shearY;
|
|
232078
|
+
return this;
|
|
232079
|
+
}
|
|
232080
|
+
multiplyByMatrixies(matrixies) {
|
|
232081
|
+
for (const matrix of matrixies) {
|
|
232082
|
+
this.multiplyByMatrix(matrix);
|
|
232083
|
+
}
|
|
232084
|
+
return this;
|
|
232085
|
+
}
|
|
232086
|
+
multiply(value) {
|
|
232087
|
+
if (Array.isArray(value)) {
|
|
232088
|
+
this.multiplyByMatrixies(value);
|
|
232089
|
+
} else {
|
|
232090
|
+
this.multiplyByMatrix(value);
|
|
232091
|
+
}
|
|
232092
|
+
return this;
|
|
232093
|
+
}
|
|
232094
|
+
copy() {
|
|
232095
|
+
return new Matrix2(this.translateX, this.translateY, this.scaleX, this.scaleY, this.shearX, this.shearY);
|
|
232096
|
+
}
|
|
232097
|
+
invert() {
|
|
232098
|
+
const { scaleX, shearY, shearX, scaleY, translateX, translateY } = this;
|
|
232099
|
+
const denom = scaleX * scaleY - shearX * shearY;
|
|
232100
|
+
this.scaleX = scaleY / denom;
|
|
232101
|
+
this.shearY = shearY / -denom;
|
|
232102
|
+
this.shearX = shearX / -denom;
|
|
232103
|
+
this.scaleY = scaleX / denom;
|
|
232104
|
+
this.translateX = (scaleY * translateX - shearX * translateY) / -denom;
|
|
232105
|
+
this.translateY = (shearY * translateX - scaleX * translateY) / denom;
|
|
232106
|
+
}
|
|
232107
|
+
getInverse() {
|
|
232108
|
+
const inverse = this.copy();
|
|
232109
|
+
inverse.invert();
|
|
232110
|
+
return inverse;
|
|
232111
|
+
}
|
|
232112
|
+
rotateByRadian(radian) {
|
|
232113
|
+
const cosAngle = Math.cos(radian);
|
|
232114
|
+
const sinAngle = Math.sin(radian);
|
|
232115
|
+
const rotationMatrix = new Matrix2(0, 0, cosAngle, cosAngle, -sinAngle, sinAngle);
|
|
232116
|
+
return this.multiply(rotationMatrix);
|
|
232117
|
+
}
|
|
232118
|
+
rotateBy(degree) {
|
|
232119
|
+
const radian = degree * Math.PI / 180;
|
|
232120
|
+
this.rotateByRadian(radian);
|
|
232121
|
+
}
|
|
232122
|
+
rotateByObjectCenter(degree, size2, scale) {
|
|
232123
|
+
const angle = degree * (Math.PI / 180);
|
|
232124
|
+
const width = size2.width * scale.x;
|
|
232125
|
+
const height = size2.height * scale.y;
|
|
232126
|
+
const centerX = width / 2;
|
|
232127
|
+
const centerY = height / 2;
|
|
232128
|
+
const x = centerX - (centerX * Math.cos(angle) - centerY * Math.sin(angle));
|
|
232129
|
+
const y = centerY - (centerX * Math.sin(angle) + centerY * Math.cos(angle));
|
|
232130
|
+
this.rotateBy(degree);
|
|
232131
|
+
this.translate(x, y);
|
|
232132
|
+
}
|
|
232133
|
+
rotateByRelativeTo(degree, x, y) {
|
|
232134
|
+
this.translateX += x;
|
|
232135
|
+
this.translateY += y;
|
|
232136
|
+
this.rotateBy(degree);
|
|
232137
|
+
this.translateX -= x;
|
|
232138
|
+
this.translateY -= y;
|
|
232139
|
+
}
|
|
232140
|
+
rotateByRadianRelativeTo(radian, x, y) {
|
|
232141
|
+
this.translateX += x;
|
|
232142
|
+
this.translateY += y;
|
|
232143
|
+
this.rotateByRadian(radian);
|
|
232144
|
+
this.translateX -= x;
|
|
232145
|
+
this.translateY -= y;
|
|
232146
|
+
}
|
|
232147
|
+
apply(point3) {
|
|
232148
|
+
const { x, y } = point3;
|
|
232149
|
+
point3.x = this.scaleX * x + this.shearX * y + this.translateX;
|
|
232150
|
+
point3.y = this.shearY * x + this.scaleY * y + this.translateY;
|
|
232151
|
+
}
|
|
232152
|
+
applyToContext(ctx) {
|
|
232153
|
+
ctx.transform(this.scaleX, this.shearY, this.shearX, this.scaleY, this.translateX, this.translateY);
|
|
232154
|
+
}
|
|
232155
|
+
getAffineMatrix() {
|
|
232156
|
+
return {
|
|
232157
|
+
a: this.scaleX,
|
|
232158
|
+
b: this.shearY,
|
|
232159
|
+
c: this.shearX,
|
|
232160
|
+
d: this.scaleY,
|
|
232161
|
+
e: this.translateX,
|
|
232162
|
+
f: this.translateY
|
|
232163
|
+
};
|
|
232164
|
+
}
|
|
232165
|
+
getCssString() {
|
|
232166
|
+
return `matrix(${this.scaleX},${this.shearY},${this.shearX},${this.scaleY},${this.translateX},${this.translateY})`;
|
|
232167
|
+
}
|
|
232168
|
+
identity() {
|
|
232169
|
+
return new Matrix2;
|
|
232170
|
+
}
|
|
232171
|
+
mirrorOrigin() {
|
|
232172
|
+
return new Matrix2(0, 0, -1, -1);
|
|
232173
|
+
}
|
|
232174
|
+
mirrorX() {
|
|
232175
|
+
return new Matrix2(0, 0, 1, -1);
|
|
232176
|
+
}
|
|
232177
|
+
mirrorY() {
|
|
232178
|
+
return new Matrix2(0, 0, -1, 1);
|
|
232179
|
+
}
|
|
232180
|
+
compare(matrix) {
|
|
232181
|
+
const { translateX, translateY, scaleX, scaleY, shearX, shearY } = matrix;
|
|
232182
|
+
return this.translateX === translateX && this.translateY === translateY && this.scaleX === scaleX && this.scaleY === scaleY && this.shearX === shearX && this.shearY === shearY;
|
|
232183
|
+
}
|
|
232184
|
+
}
|
|
232185
|
+
|
|
232035
232186
|
class Subject {
|
|
232036
232187
|
observers = [];
|
|
232037
232188
|
subscribe(observer) {
|
|
@@ -234955,7 +235106,7 @@ var Browser = /* @__PURE__ */ function() {
|
|
|
234955
235106
|
}
|
|
234956
235107
|
_createClass(Browser2, [{
|
|
234957
235108
|
key: "init",
|
|
234958
|
-
value: function
|
|
235109
|
+
value: function init(services) {
|
|
234959
235110
|
var options2 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
234960
235111
|
var i18nOptions = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
234961
235112
|
this.services = services || {
|
|
@@ -235010,7 +235161,7 @@ var Browser = /* @__PURE__ */ function() {
|
|
|
235010
235161
|
}
|
|
235011
235162
|
}, {
|
|
235012
235163
|
key: "cacheUserLanguage",
|
|
235013
|
-
value: function
|
|
235164
|
+
value: function cacheUserLanguage(lng, caches) {
|
|
235014
235165
|
var _this2 = this;
|
|
235015
235166
|
if (!caches)
|
|
235016
235167
|
caches = this.options.caches;
|
|
@@ -235404,772 +235555,6 @@ var conf = {
|
|
|
235404
235555
|
CONNECTOR_ITEM_OFFSET: 20
|
|
235405
235556
|
};
|
|
235406
235557
|
initDefaultI18N();
|
|
235407
|
-
|
|
235408
|
-
class Matrix2 {
|
|
235409
|
-
translateX;
|
|
235410
|
-
translateY;
|
|
235411
|
-
scaleX;
|
|
235412
|
-
scaleY;
|
|
235413
|
-
shearX;
|
|
235414
|
-
shearY;
|
|
235415
|
-
constructor(translateX = 0, translateY = 0, scaleX = 1, scaleY = 1, shearX = 0, shearY = 0) {
|
|
235416
|
-
this.translateX = translateX;
|
|
235417
|
-
this.translateY = translateY;
|
|
235418
|
-
this.scaleX = scaleX;
|
|
235419
|
-
this.scaleY = scaleY;
|
|
235420
|
-
this.shearX = shearX;
|
|
235421
|
-
this.shearY = shearY;
|
|
235422
|
-
this.translateX = toFiniteNumber(translateX);
|
|
235423
|
-
this.translateY = toFiniteNumber(translateY);
|
|
235424
|
-
this.scaleX = toFiniteNumber(scaleX, 1);
|
|
235425
|
-
this.scaleY = toFiniteNumber(scaleY, 1);
|
|
235426
|
-
this.shearX = toFiniteNumber(shearX);
|
|
235427
|
-
this.shearY = toFiniteNumber(shearY);
|
|
235428
|
-
}
|
|
235429
|
-
translate(x, y) {
|
|
235430
|
-
this.translateX += x;
|
|
235431
|
-
this.translateY += y;
|
|
235432
|
-
}
|
|
235433
|
-
scale(x, y) {
|
|
235434
|
-
this.scaleX = this.scaleX * x;
|
|
235435
|
-
this.scaleY = this.scaleY * y;
|
|
235436
|
-
}
|
|
235437
|
-
multiplyByMatrix(matrix) {
|
|
235438
|
-
const { translateX, translateY, scaleX, scaleY, shearX, shearY } = this;
|
|
235439
|
-
this.translateX = scaleX * matrix.translateX + shearX * matrix.translateY + translateX;
|
|
235440
|
-
this.translateY = shearY * matrix.translateX + scaleY * matrix.translateY + translateY;
|
|
235441
|
-
this.scaleX = scaleX * matrix.scaleX + shearX * matrix.shearY;
|
|
235442
|
-
this.scaleY = shearY * matrix.shearX + scaleY * matrix.scaleY;
|
|
235443
|
-
this.shearX = scaleX * matrix.shearX + shearX * matrix.scaleY;
|
|
235444
|
-
this.shearY = shearY * matrix.scaleX + scaleY * matrix.shearY;
|
|
235445
|
-
return this;
|
|
235446
|
-
}
|
|
235447
|
-
multiplyByMatrixies(matrixies) {
|
|
235448
|
-
for (const matrix of matrixies) {
|
|
235449
|
-
this.multiplyByMatrix(matrix);
|
|
235450
|
-
}
|
|
235451
|
-
return this;
|
|
235452
|
-
}
|
|
235453
|
-
multiply(value) {
|
|
235454
|
-
if (Array.isArray(value)) {
|
|
235455
|
-
this.multiplyByMatrixies(value);
|
|
235456
|
-
} else {
|
|
235457
|
-
this.multiplyByMatrix(value);
|
|
235458
|
-
}
|
|
235459
|
-
return this;
|
|
235460
|
-
}
|
|
235461
|
-
copy() {
|
|
235462
|
-
return new Matrix2(this.translateX, this.translateY, this.scaleX, this.scaleY, this.shearX, this.shearY);
|
|
235463
|
-
}
|
|
235464
|
-
invert() {
|
|
235465
|
-
const { scaleX, shearY, shearX, scaleY, translateX, translateY } = this;
|
|
235466
|
-
const denom = scaleX * scaleY - shearX * shearY;
|
|
235467
|
-
this.scaleX = scaleY / denom;
|
|
235468
|
-
this.shearY = shearY / -denom;
|
|
235469
|
-
this.shearX = shearX / -denom;
|
|
235470
|
-
this.scaleY = scaleX / denom;
|
|
235471
|
-
this.translateX = (scaleY * translateX - shearX * translateY) / -denom;
|
|
235472
|
-
this.translateY = (shearY * translateX - scaleX * translateY) / denom;
|
|
235473
|
-
}
|
|
235474
|
-
getInverse() {
|
|
235475
|
-
const inverse = this.copy();
|
|
235476
|
-
inverse.invert();
|
|
235477
|
-
return inverse;
|
|
235478
|
-
}
|
|
235479
|
-
rotateByRadian(radian) {
|
|
235480
|
-
const cosAngle = Math.cos(radian);
|
|
235481
|
-
const sinAngle = Math.sin(radian);
|
|
235482
|
-
const rotationMatrix = new Matrix2(0, 0, cosAngle, cosAngle, -sinAngle, sinAngle);
|
|
235483
|
-
return this.multiply(rotationMatrix);
|
|
235484
|
-
}
|
|
235485
|
-
rotateBy(degree) {
|
|
235486
|
-
const radian = degree * Math.PI / 180;
|
|
235487
|
-
this.rotateByRadian(radian);
|
|
235488
|
-
}
|
|
235489
|
-
rotateByObjectCenter(degree, size2, scale) {
|
|
235490
|
-
const angle = degree * (Math.PI / 180);
|
|
235491
|
-
const width = size2.width * scale.x;
|
|
235492
|
-
const height = size2.height * scale.y;
|
|
235493
|
-
const centerX = width / 2;
|
|
235494
|
-
const centerY = height / 2;
|
|
235495
|
-
const x = centerX - (centerX * Math.cos(angle) - centerY * Math.sin(angle));
|
|
235496
|
-
const y = centerY - (centerX * Math.sin(angle) + centerY * Math.cos(angle));
|
|
235497
|
-
this.rotateBy(degree);
|
|
235498
|
-
this.translate(x, y);
|
|
235499
|
-
}
|
|
235500
|
-
rotateByRelativeTo(degree, x, y) {
|
|
235501
|
-
this.translateX += x;
|
|
235502
|
-
this.translateY += y;
|
|
235503
|
-
this.rotateBy(degree);
|
|
235504
|
-
this.translateX -= x;
|
|
235505
|
-
this.translateY -= y;
|
|
235506
|
-
}
|
|
235507
|
-
rotateByRadianRelativeTo(radian, x, y) {
|
|
235508
|
-
this.translateX += x;
|
|
235509
|
-
this.translateY += y;
|
|
235510
|
-
this.rotateByRadian(radian);
|
|
235511
|
-
this.translateX -= x;
|
|
235512
|
-
this.translateY -= y;
|
|
235513
|
-
}
|
|
235514
|
-
apply(point3) {
|
|
235515
|
-
const { x, y } = point3;
|
|
235516
|
-
point3.x = this.scaleX * x + this.shearX * y + this.translateX;
|
|
235517
|
-
point3.y = this.shearY * x + this.scaleY * y + this.translateY;
|
|
235518
|
-
}
|
|
235519
|
-
applyToContext(ctx) {
|
|
235520
|
-
ctx.transform(this.scaleX, this.shearY, this.shearX, this.scaleY, this.translateX, this.translateY);
|
|
235521
|
-
}
|
|
235522
|
-
getAffineMatrix() {
|
|
235523
|
-
return {
|
|
235524
|
-
a: this.scaleX,
|
|
235525
|
-
b: this.shearY,
|
|
235526
|
-
c: this.shearX,
|
|
235527
|
-
d: this.scaleY,
|
|
235528
|
-
e: this.translateX,
|
|
235529
|
-
f: this.translateY
|
|
235530
|
-
};
|
|
235531
|
-
}
|
|
235532
|
-
getCssString() {
|
|
235533
|
-
return `matrix(${this.scaleX},${this.shearY},${this.shearX},${this.scaleY},${this.translateX},${this.translateY})`;
|
|
235534
|
-
}
|
|
235535
|
-
identity() {
|
|
235536
|
-
return new Matrix2;
|
|
235537
|
-
}
|
|
235538
|
-
mirrorOrigin() {
|
|
235539
|
-
return new Matrix2(0, 0, -1, -1);
|
|
235540
|
-
}
|
|
235541
|
-
mirrorX() {
|
|
235542
|
-
return new Matrix2(0, 0, 1, -1);
|
|
235543
|
-
}
|
|
235544
|
-
mirrorY() {
|
|
235545
|
-
return new Matrix2(0, 0, -1, 1);
|
|
235546
|
-
}
|
|
235547
|
-
compare(matrix) {
|
|
235548
|
-
const { translateX, translateY, scaleX, scaleY, shearX, shearY } = matrix;
|
|
235549
|
-
return this.translateX === translateX && this.translateY === translateY && this.scaleX === scaleX && this.scaleY === scaleY && this.shearX === shearX && this.shearY === shearY;
|
|
235550
|
-
}
|
|
235551
|
-
}
|
|
235552
|
-
|
|
235553
|
-
class SubjectOperation {
|
|
235554
|
-
observers = [];
|
|
235555
|
-
subscribe(observer) {
|
|
235556
|
-
const index = this.observers.indexOf(observer);
|
|
235557
|
-
if (index === -1) {
|
|
235558
|
-
this.observers.push(observer);
|
|
235559
|
-
}
|
|
235560
|
-
}
|
|
235561
|
-
unsubscribe(observer) {
|
|
235562
|
-
const index = this.observers.indexOf(observer);
|
|
235563
|
-
if (index !== -1) {
|
|
235564
|
-
this.observers.splice(index, 1);
|
|
235565
|
-
}
|
|
235566
|
-
}
|
|
235567
|
-
publish(subject, op) {
|
|
235568
|
-
for (const observer of this.observers) {
|
|
235569
|
-
observer(subject, op);
|
|
235570
|
-
}
|
|
235571
|
-
}
|
|
235572
|
-
}
|
|
235573
|
-
function mapItemsByOperation(item, getCallback) {
|
|
235574
|
-
const items = Array.isArray(item) ? item : [item];
|
|
235575
|
-
return items.map((item2) => {
|
|
235576
|
-
const operation = getCallback(item2);
|
|
235577
|
-
return { item: item2, operation };
|
|
235578
|
-
});
|
|
235579
|
-
}
|
|
235580
|
-
|
|
235581
|
-
class TransformationCommand {
|
|
235582
|
-
transformation;
|
|
235583
|
-
operation;
|
|
235584
|
-
reverse;
|
|
235585
|
-
constructor(transformation, operation) {
|
|
235586
|
-
this.transformation = transformation;
|
|
235587
|
-
this.operation = operation;
|
|
235588
|
-
this.reverse = this.getReverse();
|
|
235589
|
-
}
|
|
235590
|
-
merge(op) {
|
|
235591
|
-
this.operation = op;
|
|
235592
|
-
this.reverse = this.getReverse();
|
|
235593
|
-
return this;
|
|
235594
|
-
}
|
|
235595
|
-
apply() {
|
|
235596
|
-
for (const transformation of this.transformation) {
|
|
235597
|
-
transformation.apply(this.operation);
|
|
235598
|
-
}
|
|
235599
|
-
}
|
|
235600
|
-
revert() {
|
|
235601
|
-
this.reverse.forEach(({ item, operation }) => {
|
|
235602
|
-
item.apply(operation);
|
|
235603
|
-
});
|
|
235604
|
-
}
|
|
235605
|
-
getReverse() {
|
|
235606
|
-
const op = this.operation;
|
|
235607
|
-
switch (this.operation.method) {
|
|
235608
|
-
case "applyMatrix": {
|
|
235609
|
-
const op2 = this.operation;
|
|
235610
|
-
return this.transformation.map((t3) => {
|
|
235611
|
-
const itemOp = op2.items.find((i) => i.id === t3.getId());
|
|
235612
|
-
if (!itemOp)
|
|
235613
|
-
return { item: t3, operation: op2 };
|
|
235614
|
-
return {
|
|
235615
|
-
item: t3,
|
|
235616
|
-
operation: {
|
|
235617
|
-
class: "Transformation",
|
|
235618
|
-
method: "applyMatrix",
|
|
235619
|
-
items: [{
|
|
235620
|
-
id: t3.getId(),
|
|
235621
|
-
matrix: {
|
|
235622
|
-
translateX: -itemOp.matrix.translateX,
|
|
235623
|
-
translateY: -itemOp.matrix.translateY,
|
|
235624
|
-
scaleX: 1 / itemOp.matrix.scaleX,
|
|
235625
|
-
scaleY: 1 / itemOp.matrix.scaleY,
|
|
235626
|
-
shearX: 0,
|
|
235627
|
-
shearY: 0
|
|
235628
|
-
}
|
|
235629
|
-
}]
|
|
235630
|
-
}
|
|
235631
|
-
};
|
|
235632
|
-
});
|
|
235633
|
-
}
|
|
235634
|
-
case "translateTo":
|
|
235635
|
-
return mapItemsByOperation(this.transformation, (transformation) => {
|
|
235636
|
-
return {
|
|
235637
|
-
...this.operation,
|
|
235638
|
-
x: transformation.getTranslation().x,
|
|
235639
|
-
y: transformation.getTranslation().y
|
|
235640
|
-
};
|
|
235641
|
-
});
|
|
235642
|
-
case "translateBy": {
|
|
235643
|
-
const op2 = this.operation;
|
|
235644
|
-
return mapItemsByOperation(this.transformation, () => {
|
|
235645
|
-
return {
|
|
235646
|
-
...this.operation,
|
|
235647
|
-
x: -op2.x,
|
|
235648
|
-
y: -op2.y
|
|
235649
|
-
};
|
|
235650
|
-
});
|
|
235651
|
-
}
|
|
235652
|
-
case "scaleTo":
|
|
235653
|
-
case "scaleToRelativeTo": {
|
|
235654
|
-
return mapItemsByOperation(this.transformation, (transformation) => {
|
|
235655
|
-
return {
|
|
235656
|
-
...op,
|
|
235657
|
-
x: transformation.getScale().x,
|
|
235658
|
-
y: transformation.getScale().y
|
|
235659
|
-
};
|
|
235660
|
-
});
|
|
235661
|
-
}
|
|
235662
|
-
case "scaleBy":
|
|
235663
|
-
case "scaleByRelativeTo": {
|
|
235664
|
-
const op2 = this.operation;
|
|
235665
|
-
return mapItemsByOperation(this.transformation, () => {
|
|
235666
|
-
return {
|
|
235667
|
-
...op2,
|
|
235668
|
-
x: 1 / op2.x,
|
|
235669
|
-
y: 1 / op2.y
|
|
235670
|
-
};
|
|
235671
|
-
});
|
|
235672
|
-
}
|
|
235673
|
-
case "rotateTo":
|
|
235674
|
-
return mapItemsByOperation(this.transformation, (transformation) => {
|
|
235675
|
-
return {
|
|
235676
|
-
...this.operation,
|
|
235677
|
-
degree: transformation.getRotation()
|
|
235678
|
-
};
|
|
235679
|
-
});
|
|
235680
|
-
case "scaleByTranslateBy": {
|
|
235681
|
-
const op2 = this.operation;
|
|
235682
|
-
const scaleTransformation = mapItemsByOperation(this.transformation, () => {
|
|
235683
|
-
const scaleX = 1 / op2.scale.x;
|
|
235684
|
-
const scaleY = 1 / op2.scale.y;
|
|
235685
|
-
const translateX = -op2.translate.x;
|
|
235686
|
-
const translateY = -op2.translate.y;
|
|
235687
|
-
return {
|
|
235688
|
-
...op2,
|
|
235689
|
-
scale: {
|
|
235690
|
-
x: scaleX,
|
|
235691
|
-
y: scaleY
|
|
235692
|
-
},
|
|
235693
|
-
translate: {
|
|
235694
|
-
x: translateX,
|
|
235695
|
-
y: translateY
|
|
235696
|
-
}
|
|
235697
|
-
};
|
|
235698
|
-
});
|
|
235699
|
-
return scaleTransformation;
|
|
235700
|
-
}
|
|
235701
|
-
case "rotateBy": {
|
|
235702
|
-
const op2 = this.operation;
|
|
235703
|
-
return mapItemsByOperation(this.transformation, () => {
|
|
235704
|
-
return {
|
|
235705
|
-
...this.operation,
|
|
235706
|
-
degree: -op2.degree
|
|
235707
|
-
};
|
|
235708
|
-
});
|
|
235709
|
-
}
|
|
235710
|
-
case "transformMany": {
|
|
235711
|
-
const { operation, transformation } = this;
|
|
235712
|
-
return transformation.map((currTrans) => {
|
|
235713
|
-
const op2 = operation.items[currTrans.getId()];
|
|
235714
|
-
const m = op2.method === "applyMatrix" ? op2.matrix : op2.method === "scaleByTranslateBy" ? { translateX: -op2.translate.x, translateY: -op2.translate.y, scaleX: 1 / op2.scale.x, scaleY: 1 / op2.scale.y, shearX: 0, shearY: 0 } : { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 };
|
|
235715
|
-
return {
|
|
235716
|
-
item: currTrans,
|
|
235717
|
-
operation: {
|
|
235718
|
-
class: "Transformation",
|
|
235719
|
-
method: "applyMatrix",
|
|
235720
|
-
items: [{
|
|
235721
|
-
id: currTrans.getId(),
|
|
235722
|
-
matrix: {
|
|
235723
|
-
translateX: op2.method === "applyMatrix" ? -m.translateX : m.translateX,
|
|
235724
|
-
translateY: op2.method === "applyMatrix" ? -m.translateY : m.translateY,
|
|
235725
|
-
scaleX: op2.method === "applyMatrix" ? 1 / m.scaleX : m.scaleX,
|
|
235726
|
-
scaleY: op2.method === "applyMatrix" ? 1 / m.scaleY : m.scaleY,
|
|
235727
|
-
shearX: 0,
|
|
235728
|
-
shearY: 0
|
|
235729
|
-
}
|
|
235730
|
-
}]
|
|
235731
|
-
}
|
|
235732
|
-
};
|
|
235733
|
-
});
|
|
235734
|
-
}
|
|
235735
|
-
case "locked": {
|
|
235736
|
-
const op2 = this.operation;
|
|
235737
|
-
return mapItemsByOperation(this.transformation, () => {
|
|
235738
|
-
return {
|
|
235739
|
-
...op2,
|
|
235740
|
-
item: [...op2.item],
|
|
235741
|
-
method: "unlocked",
|
|
235742
|
-
locked: false
|
|
235743
|
-
};
|
|
235744
|
-
});
|
|
235745
|
-
}
|
|
235746
|
-
case "unlocked": {
|
|
235747
|
-
const op2 = this.operation;
|
|
235748
|
-
return mapItemsByOperation(this.transformation, () => {
|
|
235749
|
-
return {
|
|
235750
|
-
...op2,
|
|
235751
|
-
item: [...op2.item],
|
|
235752
|
-
method: "locked",
|
|
235753
|
-
locked: true
|
|
235754
|
-
};
|
|
235755
|
-
});
|
|
235756
|
-
}
|
|
235757
|
-
default:
|
|
235758
|
-
return [
|
|
235759
|
-
{ item: this.transformation[0], operation: this.operation }
|
|
235760
|
-
];
|
|
235761
|
-
}
|
|
235762
|
-
}
|
|
235763
|
-
}
|
|
235764
|
-
|
|
235765
|
-
class DefaultTransformationData {
|
|
235766
|
-
translateX;
|
|
235767
|
-
translateY;
|
|
235768
|
-
scaleX;
|
|
235769
|
-
scaleY;
|
|
235770
|
-
rotate;
|
|
235771
|
-
isLocked;
|
|
235772
|
-
constructor(translateX = 0, translateY = 0, scaleX = 1, scaleY = 1, rotate = 0, isLocked = false) {
|
|
235773
|
-
this.translateX = translateX;
|
|
235774
|
-
this.translateY = translateY;
|
|
235775
|
-
this.scaleX = scaleX;
|
|
235776
|
-
this.scaleY = scaleY;
|
|
235777
|
-
this.rotate = rotate;
|
|
235778
|
-
this.isLocked = isLocked;
|
|
235779
|
-
}
|
|
235780
|
-
}
|
|
235781
|
-
var defaultData = new DefaultTransformationData;
|
|
235782
|
-
|
|
235783
|
-
class Transformation {
|
|
235784
|
-
id;
|
|
235785
|
-
events;
|
|
235786
|
-
subject = new SubjectOperation;
|
|
235787
|
-
matrix = new Matrix2;
|
|
235788
|
-
previous = new Matrix2;
|
|
235789
|
-
rotate = defaultData.rotate;
|
|
235790
|
-
isLocked = false;
|
|
235791
|
-
constructor(id2 = "", events2) {
|
|
235792
|
-
this.id = id2;
|
|
235793
|
-
this.events = events2;
|
|
235794
|
-
}
|
|
235795
|
-
serialize() {
|
|
235796
|
-
return {
|
|
235797
|
-
translateX: this.matrix.translateX,
|
|
235798
|
-
translateY: this.matrix.translateY,
|
|
235799
|
-
scaleX: this.matrix.scaleX,
|
|
235800
|
-
scaleY: this.matrix.scaleY,
|
|
235801
|
-
rotate: this.rotate,
|
|
235802
|
-
isLocked: this.isLocked
|
|
235803
|
-
};
|
|
235804
|
-
}
|
|
235805
|
-
deserialize(data) {
|
|
235806
|
-
this.previous = this.matrix.copy();
|
|
235807
|
-
if (data.translateX) {
|
|
235808
|
-
this.matrix.translateX = data.translateX;
|
|
235809
|
-
}
|
|
235810
|
-
if (data.translateY) {
|
|
235811
|
-
this.matrix.translateY = data.translateY;
|
|
235812
|
-
}
|
|
235813
|
-
if (data.scaleX) {
|
|
235814
|
-
this.matrix.scaleX = data.scaleX;
|
|
235815
|
-
}
|
|
235816
|
-
if (data.scaleY) {
|
|
235817
|
-
this.matrix.scaleY = data.scaleY;
|
|
235818
|
-
}
|
|
235819
|
-
if (data.isLocked) {
|
|
235820
|
-
this.isLocked = data.isLocked;
|
|
235821
|
-
}
|
|
235822
|
-
if (data.rotate) {
|
|
235823
|
-
this.rotate = data.rotate;
|
|
235824
|
-
}
|
|
235825
|
-
this.subject.publish(this, {
|
|
235826
|
-
class: "Transformation",
|
|
235827
|
-
method: "deserialize",
|
|
235828
|
-
item: [this.id],
|
|
235829
|
-
data
|
|
235830
|
-
});
|
|
235831
|
-
return this;
|
|
235832
|
-
}
|
|
235833
|
-
copy(id2) {
|
|
235834
|
-
const { translateX, translateY, scaleX, scaleY } = this.matrix;
|
|
235835
|
-
const { rotate } = this;
|
|
235836
|
-
return new Transformation(id2 || "", this.events).deserialize({
|
|
235837
|
-
translateX,
|
|
235838
|
-
translateY,
|
|
235839
|
-
scaleX,
|
|
235840
|
-
scaleY,
|
|
235841
|
-
rotate,
|
|
235842
|
-
isLocked: false
|
|
235843
|
-
});
|
|
235844
|
-
}
|
|
235845
|
-
emit(operation) {
|
|
235846
|
-
if (this.events) {
|
|
235847
|
-
const command = new TransformationCommand([this], operation);
|
|
235848
|
-
command.apply();
|
|
235849
|
-
this.events.emit(operation, command);
|
|
235850
|
-
} else {
|
|
235851
|
-
this.apply(operation);
|
|
235852
|
-
}
|
|
235853
|
-
}
|
|
235854
|
-
setId(id2) {
|
|
235855
|
-
this.id = id2;
|
|
235856
|
-
}
|
|
235857
|
-
apply(op) {
|
|
235858
|
-
this.previous = this.matrix.copy();
|
|
235859
|
-
switch (op.method) {
|
|
235860
|
-
case "applyMatrix": {
|
|
235861
|
-
const itemOp = op.items.find((i) => i.id === this.id);
|
|
235862
|
-
if (itemOp) {
|
|
235863
|
-
this.matrix.scale(itemOp.matrix.scaleX, itemOp.matrix.scaleY);
|
|
235864
|
-
this.matrix.translate(itemOp.matrix.translateX, itemOp.matrix.translateY);
|
|
235865
|
-
}
|
|
235866
|
-
break;
|
|
235867
|
-
}
|
|
235868
|
-
case "translateTo":
|
|
235869
|
-
this.applyTranslateTo(op.x, op.y);
|
|
235870
|
-
break;
|
|
235871
|
-
case "translateBy":
|
|
235872
|
-
this.applyTranslateBy(op.x, op.y);
|
|
235873
|
-
break;
|
|
235874
|
-
case "scaleTo":
|
|
235875
|
-
this.applyScaleTo(op.x, op.y);
|
|
235876
|
-
break;
|
|
235877
|
-
case "scaleBy":
|
|
235878
|
-
this.applyScaleBy(op.x, op.y);
|
|
235879
|
-
break;
|
|
235880
|
-
case "scaleToRelativeTo":
|
|
235881
|
-
this.applyScaleToRelativeTo(op.x, op.y, op.point);
|
|
235882
|
-
break;
|
|
235883
|
-
case "scaleByRelativeTo":
|
|
235884
|
-
this.applyScaleByRelativeTo(op.x, op.y, op.point);
|
|
235885
|
-
break;
|
|
235886
|
-
case "rotateTo":
|
|
235887
|
-
this.applyRotateTo(op.degree);
|
|
235888
|
-
break;
|
|
235889
|
-
case "rotateBy":
|
|
235890
|
-
this.applyRotateBy(op.degree);
|
|
235891
|
-
break;
|
|
235892
|
-
case "scaleByTranslateBy":
|
|
235893
|
-
this.applyScaleByTranslateBy(op.scale, op.translate);
|
|
235894
|
-
break;
|
|
235895
|
-
case "transformMany":
|
|
235896
|
-
this.applyTransformMany(op.items[this.id]);
|
|
235897
|
-
break;
|
|
235898
|
-
case "locked":
|
|
235899
|
-
this.applyLocked(op.locked);
|
|
235900
|
-
break;
|
|
235901
|
-
case "unlocked":
|
|
235902
|
-
this.applyUnlocked(op.locked);
|
|
235903
|
-
break;
|
|
235904
|
-
default:
|
|
235905
|
-
return;
|
|
235906
|
-
}
|
|
235907
|
-
this.subject.publish(this, op);
|
|
235908
|
-
}
|
|
235909
|
-
applyTranslateTo(x, y) {
|
|
235910
|
-
this.matrix.translateX = x;
|
|
235911
|
-
this.matrix.translateY = y;
|
|
235912
|
-
}
|
|
235913
|
-
applyTranslateBy(x, y) {
|
|
235914
|
-
this.matrix.translate(x, y);
|
|
235915
|
-
}
|
|
235916
|
-
applyScaleTo(x, y) {
|
|
235917
|
-
this.matrix.scaleX = x;
|
|
235918
|
-
this.matrix.scaleY = y;
|
|
235919
|
-
}
|
|
235920
|
-
applyScaleBy(x, y) {
|
|
235921
|
-
this.matrix.scale(x, y);
|
|
235922
|
-
}
|
|
235923
|
-
applyScaleByTranslateBy(scale, translate) {
|
|
235924
|
-
this.matrix.scale(scale.x, scale.y);
|
|
235925
|
-
this.matrix.translate(translate.x, translate.y);
|
|
235926
|
-
}
|
|
235927
|
-
applyTransformMany(op) {
|
|
235928
|
-
if (op.method === "applyMatrix") {
|
|
235929
|
-
this.matrix.scale(op.matrix.scaleX, op.matrix.scaleY);
|
|
235930
|
-
this.matrix.translate(op.matrix.translateX, op.matrix.translateY);
|
|
235931
|
-
} else if (op.method === "scaleByTranslateBy") {
|
|
235932
|
-
this.applyScaleByTranslateBy(op.scale, op.translate);
|
|
235933
|
-
} else if (op.method === "scaleBy") {
|
|
235934
|
-
this.applyScaleBy(op.x, op.y);
|
|
235935
|
-
} else if (op.method === "translateBy") {
|
|
235936
|
-
this.applyTranslateBy(op.x, op.y);
|
|
235937
|
-
} else if (op.method === "translateTo") {
|
|
235938
|
-
this.applyTranslateTo(op.x, op.y);
|
|
235939
|
-
}
|
|
235940
|
-
}
|
|
235941
|
-
applyScaleByRelativeTo(x, y, point3) {
|
|
235942
|
-
const scaleX = this.matrix.scaleX * x;
|
|
235943
|
-
const scaleY = this.matrix.scaleY * y;
|
|
235944
|
-
this.matrix.translateX = -point3.x * scaleX + point3.x;
|
|
235945
|
-
this.matrix.translateY = -point3.y * scaleY + point3.y;
|
|
235946
|
-
this.matrix.scaleX = scaleX;
|
|
235947
|
-
this.matrix.scaleY = scaleY;
|
|
235948
|
-
}
|
|
235949
|
-
applyScaleToRelativeTo(x, y, point3) {
|
|
235950
|
-
this.applyTranslateBy(-point3.x, -point3.y);
|
|
235951
|
-
this.applyScaleTo(x, y);
|
|
235952
|
-
this.applyTranslateBy(point3.x, point3.y);
|
|
235953
|
-
}
|
|
235954
|
-
applyRotateTo(degree) {
|
|
235955
|
-
if (degree > 0) {
|
|
235956
|
-
while (degree > 360) {
|
|
235957
|
-
degree -= 360;
|
|
235958
|
-
}
|
|
235959
|
-
if (degree === 360) {
|
|
235960
|
-
degree = 0;
|
|
235961
|
-
}
|
|
235962
|
-
} else {
|
|
235963
|
-
while (degree < -360) {
|
|
235964
|
-
degree += 360;
|
|
235965
|
-
}
|
|
235966
|
-
if (degree === -360) {
|
|
235967
|
-
degree = 0;
|
|
235968
|
-
}
|
|
235969
|
-
}
|
|
235970
|
-
this.rotate = degree;
|
|
235971
|
-
}
|
|
235972
|
-
applyRotateBy(degree) {
|
|
235973
|
-
this.applyRotateTo(this.rotate + degree);
|
|
235974
|
-
}
|
|
235975
|
-
applyLocked(locked7) {
|
|
235976
|
-
this.isLocked = locked7;
|
|
235977
|
-
}
|
|
235978
|
-
applyUnlocked(locked7) {
|
|
235979
|
-
this.isLocked = locked7;
|
|
235980
|
-
}
|
|
235981
|
-
getTranslation() {
|
|
235982
|
-
return { x: this.matrix.translateX, y: this.matrix.translateY };
|
|
235983
|
-
}
|
|
235984
|
-
getScale() {
|
|
235985
|
-
return { x: this.matrix.scaleX, y: this.matrix.scaleY };
|
|
235986
|
-
}
|
|
235987
|
-
getRotation() {
|
|
235988
|
-
return this.rotate;
|
|
235989
|
-
}
|
|
235990
|
-
getInverse() {
|
|
235991
|
-
const copy22 = this.copy();
|
|
235992
|
-
copy22.matrix.invert();
|
|
235993
|
-
return copy22;
|
|
235994
|
-
}
|
|
235995
|
-
getId() {
|
|
235996
|
-
return this.id;
|
|
235997
|
-
}
|
|
235998
|
-
emitMatrix(matrix, timeStamp) {
|
|
235999
|
-
this.emit({
|
|
236000
|
-
class: "Transformation",
|
|
236001
|
-
method: "applyMatrix",
|
|
236002
|
-
items: [{ id: this.id, matrix }],
|
|
236003
|
-
timeStamp
|
|
236004
|
-
});
|
|
236005
|
-
}
|
|
236006
|
-
translateTo(x, y, timeStamp) {
|
|
236007
|
-
if (!this.id) {}
|
|
236008
|
-
this.emitMatrix({
|
|
236009
|
-
translateX: x - this.matrix.translateX,
|
|
236010
|
-
translateY: y - this.matrix.translateY,
|
|
236011
|
-
scaleX: 1,
|
|
236012
|
-
scaleY: 1,
|
|
236013
|
-
shearX: 0,
|
|
236014
|
-
shearY: 0
|
|
236015
|
-
}, timeStamp);
|
|
236016
|
-
}
|
|
236017
|
-
translateBy(x, y, timeStamp) {
|
|
236018
|
-
if (!this.id) {}
|
|
236019
|
-
if (x === 0 && y === 0) {
|
|
236020
|
-
return;
|
|
236021
|
-
}
|
|
236022
|
-
this.emitMatrix({
|
|
236023
|
-
translateX: x,
|
|
236024
|
-
translateY: y,
|
|
236025
|
-
scaleX: 1,
|
|
236026
|
-
scaleY: 1,
|
|
236027
|
-
shearX: 0,
|
|
236028
|
-
shearY: 0
|
|
236029
|
-
}, timeStamp);
|
|
236030
|
-
}
|
|
236031
|
-
scaleTo(x, y, timeStamp) {
|
|
236032
|
-
this.emitMatrix({
|
|
236033
|
-
translateX: 0,
|
|
236034
|
-
translateY: 0,
|
|
236035
|
-
scaleX: x / this.matrix.scaleX,
|
|
236036
|
-
scaleY: y / this.matrix.scaleY,
|
|
236037
|
-
shearX: 0,
|
|
236038
|
-
shearY: 0
|
|
236039
|
-
}, timeStamp);
|
|
236040
|
-
}
|
|
236041
|
-
scaleBy(x, y, timeStamp) {
|
|
236042
|
-
if (x === 0 && y === 0) {
|
|
236043
|
-
return;
|
|
236044
|
-
}
|
|
236045
|
-
this.emitMatrix({
|
|
236046
|
-
translateX: 0,
|
|
236047
|
-
translateY: 0,
|
|
236048
|
-
scaleX: x,
|
|
236049
|
-
scaleY: y,
|
|
236050
|
-
shearX: 0,
|
|
236051
|
-
shearY: 0
|
|
236052
|
-
}, timeStamp);
|
|
236053
|
-
}
|
|
236054
|
-
scaleByTranslateBy(scale, translate, timeStamp) {
|
|
236055
|
-
if (scale.x === 0 && scale.y === 0 && translate.x === 0 && translate.y === 0) {
|
|
236056
|
-
return;
|
|
236057
|
-
}
|
|
236058
|
-
this.emitMatrix({
|
|
236059
|
-
translateX: translate.x,
|
|
236060
|
-
translateY: translate.y,
|
|
236061
|
-
scaleX: scale.x,
|
|
236062
|
-
scaleY: scale.y,
|
|
236063
|
-
shearX: 0,
|
|
236064
|
-
shearY: 0
|
|
236065
|
-
}, timeStamp);
|
|
236066
|
-
}
|
|
236067
|
-
rotateTo(degree, timeStamp) {
|
|
236068
|
-
this.emit({
|
|
236069
|
-
class: "Transformation",
|
|
236070
|
-
method: "rotateTo",
|
|
236071
|
-
item: [this.id],
|
|
236072
|
-
degree,
|
|
236073
|
-
timeStamp
|
|
236074
|
-
});
|
|
236075
|
-
}
|
|
236076
|
-
rotateBy(degree, timeStamp) {
|
|
236077
|
-
this.emit({
|
|
236078
|
-
class: "Transformation",
|
|
236079
|
-
method: "rotateBy",
|
|
236080
|
-
item: [this.id],
|
|
236081
|
-
degree,
|
|
236082
|
-
timeStamp
|
|
236083
|
-
});
|
|
236084
|
-
}
|
|
236085
|
-
scaleToRelativeTo(x, y, _point, timeStamp) {
|
|
236086
|
-
this.emitMatrix({
|
|
236087
|
-
translateX: 0,
|
|
236088
|
-
translateY: 0,
|
|
236089
|
-
scaleX: x / this.matrix.scaleX,
|
|
236090
|
-
scaleY: y / this.matrix.scaleY,
|
|
236091
|
-
shearX: 0,
|
|
236092
|
-
shearY: 0
|
|
236093
|
-
}, timeStamp);
|
|
236094
|
-
}
|
|
236095
|
-
scaleByRelativeTo(x, y, point3, timeStamp) {
|
|
236096
|
-
const { scaleX: sx0, scaleY: sy0, translateX: tx0, translateY: ty0 } = this.matrix;
|
|
236097
|
-
const newSx = sx0 * x;
|
|
236098
|
-
const newSy = sy0 * y;
|
|
236099
|
-
this.emitMatrix({
|
|
236100
|
-
translateX: -point3.x * newSx + point3.x - tx0,
|
|
236101
|
-
translateY: -point3.y * newSy + point3.y - ty0,
|
|
236102
|
-
scaleX: x,
|
|
236103
|
-
scaleY: y,
|
|
236104
|
-
shearX: 0,
|
|
236105
|
-
shearY: 0
|
|
236106
|
-
}, timeStamp);
|
|
236107
|
-
}
|
|
236108
|
-
setIsLocked(isLocked, timestamp) {
|
|
236109
|
-
if (isLocked) {
|
|
236110
|
-
this.emit({
|
|
236111
|
-
class: "Transformation",
|
|
236112
|
-
method: "locked",
|
|
236113
|
-
item: [this.id],
|
|
236114
|
-
locked: true,
|
|
236115
|
-
timestamp
|
|
236116
|
-
});
|
|
236117
|
-
} else {
|
|
236118
|
-
this.emit({
|
|
236119
|
-
class: "Transformation",
|
|
236120
|
-
method: "unlocked",
|
|
236121
|
-
item: [this.id],
|
|
236122
|
-
locked: false,
|
|
236123
|
-
timestamp
|
|
236124
|
-
});
|
|
236125
|
-
}
|
|
236126
|
-
}
|
|
236127
|
-
}
|
|
236128
|
-
|
|
236129
|
-
class DrawingContext {
|
|
236130
|
-
camera;
|
|
236131
|
-
ctx;
|
|
236132
|
-
cursorCtx;
|
|
236133
|
-
matrix;
|
|
236134
|
-
isBorderInvisible = false;
|
|
236135
|
-
shapeVisibilityTreshold = 3;
|
|
236136
|
-
rectangleVisibilyTreshold = 2;
|
|
236137
|
-
constructor(camera, ctx, cursorCtx, matrix = new Matrix2) {
|
|
236138
|
-
this.camera = camera;
|
|
236139
|
-
this.ctx = ctx;
|
|
236140
|
-
this.cursorCtx = cursorCtx;
|
|
236141
|
-
this.matrix = matrix;
|
|
236142
|
-
this.setCamera(camera);
|
|
236143
|
-
}
|
|
236144
|
-
dpi() {
|
|
236145
|
-
return conf.getDPI();
|
|
236146
|
-
}
|
|
236147
|
-
setCamera(camera) {
|
|
236148
|
-
this.camera = camera;
|
|
236149
|
-
this.matrix = camera.getMatrix();
|
|
236150
|
-
const scale = this.matrix.scaleX;
|
|
236151
|
-
this.isBorderInvisible = 4 * scale < 0.1;
|
|
236152
|
-
}
|
|
236153
|
-
clear() {
|
|
236154
|
-
this.ctx.setTransform(1 * this.dpi(), 0, 0, 1 * this.dpi(), 0, 0);
|
|
236155
|
-
this.ctx.clearRect(0, 0, conf.getDocumentWidth(), conf.getDocumentHeight());
|
|
236156
|
-
this.matrix.applyToContext(this.ctx);
|
|
236157
|
-
}
|
|
236158
|
-
clearCursor() {
|
|
236159
|
-
if (!this.cursorCtx) {
|
|
236160
|
-
return;
|
|
236161
|
-
}
|
|
236162
|
-
this.cursorCtx.setTransform(1 * this.dpi(), 0, 0, 1 * this.dpi(), 0, 0);
|
|
236163
|
-
this.cursorCtx.clearRect(0, 0, conf.getDocumentWidth(), conf.getDocumentHeight());
|
|
236164
|
-
this.matrix.applyToContext(this.cursorCtx);
|
|
236165
|
-
}
|
|
236166
|
-
applyChanges() {
|
|
236167
|
-
this.matrix.applyToContext(this.ctx);
|
|
236168
|
-
}
|
|
236169
|
-
getCameraScale() {
|
|
236170
|
-
return this.camera.getScale();
|
|
236171
|
-
}
|
|
236172
|
-
}
|
|
236173
235558
|
var LinePatterns = {
|
|
236174
235559
|
solid: [],
|
|
236175
235560
|
dot: [1, 2],
|
|
@@ -236803,388 +236188,30 @@ class Paths {
|
|
|
236803
236188
|
return !isAllPathsOpened;
|
|
236804
236189
|
}
|
|
236805
236190
|
}
|
|
236806
|
-
|
|
236807
|
-
class ConnectorCommand {
|
|
236808
|
-
connector;
|
|
236809
|
-
operation;
|
|
236810
|
-
reverse;
|
|
236811
|
-
constructor(connector, operation) {
|
|
236812
|
-
this.connector = connector;
|
|
236813
|
-
this.operation = operation;
|
|
236814
|
-
this.reverse = this.getReverse();
|
|
236815
|
-
}
|
|
236816
|
-
merge(op) {
|
|
236817
|
-
this.operation = op;
|
|
236818
|
-
return this;
|
|
236819
|
-
}
|
|
236820
|
-
apply() {
|
|
236821
|
-
for (const connector of this.connector) {
|
|
236822
|
-
connector.apply(this.operation);
|
|
236823
|
-
}
|
|
236824
|
-
}
|
|
236825
|
-
revert() {
|
|
236826
|
-
for (const { item, operation } of this.reverse) {
|
|
236827
|
-
item.apply(operation);
|
|
236828
|
-
}
|
|
236829
|
-
}
|
|
236830
|
-
getReverse() {
|
|
236831
|
-
const reverse = [];
|
|
236832
|
-
switch (this.operation.method) {
|
|
236833
|
-
case "setStartPoint":
|
|
236834
|
-
for (const connector of this.connector) {
|
|
236835
|
-
reverse.push({
|
|
236836
|
-
item: connector,
|
|
236837
|
-
operation: {
|
|
236838
|
-
...this.operation,
|
|
236839
|
-
startPointData: connector.getStartPoint().serialize()
|
|
236840
|
-
}
|
|
236841
|
-
});
|
|
236842
|
-
}
|
|
236843
|
-
break;
|
|
236844
|
-
case "setEndPoint":
|
|
236845
|
-
for (const connector of this.connector) {
|
|
236846
|
-
reverse.push({
|
|
236847
|
-
item: connector,
|
|
236848
|
-
operation: {
|
|
236849
|
-
...this.operation,
|
|
236850
|
-
endPointData: connector.getEndPoint().serialize()
|
|
236851
|
-
}
|
|
236852
|
-
});
|
|
236853
|
-
}
|
|
236854
|
-
break;
|
|
236855
|
-
case "setMiddlePoint":
|
|
236856
|
-
for (const connector of this.connector) {
|
|
236857
|
-
const middlePoint = connector.getMiddlePoint();
|
|
236858
|
-
reverse.push({
|
|
236859
|
-
item: connector,
|
|
236860
|
-
operation: {
|
|
236861
|
-
...this.operation,
|
|
236862
|
-
middlePointData: middlePoint ? middlePoint.serialize() : null
|
|
236863
|
-
}
|
|
236864
|
-
});
|
|
236865
|
-
}
|
|
236866
|
-
break;
|
|
236867
|
-
case "setStartPointerStyle":
|
|
236868
|
-
for (const connector of this.connector) {
|
|
236869
|
-
reverse.push({
|
|
236870
|
-
item: connector,
|
|
236871
|
-
operation: {
|
|
236872
|
-
...this.operation,
|
|
236873
|
-
startPointerStyle: connector.getStartPointerStyle()
|
|
236874
|
-
}
|
|
236875
|
-
});
|
|
236876
|
-
}
|
|
236877
|
-
break;
|
|
236878
|
-
case "setEndPointerStyle":
|
|
236879
|
-
for (const connector of this.connector) {
|
|
236880
|
-
reverse.push({
|
|
236881
|
-
item: connector,
|
|
236882
|
-
operation: {
|
|
236883
|
-
...this.operation,
|
|
236884
|
-
endPointerStyle: connector.getEndPointerStyle()
|
|
236885
|
-
}
|
|
236886
|
-
});
|
|
236887
|
-
}
|
|
236888
|
-
break;
|
|
236889
|
-
case "setLineStyle":
|
|
236890
|
-
for (const connector of this.connector) {
|
|
236891
|
-
reverse.push({
|
|
236892
|
-
item: connector,
|
|
236893
|
-
operation: {
|
|
236894
|
-
...this.operation,
|
|
236895
|
-
lineStyle: connector.getLineStyle()
|
|
236896
|
-
}
|
|
236897
|
-
});
|
|
236898
|
-
}
|
|
236899
|
-
break;
|
|
236900
|
-
case "setBorderStyle":
|
|
236901
|
-
for (const connector of this.connector) {
|
|
236902
|
-
reverse.push({
|
|
236903
|
-
item: connector,
|
|
236904
|
-
operation: {
|
|
236905
|
-
...this.operation,
|
|
236906
|
-
borderStyle: connector.getBorderStyle()
|
|
236907
|
-
}
|
|
236908
|
-
});
|
|
236909
|
-
}
|
|
236910
|
-
break;
|
|
236911
|
-
case "setLineWidth":
|
|
236912
|
-
for (const connector of this.connector) {
|
|
236913
|
-
reverse.push({
|
|
236914
|
-
item: connector,
|
|
236915
|
-
operation: {
|
|
236916
|
-
...this.operation,
|
|
236917
|
-
lineWidth: connector.getLineWidth()
|
|
236918
|
-
}
|
|
236919
|
-
});
|
|
236920
|
-
}
|
|
236921
|
-
break;
|
|
236922
|
-
case "setLineColor":
|
|
236923
|
-
for (const connector of this.connector) {
|
|
236924
|
-
reverse.push({
|
|
236925
|
-
item: connector,
|
|
236926
|
-
operation: {
|
|
236927
|
-
...this.operation,
|
|
236928
|
-
lineColor: connector.getLineColor()
|
|
236929
|
-
}
|
|
236930
|
-
});
|
|
236931
|
-
}
|
|
236932
|
-
break;
|
|
236933
|
-
case "switchPointers":
|
|
236934
|
-
for (const connector of this.connector) {
|
|
236935
|
-
reverse.push({
|
|
236936
|
-
item: connector,
|
|
236937
|
-
operation: this.operation
|
|
236938
|
-
});
|
|
236939
|
-
}
|
|
236940
|
-
break;
|
|
236941
|
-
}
|
|
236942
|
-
return reverse;
|
|
236943
|
-
}
|
|
236944
|
-
}
|
|
236945
|
-
var _sessionStorage;
|
|
236946
|
-
if (typeof window !== "undefined" && window.sessionStorage) {
|
|
236947
|
-
_sessionStorage = window.sessionStorage;
|
|
236948
|
-
} else {
|
|
236949
|
-
|
|
236950
|
-
class NodeStoragePolyfill {
|
|
236951
|
-
_store = {};
|
|
236952
|
-
clear() {
|
|
236953
|
-
this._store = {};
|
|
236954
|
-
}
|
|
236955
|
-
getItem(key) {
|
|
236956
|
-
return Object.prototype.hasOwnProperty.call(this._store, key) ? this._store[key] : null;
|
|
236957
|
-
}
|
|
236958
|
-
key(index) {
|
|
236959
|
-
const keys = Object.keys(this._store);
|
|
236960
|
-
return keys[index] ?? null;
|
|
236961
|
-
}
|
|
236962
|
-
removeItem(key) {
|
|
236963
|
-
delete this._store[key];
|
|
236964
|
-
}
|
|
236965
|
-
setItem(key, value) {
|
|
236966
|
-
this._store[key] = value;
|
|
236967
|
-
}
|
|
236968
|
-
get length() {
|
|
236969
|
-
return Object.keys(this._store).length;
|
|
236970
|
-
}
|
|
236971
|
-
}
|
|
236972
|
-
_sessionStorage = new NodeStoragePolyfill;
|
|
236973
|
-
}
|
|
236974
|
-
|
|
236975
|
-
class SessionStorage {
|
|
236976
|
-
set(key, value) {
|
|
236977
|
-
const boardId = this.getBoardId() || "";
|
|
236978
|
-
_sessionStorage.setItem(boardId + "_" + key, JSON.stringify(value));
|
|
236979
|
-
}
|
|
236980
|
-
get(key) {
|
|
236981
|
-
const boardId = this.getBoardId() || "";
|
|
236982
|
-
const item = _sessionStorage.getItem(boardId + "_" + key);
|
|
236983
|
-
if (!item || item === "undefined") {
|
|
236984
|
-
return;
|
|
236985
|
-
}
|
|
236986
|
-
return JSON.parse(item);
|
|
236987
|
-
}
|
|
236988
|
-
remove(key) {
|
|
236989
|
-
const boardId = this.getBoardId() || "";
|
|
236990
|
-
_sessionStorage.removeItem(boardId + "_" + key);
|
|
236991
|
-
}
|
|
236992
|
-
setConnectorStrokeStyle(color) {
|
|
236993
|
-
this.set(`connectorStrokeStyle`, color);
|
|
236994
|
-
}
|
|
236995
|
-
getConnectorStrokeStyle() {
|
|
236996
|
-
return this.get("connectorStrokeStyle");
|
|
236997
|
-
}
|
|
236998
|
-
setConnectorLineWidth(width) {
|
|
236999
|
-
this.set(`connectorLineWidth`, width);
|
|
237000
|
-
}
|
|
237001
|
-
getConnectorLineWidth() {
|
|
237002
|
-
return this.get("connectorLineWidth");
|
|
237003
|
-
}
|
|
237004
|
-
setConnectorFillColor(color) {
|
|
237005
|
-
this.set(`connectorFillColor`, color);
|
|
237006
|
-
}
|
|
237007
|
-
getConnectorFillColor() {
|
|
237008
|
-
return this.get("connectorFillColor");
|
|
237009
|
-
}
|
|
237010
|
-
setConnectorPointer(type, edge) {
|
|
237011
|
-
this.set(`connector${edge.charAt(0).toUpperCase() + edge.slice(1)}Pointer`, type);
|
|
237012
|
-
}
|
|
237013
|
-
getConnectorPointer(edge) {
|
|
237014
|
-
return this.get(`connector${edge.charAt(0).toUpperCase() + edge.slice(1)}Pointer`);
|
|
237015
|
-
}
|
|
237016
|
-
setConnectorLineStyle(type) {
|
|
237017
|
-
this.set("connectorLineStyle", type);
|
|
237018
|
-
}
|
|
237019
|
-
getConnectorLineStyle() {
|
|
237020
|
-
return this.get("connectorLineStyle");
|
|
237021
|
-
}
|
|
237022
|
-
setShapeData(data) {
|
|
237023
|
-
this.set("lastShapeData", data);
|
|
237024
|
-
}
|
|
237025
|
-
getShapeData() {
|
|
237026
|
-
return this.get("lastShapeData");
|
|
237027
|
-
}
|
|
237028
|
-
setStickerData(data) {
|
|
237029
|
-
this.set("lastSticker", data);
|
|
237030
|
-
}
|
|
237031
|
-
getStickerData() {
|
|
237032
|
-
return this.get("lastSticker");
|
|
237033
|
-
}
|
|
237034
|
-
setShapeWidth(width) {
|
|
237035
|
-
this.set("shapeWidth", width);
|
|
237036
|
-
}
|
|
237037
|
-
getShapeWidth() {
|
|
237038
|
-
return this.get("shapeWidth");
|
|
237039
|
-
}
|
|
237040
|
-
setShapeHeight(height) {
|
|
237041
|
-
this.set("shapeHeight", height);
|
|
237042
|
-
}
|
|
237043
|
-
getShapeHeight() {
|
|
237044
|
-
return this.get("shapeHeight");
|
|
237045
|
-
}
|
|
237046
|
-
setImageDimensions(dimension) {
|
|
237047
|
-
this.set("imageDimensions", dimension);
|
|
237048
|
-
}
|
|
237049
|
-
getImageDimensions() {
|
|
237050
|
-
return this.get("imageDimensions");
|
|
237051
|
-
}
|
|
237052
|
-
setFontSize(itemType, size2) {
|
|
237053
|
-
this.set(`fontSize_${itemType}`, size2);
|
|
237054
|
-
}
|
|
237055
|
-
getFontSize(itemType) {
|
|
237056
|
-
return this.get(`fontSize_${itemType}`);
|
|
237057
|
-
}
|
|
237058
|
-
setFontStyles(itemType, styles) {
|
|
237059
|
-
this.set(`fontStyles_${itemType}`, styles);
|
|
237060
|
-
}
|
|
237061
|
-
getFontStyles(itemType) {
|
|
237062
|
-
return this.get(`fontStyles_${itemType}`);
|
|
237063
|
-
}
|
|
237064
|
-
setFontColor(itemType, color) {
|
|
237065
|
-
this.set(`fontColor_${itemType}`, color);
|
|
237066
|
-
}
|
|
237067
|
-
getFontColor(itemType) {
|
|
237068
|
-
return this.get(`fontColor_${itemType}`);
|
|
237069
|
-
}
|
|
237070
|
-
setFontHighlight(itemType, highlightColor) {
|
|
237071
|
-
this.set(`fontHighlightColor_${itemType}`, highlightColor);
|
|
237072
|
-
}
|
|
237073
|
-
getFontHighlight(itemType) {
|
|
237074
|
-
return this.get(`fontHighlightColor_${itemType}`);
|
|
237075
|
-
}
|
|
237076
|
-
setHorizontalAlignment(itemType, horizontalAlignment) {
|
|
237077
|
-
this.set(`fontHorizontalAlignment_${itemType}`, horizontalAlignment);
|
|
237078
|
-
}
|
|
237079
|
-
getHorizontalAlignment(itemType) {
|
|
237080
|
-
return this.get(`fontHorizontalAlignment_${itemType}`);
|
|
237081
|
-
}
|
|
237082
|
-
setVerticalAlignment(itemType, verticalAlignment) {
|
|
237083
|
-
this.set(`fontVerticalAlignment_${itemType}`, verticalAlignment);
|
|
237084
|
-
}
|
|
237085
|
-
getVerticalAlignment(itemType) {
|
|
237086
|
-
return this.get(`fontVerticalAlignment_${itemType}`);
|
|
237087
|
-
}
|
|
237088
|
-
setLastAIRequest(request) {
|
|
237089
|
-
_sessionStorage.setItem("lastAIRequest", request);
|
|
237090
|
-
}
|
|
237091
|
-
getLastAIRequest() {
|
|
237092
|
-
return _sessionStorage.getItem("lastAIRequest");
|
|
237093
|
-
}
|
|
237094
|
-
removeLastAIRequest() {
|
|
237095
|
-
_sessionStorage.removeItem("lastAIRequest");
|
|
237096
|
-
}
|
|
237097
|
-
clear() {
|
|
237098
|
-
_sessionStorage.clear();
|
|
237099
|
-
}
|
|
237100
|
-
getBoardId() {
|
|
237101
|
-
if (typeof window === "undefined") {
|
|
237102
|
-
return;
|
|
237103
|
-
}
|
|
237104
|
-
return window.location.href.split("/").pop()?.split("?")[0];
|
|
237105
|
-
}
|
|
237106
|
-
}
|
|
237107
|
-
var tempStorage = new SessionStorage;
|
|
237108
|
-
function getTranslationFromHTML(el) {
|
|
237109
|
-
const transform = el.style.transform;
|
|
237110
|
-
const translateMatch = transform.match(/translate\(([^)]+)\)/);
|
|
237111
|
-
const [translateX, translateY] = translateMatch ? translateMatch[1].split(",").map((value) => parseFloat(value)) : [0, 0];
|
|
237112
|
-
return [translateX, translateY];
|
|
237113
|
-
}
|
|
237114
|
-
function getScaleFromHTML(el) {
|
|
237115
|
-
const transform = el.style.transform;
|
|
237116
|
-
const scaleMatch = transform.match(/scale\(([^)]+)\)/);
|
|
237117
|
-
const [scaleX, scaleY] = scaleMatch ? scaleMatch[1].split(",").map((value) => parseFloat(value)) : [1, 1];
|
|
237118
|
-
return [scaleX, scaleY];
|
|
237119
|
-
}
|
|
237120
|
-
function translateElementBy(el, x, y) {
|
|
237121
|
-
const [exX, exY] = getTranslationFromHTML(el);
|
|
237122
|
-
const [newX, newY] = [exX + x, exY + y];
|
|
237123
|
-
const [scaleX, scaleY] = getScaleFromHTML(el);
|
|
237124
|
-
el.style.transform = `translate(${newX}px, ${newY}px) scale(${scaleX}, ${scaleY})`;
|
|
237125
|
-
return el;
|
|
237126
|
-
}
|
|
237127
|
-
function scaleElementBy(el, scaleX, scaleY) {
|
|
237128
|
-
const [currentScaleX, currentScaleY] = getScaleFromHTML(el);
|
|
237129
|
-
const [newScaleX, newScaleY] = [
|
|
237130
|
-
currentScaleX * scaleX,
|
|
237131
|
-
currentScaleY * scaleY
|
|
237132
|
-
];
|
|
237133
|
-
const [translateX, translateY] = getTranslationFromHTML(el);
|
|
237134
|
-
el.style.transform = `translate(${translateX}px, ${translateY}px) scale(${newScaleX}, ${newScaleY})`;
|
|
237135
|
-
return el;
|
|
237136
|
-
}
|
|
237137
|
-
function resetElementScale(el) {
|
|
237138
|
-
const [x, y] = getTranslationFromHTML(el);
|
|
237139
|
-
el.style.transform = `translate(${x}px, ${y}px) scale(1, 1)`;
|
|
237140
|
-
return el;
|
|
237141
|
-
}
|
|
237142
|
-
function positionRelatively(toPosition, positionBy, padding2 = 0) {
|
|
237143
|
-
const [translateX, translateY] = getTranslationFromHTML(toPosition);
|
|
237144
|
-
const [frameX, frameY] = getTranslationFromHTML(positionBy);
|
|
237145
|
-
const [dx, dy] = [translateX - frameX, translateY - frameY];
|
|
237146
|
-
const verticalAlignment = toPosition.getAttribute("data-vertical-alignment");
|
|
237147
|
-
const horizontalAlignment = toPosition.getAttribute("data-vertical-alignment");
|
|
237148
|
-
let paddingX = padding2;
|
|
237149
|
-
let paddingY = padding2;
|
|
237150
|
-
if (verticalAlignment && verticalAlignment === "bottom") {
|
|
237151
|
-
paddingY = -padding2;
|
|
237152
|
-
}
|
|
237153
|
-
if (horizontalAlignment && horizontalAlignment === "right") {
|
|
237154
|
-
paddingX = -padding2;
|
|
237155
|
-
}
|
|
237156
|
-
const [scaleX, scaleY] = getScaleFromHTML(toPosition);
|
|
237157
|
-
toPosition.style.transform = `translate(${dx + paddingX}px, ${dy + paddingY}px) scale(${scaleX}, ${scaleY})`;
|
|
237158
|
-
return toPosition;
|
|
237159
|
-
}
|
|
237160
|
-
function positionAbsolutely(toPosition, positionBy) {
|
|
237161
|
-
const [translateX, translateY] = getTranslationFromHTML(toPosition);
|
|
237162
|
-
const [frameX, frameY] = getTranslationFromHTML(positionBy);
|
|
237163
|
-
const [dx, dy] = [translateX + frameX, translateY + frameY];
|
|
237164
|
-
const [scaleX, scaleY] = getScaleFromHTML(toPosition);
|
|
237165
|
-
toPosition.style.transform = `translate(${dx}px, ${dy}px) scale(${scaleX}, ${scaleY})`;
|
|
237166
|
-
return toPosition;
|
|
237167
|
-
}
|
|
237168
236191
|
var Custom = {
|
|
237169
236192
|
name: "Custom",
|
|
237170
236193
|
textBounds: new Mbr(0, -10, 100, -1),
|
|
237171
|
-
path
|
|
237172
|
-
|
|
237173
|
-
|
|
237174
|
-
|
|
237175
|
-
|
|
237176
|
-
|
|
236194
|
+
get path() {
|
|
236195
|
+
return new Path2([
|
|
236196
|
+
new Line(new Point3(0, 0), new Point3(100, 0)),
|
|
236197
|
+
new Line(new Point3(100, 0), new Point3(100, 100)),
|
|
236198
|
+
new Line(new Point3(100, 100), new Point3(0, 100)),
|
|
236199
|
+
new Line(new Point3(0, 100), new Point3(0, 0))
|
|
236200
|
+
], true);
|
|
236201
|
+
},
|
|
237177
236202
|
anchorPoints: [new Point3(0, 50), new Point3(100, 50), new Point3(50, 0), new Point3(50, 100)]
|
|
237178
236203
|
};
|
|
237179
236204
|
var Frame16x9 = {
|
|
237180
236205
|
name: "16:9",
|
|
237181
236206
|
textBounds: new Mbr(0, -10, 200, -1),
|
|
237182
|
-
path
|
|
237183
|
-
|
|
237184
|
-
|
|
237185
|
-
|
|
237186
|
-
|
|
237187
|
-
|
|
236207
|
+
get path() {
|
|
236208
|
+
return new Path2([
|
|
236209
|
+
new Line(new Point3(0, 0), new Point3(200, 0)),
|
|
236210
|
+
new Line(new Point3(200, 0), new Point3(200, 200 * (739 / 1314))),
|
|
236211
|
+
new Line(new Point3(200, 200 * (739 / 1314)), new Point3(0, 200 * (739 / 1314))),
|
|
236212
|
+
new Line(new Point3(0, 200 * (739 / 1314)), new Point3(0, 0))
|
|
236213
|
+
], true);
|
|
236214
|
+
},
|
|
237188
236215
|
anchorPoints: [
|
|
237189
236216
|
new Point3(0, 100 * (739 / 1314)),
|
|
237190
236217
|
new Point3(200, 100 * (739 / 1314)),
|
|
@@ -237195,12 +236222,14 @@ var Frame16x9 = {
|
|
|
237195
236222
|
var Frame4x3 = {
|
|
237196
236223
|
name: "4:3",
|
|
237197
236224
|
textBounds: new Mbr(0, -10, 200, -1),
|
|
237198
|
-
path
|
|
237199
|
-
|
|
237200
|
-
|
|
237201
|
-
|
|
237202
|
-
|
|
237203
|
-
|
|
236225
|
+
get path() {
|
|
236226
|
+
return new Path2([
|
|
236227
|
+
new Line(new Point3(0, 0), new Point3(200, 0)),
|
|
236228
|
+
new Line(new Point3(200, 0), new Point3(200, 200 * (853 / 1138))),
|
|
236229
|
+
new Line(new Point3(200, 200 * (853 / 1138)), new Point3(0, 200 * (853 / 1138))),
|
|
236230
|
+
new Line(new Point3(0, 200 * (853 / 1138)), new Point3(0, 0))
|
|
236231
|
+
], true);
|
|
236232
|
+
},
|
|
237204
236233
|
anchorPoints: [
|
|
237205
236234
|
new Point3(0, 100 * (853 / 1138)),
|
|
237206
236235
|
new Point3(200, 100 * (853 / 1138)),
|
|
@@ -237211,12 +236240,14 @@ var Frame4x3 = {
|
|
|
237211
236240
|
var A4 = {
|
|
237212
236241
|
name: "A4",
|
|
237213
236242
|
textBounds: new Mbr(0, -15, 100, -1),
|
|
237214
|
-
path
|
|
237215
|
-
|
|
237216
|
-
|
|
237217
|
-
|
|
237218
|
-
|
|
237219
|
-
|
|
236243
|
+
get path() {
|
|
236244
|
+
return new Path2([
|
|
236245
|
+
new Line(new Point3(0, 0), new Point3(100, 0)),
|
|
236246
|
+
new Line(new Point3(100, 0), new Point3(100, 100 * (1172 / 828))),
|
|
236247
|
+
new Line(new Point3(100, 100 * (1172 / 828)), new Point3(0, 100 * (1172 / 828))),
|
|
236248
|
+
new Line(new Point3(0, 100 * (1172 / 828)), new Point3(0, 0))
|
|
236249
|
+
], true);
|
|
236250
|
+
},
|
|
237220
236251
|
anchorPoints: [
|
|
237221
236252
|
new Point3(0, 50 * (1172 / 828)),
|
|
237222
236253
|
new Point3(100, 50 * (1172 / 828)),
|
|
@@ -237227,12 +236258,14 @@ var A4 = {
|
|
|
237227
236258
|
var Letter = {
|
|
237228
236259
|
name: "Letter",
|
|
237229
236260
|
textBounds: new Mbr(0, -10, 100, -1),
|
|
237230
|
-
path
|
|
237231
|
-
|
|
237232
|
-
|
|
237233
|
-
|
|
237234
|
-
|
|
237235
|
-
|
|
236261
|
+
get path() {
|
|
236262
|
+
return new Path2([
|
|
236263
|
+
new Line(new Point3(0, 0), new Point3(100, 0)),
|
|
236264
|
+
new Line(new Point3(100, 0), new Point3(100, 100 * (1120 / 867))),
|
|
236265
|
+
new Line(new Point3(100, 100 * (1120 / 867)), new Point3(0, 100 * (1120 / 867))),
|
|
236266
|
+
new Line(new Point3(0, 100 * (1120 / 867)), new Point3(0, 0))
|
|
236267
|
+
], true);
|
|
236268
|
+
},
|
|
237236
236269
|
anchorPoints: [
|
|
237237
236270
|
new Point3(0, 50 * (1120 / 867)),
|
|
237238
236271
|
new Point3(100, 50 * (1120 / 867)),
|
|
@@ -237243,23 +236276,27 @@ var Letter = {
|
|
|
237243
236276
|
var Frame1x1 = {
|
|
237244
236277
|
name: "1:1",
|
|
237245
236278
|
textBounds: new Mbr(0, -10, 100, -1),
|
|
237246
|
-
path
|
|
237247
|
-
|
|
237248
|
-
|
|
237249
|
-
|
|
237250
|
-
|
|
237251
|
-
|
|
236279
|
+
get path() {
|
|
236280
|
+
return new Path2([
|
|
236281
|
+
new Line(new Point3(0, 0), new Point3(100, 0)),
|
|
236282
|
+
new Line(new Point3(100, 0), new Point3(100, 100)),
|
|
236283
|
+
new Line(new Point3(100, 100), new Point3(0, 100)),
|
|
236284
|
+
new Line(new Point3(0, 100), new Point3(0, 0))
|
|
236285
|
+
], true);
|
|
236286
|
+
},
|
|
237252
236287
|
anchorPoints: [new Point3(0, 50), new Point3(100, 50), new Point3(50, 0), new Point3(50, 100)]
|
|
237253
236288
|
};
|
|
237254
236289
|
var Frame3x2 = {
|
|
237255
236290
|
name: "3:2",
|
|
237256
236291
|
textBounds: new Mbr(0, -10, 200, -1),
|
|
237257
|
-
path
|
|
237258
|
-
|
|
237259
|
-
|
|
237260
|
-
|
|
237261
|
-
|
|
237262
|
-
|
|
236292
|
+
get path() {
|
|
236293
|
+
return new Path2([
|
|
236294
|
+
new Line(new Point3(0, 0), new Point3(200, 0)),
|
|
236295
|
+
new Line(new Point3(200, 0), new Point3(200, 200 * (200 / 300))),
|
|
236296
|
+
new Line(new Point3(200, 200 * (200 / 300)), new Point3(0, 200 * (200 / 300))),
|
|
236297
|
+
new Line(new Point3(0, 200 * (200 / 300)), new Point3(0, 0))
|
|
236298
|
+
], true);
|
|
236299
|
+
},
|
|
237263
236300
|
anchorPoints: [
|
|
237264
236301
|
new Point3(0, 100 * (200 / 300)),
|
|
237265
236302
|
new Point3(200, 100 * (200 / 300)),
|
|
@@ -237270,12 +236307,14 @@ var Frame3x2 = {
|
|
|
237270
236307
|
var Frame9x18 = {
|
|
237271
236308
|
name: "9:18",
|
|
237272
236309
|
textBounds: new Mbr(0, -10, 200, -1),
|
|
237273
|
-
path
|
|
237274
|
-
|
|
237275
|
-
|
|
237276
|
-
|
|
237277
|
-
|
|
237278
|
-
|
|
236310
|
+
get path() {
|
|
236311
|
+
return new Path2([
|
|
236312
|
+
new Line(new Point3(0, 0), new Point3(200, 0)),
|
|
236313
|
+
new Line(new Point3(200, 0), new Point3(200, 200 * (1230 / 612))),
|
|
236314
|
+
new Line(new Point3(200, 200 * (1230 / 612)), new Point3(0, 200 * (1230 / 612))),
|
|
236315
|
+
new Line(new Point3(0, 200 * (1230 / 612)), new Point3(0, 0))
|
|
236316
|
+
], true);
|
|
236317
|
+
},
|
|
237279
236318
|
anchorPoints: [
|
|
237280
236319
|
new Point3(0, 100 * (1230 / 612)),
|
|
237281
236320
|
new Point3(200, 100 * (1230 / 612)),
|
|
@@ -237724,6 +236763,34 @@ function parseHTMLAINode(el) {
|
|
|
237724
236763
|
return aiNodeData;
|
|
237725
236764
|
}
|
|
237726
236765
|
|
|
236766
|
+
class SubjectOperation {
|
|
236767
|
+
observers = [];
|
|
236768
|
+
subscribe(observer) {
|
|
236769
|
+
const index = this.observers.indexOf(observer);
|
|
236770
|
+
if (index === -1) {
|
|
236771
|
+
this.observers.push(observer);
|
|
236772
|
+
}
|
|
236773
|
+
}
|
|
236774
|
+
unsubscribe(observer) {
|
|
236775
|
+
const index = this.observers.indexOf(observer);
|
|
236776
|
+
if (index !== -1) {
|
|
236777
|
+
this.observers.splice(index, 1);
|
|
236778
|
+
}
|
|
236779
|
+
}
|
|
236780
|
+
publish(subject, op) {
|
|
236781
|
+
for (const observer of this.observers) {
|
|
236782
|
+
observer(subject, op);
|
|
236783
|
+
}
|
|
236784
|
+
}
|
|
236785
|
+
}
|
|
236786
|
+
function mapItemsByOperation(item, getCallback) {
|
|
236787
|
+
const items = Array.isArray(item) ? item : [item];
|
|
236788
|
+
return items.map((item2) => {
|
|
236789
|
+
const operation = getCallback(item2);
|
|
236790
|
+
return { item: item2, operation };
|
|
236791
|
+
});
|
|
236792
|
+
}
|
|
236793
|
+
|
|
237727
236794
|
class LinkToCommand {
|
|
237728
236795
|
linkTo;
|
|
237729
236796
|
operation;
|
|
@@ -239352,7 +238419,10 @@ var setLink = (editor, link, selection) => {
|
|
|
239352
238419
|
return;
|
|
239353
238420
|
}
|
|
239354
238421
|
const format = link ? "rgba(71, 120, 245, 1)" : "rgb(20, 21, 26)";
|
|
239355
|
-
|
|
238422
|
+
Transforms.setNodes(editor, { fontColor: format }, {
|
|
238423
|
+
match: (n4) => !Editor.isEditor(n4) && n4.type === "text",
|
|
238424
|
+
split: true
|
|
238425
|
+
});
|
|
239356
238426
|
for (const [node3, path22] of Editor.nodes(editor, {
|
|
239357
238427
|
match: (n4) => !Editor.isEditor(n4) && n4.type === "text"
|
|
239358
238428
|
})) {
|
|
@@ -245327,7 +244397,7 @@ function persistLeafFormats(children) {
|
|
|
245327
244397
|
}, {});
|
|
245328
244398
|
}
|
|
245329
244399
|
function plugin(opts) {
|
|
245330
|
-
var compiler2 = function
|
|
244400
|
+
var compiler2 = function compiler(node22) {
|
|
245331
244401
|
return node22.children.map(function(c) {
|
|
245332
244402
|
return deserialize(c, opts);
|
|
245333
244403
|
});
|
|
@@ -245439,6 +244509,7 @@ class MarkdownProcessor {
|
|
|
245439
244509
|
isProcessingChunk = false;
|
|
245440
244510
|
stopProcessingMarkDownCb = null;
|
|
245441
244511
|
currentNode = "";
|
|
244512
|
+
doneResolvers = [];
|
|
245442
244513
|
editor;
|
|
245443
244514
|
subject = new Subject;
|
|
245444
244515
|
constructor(editor) {
|
|
@@ -245450,6 +244521,19 @@ class MarkdownProcessor {
|
|
|
245450
244521
|
getStopProcessingMarkDownCb() {
|
|
245451
244522
|
return this.stopProcessingMarkDownCb;
|
|
245452
244523
|
}
|
|
244524
|
+
waitForDone() {
|
|
244525
|
+
if (!this.isProcessingChunk && this.chunksQueue.length === 0) {
|
|
244526
|
+
return Promise.resolve();
|
|
244527
|
+
}
|
|
244528
|
+
return new Promise((resolve) => {
|
|
244529
|
+
this.doneResolvers.push(resolve);
|
|
244530
|
+
});
|
|
244531
|
+
}
|
|
244532
|
+
notifyDone() {
|
|
244533
|
+
const resolvers = this.doneResolvers;
|
|
244534
|
+
this.doneResolvers = [];
|
|
244535
|
+
resolvers.forEach((r2) => r2());
|
|
244536
|
+
}
|
|
245453
244537
|
deserializeMarkdown(isNewParagraphNeeded) {
|
|
245454
244538
|
const lastNode = this.getText()[this.getText().length - 1];
|
|
245455
244539
|
if (lastNode.type !== "paragraph") {
|
|
@@ -245506,6 +244590,7 @@ class MarkdownProcessor {
|
|
|
245506
244590
|
async processNextChunk() {
|
|
245507
244591
|
if (this.chunksQueue.length === 0) {
|
|
245508
244592
|
this.isProcessingChunk = false;
|
|
244593
|
+
this.notifyDone();
|
|
245509
244594
|
return;
|
|
245510
244595
|
}
|
|
245511
244596
|
this.isProcessingChunk = true;
|
|
@@ -245513,6 +244598,7 @@ class MarkdownProcessor {
|
|
|
245513
244598
|
if (chunk === "StopProcessingMarkdown") {
|
|
245514
244599
|
await this.deserializeMarkdownAsync(false);
|
|
245515
244600
|
this.isProcessingChunk = false;
|
|
244601
|
+
this.notifyDone();
|
|
245516
244602
|
this.currentNode = "";
|
|
245517
244603
|
if (this.stopProcessingMarkDownCb) {
|
|
245518
244604
|
selectWholeText(this.editor);
|
|
@@ -245774,10 +244860,22 @@ function setSelectionFontStyle(editor, style) {
|
|
|
245774
244860
|
const isAllNodesContainStyle = selectionStyles.every((styleArr) => styleArr.includes(style2));
|
|
245775
244861
|
const isSomeNodeContainStyle = selectionStyles.some((styleArr) => styleArr.includes(style2));
|
|
245776
244862
|
const isAllNodesNotContainStyle = selectionStyles.every((styleArr) => !styleArr.includes(style2));
|
|
244863
|
+
let value;
|
|
245777
244864
|
if (isAllNodesContainStyle) {
|
|
245778
|
-
|
|
244865
|
+
value = false;
|
|
245779
244866
|
} else if (isSomeNodeContainStyle || isAllNodesNotContainStyle) {
|
|
245780
|
-
|
|
244867
|
+
value = true;
|
|
244868
|
+
} else {
|
|
244869
|
+
continue;
|
|
244870
|
+
}
|
|
244871
|
+
const { selection } = editor;
|
|
244872
|
+
if (selection && Range.isExpanded(selection)) {
|
|
244873
|
+
Transforms.setNodes(editor, { [style2]: value }, {
|
|
244874
|
+
match: (n4) => !Editor.isEditor(n4) && n4.type === "text",
|
|
244875
|
+
split: true
|
|
244876
|
+
});
|
|
244877
|
+
} else {
|
|
244878
|
+
Editor.addMark(editor, style2, value);
|
|
245781
244879
|
}
|
|
245782
244880
|
}
|
|
245783
244881
|
}
|
|
@@ -246382,6 +245480,589 @@ function setEditorFocus(editor, selectionContext) {
|
|
|
246382
245480
|
}
|
|
246383
245481
|
}
|
|
246384
245482
|
|
|
245483
|
+
class TransformationCommand {
|
|
245484
|
+
transformation;
|
|
245485
|
+
operation;
|
|
245486
|
+
reverse;
|
|
245487
|
+
constructor(transformation, operation) {
|
|
245488
|
+
this.transformation = transformation;
|
|
245489
|
+
this.operation = operation;
|
|
245490
|
+
this.reverse = this.getReverse();
|
|
245491
|
+
}
|
|
245492
|
+
merge(op) {
|
|
245493
|
+
this.operation = op;
|
|
245494
|
+
this.reverse = this.getReverse();
|
|
245495
|
+
return this;
|
|
245496
|
+
}
|
|
245497
|
+
apply() {
|
|
245498
|
+
for (const transformation of this.transformation) {
|
|
245499
|
+
transformation.apply(this.operation);
|
|
245500
|
+
}
|
|
245501
|
+
}
|
|
245502
|
+
revert() {
|
|
245503
|
+
this.reverse.forEach(({ item, operation }) => {
|
|
245504
|
+
item.apply(operation);
|
|
245505
|
+
});
|
|
245506
|
+
}
|
|
245507
|
+
getReverse() {
|
|
245508
|
+
const op = this.operation;
|
|
245509
|
+
switch (this.operation.method) {
|
|
245510
|
+
case "applyMatrix": {
|
|
245511
|
+
const op2 = this.operation;
|
|
245512
|
+
return this.transformation.map((t3) => {
|
|
245513
|
+
const itemOp = op2.items.find((i) => i.id === t3.getId());
|
|
245514
|
+
if (!itemOp)
|
|
245515
|
+
return { item: t3, operation: op2 };
|
|
245516
|
+
return {
|
|
245517
|
+
item: t3,
|
|
245518
|
+
operation: {
|
|
245519
|
+
class: "Transformation",
|
|
245520
|
+
method: "applyMatrix",
|
|
245521
|
+
items: [{
|
|
245522
|
+
id: t3.getId(),
|
|
245523
|
+
matrix: {
|
|
245524
|
+
translateX: -itemOp.matrix.translateX,
|
|
245525
|
+
translateY: -itemOp.matrix.translateY,
|
|
245526
|
+
scaleX: 1 / itemOp.matrix.scaleX,
|
|
245527
|
+
scaleY: 1 / itemOp.matrix.scaleY,
|
|
245528
|
+
shearX: 0,
|
|
245529
|
+
shearY: 0
|
|
245530
|
+
}
|
|
245531
|
+
}]
|
|
245532
|
+
}
|
|
245533
|
+
};
|
|
245534
|
+
});
|
|
245535
|
+
}
|
|
245536
|
+
case "translateTo":
|
|
245537
|
+
return mapItemsByOperation(this.transformation, (transformation) => {
|
|
245538
|
+
return {
|
|
245539
|
+
...this.operation,
|
|
245540
|
+
x: transformation.getTranslation().x,
|
|
245541
|
+
y: transformation.getTranslation().y
|
|
245542
|
+
};
|
|
245543
|
+
});
|
|
245544
|
+
case "translateBy": {
|
|
245545
|
+
const op2 = this.operation;
|
|
245546
|
+
return mapItemsByOperation(this.transformation, () => {
|
|
245547
|
+
return {
|
|
245548
|
+
...this.operation,
|
|
245549
|
+
x: -op2.x,
|
|
245550
|
+
y: -op2.y
|
|
245551
|
+
};
|
|
245552
|
+
});
|
|
245553
|
+
}
|
|
245554
|
+
case "scaleTo":
|
|
245555
|
+
case "scaleToRelativeTo": {
|
|
245556
|
+
return mapItemsByOperation(this.transformation, (transformation) => {
|
|
245557
|
+
return {
|
|
245558
|
+
...op,
|
|
245559
|
+
x: transformation.getScale().x,
|
|
245560
|
+
y: transformation.getScale().y
|
|
245561
|
+
};
|
|
245562
|
+
});
|
|
245563
|
+
}
|
|
245564
|
+
case "scaleBy":
|
|
245565
|
+
case "scaleByRelativeTo": {
|
|
245566
|
+
const op2 = this.operation;
|
|
245567
|
+
return mapItemsByOperation(this.transformation, () => {
|
|
245568
|
+
return {
|
|
245569
|
+
...op2,
|
|
245570
|
+
x: 1 / op2.x,
|
|
245571
|
+
y: 1 / op2.y
|
|
245572
|
+
};
|
|
245573
|
+
});
|
|
245574
|
+
}
|
|
245575
|
+
case "scaleByTranslateBy": {
|
|
245576
|
+
const op2 = this.operation;
|
|
245577
|
+
const scaleTransformation = mapItemsByOperation(this.transformation, () => {
|
|
245578
|
+
const scaleX = 1 / op2.scale.x;
|
|
245579
|
+
const scaleY = 1 / op2.scale.y;
|
|
245580
|
+
const translateX = -op2.translate.x;
|
|
245581
|
+
const translateY = -op2.translate.y;
|
|
245582
|
+
return {
|
|
245583
|
+
...op2,
|
|
245584
|
+
scale: {
|
|
245585
|
+
x: scaleX,
|
|
245586
|
+
y: scaleY
|
|
245587
|
+
},
|
|
245588
|
+
translate: {
|
|
245589
|
+
x: translateX,
|
|
245590
|
+
y: translateY
|
|
245591
|
+
}
|
|
245592
|
+
};
|
|
245593
|
+
});
|
|
245594
|
+
return scaleTransformation;
|
|
245595
|
+
}
|
|
245596
|
+
case "rotateTo":
|
|
245597
|
+
return mapItemsByOperation(this.transformation, (transformation) => {
|
|
245598
|
+
return {
|
|
245599
|
+
...this.operation,
|
|
245600
|
+
degree: transformation.getRotation()
|
|
245601
|
+
};
|
|
245602
|
+
});
|
|
245603
|
+
case "rotateBy": {
|
|
245604
|
+
const op2 = this.operation;
|
|
245605
|
+
return mapItemsByOperation(this.transformation, () => {
|
|
245606
|
+
return {
|
|
245607
|
+
...this.operation,
|
|
245608
|
+
degree: -op2.degree
|
|
245609
|
+
};
|
|
245610
|
+
});
|
|
245611
|
+
}
|
|
245612
|
+
case "transformMany": {
|
|
245613
|
+
const { operation, transformation } = this;
|
|
245614
|
+
return transformation.map((currTrans) => {
|
|
245615
|
+
const op2 = operation.items[currTrans.getId()];
|
|
245616
|
+
const m = op2.method === "applyMatrix" ? op2.matrix : op2.method === "scaleByTranslateBy" ? { translateX: -op2.translate.x, translateY: -op2.translate.y, scaleX: 1 / op2.scale.x, scaleY: 1 / op2.scale.y, shearX: 0, shearY: 0 } : { translateX: 0, translateY: 0, scaleX: 1, scaleY: 1, shearX: 0, shearY: 0 };
|
|
245617
|
+
return {
|
|
245618
|
+
item: currTrans,
|
|
245619
|
+
operation: {
|
|
245620
|
+
class: "Transformation",
|
|
245621
|
+
method: "applyMatrix",
|
|
245622
|
+
items: [{
|
|
245623
|
+
id: currTrans.getId(),
|
|
245624
|
+
matrix: {
|
|
245625
|
+
translateX: op2.method === "applyMatrix" ? -m.translateX : m.translateX,
|
|
245626
|
+
translateY: op2.method === "applyMatrix" ? -m.translateY : m.translateY,
|
|
245627
|
+
scaleX: op2.method === "applyMatrix" ? 1 / m.scaleX : m.scaleX,
|
|
245628
|
+
scaleY: op2.method === "applyMatrix" ? 1 / m.scaleY : m.scaleY,
|
|
245629
|
+
shearX: 0,
|
|
245630
|
+
shearY: 0
|
|
245631
|
+
}
|
|
245632
|
+
}]
|
|
245633
|
+
}
|
|
245634
|
+
};
|
|
245635
|
+
});
|
|
245636
|
+
}
|
|
245637
|
+
case "locked": {
|
|
245638
|
+
const op2 = this.operation;
|
|
245639
|
+
return mapItemsByOperation(this.transformation, () => {
|
|
245640
|
+
return {
|
|
245641
|
+
...op2,
|
|
245642
|
+
item: [...op2.item],
|
|
245643
|
+
method: "unlocked",
|
|
245644
|
+
locked: false
|
|
245645
|
+
};
|
|
245646
|
+
});
|
|
245647
|
+
}
|
|
245648
|
+
case "unlocked": {
|
|
245649
|
+
const op2 = this.operation;
|
|
245650
|
+
return mapItemsByOperation(this.transformation, () => {
|
|
245651
|
+
return {
|
|
245652
|
+
...op2,
|
|
245653
|
+
item: [...op2.item],
|
|
245654
|
+
method: "locked",
|
|
245655
|
+
locked: true
|
|
245656
|
+
};
|
|
245657
|
+
});
|
|
245658
|
+
}
|
|
245659
|
+
default:
|
|
245660
|
+
return [
|
|
245661
|
+
{ item: this.transformation[0], operation: this.operation }
|
|
245662
|
+
];
|
|
245663
|
+
}
|
|
245664
|
+
}
|
|
245665
|
+
}
|
|
245666
|
+
|
|
245667
|
+
class DefaultTransformationData {
|
|
245668
|
+
translateX;
|
|
245669
|
+
translateY;
|
|
245670
|
+
scaleX;
|
|
245671
|
+
scaleY;
|
|
245672
|
+
rotate;
|
|
245673
|
+
isLocked;
|
|
245674
|
+
constructor(translateX = 0, translateY = 0, scaleX = 1, scaleY = 1, rotate = 0, isLocked = false) {
|
|
245675
|
+
this.translateX = translateX;
|
|
245676
|
+
this.translateY = translateY;
|
|
245677
|
+
this.scaleX = scaleX;
|
|
245678
|
+
this.scaleY = scaleY;
|
|
245679
|
+
this.rotate = rotate;
|
|
245680
|
+
this.isLocked = isLocked;
|
|
245681
|
+
}
|
|
245682
|
+
}
|
|
245683
|
+
var defaultData = new DefaultTransformationData;
|
|
245684
|
+
|
|
245685
|
+
class Transformation {
|
|
245686
|
+
id;
|
|
245687
|
+
events;
|
|
245688
|
+
subject = new SubjectOperation;
|
|
245689
|
+
_matrix = new Matrix2;
|
|
245690
|
+
previous = new Matrix2;
|
|
245691
|
+
rotate = defaultData.rotate;
|
|
245692
|
+
isLocked = false;
|
|
245693
|
+
constructor(id2 = "", events2) {
|
|
245694
|
+
this.id = id2;
|
|
245695
|
+
this.events = events2;
|
|
245696
|
+
}
|
|
245697
|
+
getMatrixData() {
|
|
245698
|
+
const { translateX, translateY, scaleX, scaleY, shearX, shearY } = this._matrix;
|
|
245699
|
+
return { translateX, translateY, scaleX, scaleY, shearX, shearY };
|
|
245700
|
+
}
|
|
245701
|
+
toMatrix() {
|
|
245702
|
+
return this._matrix.copy();
|
|
245703
|
+
}
|
|
245704
|
+
applyToContext(ctx) {
|
|
245705
|
+
this._matrix.applyToContext(ctx);
|
|
245706
|
+
}
|
|
245707
|
+
getTranslation() {
|
|
245708
|
+
return { x: this._matrix.translateX, y: this._matrix.translateY };
|
|
245709
|
+
}
|
|
245710
|
+
getScale() {
|
|
245711
|
+
return { x: this._matrix.scaleX, y: this._matrix.scaleY };
|
|
245712
|
+
}
|
|
245713
|
+
getRotation() {
|
|
245714
|
+
return this.rotate;
|
|
245715
|
+
}
|
|
245716
|
+
setLocal(xOrData, y, scaleX, scaleY) {
|
|
245717
|
+
this.previous = this._matrix.copy();
|
|
245718
|
+
if (typeof xOrData === "object") {
|
|
245719
|
+
if (xOrData.translateX !== undefined)
|
|
245720
|
+
this._matrix.translateX = xOrData.translateX;
|
|
245721
|
+
if (xOrData.translateY !== undefined)
|
|
245722
|
+
this._matrix.translateY = xOrData.translateY;
|
|
245723
|
+
if (xOrData.scaleX !== undefined)
|
|
245724
|
+
this._matrix.scaleX = xOrData.scaleX;
|
|
245725
|
+
if (xOrData.scaleY !== undefined)
|
|
245726
|
+
this._matrix.scaleY = xOrData.scaleY;
|
|
245727
|
+
} else {
|
|
245728
|
+
this._matrix.translateX = xOrData;
|
|
245729
|
+
this._matrix.translateY = y;
|
|
245730
|
+
if (scaleX !== undefined)
|
|
245731
|
+
this._matrix.scaleX = scaleX;
|
|
245732
|
+
if (scaleY !== undefined)
|
|
245733
|
+
this._matrix.scaleY = scaleY;
|
|
245734
|
+
}
|
|
245735
|
+
this.subject.publish(this, {
|
|
245736
|
+
class: "Transformation",
|
|
245737
|
+
method: "applyMatrix",
|
|
245738
|
+
items: [{ id: this.id, matrix: this.getMatrixData() }]
|
|
245739
|
+
});
|
|
245740
|
+
}
|
|
245741
|
+
serialize() {
|
|
245742
|
+
return {
|
|
245743
|
+
translateX: this._matrix.translateX,
|
|
245744
|
+
translateY: this._matrix.translateY,
|
|
245745
|
+
scaleX: this._matrix.scaleX,
|
|
245746
|
+
scaleY: this._matrix.scaleY,
|
|
245747
|
+
rotate: this.rotate,
|
|
245748
|
+
isLocked: this.isLocked
|
|
245749
|
+
};
|
|
245750
|
+
}
|
|
245751
|
+
deserialize(data) {
|
|
245752
|
+
this.previous = this._matrix.copy();
|
|
245753
|
+
if (data.translateX) {
|
|
245754
|
+
this._matrix.translateX = data.translateX;
|
|
245755
|
+
}
|
|
245756
|
+
if (data.translateY) {
|
|
245757
|
+
this._matrix.translateY = data.translateY;
|
|
245758
|
+
}
|
|
245759
|
+
if (data.scaleX) {
|
|
245760
|
+
this._matrix.scaleX = data.scaleX;
|
|
245761
|
+
}
|
|
245762
|
+
if (data.scaleY) {
|
|
245763
|
+
this._matrix.scaleY = data.scaleY;
|
|
245764
|
+
}
|
|
245765
|
+
if (data.isLocked) {
|
|
245766
|
+
this.isLocked = data.isLocked;
|
|
245767
|
+
}
|
|
245768
|
+
if (data.rotate) {
|
|
245769
|
+
this.rotate = data.rotate;
|
|
245770
|
+
}
|
|
245771
|
+
this.subject.publish(this, {
|
|
245772
|
+
class: "Transformation",
|
|
245773
|
+
method: "deserialize",
|
|
245774
|
+
item: [this.id],
|
|
245775
|
+
data
|
|
245776
|
+
});
|
|
245777
|
+
return this;
|
|
245778
|
+
}
|
|
245779
|
+
copy(id2) {
|
|
245780
|
+
const { translateX, translateY, scaleX, scaleY } = this._matrix;
|
|
245781
|
+
const { rotate } = this;
|
|
245782
|
+
return new Transformation(id2 || "", this.events).deserialize({
|
|
245783
|
+
translateX,
|
|
245784
|
+
translateY,
|
|
245785
|
+
scaleX,
|
|
245786
|
+
scaleY,
|
|
245787
|
+
rotate,
|
|
245788
|
+
isLocked: false
|
|
245789
|
+
});
|
|
245790
|
+
}
|
|
245791
|
+
getInverse() {
|
|
245792
|
+
const copy22 = this.copy();
|
|
245793
|
+
copy22._matrix.invert();
|
|
245794
|
+
return copy22;
|
|
245795
|
+
}
|
|
245796
|
+
getId() {
|
|
245797
|
+
return this.id;
|
|
245798
|
+
}
|
|
245799
|
+
setId(id2) {
|
|
245800
|
+
this.id = id2;
|
|
245801
|
+
}
|
|
245802
|
+
emit(operation) {
|
|
245803
|
+
if (this.events) {
|
|
245804
|
+
const command = new TransformationCommand([this], operation);
|
|
245805
|
+
command.apply();
|
|
245806
|
+
this.events.emit(operation, command);
|
|
245807
|
+
} else {
|
|
245808
|
+
this.apply(operation);
|
|
245809
|
+
}
|
|
245810
|
+
}
|
|
245811
|
+
emitMatrix(matrix, timeStamp) {
|
|
245812
|
+
this.emit({
|
|
245813
|
+
class: "Transformation",
|
|
245814
|
+
method: "applyMatrix",
|
|
245815
|
+
items: [{ id: this.id, matrix }],
|
|
245816
|
+
timeStamp
|
|
245817
|
+
});
|
|
245818
|
+
}
|
|
245819
|
+
translateTo(x, y, timeStamp) {
|
|
245820
|
+
if (!this.id) {}
|
|
245821
|
+
this.emitMatrix({
|
|
245822
|
+
translateX: x - this._matrix.translateX,
|
|
245823
|
+
translateY: y - this._matrix.translateY,
|
|
245824
|
+
scaleX: 1,
|
|
245825
|
+
scaleY: 1,
|
|
245826
|
+
shearX: 0,
|
|
245827
|
+
shearY: 0
|
|
245828
|
+
}, timeStamp);
|
|
245829
|
+
}
|
|
245830
|
+
translateBy(x, y, timeStamp) {
|
|
245831
|
+
if (!this.id) {}
|
|
245832
|
+
if (x === 0 && y === 0) {
|
|
245833
|
+
return;
|
|
245834
|
+
}
|
|
245835
|
+
this.emitMatrix({
|
|
245836
|
+
translateX: x,
|
|
245837
|
+
translateY: y,
|
|
245838
|
+
scaleX: 1,
|
|
245839
|
+
scaleY: 1,
|
|
245840
|
+
shearX: 0,
|
|
245841
|
+
shearY: 0
|
|
245842
|
+
}, timeStamp);
|
|
245843
|
+
}
|
|
245844
|
+
scaleTo(x, y, timeStamp) {
|
|
245845
|
+
this.emitMatrix({
|
|
245846
|
+
translateX: 0,
|
|
245847
|
+
translateY: 0,
|
|
245848
|
+
scaleX: x / this._matrix.scaleX,
|
|
245849
|
+
scaleY: y / this._matrix.scaleY,
|
|
245850
|
+
shearX: 0,
|
|
245851
|
+
shearY: 0
|
|
245852
|
+
}, timeStamp);
|
|
245853
|
+
}
|
|
245854
|
+
scaleBy(x, y, timeStamp) {
|
|
245855
|
+
if (x === 0 && y === 0) {
|
|
245856
|
+
return;
|
|
245857
|
+
}
|
|
245858
|
+
this.emitMatrix({
|
|
245859
|
+
translateX: 0,
|
|
245860
|
+
translateY: 0,
|
|
245861
|
+
scaleX: x,
|
|
245862
|
+
scaleY: y,
|
|
245863
|
+
shearX: 0,
|
|
245864
|
+
shearY: 0
|
|
245865
|
+
}, timeStamp);
|
|
245866
|
+
}
|
|
245867
|
+
scaleByTranslateBy(scale, translate, timeStamp) {
|
|
245868
|
+
if (scale.x === 0 && scale.y === 0 && translate.x === 0 && translate.y === 0) {
|
|
245869
|
+
return;
|
|
245870
|
+
}
|
|
245871
|
+
this.emitMatrix({
|
|
245872
|
+
translateX: translate.x,
|
|
245873
|
+
translateY: translate.y,
|
|
245874
|
+
scaleX: scale.x,
|
|
245875
|
+
scaleY: scale.y,
|
|
245876
|
+
shearX: 0,
|
|
245877
|
+
shearY: 0
|
|
245878
|
+
}, timeStamp);
|
|
245879
|
+
}
|
|
245880
|
+
rotateTo(degree, timeStamp) {
|
|
245881
|
+
this.emit({
|
|
245882
|
+
class: "Transformation",
|
|
245883
|
+
method: "rotateTo",
|
|
245884
|
+
item: [this.id],
|
|
245885
|
+
degree,
|
|
245886
|
+
timeStamp
|
|
245887
|
+
});
|
|
245888
|
+
}
|
|
245889
|
+
rotateBy(degree, timeStamp) {
|
|
245890
|
+
this.emit({
|
|
245891
|
+
class: "Transformation",
|
|
245892
|
+
method: "rotateBy",
|
|
245893
|
+
item: [this.id],
|
|
245894
|
+
degree,
|
|
245895
|
+
timeStamp
|
|
245896
|
+
});
|
|
245897
|
+
}
|
|
245898
|
+
scaleToRelativeTo(x, y, _point, timeStamp) {
|
|
245899
|
+
this.emitMatrix({
|
|
245900
|
+
translateX: 0,
|
|
245901
|
+
translateY: 0,
|
|
245902
|
+
scaleX: x / this._matrix.scaleX,
|
|
245903
|
+
scaleY: y / this._matrix.scaleY,
|
|
245904
|
+
shearX: 0,
|
|
245905
|
+
shearY: 0
|
|
245906
|
+
}, timeStamp);
|
|
245907
|
+
}
|
|
245908
|
+
scaleByRelativeTo(x, y, point32, timeStamp) {
|
|
245909
|
+
const { scaleX: sx0, scaleY: sy0, translateX: tx0, translateY: ty0 } = this._matrix;
|
|
245910
|
+
const newSx = sx0 * x;
|
|
245911
|
+
const newSy = sy0 * y;
|
|
245912
|
+
this.emitMatrix({
|
|
245913
|
+
translateX: -point32.x * newSx + point32.x - tx0,
|
|
245914
|
+
translateY: -point32.y * newSy + point32.y - ty0,
|
|
245915
|
+
scaleX: x,
|
|
245916
|
+
scaleY: y,
|
|
245917
|
+
shearX: 0,
|
|
245918
|
+
shearY: 0
|
|
245919
|
+
}, timeStamp);
|
|
245920
|
+
}
|
|
245921
|
+
setIsLocked(isLocked, timestamp) {
|
|
245922
|
+
if (isLocked) {
|
|
245923
|
+
this.emit({
|
|
245924
|
+
class: "Transformation",
|
|
245925
|
+
method: "locked",
|
|
245926
|
+
item: [this.id],
|
|
245927
|
+
locked: true,
|
|
245928
|
+
timestamp
|
|
245929
|
+
});
|
|
245930
|
+
} else {
|
|
245931
|
+
this.emit({
|
|
245932
|
+
class: "Transformation",
|
|
245933
|
+
method: "unlocked",
|
|
245934
|
+
item: [this.id],
|
|
245935
|
+
locked: false,
|
|
245936
|
+
timestamp
|
|
245937
|
+
});
|
|
245938
|
+
}
|
|
245939
|
+
}
|
|
245940
|
+
apply(op) {
|
|
245941
|
+
this.previous = this._matrix.copy();
|
|
245942
|
+
switch (op.method) {
|
|
245943
|
+
case "applyMatrix": {
|
|
245944
|
+
const itemOp = op.items.find((i) => i.id === this.id);
|
|
245945
|
+
if (itemOp) {
|
|
245946
|
+
this._matrix.scale(itemOp.matrix.scaleX, itemOp.matrix.scaleY);
|
|
245947
|
+
this._matrix.translate(itemOp.matrix.translateX, itemOp.matrix.translateY);
|
|
245948
|
+
}
|
|
245949
|
+
break;
|
|
245950
|
+
}
|
|
245951
|
+
case "translateTo":
|
|
245952
|
+
this.applyTranslateTo(op.x, op.y);
|
|
245953
|
+
break;
|
|
245954
|
+
case "translateBy":
|
|
245955
|
+
this.applyTranslateBy(op.x, op.y);
|
|
245956
|
+
break;
|
|
245957
|
+
case "scaleTo":
|
|
245958
|
+
this.applyScaleTo(op.x, op.y);
|
|
245959
|
+
break;
|
|
245960
|
+
case "scaleBy":
|
|
245961
|
+
this.applyScaleBy(op.x, op.y);
|
|
245962
|
+
break;
|
|
245963
|
+
case "scaleToRelativeTo":
|
|
245964
|
+
this.applyScaleToRelativeTo(op.x, op.y, op.point);
|
|
245965
|
+
break;
|
|
245966
|
+
case "scaleByRelativeTo":
|
|
245967
|
+
this.applyScaleByRelativeTo(op.x, op.y, op.point);
|
|
245968
|
+
break;
|
|
245969
|
+
case "scaleByTranslateBy":
|
|
245970
|
+
this.applyScaleByTranslateBy(op.scale, op.translate);
|
|
245971
|
+
break;
|
|
245972
|
+
case "rotateTo":
|
|
245973
|
+
this.applyRotateTo(op.degree);
|
|
245974
|
+
break;
|
|
245975
|
+
case "rotateBy":
|
|
245976
|
+
this.applyRotateBy(op.degree);
|
|
245977
|
+
break;
|
|
245978
|
+
case "transformMany":
|
|
245979
|
+
this.applyTransformMany(op.items[this.id]);
|
|
245980
|
+
break;
|
|
245981
|
+
case "locked":
|
|
245982
|
+
this.applyLocked(op.locked);
|
|
245983
|
+
break;
|
|
245984
|
+
case "unlocked":
|
|
245985
|
+
this.applyUnlocked(op.locked);
|
|
245986
|
+
break;
|
|
245987
|
+
default:
|
|
245988
|
+
return;
|
|
245989
|
+
}
|
|
245990
|
+
this.subject.publish(this, op);
|
|
245991
|
+
}
|
|
245992
|
+
applyTranslateTo(x, y) {
|
|
245993
|
+
this._matrix.translateX = x;
|
|
245994
|
+
this._matrix.translateY = y;
|
|
245995
|
+
}
|
|
245996
|
+
applyTranslateBy(x, y) {
|
|
245997
|
+
this._matrix.translate(x, y);
|
|
245998
|
+
}
|
|
245999
|
+
applyScaleTo(x, y) {
|
|
246000
|
+
this._matrix.scaleX = x;
|
|
246001
|
+
this._matrix.scaleY = y;
|
|
246002
|
+
}
|
|
246003
|
+
applyScaleBy(x, y) {
|
|
246004
|
+
this._matrix.scale(x, y);
|
|
246005
|
+
}
|
|
246006
|
+
applyScaleByTranslateBy(scale, translate) {
|
|
246007
|
+
this._matrix.scale(scale.x, scale.y);
|
|
246008
|
+
this._matrix.translate(translate.x, translate.y);
|
|
246009
|
+
}
|
|
246010
|
+
applyTransformMany(op) {
|
|
246011
|
+
if (op.method === "applyMatrix") {
|
|
246012
|
+
this._matrix.scale(op.matrix.scaleX, op.matrix.scaleY);
|
|
246013
|
+
this._matrix.translate(op.matrix.translateX, op.matrix.translateY);
|
|
246014
|
+
} else if (op.method === "scaleByTranslateBy") {
|
|
246015
|
+
this.applyScaleByTranslateBy(op.scale, op.translate);
|
|
246016
|
+
} else if (op.method === "scaleBy") {
|
|
246017
|
+
this.applyScaleBy(op.x, op.y);
|
|
246018
|
+
} else if (op.method === "translateBy") {
|
|
246019
|
+
this.applyTranslateBy(op.x, op.y);
|
|
246020
|
+
} else if (op.method === "translateTo") {
|
|
246021
|
+
this.applyTranslateTo(op.x, op.y);
|
|
246022
|
+
}
|
|
246023
|
+
}
|
|
246024
|
+
applyScaleByRelativeTo(x, y, point32) {
|
|
246025
|
+
const scaleX = this._matrix.scaleX * x;
|
|
246026
|
+
const scaleY = this._matrix.scaleY * y;
|
|
246027
|
+
this._matrix.translateX = -point32.x * scaleX + point32.x;
|
|
246028
|
+
this._matrix.translateY = -point32.y * scaleY + point32.y;
|
|
246029
|
+
this._matrix.scaleX = scaleX;
|
|
246030
|
+
this._matrix.scaleY = scaleY;
|
|
246031
|
+
}
|
|
246032
|
+
applyScaleToRelativeTo(x, y, point32) {
|
|
246033
|
+
this.applyTranslateBy(-point32.x, -point32.y);
|
|
246034
|
+
this.applyScaleTo(x, y);
|
|
246035
|
+
this.applyTranslateBy(point32.x, point32.y);
|
|
246036
|
+
}
|
|
246037
|
+
applyRotateTo(degree) {
|
|
246038
|
+
if (degree > 0) {
|
|
246039
|
+
while (degree > 360) {
|
|
246040
|
+
degree -= 360;
|
|
246041
|
+
}
|
|
246042
|
+
if (degree === 360) {
|
|
246043
|
+
degree = 0;
|
|
246044
|
+
}
|
|
246045
|
+
} else {
|
|
246046
|
+
while (degree < -360) {
|
|
246047
|
+
degree += 360;
|
|
246048
|
+
}
|
|
246049
|
+
if (degree === -360) {
|
|
246050
|
+
degree = 0;
|
|
246051
|
+
}
|
|
246052
|
+
}
|
|
246053
|
+
this.rotate = degree;
|
|
246054
|
+
}
|
|
246055
|
+
applyRotateBy(degree) {
|
|
246056
|
+
this.applyRotateTo(this.rotate + degree);
|
|
246057
|
+
}
|
|
246058
|
+
applyLocked(locked7) {
|
|
246059
|
+
this.isLocked = locked7;
|
|
246060
|
+
}
|
|
246061
|
+
applyUnlocked(locked7) {
|
|
246062
|
+
this.isLocked = locked7;
|
|
246063
|
+
}
|
|
246064
|
+
}
|
|
246065
|
+
|
|
246385
246066
|
class ShapeCommand {
|
|
246386
246067
|
shape;
|
|
246387
246068
|
operation;
|
|
@@ -246714,6 +246395,145 @@ function applyRedo(board, operation) {
|
|
|
246714
246395
|
addOperationHandler("undo", applyUndo);
|
|
246715
246396
|
addOperationHandler("redo", applyRedo);
|
|
246716
246397
|
|
|
246398
|
+
class ConnectorCommand {
|
|
246399
|
+
connector;
|
|
246400
|
+
operation;
|
|
246401
|
+
reverse;
|
|
246402
|
+
constructor(connector, operation) {
|
|
246403
|
+
this.connector = connector;
|
|
246404
|
+
this.operation = operation;
|
|
246405
|
+
this.reverse = this.getReverse();
|
|
246406
|
+
}
|
|
246407
|
+
merge(op) {
|
|
246408
|
+
this.operation = op;
|
|
246409
|
+
return this;
|
|
246410
|
+
}
|
|
246411
|
+
apply() {
|
|
246412
|
+
for (const connector of this.connector) {
|
|
246413
|
+
connector.apply(this.operation);
|
|
246414
|
+
}
|
|
246415
|
+
}
|
|
246416
|
+
revert() {
|
|
246417
|
+
for (const { item, operation } of this.reverse) {
|
|
246418
|
+
item.apply(operation);
|
|
246419
|
+
}
|
|
246420
|
+
}
|
|
246421
|
+
getReverse() {
|
|
246422
|
+
const reverse = [];
|
|
246423
|
+
switch (this.operation.method) {
|
|
246424
|
+
case "setStartPoint":
|
|
246425
|
+
for (const connector of this.connector) {
|
|
246426
|
+
reverse.push({
|
|
246427
|
+
item: connector,
|
|
246428
|
+
operation: {
|
|
246429
|
+
...this.operation,
|
|
246430
|
+
startPointData: connector.getStartPoint().serialize()
|
|
246431
|
+
}
|
|
246432
|
+
});
|
|
246433
|
+
}
|
|
246434
|
+
break;
|
|
246435
|
+
case "setEndPoint":
|
|
246436
|
+
for (const connector of this.connector) {
|
|
246437
|
+
reverse.push({
|
|
246438
|
+
item: connector,
|
|
246439
|
+
operation: {
|
|
246440
|
+
...this.operation,
|
|
246441
|
+
endPointData: connector.getEndPoint().serialize()
|
|
246442
|
+
}
|
|
246443
|
+
});
|
|
246444
|
+
}
|
|
246445
|
+
break;
|
|
246446
|
+
case "setMiddlePoint":
|
|
246447
|
+
for (const connector of this.connector) {
|
|
246448
|
+
const middlePoint = connector.getMiddlePoint();
|
|
246449
|
+
reverse.push({
|
|
246450
|
+
item: connector,
|
|
246451
|
+
operation: {
|
|
246452
|
+
...this.operation,
|
|
246453
|
+
middlePointData: middlePoint ? middlePoint.serialize() : null
|
|
246454
|
+
}
|
|
246455
|
+
});
|
|
246456
|
+
}
|
|
246457
|
+
break;
|
|
246458
|
+
case "setStartPointerStyle":
|
|
246459
|
+
for (const connector of this.connector) {
|
|
246460
|
+
reverse.push({
|
|
246461
|
+
item: connector,
|
|
246462
|
+
operation: {
|
|
246463
|
+
...this.operation,
|
|
246464
|
+
startPointerStyle: connector.getStartPointerStyle()
|
|
246465
|
+
}
|
|
246466
|
+
});
|
|
246467
|
+
}
|
|
246468
|
+
break;
|
|
246469
|
+
case "setEndPointerStyle":
|
|
246470
|
+
for (const connector of this.connector) {
|
|
246471
|
+
reverse.push({
|
|
246472
|
+
item: connector,
|
|
246473
|
+
operation: {
|
|
246474
|
+
...this.operation,
|
|
246475
|
+
endPointerStyle: connector.getEndPointerStyle()
|
|
246476
|
+
}
|
|
246477
|
+
});
|
|
246478
|
+
}
|
|
246479
|
+
break;
|
|
246480
|
+
case "setLineStyle":
|
|
246481
|
+
for (const connector of this.connector) {
|
|
246482
|
+
reverse.push({
|
|
246483
|
+
item: connector,
|
|
246484
|
+
operation: {
|
|
246485
|
+
...this.operation,
|
|
246486
|
+
lineStyle: connector.getLineStyle()
|
|
246487
|
+
}
|
|
246488
|
+
});
|
|
246489
|
+
}
|
|
246490
|
+
break;
|
|
246491
|
+
case "setBorderStyle":
|
|
246492
|
+
for (const connector of this.connector) {
|
|
246493
|
+
reverse.push({
|
|
246494
|
+
item: connector,
|
|
246495
|
+
operation: {
|
|
246496
|
+
...this.operation,
|
|
246497
|
+
borderStyle: connector.getBorderStyle()
|
|
246498
|
+
}
|
|
246499
|
+
});
|
|
246500
|
+
}
|
|
246501
|
+
break;
|
|
246502
|
+
case "setLineWidth":
|
|
246503
|
+
for (const connector of this.connector) {
|
|
246504
|
+
reverse.push({
|
|
246505
|
+
item: connector,
|
|
246506
|
+
operation: {
|
|
246507
|
+
...this.operation,
|
|
246508
|
+
lineWidth: connector.getLineWidth()
|
|
246509
|
+
}
|
|
246510
|
+
});
|
|
246511
|
+
}
|
|
246512
|
+
break;
|
|
246513
|
+
case "setLineColor":
|
|
246514
|
+
for (const connector of this.connector) {
|
|
246515
|
+
reverse.push({
|
|
246516
|
+
item: connector,
|
|
246517
|
+
operation: {
|
|
246518
|
+
...this.operation,
|
|
246519
|
+
lineColor: connector.getLineColor()
|
|
246520
|
+
}
|
|
246521
|
+
});
|
|
246522
|
+
}
|
|
246523
|
+
break;
|
|
246524
|
+
case "switchPointers":
|
|
246525
|
+
for (const connector of this.connector) {
|
|
246526
|
+
reverse.push({
|
|
246527
|
+
item: connector,
|
|
246528
|
+
operation: this.operation
|
|
246529
|
+
});
|
|
246530
|
+
}
|
|
246531
|
+
break;
|
|
246532
|
+
}
|
|
246533
|
+
return reverse;
|
|
246534
|
+
}
|
|
246535
|
+
}
|
|
246536
|
+
|
|
246717
246537
|
class DrawingCommand {
|
|
246718
246538
|
item;
|
|
246719
246539
|
operation;
|
|
@@ -246955,8 +246775,13 @@ class CommentCommand {
|
|
|
246955
246775
|
}
|
|
246956
246776
|
}
|
|
246957
246777
|
}
|
|
246958
|
-
var
|
|
246959
|
-
|
|
246778
|
+
var byteToHex = [];
|
|
246779
|
+
for (let i = 0;i < 256; ++i) {
|
|
246780
|
+
byteToHex.push((i + 256).toString(16).slice(1));
|
|
246781
|
+
}
|
|
246782
|
+
function unsafeStringify(arr2, offset = 0) {
|
|
246783
|
+
return (byteToHex[arr2[offset + 0]] + byteToHex[arr2[offset + 1]] + byteToHex[arr2[offset + 2]] + byteToHex[arr2[offset + 3]] + "-" + byteToHex[arr2[offset + 4]] + byteToHex[arr2[offset + 5]] + "-" + byteToHex[arr2[offset + 6]] + byteToHex[arr2[offset + 7]] + "-" + byteToHex[arr2[offset + 8]] + byteToHex[arr2[offset + 9]] + "-" + byteToHex[arr2[offset + 10]] + byteToHex[arr2[offset + 11]] + byteToHex[arr2[offset + 12]] + byteToHex[arr2[offset + 13]] + byteToHex[arr2[offset + 14]] + byteToHex[arr2[offset + 15]]).toLowerCase();
|
|
246784
|
+
}
|
|
246960
246785
|
var getRandomValues;
|
|
246961
246786
|
var rnds8 = new Uint8Array(16);
|
|
246962
246787
|
function rng() {
|
|
@@ -246968,13 +246793,8 @@ function rng() {
|
|
|
246968
246793
|
}
|
|
246969
246794
|
return getRandomValues(rnds8);
|
|
246970
246795
|
}
|
|
246971
|
-
var
|
|
246972
|
-
|
|
246973
|
-
byteToHex.push((i + 256).toString(16).slice(1));
|
|
246974
|
-
}
|
|
246975
|
-
function unsafeStringify(arr2, offset = 0) {
|
|
246976
|
-
return (byteToHex[arr2[offset + 0]] + byteToHex[arr2[offset + 1]] + byteToHex[arr2[offset + 2]] + byteToHex[arr2[offset + 3]] + "-" + byteToHex[arr2[offset + 4]] + byteToHex[arr2[offset + 5]] + "-" + byteToHex[arr2[offset + 6]] + byteToHex[arr2[offset + 7]] + "-" + byteToHex[arr2[offset + 8]] + byteToHex[arr2[offset + 9]] + "-" + byteToHex[arr2[offset + 10]] + byteToHex[arr2[offset + 11]] + byteToHex[arr2[offset + 12]] + byteToHex[arr2[offset + 13]] + byteToHex[arr2[offset + 14]] + byteToHex[arr2[offset + 15]]).toLowerCase();
|
|
246977
|
-
}
|
|
246796
|
+
var randomUUID = typeof crypto !== "undefined" && crypto.randomUUID && crypto.randomUUID.bind(crypto);
|
|
246797
|
+
var native_default = { randomUUID };
|
|
246978
246798
|
function v4(options2, buf, offset) {
|
|
246979
246799
|
if (native_default.randomUUID && !buf && !options2) {
|
|
246980
246800
|
return native_default.randomUUID();
|
|
@@ -247225,12 +247045,11 @@ class Comment {
|
|
|
247225
247045
|
});
|
|
247226
247046
|
}
|
|
247227
247047
|
transform() {
|
|
247228
|
-
const
|
|
247229
|
-
if (
|
|
247230
|
-
this.anchor = new Point3(
|
|
247048
|
+
const { translateX, translateY } = this.transformation.getMatrixData();
|
|
247049
|
+
if (translateX && translateY) {
|
|
247050
|
+
this.anchor = new Point3(translateX, translateY);
|
|
247231
247051
|
} else {
|
|
247232
|
-
|
|
247233
|
-
matrix.translateY = this.anchor.y;
|
|
247052
|
+
this.transformation.setLocal(this.anchor.x, this.anchor.y);
|
|
247234
247053
|
}
|
|
247235
247054
|
}
|
|
247236
247055
|
getUnreadMessages(userId = ANONYMOUS_ID) {
|
|
@@ -247339,7 +247158,7 @@ class Comment {
|
|
|
247339
247158
|
render(context) {}
|
|
247340
247159
|
renderHTML(documentFactory) {
|
|
247341
247160
|
const div = documentFactory.createElement("comment-item");
|
|
247342
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
247161
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
247343
247162
|
const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
247344
247163
|
div.style.transformOrigin = "top left";
|
|
247345
247164
|
div.style.transform = transform;
|
|
@@ -248488,18 +248307,25 @@ class RTreeIndex {
|
|
|
248488
248307
|
}
|
|
248489
248308
|
}
|
|
248490
248309
|
|
|
248491
|
-
class Container
|
|
248310
|
+
class Container {
|
|
248492
248311
|
id;
|
|
248493
248312
|
item;
|
|
248494
248313
|
layer;
|
|
248495
248314
|
zIndex;
|
|
248315
|
+
left;
|
|
248316
|
+
top;
|
|
248317
|
+
right;
|
|
248318
|
+
bottom;
|
|
248496
248319
|
constructor(id2, item, layer, zIndex) {
|
|
248497
|
-
const rect = item.getMbrWithChildren();
|
|
248498
|
-
super(rect.left, rect.top, rect.right, rect.bottom);
|
|
248499
248320
|
this.id = id2;
|
|
248500
248321
|
this.item = item;
|
|
248501
248322
|
this.layer = layer;
|
|
248502
248323
|
this.zIndex = zIndex;
|
|
248324
|
+
const rect = item.getMbrWithChildren();
|
|
248325
|
+
this.left = rect.left;
|
|
248326
|
+
this.top = rect.top;
|
|
248327
|
+
this.right = rect.right;
|
|
248328
|
+
this.bottom = rect.bottom;
|
|
248503
248329
|
}
|
|
248504
248330
|
}
|
|
248505
248331
|
|
|
@@ -249846,7 +249672,7 @@ class BaseItem extends Mbr {
|
|
|
249846
249672
|
}
|
|
249847
249673
|
renderHTML(documentFactory) {
|
|
249848
249674
|
const div = documentFactory.createElement("base-item");
|
|
249849
|
-
const { translateX, translateY } = this.transformation.
|
|
249675
|
+
const { translateX, translateY } = this.transformation.getMatrixData();
|
|
249850
249676
|
const transform = `translate(${translateX}px, ${translateY}px) scale(1, 1)`;
|
|
249851
249677
|
div.style.backgroundColor = "#b2b0c3";
|
|
249852
249678
|
div.id = this.getId();
|
|
@@ -249987,7 +249813,7 @@ class RichText extends BaseItem {
|
|
|
249987
249813
|
mbr.right += 20;
|
|
249988
249814
|
mbr.bottom += 20;
|
|
249989
249815
|
}
|
|
249990
|
-
const linkMbr = mbr.getTransformed(this.transformation.
|
|
249816
|
+
const linkMbr = mbr.getTransformed(this.transformation.toMatrix());
|
|
249991
249817
|
if (linkMbr.isUnderPoint(point32)) {
|
|
249992
249818
|
return { hyperLink, linkMbr };
|
|
249993
249819
|
}
|
|
@@ -250184,12 +250010,13 @@ class RichText extends BaseItem {
|
|
|
250184
250010
|
return this.shrinkWidth;
|
|
250185
250011
|
}
|
|
250186
250012
|
getTransformedContainer() {
|
|
250187
|
-
let matrix = this.transformation.matrix;
|
|
250188
250013
|
if (this.insideOf === "Frame") {
|
|
250014
|
+
const { translateX, translateY, scaleX } = this.transformation.getMatrixData();
|
|
250189
250015
|
const scaleY = this.getMbr().getHeight() * 2 / 10;
|
|
250190
|
-
matrix = new Matrix2(
|
|
250016
|
+
const matrix = new Matrix2(translateX, translateY, scaleX, scaleY);
|
|
250017
|
+
return this.container.getTransformed(matrix);
|
|
250191
250018
|
}
|
|
250192
|
-
return this.container.getTransformed(
|
|
250019
|
+
return this.container.getTransformed(this.transformation.toMatrix());
|
|
250193
250020
|
}
|
|
250194
250021
|
emitWithoutApplying = (op) => {
|
|
250195
250022
|
if (this.board.events) {
|
|
@@ -250550,7 +250377,7 @@ class RichText extends BaseItem {
|
|
|
250550
250377
|
ctx.translate(this.left, this.top);
|
|
250551
250378
|
const shouldScale = !this.isInShape && !this.autoSize;
|
|
250552
250379
|
if (shouldScale) {
|
|
250553
|
-
const { scaleX, scaleY } = this.transformation.
|
|
250380
|
+
const { scaleX, scaleY } = this.transformation.getMatrixData();
|
|
250554
250381
|
ctx.scale(scaleX, scaleY);
|
|
250555
250382
|
}
|
|
250556
250383
|
const shouldClip = this.insideOf === "Shape" || this.insideOf === "Sticker";
|
|
@@ -250683,7 +250510,7 @@ class RichText extends BaseItem {
|
|
|
250683
250510
|
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
250684
250511
|
};
|
|
250685
250512
|
const elements = this.editor.editor.children.map(renderNode);
|
|
250686
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
250513
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
250687
250514
|
const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
250688
250515
|
const transformedWidth = this.getTransformedContainer().getWidth();
|
|
250689
250516
|
const transformedHeight = this.getTransformedContainer().getHeight();
|
|
@@ -250781,6 +250608,250 @@ class RichText extends BaseItem {
|
|
|
250781
250608
|
return this.prevMbr;
|
|
250782
250609
|
}
|
|
250783
250610
|
}
|
|
250611
|
+
function updateRects(board, ref, mbr, verticalOffset, horizontalOffset, fit = "contextPanel") {
|
|
250612
|
+
const { selection, camera } = board;
|
|
250613
|
+
const panel = ref.current;
|
|
250614
|
+
const selectionMbr = mbr ?? selection.getMbr();
|
|
250615
|
+
const selectionItems = selection.items;
|
|
250616
|
+
const richTextSelection = selectionItems.getSingle() instanceof RichText ? selectionItems.list()[0] : undefined;
|
|
250617
|
+
if (panel && selectionMbr) {
|
|
250618
|
+
if (fit === "contextPanel") {
|
|
250619
|
+
const panelRect = getContextPanelRect(selectionMbr, camera, panel, !!richTextSelection, horizontalOffset, verticalOffset);
|
|
250620
|
+
return panelRect;
|
|
250621
|
+
}
|
|
250622
|
+
if (fit === "linkToBtn") {
|
|
250623
|
+
if (!mbr) {
|
|
250624
|
+
return null;
|
|
250625
|
+
}
|
|
250626
|
+
const panelRect = fitLinkToBtn(selectionMbr.getTransformed(camera.getMatrix()), camera.window.getMbr(), Mbr.fromDomRect(panel.getBoundingClientRect()), verticalOffset, horizontalOffset);
|
|
250627
|
+
return panelRect;
|
|
250628
|
+
}
|
|
250629
|
+
if (fit === "comment") {
|
|
250630
|
+
if (!mbr) {
|
|
250631
|
+
return null;
|
|
250632
|
+
}
|
|
250633
|
+
const panelRect = fitComment(selectionMbr.getTransformed(camera.getMatrix()), Mbr.fromDomRect(panel.getBoundingClientRect()), verticalOffset, horizontalOffset);
|
|
250634
|
+
return panelRect;
|
|
250635
|
+
}
|
|
250636
|
+
if (fit === "threadPanel") {
|
|
250637
|
+
if (!mbr) {
|
|
250638
|
+
return null;
|
|
250639
|
+
}
|
|
250640
|
+
const panelRect = fitThreadPanel(selectionMbr.getTransformed(camera.getMatrix()), camera.window.getMbr(), Mbr.fromDomRect(panel.getBoundingClientRect()), verticalOffset, horizontalOffset);
|
|
250641
|
+
return panelRect;
|
|
250642
|
+
}
|
|
250643
|
+
if (fit === "boardMenu") {
|
|
250644
|
+
if (!mbr) {
|
|
250645
|
+
return null;
|
|
250646
|
+
}
|
|
250647
|
+
const panelRect = fitBoardMenu(selectionMbr.getTransformed(camera.getMatrix()), camera.window.getMbr(), Mbr.fromDomRect(panel.getBoundingClientRect()), verticalOffset, horizontalOffset);
|
|
250648
|
+
return panelRect;
|
|
250649
|
+
}
|
|
250650
|
+
if (fit === "hyperLink") {
|
|
250651
|
+
if (!mbr) {
|
|
250652
|
+
return null;
|
|
250653
|
+
}
|
|
250654
|
+
const panelRect = fitHyperLink(selectionMbr.getTransformed(camera.getMatrix()), Mbr.fromDomRect(panel.getBoundingClientRect()), camera.window.getMbr(), verticalOffset);
|
|
250655
|
+
return panelRect;
|
|
250656
|
+
}
|
|
250657
|
+
}
|
|
250658
|
+
return null;
|
|
250659
|
+
}
|
|
250660
|
+
function getContextPanelRect(selectionMbr, camera, panel, toLeft, horizontalOffset, verticalOffset) {
|
|
250661
|
+
const transformedMbr = selectionMbr.getTransformed(camera.getMatrix());
|
|
250662
|
+
const windowMbr = camera.window.getMbr();
|
|
250663
|
+
const panelRectFromDom = Mbr.fromDomRect(panel.getBoundingClientRect());
|
|
250664
|
+
const panelRect = toLeft ? fitContextPanelToLeft(transformedMbr, windowMbr, panelRectFromDom, verticalOffset, horizontalOffset) : fitContextPanelToCenter(transformedMbr, windowMbr, panelRectFromDom, verticalOffset, horizontalOffset);
|
|
250665
|
+
return panelRect;
|
|
250666
|
+
}
|
|
250667
|
+
function fitContextPanelToLeft(selectionMbr, view, panel, verticalOffset = 40, horizontalOffset = 80) {
|
|
250668
|
+
const panelHeight = panel.getHeight();
|
|
250669
|
+
const panelWidth = panel.getWidth();
|
|
250670
|
+
const newPanel = new Mbr;
|
|
250671
|
+
const topSpace = selectionMbr.top - view.top;
|
|
250672
|
+
const hasEnoughTopSpace = topSpace >= panelHeight + verticalOffset;
|
|
250673
|
+
if (hasEnoughTopSpace) {
|
|
250674
|
+
newPanel.top = selectionMbr.top - panelHeight - verticalOffset;
|
|
250675
|
+
if (newPanel.top < view.top) {
|
|
250676
|
+
newPanel.top = view.top + verticalOffset;
|
|
250677
|
+
}
|
|
250678
|
+
} else {
|
|
250679
|
+
const usePanelTop = panel.top > 1 && panel.top > selectionMbr.top + verticalOffset;
|
|
250680
|
+
newPanel.top = usePanelTop ? panel.top : selectionMbr.bottom + verticalOffset;
|
|
250681
|
+
const isOverflowingBottom = newPanel.top + panelHeight > view.bottom;
|
|
250682
|
+
const isLargeOffsetForRichText = newPanel.top >= selectionMbr.bottom + verticalOffset * 2;
|
|
250683
|
+
if (isOverflowingBottom || isLargeOffsetForRichText) {
|
|
250684
|
+
newPanel.top = selectionMbr.bottom - (panelHeight + verticalOffset);
|
|
250685
|
+
}
|
|
250686
|
+
}
|
|
250687
|
+
newPanel.bottom = newPanel.top + panelHeight;
|
|
250688
|
+
fitContextPanelInViewRect(newPanel, view, verticalOffset);
|
|
250689
|
+
const itemMbr = selectionMbr.getMbr();
|
|
250690
|
+
newPanel.left = itemMbr.left;
|
|
250691
|
+
adjustPanelHorizontal(newPanel, panelWidth, view, horizontalOffset);
|
|
250692
|
+
return newPanel;
|
|
250693
|
+
}
|
|
250694
|
+
function fitContextPanelToCenter(selectionMbr, view, panel, verticalOffset = 40, horizontalOffset = 80) {
|
|
250695
|
+
const panelHeight = panel.getHeight();
|
|
250696
|
+
const panelWidth = panel.getWidth();
|
|
250697
|
+
const newPanel = new Mbr;
|
|
250698
|
+
const topSpace = selectionMbr.top - view.top;
|
|
250699
|
+
const bottomSpace = view.bottom - selectionMbr.bottom;
|
|
250700
|
+
const shouldPlaceAbove = topSpace > bottomSpace - panelHeight;
|
|
250701
|
+
if (shouldPlaceAbove) {
|
|
250702
|
+
newPanel.top = selectionMbr.top - panelHeight - verticalOffset;
|
|
250703
|
+
if (newPanel.top < view.top) {
|
|
250704
|
+
newPanel.top = view.top + verticalOffset;
|
|
250705
|
+
}
|
|
250706
|
+
} else {
|
|
250707
|
+
newPanel.top = selectionMbr.bottom + verticalOffset;
|
|
250708
|
+
const isOverflowingBottom = newPanel.top + panelHeight > view.bottom;
|
|
250709
|
+
const isLargeOffsetForRichText = newPanel.top >= selectionMbr.bottom + verticalOffset * 2;
|
|
250710
|
+
if (isOverflowingBottom || isLargeOffsetForRichText) {
|
|
250711
|
+
newPanel.top = selectionMbr.bottom - (panelHeight + verticalOffset);
|
|
250712
|
+
}
|
|
250713
|
+
}
|
|
250714
|
+
newPanel.bottom = newPanel.top + panelHeight;
|
|
250715
|
+
fitContextPanelInViewRect(newPanel, view, verticalOffset);
|
|
250716
|
+
const itemCenter = selectionMbr.getCenter();
|
|
250717
|
+
newPanel.left = itemCenter.x - panelWidth / 2;
|
|
250718
|
+
adjustPanelHorizontal(newPanel, panelWidth, view, horizontalOffset);
|
|
250719
|
+
return newPanel;
|
|
250720
|
+
}
|
|
250721
|
+
function adjustPanelHorizontal(newPanel, panelWidth, view, horizontalOffset) {
|
|
250722
|
+
newPanel.right = newPanel.left + panelWidth;
|
|
250723
|
+
if (newPanel.left < view.left + horizontalOffset) {
|
|
250724
|
+
newPanel.left = view.left + horizontalOffset;
|
|
250725
|
+
} else if (newPanel.right + horizontalOffset > view.right) {
|
|
250726
|
+
newPanel.left = view.right - (panelWidth + horizontalOffset);
|
|
250727
|
+
}
|
|
250728
|
+
newPanel.right = newPanel.left + panelWidth;
|
|
250729
|
+
}
|
|
250730
|
+
function fitContextPanelInViewRect(panel, view, verticalOffset) {
|
|
250731
|
+
const panelHeight = panel.getHeight();
|
|
250732
|
+
if (panel.top <= view.top + verticalOffset) {
|
|
250733
|
+
panel.top = view.top + 2 * verticalOffset;
|
|
250734
|
+
panel.bottom = panel.top + panelHeight;
|
|
250735
|
+
}
|
|
250736
|
+
if (panel.bottom >= view.bottom - verticalOffset) {
|
|
250737
|
+
panel.bottom = view.bottom - 2 * verticalOffset;
|
|
250738
|
+
panel.top = panel.bottom - panelHeight;
|
|
250739
|
+
}
|
|
250740
|
+
}
|
|
250741
|
+
function fitLinkToBtn(itemMbr, view, panel, verticalOffset = -2, horizontalOffset = -2) {
|
|
250742
|
+
const panelHeight = panel.getHeight();
|
|
250743
|
+
const newPanel = new Mbr;
|
|
250744
|
+
newPanel.top = itemMbr.top - panelHeight - verticalOffset;
|
|
250745
|
+
newPanel.top = newPanel.top + panelHeight;
|
|
250746
|
+
newPanel.bottom = newPanel.top + panelHeight * 2;
|
|
250747
|
+
const panelWidth = panel.getWidth();
|
|
250748
|
+
newPanel.left = itemMbr.right - panelWidth + horizontalOffset;
|
|
250749
|
+
return newPanel;
|
|
250750
|
+
}
|
|
250751
|
+
function fitHyperLink(linkMbr, panel, view, offset = 20) {
|
|
250752
|
+
const panelHeight = panel.getHeight();
|
|
250753
|
+
const newPanel = new Mbr;
|
|
250754
|
+
newPanel.top = linkMbr.bottom;
|
|
250755
|
+
newPanel.bottom = panelHeight + newPanel.top;
|
|
250756
|
+
const panelWidth = panel.getWidth();
|
|
250757
|
+
newPanel.left = linkMbr.left;
|
|
250758
|
+
newPanel.right = newPanel.left + panelWidth;
|
|
250759
|
+
return newPanel;
|
|
250760
|
+
}
|
|
250761
|
+
function fitComment(anchor, panel, verticalOffset = 0, horizontalOffset = 0) {
|
|
250762
|
+
const panelHeight = panel.getHeight();
|
|
250763
|
+
const newPanel = new Mbr;
|
|
250764
|
+
newPanel.top = anchor.top - panelHeight - verticalOffset;
|
|
250765
|
+
newPanel.bottom = newPanel.top + panelHeight;
|
|
250766
|
+
const panelWidth = panel.getWidth();
|
|
250767
|
+
newPanel.left = anchor.left - panelWidth / 2 - horizontalOffset;
|
|
250768
|
+
newPanel.right = newPanel.left + panelWidth;
|
|
250769
|
+
return newPanel;
|
|
250770
|
+
}
|
|
250771
|
+
function fitBoardMenu(anchor, view, panel, verticalOffset = 20, horizontalOffset = 20) {
|
|
250772
|
+
const panelHeight = panel.getHeight();
|
|
250773
|
+
const panelWidth = panel.getWidth();
|
|
250774
|
+
const newPanel = new Mbr;
|
|
250775
|
+
newPanel.top = anchor.top;
|
|
250776
|
+
newPanel.bottom = newPanel.top + panelHeight;
|
|
250777
|
+
if (newPanel.bottom > view.bottom - verticalOffset) {
|
|
250778
|
+
newPanel.bottom = view.bottom - verticalOffset;
|
|
250779
|
+
newPanel.top = newPanel.bottom - panelHeight;
|
|
250780
|
+
}
|
|
250781
|
+
newPanel.left = anchor.left;
|
|
250782
|
+
newPanel.right = newPanel.left + panelWidth;
|
|
250783
|
+
if (newPanel.right > view.right - horizontalOffset) {
|
|
250784
|
+
newPanel.right = view.right - horizontalOffset;
|
|
250785
|
+
newPanel.left = newPanel.right - panelWidth;
|
|
250786
|
+
}
|
|
250787
|
+
return newPanel;
|
|
250788
|
+
}
|
|
250789
|
+
function fitThreadPanel(anchor, view, panel, verticalOffset = 50, horizontalOffset = 50) {
|
|
250790
|
+
const panelHeight = panel.getHeight();
|
|
250791
|
+
const panelWidth = panel.getWidth();
|
|
250792
|
+
const newPanel = new Mbr;
|
|
250793
|
+
newPanel.top = anchor.top - panelHeight / 2;
|
|
250794
|
+
if (newPanel.top < view.top + verticalOffset) {
|
|
250795
|
+
newPanel.top = view.top + verticalOffset;
|
|
250796
|
+
}
|
|
250797
|
+
newPanel.bottom = newPanel.top + panelHeight;
|
|
250798
|
+
if (newPanel.bottom > view.bottom - verticalOffset) {
|
|
250799
|
+
newPanel.bottom = view.bottom - verticalOffset;
|
|
250800
|
+
newPanel.top = newPanel.bottom - panelHeight;
|
|
250801
|
+
}
|
|
250802
|
+
newPanel.left = anchor.left;
|
|
250803
|
+
newPanel.right = newPanel.left + panelWidth;
|
|
250804
|
+
if (newPanel.right > view.right - horizontalOffset) {
|
|
250805
|
+
newPanel.right = anchor.right;
|
|
250806
|
+
newPanel.left = newPanel.right - panelWidth;
|
|
250807
|
+
}
|
|
250808
|
+
return newPanel;
|
|
250809
|
+
}
|
|
250810
|
+
|
|
250811
|
+
class DrawingContext2 {
|
|
250812
|
+
camera;
|
|
250813
|
+
ctx;
|
|
250814
|
+
cursorCtx;
|
|
250815
|
+
matrix;
|
|
250816
|
+
isBorderInvisible = false;
|
|
250817
|
+
shapeVisibilityTreshold = 3;
|
|
250818
|
+
rectangleVisibilyTreshold = 2;
|
|
250819
|
+
constructor(camera, ctx, cursorCtx, matrix = new Matrix2) {
|
|
250820
|
+
this.camera = camera;
|
|
250821
|
+
this.ctx = ctx;
|
|
250822
|
+
this.cursorCtx = cursorCtx;
|
|
250823
|
+
this.matrix = matrix;
|
|
250824
|
+
this.setCamera(camera);
|
|
250825
|
+
}
|
|
250826
|
+
dpi() {
|
|
250827
|
+
return conf.getDPI();
|
|
250828
|
+
}
|
|
250829
|
+
setCamera(camera) {
|
|
250830
|
+
this.camera = camera;
|
|
250831
|
+
this.matrix = camera.getMatrix();
|
|
250832
|
+
const scale = this.matrix.scaleX;
|
|
250833
|
+
this.isBorderInvisible = 4 * scale < 0.1;
|
|
250834
|
+
}
|
|
250835
|
+
clear() {
|
|
250836
|
+
this.ctx.setTransform(1 * this.dpi(), 0, 0, 1 * this.dpi(), 0, 0);
|
|
250837
|
+
this.ctx.clearRect(0, 0, conf.getDocumentWidth(), conf.getDocumentHeight());
|
|
250838
|
+
this.matrix.applyToContext(this.ctx);
|
|
250839
|
+
}
|
|
250840
|
+
clearCursor() {
|
|
250841
|
+
if (!this.cursorCtx) {
|
|
250842
|
+
return;
|
|
250843
|
+
}
|
|
250844
|
+
this.cursorCtx.setTransform(1 * this.dpi(), 0, 0, 1 * this.dpi(), 0, 0);
|
|
250845
|
+
this.cursorCtx.clearRect(0, 0, conf.getDocumentWidth(), conf.getDocumentHeight());
|
|
250846
|
+
this.matrix.applyToContext(this.cursorCtx);
|
|
250847
|
+
}
|
|
250848
|
+
applyChanges() {
|
|
250849
|
+
this.matrix.applyToContext(this.ctx);
|
|
250850
|
+
}
|
|
250851
|
+
getCameraScale() {
|
|
250852
|
+
return this.camera.getScale();
|
|
250853
|
+
}
|
|
250854
|
+
}
|
|
250784
250855
|
|
|
250785
250856
|
class Schema {
|
|
250786
250857
|
constructor(property, normal, space) {
|
|
@@ -262271,10 +262342,10 @@ function zwitch(key, options2) {
|
|
|
262271
262342
|
const settings = options2 || {};
|
|
262272
262343
|
function one4(value, ...parameters) {
|
|
262273
262344
|
let fn = one4.invalid;
|
|
262274
|
-
const
|
|
262345
|
+
const handlers2 = one4.handlers;
|
|
262275
262346
|
if (value && own6.call(value, key)) {
|
|
262276
262347
|
const id2 = String(value[key]);
|
|
262277
|
-
fn = own6.call(
|
|
262348
|
+
fn = own6.call(handlers2, id2) ? handlers2[id2] : one4.unknown;
|
|
262278
262349
|
}
|
|
262279
262350
|
if (fn) {
|
|
262280
262351
|
return fn.call(this, value, ...parameters);
|
|
@@ -263625,17 +263696,17 @@ class AINode extends BaseItem {
|
|
|
263625
263696
|
}
|
|
263626
263697
|
transformPath() {
|
|
263627
263698
|
const { left, right, top, bottom } = this.text.getTransformedContainer();
|
|
263628
|
-
const { scaleX, scaleY } = this.transformation.
|
|
263699
|
+
const { scaleX, scaleY, translateX: nodeTranslateX, translateY: nodeTranslateY } = this.transformation.getMatrixData();
|
|
263629
263700
|
const minScale = Math.min(scaleX, scaleY);
|
|
263630
263701
|
const leftOffset = 20 * minScale;
|
|
263631
263702
|
const topOffset = 20 * minScale;
|
|
263632
263703
|
const nodeRight = right + 80 * minScale;
|
|
263633
263704
|
const nodeBottom = bottom + (bottom - top > 400 ? 60 : 40) * minScale;
|
|
263634
263705
|
if (!this.path || this.text.left < this.path.getMbr().left + leftOffset && this.text.top < this.path.getMbr().top + topOffset) {
|
|
263635
|
-
this.text.left =
|
|
263636
|
-
this.text.top =
|
|
263706
|
+
this.text.left = nodeTranslateX + leftOffset;
|
|
263707
|
+
this.text.top = nodeTranslateY + topOffset;
|
|
263637
263708
|
}
|
|
263638
|
-
this.path = createNodePath(new Mbr(left, top, nodeRight, nodeBottom), this.transformation.
|
|
263709
|
+
this.path = createNodePath(new Mbr(left, top, nodeRight, nodeBottom), this.transformation.toMatrix());
|
|
263639
263710
|
const scaledSize = BUTTON_SIZE * minScale;
|
|
263640
263711
|
this.buttonMbr = new Mbr(nodeRight - scaledSize * 2, nodeBottom - scaledSize * 2, nodeRight - scaledSize, nodeBottom - scaledSize);
|
|
263641
263712
|
}
|
|
@@ -263796,7 +263867,7 @@ class AINode extends BaseItem {
|
|
|
263796
263867
|
}
|
|
263797
263868
|
renderHTML(documentFactory) {
|
|
263798
263869
|
const div = documentFactory.createElement("ainode-item");
|
|
263799
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
263870
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
263800
263871
|
const mbr = this.getMbr();
|
|
263801
263872
|
const width = mbr.getWidth();
|
|
263802
263873
|
const height = mbr.getHeight();
|
|
@@ -264041,14 +264112,13 @@ function getControlPoint(data, findItem2) {
|
|
|
264041
264112
|
}
|
|
264042
264113
|
}
|
|
264043
264114
|
function toRelativePoint(point5, item) {
|
|
264044
|
-
const
|
|
264045
|
-
const inverse = matrix.getInverse();
|
|
264115
|
+
const inverse = item.transformation ? item.transformation.getInverse().toMatrix() : new Matrix2;
|
|
264046
264116
|
point5 = point5.copy();
|
|
264047
264117
|
point5.transform(inverse);
|
|
264048
264118
|
return point5;
|
|
264049
264119
|
}
|
|
264050
264120
|
function fromRelativePoint(relativePoint, item, edge) {
|
|
264051
|
-
const matrix = item.transformation?.
|
|
264121
|
+
const matrix = item.transformation?.toMatrix() ?? new Matrix2;
|
|
264052
264122
|
const point5 = relativePoint.copy();
|
|
264053
264123
|
point5.transform(matrix);
|
|
264054
264124
|
if (item instanceof RichText || item instanceof AINode) {
|
|
@@ -265253,7 +265323,7 @@ class Connector2 extends BaseItem {
|
|
|
265253
265323
|
}
|
|
265254
265324
|
renderHTML(documentFactory) {
|
|
265255
265325
|
const div = documentFactory.createElement("connector-item");
|
|
265256
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
265326
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
265257
265327
|
const mbr = this.getMbr();
|
|
265258
265328
|
const width = mbr.getWidth();
|
|
265259
265329
|
const height = mbr.getHeight();
|
|
@@ -265318,7 +265388,7 @@ class Connector2 extends BaseItem {
|
|
|
265318
265388
|
return div;
|
|
265319
265389
|
}
|
|
265320
265390
|
renderPathHTML(documentFactory, path22) {
|
|
265321
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
265391
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
265322
265392
|
const pathElement = path22.renderHTML(documentFactory);
|
|
265323
265393
|
const paths = Array.isArray(pathElement) ? pathElement : [pathElement];
|
|
265324
265394
|
paths.forEach((element4) => {
|
|
@@ -265340,8 +265410,7 @@ class Connector2 extends BaseItem {
|
|
|
265340
265410
|
text5.transformation = undefined;
|
|
265341
265411
|
const mbr = this.getMbr();
|
|
265342
265412
|
const transformation = new Transformation;
|
|
265343
|
-
transformation.
|
|
265344
|
-
transformation.matrix.translateY = mbr.top;
|
|
265413
|
+
transformation.setLocal(mbr.left, mbr.top);
|
|
265345
265414
|
return {
|
|
265346
265415
|
itemType: "Connector",
|
|
265347
265416
|
transformation: transformation.serialize(),
|
|
@@ -265421,7 +265490,7 @@ class Connector2 extends BaseItem {
|
|
|
265421
265490
|
previous22.translateX = 0;
|
|
265422
265491
|
previous22.translateY = 0;
|
|
265423
265492
|
previous22.invert();
|
|
265424
|
-
const currUnscaled = this.transformation.
|
|
265493
|
+
const currUnscaled = this.transformation.toMatrix();
|
|
265425
265494
|
currUnscaled.translateX = 0;
|
|
265426
265495
|
currUnscaled.translateY = 0;
|
|
265427
265496
|
const delta = previous22.multiplyByMatrix(currUnscaled);
|
|
@@ -265448,7 +265517,7 @@ class Connector2 extends BaseItem {
|
|
|
265448
265517
|
previous22.scaleX = 1;
|
|
265449
265518
|
previous22.scaleY = 1;
|
|
265450
265519
|
previous22.invert();
|
|
265451
|
-
const currUnscaled = this.transformation.
|
|
265520
|
+
const currUnscaled = this.transformation.toMatrix();
|
|
265452
265521
|
currUnscaled.scaleX = 1;
|
|
265453
265522
|
currUnscaled.scaleY = 1;
|
|
265454
265523
|
const delta = previous22.multiplyByMatrix(currUnscaled);
|
|
@@ -267322,7 +267391,7 @@ class Shape extends BaseItem {
|
|
|
267322
267391
|
}
|
|
267323
267392
|
renderHTML(documentFactory) {
|
|
267324
267393
|
const div = documentFactory.createElement("shape-item");
|
|
267325
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
267394
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
267326
267395
|
const mbr = this.getMbr();
|
|
267327
267396
|
const width = mbr.getWidth();
|
|
267328
267397
|
const height = mbr.getHeight();
|
|
@@ -267411,8 +267480,8 @@ class Shape extends BaseItem {
|
|
|
267411
267480
|
this.path = Shapes[this.shapeType].createPath(this.mbr);
|
|
267412
267481
|
this.textContainer = Shapes[this.shapeType].textBounds.copy();
|
|
267413
267482
|
this.text.setContainer(this.textContainer.copy());
|
|
267414
|
-
this.textContainer.transform(this.transformation.
|
|
267415
|
-
this.path.transform(this.transformation.
|
|
267483
|
+
this.textContainer.transform(this.transformation.toMatrix());
|
|
267484
|
+
this.path.transform(this.transformation.toMatrix());
|
|
267416
267485
|
this.path.setBackgroundColor(this.backgroundColor);
|
|
267417
267486
|
this.path.setBackgroundOpacity(this.backgroundOpacity);
|
|
267418
267487
|
this.path.setBorderColor(this.borderColor);
|
|
@@ -267427,7 +267496,7 @@ class Shape extends BaseItem {
|
|
|
267427
267496
|
const anchorPoints = Shapes[this.shapeType].anchorPoints;
|
|
267428
267497
|
const points = [];
|
|
267429
267498
|
for (const anchorPoint of anchorPoints) {
|
|
267430
|
-
points.push(anchorPoint.getTransformed(this.transformation.
|
|
267499
|
+
points.push(anchorPoint.getTransformed(this.transformation.toMatrix()));
|
|
267431
267500
|
}
|
|
267432
267501
|
return points;
|
|
267433
267502
|
}
|
|
@@ -267595,10 +267664,9 @@ class Sticker extends BaseItem {
|
|
|
267595
267664
|
}
|
|
267596
267665
|
this.stickerPath = StickerShape.stickerPath.copy();
|
|
267597
267666
|
this.textContainer = StickerShape.textBounds.copy();
|
|
267598
|
-
|
|
267599
|
-
this.stickerPath.transform(matrix);
|
|
267667
|
+
this.stickerPath.transform(this.transformation.toMatrix());
|
|
267600
267668
|
this.text.setContainer(this.textContainer.copy());
|
|
267601
|
-
this.textContainer.transform(this.transformation.
|
|
267669
|
+
this.textContainer.transform(this.transformation.toMatrix());
|
|
267602
267670
|
this.stickerPath.setBackgroundColor(this.backgroundColor);
|
|
267603
267671
|
this.saveStickerData();
|
|
267604
267672
|
}
|
|
@@ -267699,7 +267767,7 @@ class Sticker extends BaseItem {
|
|
|
267699
267767
|
}
|
|
267700
267768
|
renderHTML(documentFactory) {
|
|
267701
267769
|
const div = documentFactory.createElement("sticker-item");
|
|
267702
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
267770
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
267703
267771
|
const transform = `translate(${Math.round(translateX)}px, ${Math.round(translateY)}px) scale(${scaleX}, ${scaleY})`;
|
|
267704
267772
|
const itemMbr = this.getMbr();
|
|
267705
267773
|
const height2 = itemMbr.getHeight();
|
|
@@ -267780,7 +267848,7 @@ class Sticker extends BaseItem {
|
|
|
267780
267848
|
const anchorPoints = StickerShape.anchorPoints;
|
|
267781
267849
|
const points = [];
|
|
267782
267850
|
for (const anchorPoint of anchorPoints) {
|
|
267783
|
-
points.push(anchorPoint.getTransformed(this.transformation.
|
|
267851
|
+
points.push(anchorPoint.getTransformed(this.transformation.toMatrix()));
|
|
267784
267852
|
}
|
|
267785
267853
|
return points;
|
|
267786
267854
|
}
|
|
@@ -267794,20 +267862,7 @@ class Sticker extends BaseItem {
|
|
|
267794
267862
|
if (line.end.y < line.start.y) {
|
|
267795
267863
|
y -= l2 * height;
|
|
267796
267864
|
}
|
|
267797
|
-
this.transformation.
|
|
267798
|
-
class: "Transformation",
|
|
267799
|
-
method: "translateTo",
|
|
267800
|
-
item: [this.id],
|
|
267801
|
-
x,
|
|
267802
|
-
y
|
|
267803
|
-
});
|
|
267804
|
-
this.transformation.apply({
|
|
267805
|
-
class: "Transformation",
|
|
267806
|
-
method: "scaleTo",
|
|
267807
|
-
item: [this.id],
|
|
267808
|
-
x: l2,
|
|
267809
|
-
y: l2
|
|
267810
|
-
});
|
|
267865
|
+
this.transformation.setLocal(x, y, l2, l2);
|
|
267811
267866
|
this.saveStickerData();
|
|
267812
267867
|
}
|
|
267813
267868
|
applyTransformToCenter(pt, newWidth) {
|
|
@@ -267815,35 +267870,9 @@ class Sticker extends BaseItem {
|
|
|
267815
267870
|
const scale = newWidth / width;
|
|
267816
267871
|
const w = width * scale;
|
|
267817
267872
|
const h2 = height * scale;
|
|
267818
|
-
this.transformation.
|
|
267819
|
-
class: "Transformation",
|
|
267820
|
-
method: "translateTo",
|
|
267821
|
-
item: [this.id],
|
|
267822
|
-
x: pt.x - w / 2,
|
|
267823
|
-
y: pt.y - h2 / 2
|
|
267824
|
-
});
|
|
267825
|
-
this.transformation.apply({
|
|
267826
|
-
class: "Transformation",
|
|
267827
|
-
method: "scaleTo",
|
|
267828
|
-
item: [this.id],
|
|
267829
|
-
x: scale,
|
|
267830
|
-
y: scale
|
|
267831
|
-
});
|
|
267873
|
+
this.transformation.setLocal(pt.x - w / 2, pt.y - h2 / 2, scale, scale);
|
|
267832
267874
|
} else {
|
|
267833
|
-
this.transformation.
|
|
267834
|
-
class: "Transformation",
|
|
267835
|
-
method: "translateTo",
|
|
267836
|
-
item: [this.id],
|
|
267837
|
-
x: pt.x - width / 2,
|
|
267838
|
-
y: pt.y - height / 2
|
|
267839
|
-
});
|
|
267840
|
-
this.transformation.apply({
|
|
267841
|
-
class: "Transformation",
|
|
267842
|
-
method: "scaleTo",
|
|
267843
|
-
item: [this.id],
|
|
267844
|
-
x: 1,
|
|
267845
|
-
y: 1
|
|
267846
|
-
});
|
|
267875
|
+
this.transformation.setLocal(pt.x - width / 2, pt.y - height / 2, 1, 1);
|
|
267847
267876
|
}
|
|
267848
267877
|
}
|
|
267849
267878
|
doResize(resizeType, pointer, mbr, opposite, startMbr, timeStamp) {
|
|
@@ -267930,7 +267959,7 @@ async function exportBoardSnapshot({
|
|
|
267930
267959
|
const selectionMatrix = new Matrix2(translationX, translationY, scaleX, scaleY);
|
|
267931
267960
|
camera.matrix = selectionMatrix;
|
|
267932
267961
|
}
|
|
267933
|
-
const context = new
|
|
267962
|
+
const context = new DrawingContext2(camera, ctx);
|
|
267934
267963
|
context.setCamera(camera);
|
|
267935
267964
|
context.ctx.setTransform(upscaleFactor, 0, 0, upscaleFactor, 0, 0);
|
|
267936
267965
|
context.matrix.applyToContext(context.ctx);
|
|
@@ -268144,7 +268173,7 @@ class Frame2 extends BaseItem {
|
|
|
268144
268173
|
const res = this.getCanChangeRatio() ? getResize(resizeType, pointer, mbr, opposite) : getProportionalResize(resizeType, pointer, mbr, opposite);
|
|
268145
268174
|
if (!res) {
|
|
268146
268175
|
return {
|
|
268147
|
-
matrix: this.transformation.
|
|
268176
|
+
matrix: this.transformation.toMatrix(),
|
|
268148
268177
|
mbr: this.getMbr()
|
|
268149
268178
|
};
|
|
268150
268179
|
}
|
|
@@ -268243,8 +268272,9 @@ class Frame2 extends BaseItem {
|
|
|
268243
268272
|
return this;
|
|
268244
268273
|
}
|
|
268245
268274
|
getSavedProportionsMatrix() {
|
|
268246
|
-
const
|
|
268247
|
-
const
|
|
268275
|
+
const { scaleX, scaleY } = this.transformation.getMatrixData();
|
|
268276
|
+
const newScale = Math.min(scaleX, scaleY);
|
|
268277
|
+
const newMatrix = this.transformation.toMatrix();
|
|
268248
268278
|
newMatrix.scaleX = newScale;
|
|
268249
268279
|
newMatrix.scaleY = newScale;
|
|
268250
268280
|
return newMatrix;
|
|
@@ -268258,8 +268288,8 @@ class Frame2 extends BaseItem {
|
|
|
268258
268288
|
this.textContainer.transform(newMatrix);
|
|
268259
268289
|
this.transformation.applyScaleTo(newMatrix.scaleX, newMatrix.scaleY);
|
|
268260
268290
|
} else {
|
|
268261
|
-
this.path.transform(this.transformation.
|
|
268262
|
-
this.textContainer.transform(this.transformation.
|
|
268291
|
+
this.path.transform(this.transformation.toMatrix());
|
|
268292
|
+
this.textContainer.transform(this.transformation.toMatrix());
|
|
268263
268293
|
}
|
|
268264
268294
|
this.path.setBackgroundColor(this.backgroundColor);
|
|
268265
268295
|
this.path.setBackgroundOpacity(this.backgroundOpacity);
|
|
@@ -268315,7 +268345,7 @@ class Frame2 extends BaseItem {
|
|
|
268315
268345
|
const anchorPoints = Frames[this.shapeType].anchorPoints;
|
|
268316
268346
|
const points = [];
|
|
268317
268347
|
for (const anchorPoint of anchorPoints) {
|
|
268318
|
-
points.push(anchorPoint.getTransformed(this.transformation.
|
|
268348
|
+
points.push(anchorPoint.getTransformed(this.transformation.toMatrix()));
|
|
268319
268349
|
}
|
|
268320
268350
|
return points;
|
|
268321
268351
|
}
|
|
@@ -268491,7 +268521,7 @@ class Frame2 extends BaseItem {
|
|
|
268491
268521
|
div.style.borderColor = this.borderColor;
|
|
268492
268522
|
div.style.borderWidth = `${this.borderWidth}px`;
|
|
268493
268523
|
div.style.borderStyle = this.borderStyle;
|
|
268494
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
268524
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
268495
268525
|
const transform = `translate(${Math.round(translateX)}px, ${Math.round(translateY)}px) scale(1, 1)`;
|
|
268496
268526
|
const width2 = this.getMbr().getWidth();
|
|
268497
268527
|
const height2 = this.getMbr().getHeight();
|
|
@@ -268801,13 +268831,13 @@ class VideoItem extends BaseItem {
|
|
|
268801
268831
|
this.shootLoadCallbacks();
|
|
268802
268832
|
};
|
|
268803
268833
|
updateMbr() {
|
|
268804
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
268834
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
268805
268835
|
this.left = translateX;
|
|
268806
268836
|
this.top = translateY;
|
|
268807
268837
|
this.right = this.left + this.videoDimension.width * scaleX;
|
|
268808
268838
|
this.bottom = this.top + this.videoDimension.height * scaleY;
|
|
268809
268839
|
const playBtnSize = 50;
|
|
268810
|
-
const scaledPlayBtn = playBtnSize * this.transformation.
|
|
268840
|
+
const scaledPlayBtn = playBtnSize * this.transformation.getMatrixData().scaleX;
|
|
268811
268841
|
this.playBtnMbr = new Mbr(this.left + this.getWidth() / 2 - scaledPlayBtn / 2, this.top + this.getHeight() / 2 - scaledPlayBtn / 2, this.right - this.getWidth() / 2 + scaledPlayBtn / 2, this.bottom - this.getHeight() / 2 + scaledPlayBtn / 2);
|
|
268812
268842
|
}
|
|
268813
268843
|
render(context) {
|
|
@@ -268823,7 +268853,7 @@ class VideoItem extends BaseItem {
|
|
|
268823
268853
|
return;
|
|
268824
268854
|
}
|
|
268825
268855
|
ctx.save();
|
|
268826
|
-
this.transformation.
|
|
268856
|
+
this.transformation.applyToContext(ctx);
|
|
268827
268857
|
ctx.drawImage(this.preview, 0, 0);
|
|
268828
268858
|
if (this.shouldShowControls && this.previewUrl) {
|
|
268829
268859
|
ctx.restore();
|
|
@@ -268844,7 +268874,7 @@ class VideoItem extends BaseItem {
|
|
|
268844
268874
|
}
|
|
268845
268875
|
renderHTML(documentFactory) {
|
|
268846
268876
|
const div = documentFactory.createElement("video-item");
|
|
268847
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
268877
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
268848
268878
|
const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
268849
268879
|
div.style.backgroundImage = this.previewUrl ? `url(${this.previewUrl})` : `url(${createPlaceholderImage(this.videoDimension.width, this.videoDimension.height).src})`;
|
|
268850
268880
|
div.id = this.getId();
|
|
@@ -269289,7 +269319,7 @@ class AudioItem extends BaseItem {
|
|
|
269289
269319
|
this.shootLoadCallbacks();
|
|
269290
269320
|
};
|
|
269291
269321
|
updateMbr() {
|
|
269292
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
269322
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
269293
269323
|
this.left = translateX;
|
|
269294
269324
|
this.top = translateY;
|
|
269295
269325
|
this.right = this.left + conf.AUDIO_DIMENSIONS.width * scaleX;
|
|
@@ -269319,7 +269349,7 @@ class AudioItem extends BaseItem {
|
|
|
269319
269349
|
}
|
|
269320
269350
|
renderHTML(documentFactory) {
|
|
269321
269351
|
const div = documentFactory.createElement("audio-item");
|
|
269322
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
269352
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
269323
269353
|
const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
269324
269354
|
div.id = this.getId();
|
|
269325
269355
|
div.style.width = `${conf.AUDIO_DIMENSIONS.width}px`;
|
|
@@ -269669,7 +269699,7 @@ class Placeholder extends BaseItem {
|
|
|
269669
269699
|
const anchorPoints = Shapes[this.shapeType].anchorPoints;
|
|
269670
269700
|
const points = [];
|
|
269671
269701
|
for (const anchorPoint of anchorPoints) {
|
|
269672
|
-
points.push(anchorPoint.getTransformed(this.transformation.
|
|
269702
|
+
points.push(anchorPoint.getTransformed(this.transformation.toMatrix()));
|
|
269673
269703
|
}
|
|
269674
269704
|
return points;
|
|
269675
269705
|
}
|
|
@@ -269687,7 +269717,7 @@ class Placeholder extends BaseItem {
|
|
|
269687
269717
|
}
|
|
269688
269718
|
transformPath() {
|
|
269689
269719
|
this.path = Shapes[this.shapeType].createPath(this.mbr);
|
|
269690
|
-
this.path.transform(this.transformation.
|
|
269720
|
+
this.path.transform(this.transformation.toMatrix());
|
|
269691
269721
|
this.path.setBackgroundColor(this.backgroundColor);
|
|
269692
269722
|
this.path.setBorderColor("transparent");
|
|
269693
269723
|
}
|
|
@@ -269754,7 +269784,7 @@ class Placeholder extends BaseItem {
|
|
|
269754
269784
|
function getPlaceholderImage(board, imageDimension) {
|
|
269755
269785
|
const placeholderCanvas = conf.documentFactory.createElement("canvas");
|
|
269756
269786
|
const placeholderContext = placeholderCanvas.getContext("2d");
|
|
269757
|
-
const context = new
|
|
269787
|
+
const context = new DrawingContext2(board.camera, placeholderContext);
|
|
269758
269788
|
const placeholder = new Placeholder(board);
|
|
269759
269789
|
if (imageDimension) {
|
|
269760
269790
|
placeholderCanvas.width = imageDimension.width;
|
|
@@ -269882,7 +269912,7 @@ class ImageItem extends BaseItem {
|
|
|
269882
269912
|
this.subject.publish(this);
|
|
269883
269913
|
};
|
|
269884
269914
|
updateMbr() {
|
|
269885
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
269915
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
269886
269916
|
const rotation = this.transformation.getRotation();
|
|
269887
269917
|
const width2 = this.image.width * scaleX;
|
|
269888
269918
|
const height2 = this.image.height * scaleY;
|
|
@@ -269925,10 +269955,11 @@ class ImageItem extends BaseItem {
|
|
|
269925
269955
|
};
|
|
269926
269956
|
}
|
|
269927
269957
|
setCoordinates() {
|
|
269928
|
-
|
|
269929
|
-
this.
|
|
269930
|
-
this.
|
|
269931
|
-
this.
|
|
269958
|
+
const { translateX: coordX, translateY: coordY, scaleX: coordScaleX, scaleY: coordScaleY } = this.transformation.getMatrixData();
|
|
269959
|
+
this.left = coordX;
|
|
269960
|
+
this.top = coordY;
|
|
269961
|
+
this.right = this.left + this.image.width * coordScaleX;
|
|
269962
|
+
this.bottom = this.top + this.image.height * coordScaleY;
|
|
269932
269963
|
this.subject.publish(this);
|
|
269933
269964
|
}
|
|
269934
269965
|
shootBeforeLoadCallbacks() {
|
|
@@ -269995,7 +270026,7 @@ class ImageItem extends BaseItem {
|
|
|
269995
270026
|
}
|
|
269996
270027
|
const ctx = context.ctx;
|
|
269997
270028
|
ctx.save();
|
|
269998
|
-
this.transformation.
|
|
270029
|
+
this.transformation.applyToContext(ctx);
|
|
269999
270030
|
const rotation = this.transformation.getRotation();
|
|
270000
270031
|
if (rotation !== 0) {
|
|
270001
270032
|
const imgWidth = this.image.width || 0;
|
|
@@ -270013,7 +270044,7 @@ class ImageItem extends BaseItem {
|
|
|
270013
270044
|
}
|
|
270014
270045
|
renderHTML(documentFactory) {
|
|
270015
270046
|
const div = documentFactory.createElement("image-item");
|
|
270016
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
270047
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
270017
270048
|
const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
270018
270049
|
div.style.backgroundImage = `url(${this.storageLink})`;
|
|
270019
270050
|
div.id = this.getId();
|
|
@@ -270164,7 +270195,7 @@ class Drawing extends BaseItem {
|
|
|
270164
270195
|
untransformedMbr.top -= offset;
|
|
270165
270196
|
untransformedMbr.right += offset;
|
|
270166
270197
|
untransformedMbr.bottom += offset;
|
|
270167
|
-
const mbr = untransformedMbr.getTransformed(this.transformation.
|
|
270198
|
+
const mbr = untransformedMbr.getTransformed(this.transformation.toMatrix());
|
|
270168
270199
|
this.left = mbr.left;
|
|
270169
270200
|
this.top = mbr.top;
|
|
270170
270201
|
this.right = mbr.right;
|
|
@@ -270211,7 +270242,7 @@ class Drawing extends BaseItem {
|
|
|
270211
270242
|
}
|
|
270212
270243
|
updateLines() {
|
|
270213
270244
|
this.lines = [];
|
|
270214
|
-
const matrix = this.transformation.
|
|
270245
|
+
const matrix = this.transformation.toMatrix();
|
|
270215
270246
|
if (this.points.length < 2) {
|
|
270216
270247
|
return;
|
|
270217
270248
|
}
|
|
@@ -270259,7 +270290,7 @@ class Drawing extends BaseItem {
|
|
|
270259
270290
|
ctx.lineWidth = this.strokeWidth;
|
|
270260
270291
|
ctx.lineCap = "round";
|
|
270261
270292
|
ctx.setLineDash(this.linePattern);
|
|
270262
|
-
this.transformation.
|
|
270293
|
+
this.transformation.applyToContext(ctx);
|
|
270263
270294
|
ctx.stroke(this.path2d.nativePath);
|
|
270264
270295
|
ctx.restore();
|
|
270265
270296
|
if (this.getLinkTo()) {
|
|
@@ -270269,7 +270300,7 @@ class Drawing extends BaseItem {
|
|
|
270269
270300
|
}
|
|
270270
270301
|
renderHTML(documentFactory) {
|
|
270271
270302
|
const div = documentFactory.createElement("drawing-item");
|
|
270272
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
270303
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
270273
270304
|
const mbr = this.getMbr();
|
|
270274
270305
|
const width2 = mbr.getWidth();
|
|
270275
270306
|
const height2 = mbr.getHeight();
|
|
@@ -270458,8 +270489,9 @@ class Drawing extends BaseItem {
|
|
|
270458
270489
|
return null;
|
|
270459
270490
|
}
|
|
270460
270491
|
isPointNearLine(point5, threshold = 10) {
|
|
270461
|
-
const
|
|
270462
|
-
const
|
|
270492
|
+
const { translateX: drawingTranslateX, translateY: drawingTranslateY, scaleX: drawingScaleX, scaleY: drawingScaleY } = this.transformation.getMatrixData();
|
|
270493
|
+
const transformedMouseX = (point5.x - drawingTranslateX) / drawingScaleX;
|
|
270494
|
+
const transformedMouseY = (point5.y - drawingTranslateY) / drawingScaleY;
|
|
270463
270495
|
const transformedMouse = new Point3(transformedMouseX, transformedMouseY);
|
|
270464
270496
|
for (let i = 0;i < this.points.length - 1; i++) {
|
|
270465
270497
|
const p1 = this.points[i];
|
|
@@ -271779,40 +271811,16 @@ class AddFrame extends BoardTool {
|
|
|
271779
271811
|
this.applyTranslateBy(-this.frame.getMbr().getWidth() / 2, -this.frame.getMbr().getHeight() / 2);
|
|
271780
271812
|
}
|
|
271781
271813
|
applyScaleTo(x, y) {
|
|
271782
|
-
this.frame.transformation.
|
|
271783
|
-
class: "Transformation",
|
|
271784
|
-
method: "scaleTo",
|
|
271785
|
-
item: [this.frame.getId()],
|
|
271786
|
-
x,
|
|
271787
|
-
y
|
|
271788
|
-
});
|
|
271814
|
+
this.frame.transformation.setLocal({ scaleX: x, scaleY: y });
|
|
271789
271815
|
}
|
|
271790
271816
|
applyScaleBy(x, y) {
|
|
271791
|
-
this.frame.transformation.
|
|
271792
|
-
class: "Transformation",
|
|
271793
|
-
method: "scaleBy",
|
|
271794
|
-
item: [this.frame.getId()],
|
|
271795
|
-
x,
|
|
271796
|
-
y
|
|
271797
|
-
});
|
|
271817
|
+
this.frame.transformation.scaleBy(x, y);
|
|
271798
271818
|
}
|
|
271799
271819
|
applyTranslateTo(x, y) {
|
|
271800
|
-
this.frame.transformation.
|
|
271801
|
-
class: "Transformation",
|
|
271802
|
-
method: "translateTo",
|
|
271803
|
-
item: [this.frame.getId()],
|
|
271804
|
-
x,
|
|
271805
|
-
y
|
|
271806
|
-
});
|
|
271820
|
+
this.frame.transformation.setLocal(x, y);
|
|
271807
271821
|
}
|
|
271808
271822
|
applyTranslateBy(x, y) {
|
|
271809
|
-
this.frame.transformation.
|
|
271810
|
-
class: "Transformation",
|
|
271811
|
-
method: "translateBy",
|
|
271812
|
-
item: [this.frame.getId()],
|
|
271813
|
-
x,
|
|
271814
|
-
y
|
|
271815
|
-
});
|
|
271823
|
+
this.frame.transformation.translateBy(x, y);
|
|
271816
271824
|
}
|
|
271817
271825
|
applyAddChildren(children) {
|
|
271818
271826
|
const childrenIds = children.map((child) => {
|
|
@@ -271880,20 +271888,7 @@ class AddShape extends BoardTool {
|
|
|
271880
271888
|
initTransformation(sx, sy) {
|
|
271881
271889
|
sx = sx || this.bounds.getWidth() / 100;
|
|
271882
271890
|
sy = sy || this.bounds.getHeight() / 100;
|
|
271883
|
-
this.shape.transformation.
|
|
271884
|
-
class: "Transformation",
|
|
271885
|
-
method: "translateTo",
|
|
271886
|
-
item: [this.shape.getId()],
|
|
271887
|
-
x: this.bounds.left,
|
|
271888
|
-
y: this.bounds.top
|
|
271889
|
-
});
|
|
271890
|
-
this.shape.transformation.apply({
|
|
271891
|
-
class: "Transformation",
|
|
271892
|
-
method: "scaleTo",
|
|
271893
|
-
item: [this.shape.getId()],
|
|
271894
|
-
x: sx,
|
|
271895
|
-
y: sy
|
|
271896
|
-
});
|
|
271891
|
+
this.shape.transformation.setLocal(this.bounds.left, this.bounds.top, sx, sy);
|
|
271897
271892
|
}
|
|
271898
271893
|
leftButtonDown() {
|
|
271899
271894
|
if (this.type === "None") {
|
|
@@ -272416,11 +272411,11 @@ class ExportSnapshot extends Tool {
|
|
|
272416
272411
|
const cameraCenter = this.board.camera.getMbr().getCenter();
|
|
272417
272412
|
this.mbr = new Mbr(cameraCenter.x - conf.EXPORT_SELECTION_BOX_WIDTH / 2, cameraCenter.y - conf.EXPORT_SELECTION_BOX_HEIGHT / 2, cameraCenter.x + conf.EXPORT_SELECTION_BOX_WIDTH / 2, cameraCenter.y + conf.EXPORT_SELECTION_BOX_HEIGHT / 2, "transparent", "transparent", 1);
|
|
272418
272413
|
this.board.selection.disable();
|
|
272419
|
-
this.tempDrawingContext = new
|
|
272414
|
+
this.tempDrawingContext = new DrawingContext2(board.camera, this.tempCtx);
|
|
272420
272415
|
}
|
|
272421
272416
|
rectMoveTo(x, y) {
|
|
272422
272417
|
this.transformation.translateTo(x, y);
|
|
272423
|
-
this.mbr.transform(this.transformation.
|
|
272418
|
+
this.mbr.transform(this.transformation.toMatrix());
|
|
272424
272419
|
this.board.tools.publish();
|
|
272425
272420
|
}
|
|
272426
272421
|
resize() {
|
|
@@ -272702,7 +272697,7 @@ function createCanvasDrawer(board) {
|
|
|
272702
272697
|
const camera = new Camera;
|
|
272703
272698
|
const newCameraMatix = new Matrix2(-mbr.left, -mbr.top, 1, 1);
|
|
272704
272699
|
camera.matrix = newCameraMatix;
|
|
272705
|
-
const context = new
|
|
272700
|
+
const context = new DrawingContext2(camera, ctx);
|
|
272706
272701
|
context.setCamera(camera);
|
|
272707
272702
|
context.ctx.setTransform(board2.camera.getMatrix().scaleX, 0, 0, board2.camera.getMatrix().scaleY, 0, 0);
|
|
272708
272703
|
context.matrix.applyToContext(context.ctx);
|
|
@@ -274599,20 +274594,7 @@ class ShapeTool extends CustomTool {
|
|
|
274599
274594
|
initTransformation(sx, sy) {
|
|
274600
274595
|
sx = sx || this.bounds.getWidth() / 100;
|
|
274601
274596
|
sy = sy || this.bounds.getHeight() / 100;
|
|
274602
|
-
this.item.transformation.
|
|
274603
|
-
class: "Transformation",
|
|
274604
|
-
method: "translateTo",
|
|
274605
|
-
item: [this.item.getId()],
|
|
274606
|
-
x: this.bounds.left,
|
|
274607
|
-
y: this.bounds.top
|
|
274608
|
-
});
|
|
274609
|
-
this.item.transformation.apply({
|
|
274610
|
-
class: "Transformation",
|
|
274611
|
-
method: "scaleTo",
|
|
274612
|
-
item: [this.item.getId()],
|
|
274613
|
-
x: sx,
|
|
274614
|
-
y: sy
|
|
274615
|
-
});
|
|
274597
|
+
this.item.transformation.setLocal(this.bounds.left, this.bounds.top, sx, sy);
|
|
274616
274598
|
}
|
|
274617
274599
|
pointerDown() {
|
|
274618
274600
|
this.isDown = true;
|
|
@@ -274683,22 +274665,10 @@ class StickerTool extends CustomTool {
|
|
|
274683
274665
|
}
|
|
274684
274666
|
pointerDown() {
|
|
274685
274667
|
const point5 = this.board.pointer.point;
|
|
274686
|
-
this.item.transformation.
|
|
274687
|
-
class: "Transformation",
|
|
274688
|
-
method: "translateTo",
|
|
274689
|
-
item: [this.item.getId()],
|
|
274690
|
-
x: point5.x - this.settings.width / 2,
|
|
274691
|
-
y: point5.y - this.settings.height / 2
|
|
274692
|
-
});
|
|
274668
|
+
this.item.transformation.setLocal(point5.x - this.settings.width / 2, point5.y - this.settings.height / 2);
|
|
274693
274669
|
const width2 = this.item.getWidth();
|
|
274694
274670
|
const height3 = this.item.getHeight();
|
|
274695
|
-
this.item.transformation.
|
|
274696
|
-
class: "Transformation",
|
|
274697
|
-
method: "scaleBy",
|
|
274698
|
-
item: [this.item.getId()],
|
|
274699
|
-
x: width2 / this.settings.width,
|
|
274700
|
-
y: height3 / this.settings.height
|
|
274701
|
-
});
|
|
274671
|
+
this.item.transformation.scaleBy(width2 / this.settings.width, height3 / this.settings.height);
|
|
274702
274672
|
const addedItem = this.board.add(this.item);
|
|
274703
274673
|
this.board.selection.removeAll();
|
|
274704
274674
|
this.board.selection.add(addedItem);
|
|
@@ -275307,7 +275277,7 @@ class Star2 extends BaseItem {
|
|
|
275307
275277
|
}
|
|
275308
275278
|
transformPath() {
|
|
275309
275279
|
this.path = starPath.copy();
|
|
275310
|
-
this.path.transform(this.transformation.
|
|
275280
|
+
this.path.transform(this.transformation.toMatrix());
|
|
275311
275281
|
this.path.setBackgroundColor(this.backgroundColor);
|
|
275312
275282
|
this.path.setBorderColor(this.borderColor);
|
|
275313
275283
|
this.path.setBorderWidth(this.borderWidth);
|
|
@@ -275335,7 +275305,7 @@ class Star2 extends BaseItem {
|
|
|
275335
275305
|
}
|
|
275336
275306
|
renderHTML(documentFactory) {
|
|
275337
275307
|
const div = documentFactory.createElement("star-item");
|
|
275338
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
275308
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
275339
275309
|
const mbr = this.getMbr();
|
|
275340
275310
|
const unscaledWidth = mbr.getWidth() / scaleX;
|
|
275341
275311
|
const unscaledHeight = mbr.getHeight() / scaleY;
|
|
@@ -275422,13 +275392,7 @@ class AddCounter extends StickerTool {
|
|
|
275422
275392
|
const x = (left + right) / 2 - COUNTER_DIMENSIONS.width / 2;
|
|
275423
275393
|
const y = (top + bottom) / 2 - COUNTER_DIMENSIONS.height / 2;
|
|
275424
275394
|
const counter2 = new Counter(this.board, "");
|
|
275425
|
-
counter2.transformation.
|
|
275426
|
-
class: "Transformation",
|
|
275427
|
-
method: "translateTo",
|
|
275428
|
-
item: [counter2.getId()],
|
|
275429
|
-
x,
|
|
275430
|
-
y
|
|
275431
|
-
});
|
|
275395
|
+
counter2.transformation.setLocal(x, y);
|
|
275432
275396
|
const addedCounter = this.board.add(counter2);
|
|
275433
275397
|
this.board.selection.add(addedCounter);
|
|
275434
275398
|
}
|
|
@@ -275466,7 +275430,7 @@ class Counter extends BaseItem {
|
|
|
275466
275430
|
}
|
|
275467
275431
|
}
|
|
275468
275432
|
updateMbr() {
|
|
275469
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
275433
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
275470
275434
|
this.left = translateX;
|
|
275471
275435
|
this.top = translateY;
|
|
275472
275436
|
this.right = this.left + COUNTER_DIMENSIONS.width * scaleX;
|
|
@@ -275658,7 +275622,7 @@ class Card extends BaseItem {
|
|
|
275658
275622
|
}
|
|
275659
275623
|
renderHTML(documentFactory) {
|
|
275660
275624
|
const div = super.renderHTML(documentFactory);
|
|
275661
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
275625
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
275662
275626
|
const transform = `translate(${translateX}px, ${translateY}px) scale(${scaleX}, ${scaleY})`;
|
|
275663
275627
|
div.style.backgroundImage = `url(${this.imageToRender?.src || this.backsideUrl})`;
|
|
275664
275628
|
div.id = this.getId();
|
|
@@ -275672,7 +275636,7 @@ class Card extends BaseItem {
|
|
|
275672
275636
|
return div;
|
|
275673
275637
|
}
|
|
275674
275638
|
updateMbr() {
|
|
275675
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
275639
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
275676
275640
|
const rotation = this.transformation.getRotation();
|
|
275677
275641
|
const height3 = this.dimensions.height * scaleY;
|
|
275678
275642
|
const width2 = this.dimensions.width * scaleX;
|
|
@@ -275822,24 +275786,12 @@ class Deck extends BaseItem {
|
|
|
275822
275786
|
const canAddItem = !this.index?.getById(childId) && foundItem instanceof Card && (typeof this.isPerpendicular === "undefined" || this.isPerpendicular === foundItem.getIsRotatedPerpendicular()) && (!firstCardDimensions || firstCardDimensions.width === foundItem.getDimensions().width && firstCardDimensions.height === foundItem.getDimensions().height);
|
|
275823
275787
|
if (canAddItem) {
|
|
275824
275788
|
this.isPerpendicular = foundItem.getIsRotatedPerpendicular();
|
|
275825
|
-
foundItem.transformation.
|
|
275826
|
-
class: "Transformation",
|
|
275827
|
-
method: "translateTo",
|
|
275828
|
-
item: [this.id],
|
|
275829
|
-
x: this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET),
|
|
275830
|
-
y: this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0)
|
|
275831
|
-
});
|
|
275789
|
+
foundItem.transformation.setLocal(this.left + (this.index?.list().length || 0) * (this.isPerpendicular ? 0 : conf.DECK_HORIZONTAL_OFFSET), this.top + (this.index?.list().length || 0) * (this.isPerpendicular ? conf.DECK_VERTICAL_OFFSET : 0));
|
|
275832
275790
|
if (firstCard) {
|
|
275833
|
-
const { scaleX, scaleY } = foundItem.transformation.
|
|
275834
|
-
const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.
|
|
275791
|
+
const { scaleX, scaleY } = foundItem.transformation.getMatrixData();
|
|
275792
|
+
const { scaleX: targetScaleX, scaleY: targetScaleY } = firstCard.transformation.getMatrixData();
|
|
275835
275793
|
if (scaleX !== targetScaleX || scaleY !== targetScaleY) {
|
|
275836
|
-
foundItem.transformation.
|
|
275837
|
-
class: "Transformation",
|
|
275838
|
-
method: "scaleTo",
|
|
275839
|
-
item: [this.id],
|
|
275840
|
-
x: targetScaleX,
|
|
275841
|
-
y: targetScaleY
|
|
275842
|
-
});
|
|
275794
|
+
foundItem.transformation.setLocal({ scaleX: targetScaleX, scaleY: targetScaleY });
|
|
275843
275795
|
}
|
|
275844
275796
|
}
|
|
275845
275797
|
this.board.selection.remove(foundItem);
|
|
@@ -275941,7 +275893,7 @@ class Deck extends BaseItem {
|
|
|
275941
275893
|
this.subject.publish(this);
|
|
275942
275894
|
}
|
|
275943
275895
|
updateMbr() {
|
|
275944
|
-
const { translateX, translateY } = this.transformation.
|
|
275896
|
+
const { translateX, translateY } = this.transformation.getMatrixData();
|
|
275945
275897
|
const items = this.index.list();
|
|
275946
275898
|
const itemsMbr = items[0]?.getMbr().combine(items.slice(1).map((item) => item.getMbr()));
|
|
275947
275899
|
this.left = translateX;
|
|
@@ -276015,7 +275967,7 @@ class Deck extends BaseItem {
|
|
|
276015
275967
|
if (!topCard) {
|
|
276016
275968
|
return div;
|
|
276017
275969
|
}
|
|
276018
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
275970
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
276019
275971
|
const transform = `translate(${translateX}px, ${translateY}px) scale(1, 1)`;
|
|
276020
275972
|
const topCardElement = topCard.renderHTML(documentFactory);
|
|
276021
275973
|
div.appendChild(topCardElement);
|
|
@@ -276170,13 +276122,7 @@ function createDeck(event, board) {
|
|
|
276170
276122
|
const onlyCards = board.selection.items.isAllItemsType("Card");
|
|
276171
276123
|
if (onlyCards) {
|
|
276172
276124
|
const deck = new Deck(board, "");
|
|
276173
|
-
deck.transformation.
|
|
276174
|
-
class: "Transformation",
|
|
276175
|
-
method: "translateTo",
|
|
276176
|
-
item: [deck.getId()],
|
|
276177
|
-
x: cardsOrDecks[cardsOrDecks.length - 1].left,
|
|
276178
|
-
y: cardsOrDecks[cardsOrDecks.length - 1].top
|
|
276179
|
-
});
|
|
276125
|
+
deck.transformation.setLocal(cardsOrDecks[cardsOrDecks.length - 1].left, cardsOrDecks[cardsOrDecks.length - 1].top);
|
|
276180
276126
|
const addedDeck = board.add(deck);
|
|
276181
276127
|
board.selection.items.removeAll();
|
|
276182
276128
|
addedDeck.addChildItems(cardsOrDecks);
|
|
@@ -276261,7 +276207,7 @@ class Dice extends BaseItem {
|
|
|
276261
276207
|
}
|
|
276262
276208
|
transformPath() {
|
|
276263
276209
|
this.path = createRoundedRectanglePath(this).copy();
|
|
276264
|
-
this.path.transform(this.transformation.
|
|
276210
|
+
this.path.transform(this.transformation.toMatrix());
|
|
276265
276211
|
this.path.setBackgroundColor(this.backgroundColor);
|
|
276266
276212
|
this.path.setBorderColor(this.borderColor);
|
|
276267
276213
|
this.path.setBorderWidth(this.borderWidth);
|
|
@@ -276483,7 +276429,7 @@ class Dice extends BaseItem {
|
|
|
276483
276429
|
}
|
|
276484
276430
|
renderHTML(documentFactory) {
|
|
276485
276431
|
const div = super.renderHTML(documentFactory);
|
|
276486
|
-
const { translateX, translateY, scaleX, scaleY } = this.transformation.
|
|
276432
|
+
const { translateX, translateY, scaleX, scaleY } = this.transformation.getMatrixData();
|
|
276487
276433
|
const mbr = this.getMbr();
|
|
276488
276434
|
const width2 = mbr.getWidth();
|
|
276489
276435
|
const height3 = mbr.getHeight();
|
|
@@ -276732,7 +276678,7 @@ class Screen extends BaseItem {
|
|
|
276732
276678
|
}
|
|
276733
276679
|
transformPath() {
|
|
276734
276680
|
this.path = screenPath.copy();
|
|
276735
|
-
this.path.transform(this.transformation.
|
|
276681
|
+
this.path.transform(this.transformation.toMatrix());
|
|
276736
276682
|
this.path.setBackgroundColor(this.backgroundColor);
|
|
276737
276683
|
this.path.setBorderColor(this.borderColor);
|
|
276738
276684
|
this.path.setBorderWidth(this.borderWidth);
|
|
@@ -276846,8 +276792,11 @@ class Camera {
|
|
|
276846
276792
|
boardId = "";
|
|
276847
276793
|
observableItem = null;
|
|
276848
276794
|
throttledZoom;
|
|
276849
|
-
isAnimating = false;
|
|
276850
276795
|
isTrackingAnimation = false;
|
|
276796
|
+
localAnimationTarget = null;
|
|
276797
|
+
localAnimationId = null;
|
|
276798
|
+
localLastTime = null;
|
|
276799
|
+
localSpringVelocity = { translateX: 0, translateY: 0, scaleX: 0, scaleY: 0 };
|
|
276851
276800
|
trackingAnimationId = null;
|
|
276852
276801
|
trackingTarget = null;
|
|
276853
276802
|
lastTrackingTime = null;
|
|
@@ -276927,7 +276876,7 @@ class Camera {
|
|
|
276927
276876
|
}
|
|
276928
276877
|
view(_left, _top, _scale) {}
|
|
276929
276878
|
zoomRelativeToPointerBy(scale) {
|
|
276930
|
-
this.zoomRelativeToPointBy(scale, this.pointer.x, this.pointer.y
|
|
276879
|
+
this.zoomRelativeToPointBy(scale, this.pointer.x, this.pointer.y);
|
|
276931
276880
|
}
|
|
276932
276881
|
zoomRelativeToPointBy(scale, x, y, duration = 400) {
|
|
276933
276882
|
const startScaleX = this.matrix.scaleX;
|
|
@@ -276953,23 +276902,12 @@ class Camera {
|
|
|
276953
276902
|
this.subject.publish(this);
|
|
276954
276903
|
return;
|
|
276955
276904
|
}
|
|
276956
|
-
|
|
276957
|
-
|
|
276958
|
-
|
|
276959
|
-
|
|
276960
|
-
|
|
276961
|
-
|
|
276962
|
-
const easedProgress = this.easeOutQuad(progress);
|
|
276963
|
-
this.matrix.translateX = this.lerp(startTranslateX, targetTranslateX, easedProgress);
|
|
276964
|
-
this.matrix.translateY = this.lerp(startTranslateY, targetTranslateY, easedProgress);
|
|
276965
|
-
this.matrix.scaleX = this.lerp(startScaleX, finalScaleX, easedProgress);
|
|
276966
|
-
this.matrix.scaleY = this.lerp(startScaleY, finalScaleY, easedProgress);
|
|
276967
|
-
this.subject.publish(this);
|
|
276968
|
-
if (progress < 1) {
|
|
276969
|
-
safeRequestAnimationFrame(animate);
|
|
276970
|
-
}
|
|
276971
|
-
};
|
|
276972
|
-
safeRequestAnimationFrame(animate);
|
|
276905
|
+
this.animateLocalToTarget({
|
|
276906
|
+
translateX: targetTranslateX,
|
|
276907
|
+
translateY: targetTranslateY,
|
|
276908
|
+
scaleX: finalScaleX,
|
|
276909
|
+
scaleY: finalScaleY
|
|
276910
|
+
});
|
|
276973
276911
|
}
|
|
276974
276912
|
saveDownEvent(event) {
|
|
276975
276913
|
this.touchEvents.set(event.pointerId, event);
|
|
@@ -277199,13 +277137,6 @@ class Camera {
|
|
|
277199
277137
|
}
|
|
277200
277138
|
}
|
|
277201
277139
|
viewRectangle(mbr, offsetInPercent = 10, duration = 500) {
|
|
277202
|
-
if (duration <= 0) {
|
|
277203
|
-
duration = 1;
|
|
277204
|
-
}
|
|
277205
|
-
if (this.isAnimating) {
|
|
277206
|
-
return;
|
|
277207
|
-
}
|
|
277208
|
-
this.isAnimating = true;
|
|
277209
277140
|
if (mbr.left === mbr.right && mbr.bottom === mbr.top) {
|
|
277210
277141
|
mbr.left -= 100;
|
|
277211
277142
|
mbr.right += 100;
|
|
@@ -277228,9 +277159,6 @@ class Camera {
|
|
|
277228
277159
|
targetScale = Math.min(targetScale, this.maxScale);
|
|
277229
277160
|
const translationX = this.window.width / 2 - (mbrWithOffset.left + mbrWidth / 2) * targetScale;
|
|
277230
277161
|
const translationY = this.window.height / 2 - (mbrWithOffset.top + mbrHeight / 2) * targetScale;
|
|
277231
|
-
const startTranslationX = this.matrix.translateX;
|
|
277232
|
-
const startTranslationY = this.matrix.translateY;
|
|
277233
|
-
const startScale = this.matrix.scaleX;
|
|
277234
277162
|
if (duration === 0) {
|
|
277235
277163
|
this.matrix.translateX = translationX;
|
|
277236
277164
|
this.matrix.translateY = translationY;
|
|
@@ -277239,29 +277167,76 @@ class Camera {
|
|
|
277239
277167
|
this.subject.publish(this);
|
|
277240
277168
|
return;
|
|
277241
277169
|
}
|
|
277242
|
-
|
|
277243
|
-
|
|
277244
|
-
|
|
277245
|
-
|
|
277246
|
-
|
|
277247
|
-
|
|
277248
|
-
|
|
277249
|
-
|
|
277250
|
-
|
|
277170
|
+
this.animateLocalToTarget({
|
|
277171
|
+
translateX: translationX,
|
|
277172
|
+
translateY: translationY,
|
|
277173
|
+
scaleX: targetScale,
|
|
277174
|
+
scaleY: targetScale
|
|
277175
|
+
});
|
|
277176
|
+
}
|
|
277177
|
+
cancelLocalAnimation() {
|
|
277178
|
+
if (this.localAnimationId !== null) {
|
|
277179
|
+
cancelAnimationFrame(this.localAnimationId);
|
|
277180
|
+
this.localAnimationId = null;
|
|
277181
|
+
}
|
|
277182
|
+
this.localAnimationTarget = null;
|
|
277183
|
+
this.localLastTime = null;
|
|
277184
|
+
this.localSpringVelocity = { translateX: 0, translateY: 0, scaleX: 0, scaleY: 0 };
|
|
277185
|
+
}
|
|
277186
|
+
animateLocalToTarget(target) {
|
|
277187
|
+
this.localAnimationTarget = target;
|
|
277188
|
+
if (this.localAnimationId !== null) {
|
|
277189
|
+
return;
|
|
277190
|
+
}
|
|
277191
|
+
this.localLastTime = null;
|
|
277192
|
+
const STIFFNESS = 150;
|
|
277193
|
+
const DAMPING = 28;
|
|
277194
|
+
const SNAP_PX = 0.5;
|
|
277195
|
+
const SNAP_SCALE = 0.0005;
|
|
277196
|
+
const SNAP_VEL = 1;
|
|
277197
|
+
const springStep = (pos, tgt, vel, dt) => {
|
|
277198
|
+
const acc = STIFFNESS * (tgt - pos) - DAMPING * vel;
|
|
277199
|
+
const newVel = vel + acc * dt;
|
|
277200
|
+
return [pos + newVel * dt, newVel];
|
|
277201
|
+
};
|
|
277202
|
+
const loop = () => {
|
|
277203
|
+
const tgt = this.localAnimationTarget;
|
|
277204
|
+
if (!tgt) {
|
|
277205
|
+
this.localAnimationId = null;
|
|
277206
|
+
return;
|
|
277207
|
+
}
|
|
277208
|
+
const now = performance.now();
|
|
277209
|
+
const dt = Math.min(this.localLastTime !== null ? now - this.localLastTime : 16, 50) / 1000;
|
|
277210
|
+
this.localLastTime = now;
|
|
277211
|
+
const v = this.localSpringVelocity;
|
|
277212
|
+
const [tx, vtx] = springStep(this.matrix.translateX, tgt.translateX, v.translateX, dt);
|
|
277213
|
+
const [ty, vty] = springStep(this.matrix.translateY, tgt.translateY, v.translateY, dt);
|
|
277214
|
+
const [sx, vsx] = springStep(this.matrix.scaleX, tgt.scaleX, v.scaleX, dt);
|
|
277215
|
+
const [sy, vsy] = springStep(this.matrix.scaleY, tgt.scaleY, v.scaleY, dt);
|
|
277216
|
+
this.matrix.translateX = tx;
|
|
277217
|
+
this.matrix.translateY = ty;
|
|
277218
|
+
this.matrix.scaleX = sx;
|
|
277219
|
+
this.matrix.scaleY = sy;
|
|
277220
|
+
this.localSpringVelocity = { translateX: vtx, translateY: vty, scaleX: vsx, scaleY: vsy };
|
|
277221
|
+
this.updateBoardPointer();
|
|
277251
277222
|
this.subject.publish(this);
|
|
277252
|
-
|
|
277253
|
-
|
|
277254
|
-
|
|
277255
|
-
this.
|
|
277223
|
+
const settled = Math.abs(tgt.translateX - tx) < SNAP_PX && Math.abs(tgt.translateY - ty) < SNAP_PX && Math.abs(tgt.scaleX - sx) < SNAP_SCALE && Math.abs(vtx) < SNAP_VEL && Math.abs(vty) < SNAP_VEL;
|
|
277224
|
+
if (settled) {
|
|
277225
|
+
this.matrix.translateX = tgt.translateX;
|
|
277226
|
+
this.matrix.translateY = tgt.translateY;
|
|
277227
|
+
this.matrix.scaleX = tgt.scaleX;
|
|
277228
|
+
this.matrix.scaleY = tgt.scaleY;
|
|
277229
|
+
this.localSpringVelocity = { translateX: 0, translateY: 0, scaleX: 0, scaleY: 0 };
|
|
277230
|
+
this.localAnimationTarget = null;
|
|
277231
|
+
this.localAnimationId = null;
|
|
277232
|
+
this.localLastTime = null;
|
|
277233
|
+
this.updateBoardPointer();
|
|
277234
|
+
this.subject.publish(this);
|
|
277235
|
+
return;
|
|
277256
277236
|
}
|
|
277237
|
+
this.localAnimationId = safeRequestAnimationFrame(loop) || null;
|
|
277257
277238
|
};
|
|
277258
|
-
safeRequestAnimationFrame(
|
|
277259
|
-
}
|
|
277260
|
-
lerp(a2, b2, time2) {
|
|
277261
|
-
return a2 + (b2 - a2) * time2;
|
|
277262
|
-
}
|
|
277263
|
-
easeOutQuad(time2) {
|
|
277264
|
-
return time2 * (2 - time2);
|
|
277239
|
+
this.localAnimationId = safeRequestAnimationFrame(loop) || null;
|
|
277265
277240
|
}
|
|
277266
277241
|
zoomToFit(rect, offsetInPercent = 10, duration = 480) {
|
|
277267
277242
|
this.viewRectangle(rect, offsetInPercent, duration);
|
|
@@ -277270,11 +277245,13 @@ class Camera {
|
|
|
277270
277245
|
return { x: 0, y: 0 };
|
|
277271
277246
|
}
|
|
277272
277247
|
translateTo(x, y) {
|
|
277248
|
+
this.cancelLocalAnimation();
|
|
277273
277249
|
this.matrix.translate(x, y);
|
|
277274
277250
|
this.updateBoardPointer();
|
|
277275
277251
|
this.subject.publish(this);
|
|
277276
277252
|
}
|
|
277277
277253
|
translateBy(x, y) {
|
|
277254
|
+
this.cancelLocalAnimation();
|
|
277278
277255
|
this.matrix.translate(x * this.matrix.scaleX, y * this.matrix.scaleY);
|
|
277279
277256
|
this.updateBoardPointer();
|
|
277280
277257
|
this.subject.publish(this);
|
|
@@ -279267,8 +279244,8 @@ function handleMultipleItemsResize({
|
|
|
279267
279244
|
let itemX = item.getMbr().left;
|
|
279268
279245
|
let itemY = item.getMbr().top;
|
|
279269
279246
|
if (item.itemType === "Drawing") {
|
|
279270
|
-
itemX = item.transformation.
|
|
279271
|
-
itemY = item.transformation.
|
|
279247
|
+
itemX = item.transformation.getMatrixData().translateX;
|
|
279248
|
+
itemY = item.transformation.getMatrixData().translateY;
|
|
279272
279249
|
}
|
|
279273
279250
|
const deltaX = itemX - initMbr.left;
|
|
279274
279251
|
const translateX = deltaX * matrix.scaleX - deltaX + matrix.translateX;
|
|
@@ -283638,6 +283615,21 @@ function insertEventsFromOtherConnectionsIntoList(value, list6, board) {
|
|
|
283638
283615
|
}
|
|
283639
283616
|
const events2 = expandEvents(eventArray);
|
|
283640
283617
|
board.selection.memoize();
|
|
283618
|
+
const focusedTextId = board.selection.memorySnapshot?.focus?.textToEdit;
|
|
283619
|
+
let localOpOriginalSelection = null;
|
|
283620
|
+
if (focusedTextId) {
|
|
283621
|
+
const allUnconfirmed = [...list6.getRecordsToSend(), ...list6.getNewRecords()];
|
|
283622
|
+
for (const rec of allUnconfirmed) {
|
|
283623
|
+
const op = rec.event.body.operation;
|
|
283624
|
+
if (op.class === "RichText" && op.method === "edit") {
|
|
283625
|
+
const items = Array.isArray(op.item) ? op.item : [op.item];
|
|
283626
|
+
if (items.includes(focusedTextId)) {
|
|
283627
|
+
localOpOriginalSelection = op.selection;
|
|
283628
|
+
break;
|
|
283629
|
+
}
|
|
283630
|
+
}
|
|
283631
|
+
}
|
|
283632
|
+
}
|
|
283641
283633
|
const createdItems = [];
|
|
283642
283634
|
const updatedText = [];
|
|
283643
283635
|
const filter = (rec) => {
|
|
@@ -283647,6 +283639,10 @@ function insertEventsFromOtherConnectionsIntoList(value, list6, board) {
|
|
|
283647
283639
|
createdItems.push(...creating);
|
|
283648
283640
|
return false;
|
|
283649
283641
|
}
|
|
283642
|
+
if (op.class === "RichText" && op.method === "edit") {
|
|
283643
|
+
const items = Array.isArray(op.item) ? op.item : [op.item];
|
|
283644
|
+
updatedText.push(...items);
|
|
283645
|
+
}
|
|
283650
283646
|
return true;
|
|
283651
283647
|
};
|
|
283652
283648
|
list6.revertUnconfirmed(filter);
|
|
@@ -283665,7 +283661,28 @@ function insertEventsFromOtherConnectionsIntoList(value, list6, board) {
|
|
|
283665
283661
|
return arr2.some((item) => lookup9.has(item));
|
|
283666
283662
|
};
|
|
283667
283663
|
const currSelection = board.selection.list().map((item) => item.getId());
|
|
283668
|
-
|
|
283664
|
+
const memoizedCursor = board.selection.memorySnapshot?.focus?.selection;
|
|
283665
|
+
if (focusedTextId && localOpOriginalSelection && memoizedCursor && hasAnyOverlap(currSelection, updatedText)) {
|
|
283666
|
+
const rt = board.items.getById(focusedTextId)?.getRichText();
|
|
283667
|
+
if (rt) {
|
|
283668
|
+
const otAdjustedCursor = rt.editor.getSelection();
|
|
283669
|
+
if (otAdjustedCursor && memoizedCursor.anchor.path.length > 0 && memoizedCursor.focus.path.length > 0) {
|
|
283670
|
+
const deltaAnchor = otAdjustedCursor.anchor.offset - (localOpOriginalSelection?.anchor?.offset ?? 0);
|
|
283671
|
+
const deltaFocus = otAdjustedCursor.focus.offset - (localOpOriginalSelection?.focus?.offset ?? 0);
|
|
283672
|
+
const adjustedSelection = {
|
|
283673
|
+
anchor: {
|
|
283674
|
+
path: memoizedCursor.anchor.path,
|
|
283675
|
+
offset: memoizedCursor.anchor.offset + deltaAnchor
|
|
283676
|
+
},
|
|
283677
|
+
focus: {
|
|
283678
|
+
path: memoizedCursor.focus.path,
|
|
283679
|
+
offset: memoizedCursor.focus.offset + deltaFocus
|
|
283680
|
+
}
|
|
283681
|
+
};
|
|
283682
|
+
rt.editorTransforms.select(rt.editor.editor, adjustedSelection);
|
|
283683
|
+
}
|
|
283684
|
+
}
|
|
283685
|
+
} else if (hasAnyOverlap(currSelection, createdItems) || hasAnyOverlap(currSelection, updatedText)) {
|
|
283669
283686
|
board.selection.applyMemoizedCaretOrRange();
|
|
283670
283687
|
}
|
|
283671
283688
|
}
|
|
@@ -283938,16 +283955,16 @@ function createEvents(board, connection, lastIndex) {
|
|
|
283938
283955
|
return new Events2(board, connection, lastIndex);
|
|
283939
283956
|
}
|
|
283940
283957
|
function createMessageRouter() {
|
|
283941
|
-
const
|
|
283958
|
+
const handlers2 = new Map;
|
|
283942
283959
|
function addHandler(type, handler) {
|
|
283943
|
-
|
|
283960
|
+
handlers2.set(type, (message, board) => {
|
|
283944
283961
|
if (message.type === type) {
|
|
283945
283962
|
handler(message, board);
|
|
283946
283963
|
}
|
|
283947
283964
|
});
|
|
283948
283965
|
}
|
|
283949
283966
|
function handleMessage(message, board) {
|
|
283950
|
-
const handler =
|
|
283967
|
+
const handler = handlers2.get(message.type);
|
|
283951
283968
|
if (handler) {
|
|
283952
283969
|
handler(message, board);
|
|
283953
283970
|
} else {
|
|
@@ -364809,7 +364826,7 @@ class CanvasBase extends React106.Component {
|
|
|
364809
364826
|
if (!ctx || !cursorsCtx) {
|
|
364810
364827
|
return;
|
|
364811
364828
|
}
|
|
364812
|
-
const context = new
|
|
364829
|
+
const context = new DrawingContext2(this.props.board.camera, ctx, cursorsCtx);
|
|
364813
364830
|
const { board } = this.props;
|
|
364814
364831
|
context.setCamera(board.camera);
|
|
364815
364832
|
context.clear();
|
|
@@ -364996,7 +365013,7 @@ var CanvasNoRouter = ({ app, board, children }) => {
|
|
|
364996
365013
|
if (!ctx || !cursorsCtx) {
|
|
364997
365014
|
return;
|
|
364998
365015
|
}
|
|
364999
|
-
const context = new
|
|
365016
|
+
const context = new DrawingContext2(board.camera, ctx, cursorsCtx);
|
|
365000
365017
|
context.setCamera(board.camera);
|
|
365001
365018
|
context.clear();
|
|
365002
365019
|
context.clearCursor();
|