@hprint/core 0.0.7 → 0.0.9-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ServersPlugin.d.ts +12 -4
- package/dist/ServersPlugin.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.mjs +70 -46
- package/package.json +2 -2
- package/src/ContextMenu.js +277 -277
- package/src/Instance.ts +79 -79
- package/src/ServersPlugin.ts +442 -411
- package/src/index.ts +11 -11
- package/src/objects/CustomRect.js +21 -21
- package/src/objects/CustomTextbox.js +165 -165
- package/src/plugin.ts +88 -88
- package/src/styles/contextMenu.css +60 -60
- package/src/utils/fabric-history.js +232 -232
- package/src/utils/utils.ts +165 -165
- package/tsconfig.json +10 -10
- package/vite.config.ts +29 -29
package/dist/index.mjs
CHANGED
|
@@ -336,7 +336,7 @@ var Sn = {
|
|
|
336
336
|
ctrlKey: 17,
|
|
337
337
|
altKey: 18,
|
|
338
338
|
metaKey: 91
|
|
339
|
-
},
|
|
339
|
+
}, _t = {
|
|
340
340
|
16: !1,
|
|
341
341
|
18: !1,
|
|
342
342
|
17: !1,
|
|
@@ -374,8 +374,8 @@ function Or(f, r) {
|
|
|
374
374
|
}
|
|
375
375
|
function Er(f) {
|
|
376
376
|
var r = f.keyCode || f.which || f.charCode, g = ft.indexOf(r);
|
|
377
|
-
if (g >= 0 && ft.splice(g, 1), f.key && f.key.toLowerCase() === "meta" && ft.splice(0, ft.length), (r === 93 || r === 224) && (r = 91), r in
|
|
378
|
-
|
|
377
|
+
if (g >= 0 && ft.splice(g, 1), f.key && f.key.toLowerCase() === "meta" && ft.splice(0, ft.length), (r === 93 || r === 224) && (r = 91), r in _t) {
|
|
378
|
+
_t[r] = !1;
|
|
379
379
|
for (var _ in $t)
|
|
380
380
|
$t[_] === r && (It[_] = !1);
|
|
381
381
|
}
|
|
@@ -422,9 +422,9 @@ function qi(f, r, g, _) {
|
|
|
422
422
|
var y;
|
|
423
423
|
if (r.scope === g || r.scope === "all") {
|
|
424
424
|
y = r.mods.length > 0;
|
|
425
|
-
for (var C in
|
|
426
|
-
Object.prototype.hasOwnProperty.call(
|
|
427
|
-
(r.mods.length === 0 && !
|
|
425
|
+
for (var C in _t)
|
|
426
|
+
Object.prototype.hasOwnProperty.call(_t, C) && (!_t[C] && r.mods.indexOf(+C) > -1 || _t[C] && r.mods.indexOf(+C) === -1) && (y = !1);
|
|
427
|
+
(r.mods.length === 0 && !_t[16] && !_t[18] && !_t[17] && !_t[91] || y || r.shortcut === "*") && r.method(f, r) === !1 && (f.preventDefault ? f.preventDefault() : f.returnValue = !1, f.stopPropagation && f.stopPropagation(), f.cancelBubble && (f.cancelBubble = !0));
|
|
428
428
|
}
|
|
429
429
|
}
|
|
430
430
|
}
|
|
@@ -434,15 +434,15 @@ function Ki(f, r) {
|
|
|
434
434
|
if ((_ === 93 || _ === 224) && (_ = 91), ft.indexOf(_) === -1 && _ !== 229 && ft.push(_), ["ctrlKey", "altKey", "shiftKey", "metaKey"].forEach(function(o) {
|
|
435
435
|
var h = zi[o];
|
|
436
436
|
f[o] && ft.indexOf(h) === -1 ? ft.push(h) : !f[o] && ft.indexOf(h) > -1 ? ft.splice(ft.indexOf(h), 1) : o === "metaKey" && f[o] && ft.length === 3 && (f.ctrlKey || f.shiftKey || f.altKey || (ft = ft.slice(ft.indexOf(h))));
|
|
437
|
-
}), _ in
|
|
438
|
-
|
|
437
|
+
}), _ in _t) {
|
|
438
|
+
_t[_] = !0;
|
|
439
439
|
for (var y in $t)
|
|
440
440
|
$t[y] === _ && (It[y] = !0);
|
|
441
441
|
if (!g) return;
|
|
442
442
|
}
|
|
443
|
-
for (var C in
|
|
444
|
-
Object.prototype.hasOwnProperty.call(
|
|
445
|
-
f.getModifierState && !(f.altKey && !f.ctrlKey) && f.getModifierState("AltGraph") && (ft.indexOf(17) === -1 && ft.push(17), ft.indexOf(18) === -1 && ft.push(18),
|
|
443
|
+
for (var C in _t)
|
|
444
|
+
Object.prototype.hasOwnProperty.call(_t, C) && (_t[C] = f[zi[C]]);
|
|
445
|
+
f.getModifierState && !(f.altKey && !f.ctrlKey) && f.getModifierState("AltGraph") && (ft.indexOf(17) === -1 && ft.push(17), ft.indexOf(18) === -1 && ft.push(18), _t[17] = !0, _t[18] = !0);
|
|
446
446
|
var T = pe();
|
|
447
447
|
if (g)
|
|
448
448
|
for (var c = 0; c < g.length; c++)
|
|
@@ -611,11 +611,11 @@ const Lr = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a
|
|
|
611
611
|
function Fr(f) {
|
|
612
612
|
return typeof f == "string" && Lr.test(f);
|
|
613
613
|
}
|
|
614
|
-
var
|
|
614
|
+
var vt = [];
|
|
615
615
|
for (var Je = 0; Je < 256; ++Je)
|
|
616
|
-
|
|
616
|
+
vt.push((Je + 256).toString(16).substr(1));
|
|
617
617
|
function Rr(f) {
|
|
618
|
-
var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, g = (
|
|
618
|
+
var r = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 0, g = (vt[f[r + 0]] + vt[f[r + 1]] + vt[f[r + 2]] + vt[f[r + 3]] + "-" + vt[f[r + 4]] + vt[f[r + 5]] + "-" + vt[f[r + 6]] + vt[f[r + 7]] + "-" + vt[f[r + 8]] + vt[f[r + 9]] + "-" + vt[f[r + 10]] + vt[f[r + 11]] + vt[f[r + 12]] + vt[f[r + 13]] + vt[f[r + 14]] + vt[f[r + 15]]).toLowerCase();
|
|
619
619
|
if (!Fr(g))
|
|
620
620
|
throw TypeError("Stringified UUID is invalid");
|
|
621
621
|
return g;
|
|
@@ -20826,7 +20826,7 @@ gl_FragColor.rgb *= color.a;
|
|
|
20826
20826
|
})();
|
|
20827
20827
|
})(si)), si;
|
|
20828
20828
|
}
|
|
20829
|
-
var
|
|
20829
|
+
var mt = No(), ue = /* @__PURE__ */ ((f) => (f.ONE = "selectOne", f.MULTI = "selectMultiple", f.CANCEL = "selectCancel", f))(ue || {}), te = /* @__PURE__ */ ((f) => (f.EMPTY = "", f.ONE = "one", f.MULTI = "multiple", f))(te || {});
|
|
20830
20830
|
function fr(f) {
|
|
20831
20831
|
f && f.forEach((r) => {
|
|
20832
20832
|
r.objects ? fr(r.objects) : r.type === "text" && (r.type = "textbox");
|
|
@@ -20843,7 +20843,7 @@ const ge = class ge {
|
|
|
20843
20843
|
_emitSelectEvent() {
|
|
20844
20844
|
if (!this.canvas)
|
|
20845
20845
|
throw TypeError("还未初始化");
|
|
20846
|
-
const r = this.canvas.getActiveObjects().filter((g) => !(g instanceof
|
|
20846
|
+
const r = this.canvas.getActiveObjects().filter((g) => !(g instanceof mt.fabric.GuideLine));
|
|
20847
20847
|
r && r.length === 1 ? (this.selectedMode = te.ONE, this.editor.emit(ue.ONE, r)) : r && r.length > 1 ? (this.selectedMode = te.MULTI, this.editor.emit(ue.MULTI, r)) : this.editor.emit(ue.CANCEL);
|
|
20848
20848
|
}
|
|
20849
20849
|
getSelectMode() {
|
|
@@ -20863,7 +20863,7 @@ const ge = class ge {
|
|
|
20863
20863
|
renderITextPath(r) {
|
|
20864
20864
|
r.forEach((g) => {
|
|
20865
20865
|
const _ = this.canvas.getObjects().find((y) => y.id === g.id);
|
|
20866
|
-
_ &&
|
|
20866
|
+
_ && mt.fabric.Path.fromObject(g.path, (y) => {
|
|
20867
20867
|
_.set("path", y);
|
|
20868
20868
|
});
|
|
20869
20869
|
});
|
|
@@ -20915,7 +20915,9 @@ const ge = class ge {
|
|
|
20915
20915
|
getJson(r) {
|
|
20916
20916
|
const g = this.getExtensionKey(), _ = this.canvas.toJSON(g);
|
|
20917
20917
|
return r?.clearSrc && _.objects.forEach((y) => {
|
|
20918
|
-
["qrcode", "barcode"].includes(
|
|
20918
|
+
["qrcode", "barcode", "imageTextList"].includes(
|
|
20919
|
+
y.extensionType
|
|
20920
|
+
) && (y.src = "");
|
|
20919
20921
|
}), _;
|
|
20920
20922
|
}
|
|
20921
20923
|
getExtensionKey() {
|
|
@@ -20974,7 +20976,7 @@ const ge = class ge {
|
|
|
20974
20976
|
saveSvg() {
|
|
20975
20977
|
this.editor.hooksEntity.hookSaveBefore.callAsync("", () => {
|
|
20976
20978
|
const { fontOption: r, svgOption: g } = this._getSaveSvgOption();
|
|
20977
|
-
|
|
20979
|
+
mt.fabric.fontPaths = {
|
|
20978
20980
|
...r
|
|
20979
20981
|
};
|
|
20980
20982
|
const _ = this.canvas.toSVG(g), y = `data:image/svg+xml;charset=utf-8,${encodeURIComponent(_)}`;
|
|
@@ -21006,6 +21008,26 @@ const ge = class ge {
|
|
|
21006
21008
|
});
|
|
21007
21009
|
});
|
|
21008
21010
|
}
|
|
21011
|
+
getSVG(r) {
|
|
21012
|
+
return new Promise((g) => {
|
|
21013
|
+
this.editor.hooksEntity.hookSaveBefore.callAsync("", () => {
|
|
21014
|
+
this.canvas.setViewportTransform([1, 0, 0, 1, 0, 0]);
|
|
21015
|
+
const { fontOption: _, svgOption: y } = this._getSaveSvgOption({
|
|
21016
|
+
ignoreFont: !0,
|
|
21017
|
+
width: r?.width,
|
|
21018
|
+
height: r?.height
|
|
21019
|
+
});
|
|
21020
|
+
mt.fabric.fontPaths = {
|
|
21021
|
+
..._
|
|
21022
|
+
};
|
|
21023
|
+
const C = this.canvas.toSVG(y);
|
|
21024
|
+
this.editor.hooksEntity.hookSaveAfter.callAsync(
|
|
21025
|
+
C,
|
|
21026
|
+
() => g(C)
|
|
21027
|
+
);
|
|
21028
|
+
});
|
|
21029
|
+
});
|
|
21030
|
+
}
|
|
21009
21031
|
preview() {
|
|
21010
21032
|
return new Promise((r) => {
|
|
21011
21033
|
this.editor.hooksEntity.hookSaveBefore.callAsync("", () => {
|
|
@@ -21022,27 +21044,28 @@ const ge = class ge {
|
|
|
21022
21044
|
return new Promise((r) => {
|
|
21023
21045
|
});
|
|
21024
21046
|
}
|
|
21025
|
-
_getSaveSvgOption() {
|
|
21026
|
-
const
|
|
21027
|
-
let
|
|
21028
|
-
|
|
21029
|
-
const
|
|
21030
|
-
|
|
21031
|
-
const a
|
|
21032
|
-
|
|
21033
|
-
|
|
21034
|
-
|
|
21035
|
-
|
|
21047
|
+
_getSaveSvgOption(r) {
|
|
21048
|
+
const g = this.canvas.getObjects().find((a) => a.id === "workspace");
|
|
21049
|
+
let _ = this.canvas.getObjects().filter((a) => a.type == "textbox").map((a) => a.fontFamily);
|
|
21050
|
+
_ = Array.from(new Set(_));
|
|
21051
|
+
const y = this.editor.getPlugin("FontPlugin").cacheList, C = {};
|
|
21052
|
+
if (!r?.ignoreFont)
|
|
21053
|
+
for (const a of _) {
|
|
21054
|
+
const t = y.find((n) => n.name === a);
|
|
21055
|
+
C[a] = t.file;
|
|
21056
|
+
}
|
|
21057
|
+
console.log("_getSaveSvgOption", C);
|
|
21058
|
+
const { left: T, top: c, width: i, height: l } = g;
|
|
21036
21059
|
return {
|
|
21037
|
-
fontOption:
|
|
21060
|
+
fontOption: C,
|
|
21038
21061
|
svgOption: {
|
|
21039
|
-
width:
|
|
21040
|
-
height:
|
|
21062
|
+
width: r?.width ?? i,
|
|
21063
|
+
height: r?.height ?? l,
|
|
21041
21064
|
viewBox: {
|
|
21042
|
-
x:
|
|
21043
|
-
y:
|
|
21044
|
-
width:
|
|
21045
|
-
height:
|
|
21065
|
+
x: T,
|
|
21066
|
+
y: c,
|
|
21067
|
+
width: i,
|
|
21068
|
+
height: l
|
|
21046
21069
|
}
|
|
21047
21070
|
}
|
|
21048
21071
|
};
|
|
@@ -21080,6 +21103,7 @@ ge.pluginName = "ServersPlugin", ge.apis = [
|
|
|
21080
21103
|
"saveSvg",
|
|
21081
21104
|
"saveImg",
|
|
21082
21105
|
"getBase64",
|
|
21106
|
+
"getSVG",
|
|
21083
21107
|
"clear",
|
|
21084
21108
|
"preview",
|
|
21085
21109
|
"staticPreview",
|
|
@@ -22067,7 +22091,7 @@ class ea extends br {
|
|
|
22067
22091
|
return g ? super.off(r, g) : this;
|
|
22068
22092
|
}
|
|
22069
22093
|
}
|
|
22070
|
-
|
|
22094
|
+
mt.fabric.Rect = mt.fabric.util.createClass(mt.fabric.Rect, {
|
|
22071
22095
|
type: "rect",
|
|
22072
22096
|
initialize: function(f) {
|
|
22073
22097
|
f || (f = {}), this.callSuper("initialize", f);
|
|
@@ -22077,11 +22101,11 @@ _t.fabric.Rect = _t.fabric.util.createClass(_t.fabric.Rect, {
|
|
|
22077
22101
|
this.rx = 1 / this.scaleX * r, this.ry = 1 / this.scaleY * r, this.callSuper("_render", f);
|
|
22078
22102
|
}
|
|
22079
22103
|
});
|
|
22080
|
-
|
|
22081
|
-
return
|
|
22104
|
+
mt.fabric.Rect.fromObject = function(f, r) {
|
|
22105
|
+
return mt.fabric.Object._fromObject("Rect", f, r);
|
|
22082
22106
|
};
|
|
22083
|
-
const ia =
|
|
22084
|
-
|
|
22107
|
+
const ia = mt.fabric.Rect;
|
|
22108
|
+
mt.fabric.Textbox = mt.fabric.util.createClass(mt.fabric.Textbox, {
|
|
22085
22109
|
type: "textbox",
|
|
22086
22110
|
_renderChars: function(f, r, g, _, y, C) {
|
|
22087
22111
|
var T = this.getHeightOfLine(C), c = this.textAlign.indexOf("justify") !== -1, i, l, a = "", t, n = 0, e, o = this.path, h = !c && this.charSpacing === 0 && this.isEmptyStyles(C) && !o, s = this.direction === "ltr", u = this.direction === "ltr" ? 1 : -1, d, m = r.canvas.getAttribute("dir");
|
|
@@ -22099,7 +22123,7 @@ _t.fabric.Textbox = _t.fabric.util.createClass(_t.fabric.Textbox, {
|
|
|
22099
22123
|
return;
|
|
22100
22124
|
}
|
|
22101
22125
|
for (var p = 0, v = g.length - 1; p <= v; p++)
|
|
22102
|
-
e = p === v || this.charSpacing || o, a += g[p], t = this.__charBounds[C][p], n === 0 ? (_ += u * (t.kernedWidth - t.width), n += t.width) : n += t.kernedWidth, c && !e && this._reSpaceAndTab.test(g[p]) && (e = !0), e || (i = i || this.getCompleteStyleDeclaration(C, p), l = this.getCompleteStyleDeclaration(C, p + 1), e =
|
|
22126
|
+
e = p === v || this.charSpacing || o, a += g[p], t = this.__charBounds[C][p], n === 0 ? (_ += u * (t.kernedWidth - t.width), n += t.width) : n += t.kernedWidth, c && !e && this._reSpaceAndTab.test(g[p]) && (e = !0), e || (i = i || this.getCompleteStyleDeclaration(C, p), l = this.getCompleteStyleDeclaration(C, p + 1), e = mt.fabric.util.hasStyleChanged(
|
|
22103
22127
|
i,
|
|
22104
22128
|
l,
|
|
22105
22129
|
!1
|
|
@@ -22133,11 +22157,11 @@ _t.fabric.Textbox = _t.fabric.util.createClass(_t.fabric.Textbox, {
|
|
|
22133
22157
|
}
|
|
22134
22158
|
}
|
|
22135
22159
|
});
|
|
22136
|
-
|
|
22160
|
+
mt.fabric.Textbox.fromObject = function(f, r) {
|
|
22137
22161
|
const { text: g } = f;
|
|
22138
|
-
return r(new
|
|
22162
|
+
return r(new mt.fabric.Textbox(g, f));
|
|
22139
22163
|
};
|
|
22140
|
-
const na =
|
|
22164
|
+
const na = mt.fabric.Rect, ra = mt.fabric;
|
|
22141
22165
|
export {
|
|
22142
22166
|
ia as CustomRect,
|
|
22143
22167
|
na as CustomTextbox,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hprint/core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.9-alpha.0",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"hotkeys-js": "~3.8.9",
|
|
34
34
|
"tapable": "~2.3.0",
|
|
35
35
|
"uuid": "~8.3.2",
|
|
36
|
-
"@hprint/shared": "0.0.
|
|
36
|
+
"@hprint/shared": "0.0.9-alpha.0"
|
|
37
37
|
},
|
|
38
38
|
"scripts": {
|
|
39
39
|
"build": "vite build",
|