@meta2d/core 1.0.17 → 1.0.19

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.
@@ -0,0 +1,95 @@
1
+ var Title = /** @class */ (function () {
2
+ function Title(parentElement) {
3
+ var _this = this;
4
+ this.parentElement = parentElement;
5
+ this.box = document.createElement('div');
6
+ this.box.className = 'meta2d-title';
7
+ parentElement.appendChild(this.box);
8
+ this.box.onmouseleave = function () {
9
+ _this.hide();
10
+ };
11
+ var sheet;
12
+ for (var i = 0; i < document.styleSheets.length; i++) {
13
+ if (document.styleSheets[i].title === 'le5le.com/title') {
14
+ sheet = document.styleSheets[i];
15
+ }
16
+ }
17
+ if (!sheet) {
18
+ var style = document.createElement('style');
19
+ style.type = 'text/css';
20
+ style.title = 'le5le.com/title';
21
+ document.head.appendChild(style);
22
+ style = document.createElement('style');
23
+ style.type = 'text/css';
24
+ document.head.appendChild(style);
25
+ sheet = style.sheet;
26
+ sheet.insertRule('.meta2d-title{position:absolute;padding:0;z-index:10;left: -9999px;top: -9999px;width:8px;height:8px;cursor: crosshair;}');
27
+ }
28
+ }
29
+ /**
30
+ * @returns 此次应该展示的 title
31
+ */
32
+ Title.getTitle = function (anchor) {
33
+ // if (anchor.titleFnJs && !anchor.titleFn) {
34
+ // try {
35
+ // anchor.titleFn = new Function('anchor', anchor.titleFnJs) as (
36
+ // anchor: Point
37
+ // ) => string;
38
+ // } catch (error) {
39
+ // console.log('titleFnJs', error);
40
+ // }
41
+ // }
42
+ // return anchor.titleFn ? anchor.titleFn(anchor) : String(anchor.title);
43
+ };
44
+ /**
45
+ * @returns 返回设置前的 rect
46
+ */
47
+ Title.prototype.setText = function (anchor) {
48
+ this.box.title = anchor.title;
49
+ };
50
+ /**
51
+ * 更新文字
52
+ */
53
+ Title.prototype.updateText = function (anchor) {
54
+ var _a;
55
+ if (((_a = this.currentAnchor) === null || _a === void 0 ? void 0 : _a.id) !== anchor.id) {
56
+ return;
57
+ }
58
+ if (Title.titleEmpty(anchor)) {
59
+ return;
60
+ }
61
+ this.setText(anchor);
62
+ this.changePositionByAnchor(anchor);
63
+ };
64
+ /**
65
+ * 改变文字会 影响 box 的大小,需要重新设置位置
66
+ * @param oldRect 原
67
+ * @param newRect 新
68
+ */
69
+ Title.prototype.changePositionByAnchor = function (anchor) {
70
+ this.box.style.left = anchor.x - 4 + 'px';
71
+ this.box.style.top = anchor.y - 4 + 'px';
72
+ };
73
+ Title.titleEmpty = function (anchor) {
74
+ return !anchor.title; // && !anchor.titleFn && !anchor.titleFnJs;
75
+ };
76
+ Title.prototype.show = function (anchor) {
77
+ if (Title.titleEmpty(anchor)) {
78
+ return;
79
+ }
80
+ this.currentAnchor = anchor;
81
+ this.setText(anchor);
82
+ this.changePositionByAnchor(anchor);
83
+ };
84
+ Title.prototype.hide = function () {
85
+ this.box.style.left = '-9999px';
86
+ this.box.title = '';
87
+ this.currentAnchor = null;
88
+ };
89
+ Title.prototype.destroy = function () {
90
+ this.box.onmouseleave = null;
91
+ };
92
+ return Title;
93
+ }());
94
+ export { Title };
95
+ //# sourceMappingURL=title.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"title.js","sourceRoot":"","sources":["../../../../packages/core/src/title/title.ts"],"names":[],"mappings":"AAEA;IAGE,eAAmB,aAA0B;QAA7C,iBA+BC;QA/BkB,kBAAa,GAAb,aAAa,CAAa;QAC3C,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC,GAAG,CAAC,SAAS,GAAG,cAAc,CAAC;QAEpC,aAAa,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAEpC,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG;YACtB,KAAI,CAAC,IAAI,EAAE,CAAC;QACd,CAAC,CAAC;QAEF,IAAI,KAAU,CAAC;QACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,QAAQ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EAAE;YAC5B,OAAO;SACR;QAED,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED;;;;OAIG;IACK,sCAAsB,GAA9B,UAA+B,MAAa;QAC1C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;QAC1C,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC;IAC3C,CAAC;IAEc,gBAAU,GAAzB,UAA0B,MAAa;QACrC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,2CAA2C;IACnE,CAAC;IAED,oBAAI,GAAJ,UAAK,MAAa;QAChB,IAAI,KAAK,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE;YAC5B,OAAO;SACR;QACD,IAAI,CAAC,aAAa,GAAG,MAAM,CAAC;QAC5B,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;IACtC,CAAC;IAED,oBAAI,GAAJ;QACE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,GAAG,SAAS,CAAC;QAChC,IAAI,CAAC,GAAG,CAAC,KAAK,GAAG,EAAE,CAAC;QACpB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC;IAC5B,CAAC;IAED,uBAAO,GAAP;QACE,IAAI,CAAC,GAAG,CAAC,YAAY,GAAG,IAAI,CAAC;IAC/B,CAAC;IACH,YAAC;AAAD,CAAC,AA1GD,IA0GC"}
@@ -1,2 +1,3 @@
1
1
  export declare function fileToBase64(file: File): Promise<string>;
2
2
  export declare function uploadFile(file: File, url: string, params: Record<string, any>, headers: Record<string, string>): Promise<string>;
3
+ export declare function loadCss(url: string, success?: any, error?: any): void;
package/src/utils/file.js CHANGED
@@ -81,4 +81,12 @@ export function uploadFile(file, url, params, headers) {
81
81
  });
82
82
  });
83
83
  }
84
+ export function loadCss(url, success, error) {
85
+ var link = document.createElement('link');
86
+ link.href = url;
87
+ link.rel = 'stylesheet';
88
+ success && (link.onload = success);
89
+ error && (link.onerror = error);
90
+ document.head.appendChild(link);
91
+ }
84
92
  //# sourceMappingURL=file.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"file.js","sourceRoot":"","sources":["../../../../packages/core/src/utils/file.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,MAAM,UAAgB,YAAY,CAAC,IAAU;;;YAC3C,sBAAO,IAAI,OAAO,CAAC,UAAC,OAAO,EAAE,MAAM;oBACjC,IAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;oBAChC,MAAM,CAAC,MAAM,GAAG,UAAC,CAAC;wBAChB,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,MAAgB,CAAC,CAAC;oBACrC,CAAC,CAAC;oBACF,MAAM,CAAC,OAAO,GAAG,UAAC,CAAC;wBACjB,MAAM,CAAC,CAAC,CAAC,CAAC;oBACZ,CAAC,CAAC;oBACF,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;gBAC7B,CAAC,CAAC,EAAC;;;CACJ;AAED,MAAM,UAAgB,UAAU,CAC9B,IAAU,EACV,GAAW,EACX,MAA2B,EAC3B,OAA+B;;;;;;oBAEzB,QAAQ,GAAG,IAAI,QAAQ,EAAE,CAAC;oBAChC,+BAA+B;oBAC/B,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;oBAC9B,IAAI,MAAM,EAAE;wBACV,KAAW,GAAG,IAAI,MAAM,EAAE;4BACxB,IAAI,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,EAAE;gCAC9B,QAAQ,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,CAA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