@chenyomi/leafer-htmltext-editor 1.0.8 → 1.0.10
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/index.cjs +4 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.mts +64 -0
- package/dist/index.d.ts +51 -5
- package/dist/index.mjs +4 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +16 -8
- package/dist/TextEditTool/index.d.ts +0 -17
- package/dist/TextEditTool/index.d.ts.map +0 -1
- package/dist/TextEditTool/index.js +0 -113
- package/dist/TextEditTool/utils.d.ts +0 -8
- package/dist/TextEditTool/utils.d.ts.map +0 -1
- package/dist/TextEditTool/utils.js +0 -256
- package/dist/TextEditor.d.ts +0 -30
- package/dist/TextEditor.d.ts.map +0 -1
- package/dist/TextEditor.js +0 -169
- package/dist/esm/TextEditTool/index.d.ts +0 -17
- package/dist/esm/TextEditTool/index.d.ts.map +0 -1
- package/dist/esm/TextEditTool/index.js +0 -110
- package/dist/esm/TextEditTool/utils.d.ts +0 -8
- package/dist/esm/TextEditTool/utils.d.ts.map +0 -1
- package/dist/esm/TextEditTool/utils.js +0 -248
- package/dist/esm/TextEditor.d.ts +0 -30
- package/dist/esm/TextEditor.d.ts.map +0 -1
- package/dist/esm/TextEditor.js +0 -166
- package/dist/esm/fonts/font.d.ts +0 -17
- package/dist/esm/fonts/font.d.ts.map +0 -1
- package/dist/esm/fonts/font.js +0 -68
- package/dist/esm/fonts/utils.d.ts +0 -9
- package/dist/esm/fonts/utils.d.ts.map +0 -1
- package/dist/esm/fonts/utils.js +0 -170
- package/dist/esm/index.d.ts +0 -18
- package/dist/esm/index.d.ts.map +0 -1
- package/dist/esm/utils.d.ts +0 -3
- package/dist/esm/utils.d.ts.map +0 -1
- package/dist/esm/utils.js +0 -266
- package/dist/fonts/font.d.ts +0 -17
- package/dist/fonts/font.d.ts.map +0 -1
- package/dist/fonts/font.js +0 -72
- package/dist/fonts/utils.d.ts +0 -9
- package/dist/fonts/utils.d.ts.map +0 -1
- package/dist/fonts/utils.js +0 -180
- package/dist/index.d.ts.map +0 -1
- package/dist/index.esm.js +0 -140
- package/dist/index.js +0 -178
- package/dist/utils.d.ts +0 -3
- package/dist/utils.d.ts.map +0 -1
- package/dist/utils.js +0 -271
- package/src/TextEditTool/index.ts +0 -132
- package/src/TextEditTool/utils.ts +0 -288
- package/src/TextEditor.ts +0 -213
- package/src/fonts/font.ts +0 -86
- package/src/fonts/utils.ts +0 -232
- package/src/htmltext-editor.css +0 -103
- package/src/index.ts +0 -163
- package/src/utils.ts +0 -294
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.TextEditTool = void 0;
|
|
13
|
-
const editor_1 = require("@leafer-in/editor");
|
|
14
|
-
const leafer_ui_1 = require("leafer-ui");
|
|
15
|
-
const __1 = require("../");
|
|
16
|
-
const utils_1 = require("../utils");
|
|
17
|
-
console.log('初始化文本外部编辑插件');
|
|
18
|
-
let TextEditTool = class TextEditTool extends editor_1.EditTool {
|
|
19
|
-
get tag() {
|
|
20
|
-
return "TextEditTool";
|
|
21
|
-
}
|
|
22
|
-
constructor(editor) {
|
|
23
|
-
super(editor);
|
|
24
|
-
this.quill = null;
|
|
25
|
-
this.isUpdatingPoints = false;
|
|
26
|
-
this.curveAmount = 0;
|
|
27
|
-
this.eventIds = [];
|
|
28
|
-
this.updateBoxDebounced = this.debounce((text) => {
|
|
29
|
-
(0, utils_1.updataHtmlText)(text);
|
|
30
|
-
}, 300);
|
|
31
|
-
}
|
|
32
|
-
debounce(func, wait) {
|
|
33
|
-
let timeout = null;
|
|
34
|
-
return ((...args) => {
|
|
35
|
-
if (timeout !== null) {
|
|
36
|
-
window.clearTimeout(timeout);
|
|
37
|
-
}
|
|
38
|
-
timeout = window.setTimeout(() => func.apply(this, args), wait);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
addEvent() {
|
|
42
|
-
const { editor } = __1.quillManager.getCanvas();
|
|
43
|
-
const text = editor._target.findOne("HTMLText");
|
|
44
|
-
const { scaleX, scaleY } = text.worldTransform;
|
|
45
|
-
const zoomScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
|
|
46
|
-
const div = document.querySelector("#textInnerEditor");
|
|
47
|
-
const { style } = div;
|
|
48
|
-
this.eventIds = [
|
|
49
|
-
editor.on_(editor_1.EditorScaleEvent.SCALE, (e) => {
|
|
50
|
-
if (!text.data.canChangeBox) {
|
|
51
|
-
text.data.canChangeBox = true;
|
|
52
|
-
}
|
|
53
|
-
if (text.data.canChangeBox) {
|
|
54
|
-
style.width = text.parent.width * zoomScale + "px";
|
|
55
|
-
style.height = "auto";
|
|
56
|
-
}
|
|
57
|
-
this.updateBoxDebounced(text);
|
|
58
|
-
}),
|
|
59
|
-
editor.on_(leafer_ui_1.PointerEvent.DOUBLE_TAP, () => {
|
|
60
|
-
if (!text.parent.locked) {
|
|
61
|
-
editor.openInnerEditor(text, true);
|
|
62
|
-
}
|
|
63
|
-
}),
|
|
64
|
-
];
|
|
65
|
-
}
|
|
66
|
-
onLoad() {
|
|
67
|
-
const { editor } = __1.quillManager.getCanvas();
|
|
68
|
-
console.log(editor.target, 123);
|
|
69
|
-
const text = editor.target.findOne("HTMLText");
|
|
70
|
-
const { scaleX, scaleY } = text.worldTransform;
|
|
71
|
-
const zoomScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
|
|
72
|
-
this.addEvent();
|
|
73
|
-
this.quill = __1.quillManager.getQuill();
|
|
74
|
-
this.quill.clipboard.dangerouslyPasteHTML(text.text);
|
|
75
|
-
const div = document.querySelector("#textInnerEditor");
|
|
76
|
-
const { style } = div;
|
|
77
|
-
if (text.data.canChangeBox) {
|
|
78
|
-
style.width = text.parent.width * zoomScale + "px";
|
|
79
|
-
style.height = text.parent.height * zoomScale + "px";
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
style.width = "auto";
|
|
83
|
-
style.height = "auto";
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
updateChangeBoxBound(text) {
|
|
87
|
-
text &&
|
|
88
|
-
text.set({
|
|
89
|
-
width: text.__layout.boxBounds.width,
|
|
90
|
-
height: text.__layout.boxBounds.height,
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
|
-
onUpdate() {
|
|
94
|
-
const { editor } = __1.quillManager.getCanvas();
|
|
95
|
-
const text = editor._target.findOne("HTMLText");
|
|
96
|
-
const el = editor._target;
|
|
97
|
-
console.log("文本bound更新");
|
|
98
|
-
if (this.curveAmount == text.curveAmount)
|
|
99
|
-
return;
|
|
100
|
-
if (this.isUpdatingPoints)
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
onUnload() {
|
|
104
|
-
const { editor } = __1.quillManager.getCanvas();
|
|
105
|
-
editor.off_(this.eventIds);
|
|
106
|
-
}
|
|
107
|
-
onDestroy() { }
|
|
108
|
-
};
|
|
109
|
-
exports.TextEditTool = TextEditTool;
|
|
110
|
-
exports.TextEditTool = TextEditTool = __decorate([
|
|
111
|
-
(0, editor_1.registerEditTool)(),
|
|
112
|
-
__metadata("design:paramtypes", [Object])
|
|
113
|
-
], TextEditTool);
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare function getArcRadius(fontSize: number, curveAmount: number): number;
|
|
2
|
-
export declare const handleShowCurve: (element: any, op: boolean) => void;
|
|
3
|
-
export declare function toSuperscript(input: string): string;
|
|
4
|
-
export declare function toSubscript(input: string): string;
|
|
5
|
-
export declare const superscriptMapVal: string[];
|
|
6
|
-
export declare const subscriptMapVal: string[];
|
|
7
|
-
export declare function toNormal(input: string): string;
|
|
8
|
-
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/TextEditTool/utils.ts"],"names":[],"mappings":"AAEA,wBAAgB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,WAAW,EAAE,MAAM,GAAG,MAAM,CAM1E;AAED,eAAO,MAAM,eAAe,GAAI,SAAS,GAAG,EAAE,IAAI,OAAO,SAsExD,CAAA;AAgKD,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMnD;AAED,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAMjD;AAED,eAAO,MAAM,iBAAiB,UAAgC,CAAA;AAE9D,eAAO,MAAM,eAAe,UAA8B,CAAA;AAuB1D,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAM9C"}
|
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.subscriptMapVal = exports.superscriptMapVal = exports.handleShowCurve = void 0;
|
|
4
|
-
exports.getArcRadius = getArcRadius;
|
|
5
|
-
exports.toSuperscript = toSuperscript;
|
|
6
|
-
exports.toSubscript = toSubscript;
|
|
7
|
-
exports.toNormal = toNormal;
|
|
8
|
-
const html_1 = require("@leafer-in/html");
|
|
9
|
-
const leafer_ui_1 = require("leafer-ui");
|
|
10
|
-
function getArcRadius(fontSize, curveAmount) {
|
|
11
|
-
if (curveAmount === 0)
|
|
12
|
-
return Infinity;
|
|
13
|
-
const theta = (330 * fontSize * 72) / 96;
|
|
14
|
-
const radius = theta / Math.abs(curveAmount);
|
|
15
|
-
return radius;
|
|
16
|
-
}
|
|
17
|
-
const handleShowCurve = (element, op) => {
|
|
18
|
-
const box = element.findOne('Box');
|
|
19
|
-
box && element.remove(box);
|
|
20
|
-
const text = element.findOne('HTMLText');
|
|
21
|
-
const { boxBounds, x, y } = text;
|
|
22
|
-
const { width } = boxBounds;
|
|
23
|
-
if (!text.curveAmount) {
|
|
24
|
-
text.opacity = 1;
|
|
25
|
-
text.visible = true;
|
|
26
|
-
return;
|
|
27
|
-
}
|
|
28
|
-
text.text = text.text.replace(/\u200B/g, '').replace(/<br\s*\/?>/gi, '\n');
|
|
29
|
-
text.opacity = 0;
|
|
30
|
-
const radius = getArcRadius(text.fontSize, text.curveAmount);
|
|
31
|
-
const C = 2 * Math.PI * radius;
|
|
32
|
-
const dis = text.text.length + 2;
|
|
33
|
-
const tW = width / dis;
|
|
34
|
-
let startW = 0;
|
|
35
|
-
if (C > tW * text.text.length) {
|
|
36
|
-
startW = (C - tW * text.text.length) / 2;
|
|
37
|
-
}
|
|
38
|
-
const startWPr = (startW * 360) / C;
|
|
39
|
-
const group = new leafer_ui_1.Box({
|
|
40
|
-
x: 0,
|
|
41
|
-
y: 0,
|
|
42
|
-
editable: false,
|
|
43
|
-
resizeChildren: true
|
|
44
|
-
});
|
|
45
|
-
let path;
|
|
46
|
-
const offsetK = text.fontSize * text.lineHeight.value || 0;
|
|
47
|
-
const offsetY = text.curveAmount > 0 ? radius + offsetK : -radius;
|
|
48
|
-
if (text.curveAmount > 0) {
|
|
49
|
-
path = `G ${x + width / 2} ${offsetY} ${radius} ${radius} 90 ${startWPr} ${360 - startWPr} 0`;
|
|
50
|
-
}
|
|
51
|
-
else {
|
|
52
|
-
const a = 180 - startWPr;
|
|
53
|
-
path = `G ${x + width / 2} ${offsetY} ${radius} ${radius} 90 ${a} ${-a} 1`;
|
|
54
|
-
}
|
|
55
|
-
const pathLine = new leafer_ui_1.Path({
|
|
56
|
-
x: 0,
|
|
57
|
-
y: 0,
|
|
58
|
-
motionPath: true,
|
|
59
|
-
editable: false,
|
|
60
|
-
path: path
|
|
61
|
-
});
|
|
62
|
-
group.add(pathLine);
|
|
63
|
-
group.set({
|
|
64
|
-
opacity: op ? 0.2 : 1
|
|
65
|
-
});
|
|
66
|
-
Array.from(text.text).forEach((ch, i) => {
|
|
67
|
-
const str = new html_1.HTMLText({
|
|
68
|
-
text: ch,
|
|
69
|
-
around: text.curveAmount > 0 ? 'bottom' : 'top',
|
|
70
|
-
fontSize: text.fontSize,
|
|
71
|
-
fontFamily: text.fontFamily,
|
|
72
|
-
fontWeight: text.fontWeight,
|
|
73
|
-
motion: i * tW + tW / 2,
|
|
74
|
-
textDecoration: text.textDecoration,
|
|
75
|
-
textCase: text.textCase,
|
|
76
|
-
textAlign: text.textAlign,
|
|
77
|
-
motionRotation: text.curveAmount > 0 ? 3 : -2,
|
|
78
|
-
fill: text.fill
|
|
79
|
-
});
|
|
80
|
-
group.add(str);
|
|
81
|
-
});
|
|
82
|
-
element.add(group);
|
|
83
|
-
};
|
|
84
|
-
exports.handleShowCurve = handleShowCurve;
|
|
85
|
-
const baseSuperscript = {
|
|
86
|
-
'0': '⁰',
|
|
87
|
-
'1': '¹',
|
|
88
|
-
'2': '²',
|
|
89
|
-
'3': '³',
|
|
90
|
-
'4': '⁴',
|
|
91
|
-
'5': '⁵',
|
|
92
|
-
'6': '⁶',
|
|
93
|
-
'7': '⁷',
|
|
94
|
-
'8': '⁸',
|
|
95
|
-
'9': '⁹',
|
|
96
|
-
a: 'ᵃ',
|
|
97
|
-
b: 'ᵇ',
|
|
98
|
-
c: 'ᶜ',
|
|
99
|
-
d: 'ᵈ',
|
|
100
|
-
e: 'ᵉ',
|
|
101
|
-
f: 'ᶠ',
|
|
102
|
-
g: 'ᵍ',
|
|
103
|
-
h: 'ʰ',
|
|
104
|
-
i: 'ⁱ',
|
|
105
|
-
j: 'ʲ',
|
|
106
|
-
k: 'ᵏ',
|
|
107
|
-
l: 'ˡ',
|
|
108
|
-
m: 'ᵐ',
|
|
109
|
-
n: 'ⁿ',
|
|
110
|
-
o: 'ᵒ',
|
|
111
|
-
p: 'ᵖ',
|
|
112
|
-
r: 'ʳ',
|
|
113
|
-
s: 'ˢ',
|
|
114
|
-
t: 'ᵗ',
|
|
115
|
-
u: 'ᵘ',
|
|
116
|
-
v: 'ᵛ',
|
|
117
|
-
w: 'ʷ',
|
|
118
|
-
x: 'ˣ',
|
|
119
|
-
y: 'ʸ',
|
|
120
|
-
z: 'ᶻ',
|
|
121
|
-
A: 'ᴬ',
|
|
122
|
-
B: 'ᴮ',
|
|
123
|
-
D: 'ᴰ',
|
|
124
|
-
E: 'ᴱ',
|
|
125
|
-
G: 'ᴳ',
|
|
126
|
-
H: 'ᴴ',
|
|
127
|
-
I: 'ᴵ',
|
|
128
|
-
J: 'ᴶ',
|
|
129
|
-
K: 'ᴷ',
|
|
130
|
-
L: 'ᴸ',
|
|
131
|
-
M: 'ᴹ',
|
|
132
|
-
N: 'ᴺ',
|
|
133
|
-
O: 'ᴼ',
|
|
134
|
-
P: 'ᴾ',
|
|
135
|
-
R: 'ᴿ',
|
|
136
|
-
T: 'ᵀ',
|
|
137
|
-
U: 'ᵁ',
|
|
138
|
-
W: 'ᵂ',
|
|
139
|
-
'+': '⁺',
|
|
140
|
-
'-': '⁻',
|
|
141
|
-
'=': '⁼',
|
|
142
|
-
'(': '⁽',
|
|
143
|
-
')': '⁾'
|
|
144
|
-
};
|
|
145
|
-
const baseSubscript = {
|
|
146
|
-
'0': '₀',
|
|
147
|
-
'1': '₁',
|
|
148
|
-
'2': '₂',
|
|
149
|
-
'3': '₃',
|
|
150
|
-
'4': '₄',
|
|
151
|
-
'5': '₅',
|
|
152
|
-
'6': '₆',
|
|
153
|
-
'7': '₇',
|
|
154
|
-
'8': '₈',
|
|
155
|
-
'9': '₉',
|
|
156
|
-
a: 'ₐ',
|
|
157
|
-
e: 'ₑ',
|
|
158
|
-
h: 'ₕ',
|
|
159
|
-
i: 'ᵢ',
|
|
160
|
-
j: 'ⱼ',
|
|
161
|
-
k: 'ₖ',
|
|
162
|
-
l: 'ₗ',
|
|
163
|
-
m: 'ₘ',
|
|
164
|
-
n: 'ₙ',
|
|
165
|
-
o: 'ₒ',
|
|
166
|
-
p: 'ₚ',
|
|
167
|
-
r: 'ᵣ',
|
|
168
|
-
s: 'ₛ',
|
|
169
|
-
t: 'ₜ',
|
|
170
|
-
u: 'ᵤ',
|
|
171
|
-
v: 'ᵥ',
|
|
172
|
-
x: 'ₓ',
|
|
173
|
-
'+': '₊',
|
|
174
|
-
'-': '₋',
|
|
175
|
-
'=': '₌',
|
|
176
|
-
'(': '₍',
|
|
177
|
-
')': '₎',
|
|
178
|
-
β: 'ᵦ',
|
|
179
|
-
γ: 'ᵧ',
|
|
180
|
-
ρ: 'ᵨ',
|
|
181
|
-
φ: 'ᵩ',
|
|
182
|
-
χ: 'ᵪ'
|
|
183
|
-
};
|
|
184
|
-
function invertMap(map) {
|
|
185
|
-
const inv = {};
|
|
186
|
-
for (const k in map) {
|
|
187
|
-
inv[map[k]] = map[k];
|
|
188
|
-
}
|
|
189
|
-
return inv;
|
|
190
|
-
}
|
|
191
|
-
const knownSupers = invertMap(baseSuperscript);
|
|
192
|
-
const knownSubs = invertMap(baseSubscript);
|
|
193
|
-
function buildSuperscriptMap(baseSup, baseSub) {
|
|
194
|
-
const out = {};
|
|
195
|
-
for (const k in baseSup)
|
|
196
|
-
out[k] = baseSup[k];
|
|
197
|
-
for (const base in baseSub) {
|
|
198
|
-
const subChar = baseSub[base];
|
|
199
|
-
if (base in baseSup)
|
|
200
|
-
out[subChar] = baseSup[base];
|
|
201
|
-
}
|
|
202
|
-
for (const supChar in knownSupers)
|
|
203
|
-
out[supChar] = supChar;
|
|
204
|
-
return out;
|
|
205
|
-
}
|
|
206
|
-
function buildSubscriptMap(baseSup, baseSub) {
|
|
207
|
-
const out = {};
|
|
208
|
-
for (const k in baseSub)
|
|
209
|
-
out[k] = baseSub[k];
|
|
210
|
-
for (const base in baseSup) {
|
|
211
|
-
const supChar = baseSup[base];
|
|
212
|
-
if (base in baseSub)
|
|
213
|
-
out[supChar] = baseSub[base];
|
|
214
|
-
}
|
|
215
|
-
for (const subChar in knownSubs)
|
|
216
|
-
out[subChar] = subChar;
|
|
217
|
-
return out;
|
|
218
|
-
}
|
|
219
|
-
const superscriptMap = buildSuperscriptMap(baseSuperscript, baseSubscript);
|
|
220
|
-
const subscriptMap = buildSubscriptMap(baseSuperscript, baseSubscript);
|
|
221
|
-
function toSuperscript(input) {
|
|
222
|
-
let out = '';
|
|
223
|
-
for (const ch of input) {
|
|
224
|
-
out += superscriptMap[ch] ?? ch;
|
|
225
|
-
}
|
|
226
|
-
return out;
|
|
227
|
-
}
|
|
228
|
-
function toSubscript(input) {
|
|
229
|
-
let out = '';
|
|
230
|
-
for (const ch of input) {
|
|
231
|
-
out += subscriptMap[ch] ?? ch;
|
|
232
|
-
}
|
|
233
|
-
return out;
|
|
234
|
-
}
|
|
235
|
-
exports.superscriptMapVal = Object.values(superscriptMap);
|
|
236
|
-
exports.subscriptMapVal = Object.values(subscriptMap);
|
|
237
|
-
function buildNormalMap(baseSup, baseSub) {
|
|
238
|
-
const normal = {};
|
|
239
|
-
for (const base in baseSup) {
|
|
240
|
-
const supChar = baseSup[base];
|
|
241
|
-
normal[supChar] = base;
|
|
242
|
-
}
|
|
243
|
-
for (const base in baseSub) {
|
|
244
|
-
const subChar = baseSub[base];
|
|
245
|
-
normal[subChar] = base;
|
|
246
|
-
}
|
|
247
|
-
return normal;
|
|
248
|
-
}
|
|
249
|
-
const normalMap = buildNormalMap(baseSuperscript, baseSubscript);
|
|
250
|
-
function toNormal(input) {
|
|
251
|
-
let out = '';
|
|
252
|
-
for (const ch of input) {
|
|
253
|
-
out += normalMap[ch] ?? ch;
|
|
254
|
-
}
|
|
255
|
-
return out;
|
|
256
|
-
}
|
package/dist/TextEditor.d.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { InnerEditor } from "@leafer-in/editor";
|
|
2
|
-
export declare class TextEditor extends InnerEditor {
|
|
3
|
-
get tag(): string;
|
|
4
|
-
editTarget: any;
|
|
5
|
-
editDom: any;
|
|
6
|
-
config: {
|
|
7
|
-
selectAll: boolean;
|
|
8
|
-
};
|
|
9
|
-
eventIds: any[];
|
|
10
|
-
protected selectText: {
|
|
11
|
-
start: number;
|
|
12
|
-
end: number;
|
|
13
|
-
text: string;
|
|
14
|
-
} | undefined;
|
|
15
|
-
protected inBody: boolean | undefined;
|
|
16
|
-
protected isHTMLText: boolean | undefined;
|
|
17
|
-
protected _keyEvent: boolean | undefined;
|
|
18
|
-
quill: any;
|
|
19
|
-
isComposing: boolean;
|
|
20
|
-
private misspelledWords;
|
|
21
|
-
private overlay;
|
|
22
|
-
private get isOASystem();
|
|
23
|
-
onLoad(): void;
|
|
24
|
-
private onSelectionChange;
|
|
25
|
-
private onInput;
|
|
26
|
-
onUpdate(): void;
|
|
27
|
-
private isUpdatingPoints;
|
|
28
|
-
onUnload(): void;
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=TextEditor.d.ts.map
|
package/dist/TextEditor.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"TextEditor.d.ts","sourceRoot":"","sources":["../src/TextEditor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAuB,MAAM,mBAAmB,CAAC;AAIrE,qBACa,UAAW,SAAQ,WAAW;IACzC,IAAW,GAAG,WAEb;IACc,UAAU,EAAE,GAAG,CAAC;IAExB,OAAO,EAAE,GAAG,CAAC;IACb,MAAM;;MAEX;IAEK,QAAQ,EAAE,GAAG,EAAE,CAAM;IAE5B,SAAS,CAAC,UAAU,EAChB;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,GAAG,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,GAC5C,SAAS,CAAa;IAC1B,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,SAAS,CAAa;IAClD,SAAS,CAAC,UAAU,EAAE,OAAO,GAAG,SAAS,CAAa;IACtD,SAAS,CAAC,SAAS,EAAE,OAAO,GAAG,SAAS,CAAa;IAC9C,KAAK,EAAE,GAAG,CAAQ;IAClB,WAAW,EAAE,OAAO,CAAS;IAGpC,OAAO,CAAC,eAAe,CAIf;IACR,OAAO,CAAC,OAAO,CAA+B;IAG9C,OAAO,KAAK,UAAU,GAErB;IACM,MAAM,IAAI,IAAI;IA4FrB,OAAO,CAAC,iBAAiB,CAEvB;IAEF,OAAO,CAAC,OAAO,CAUb;IAEK,QAAQ;IA0Bf,OAAO,CAAC,gBAAgB,CAAS;IAC1B,QAAQ,IAAI,IAAI;CAsCxB"}
|
package/dist/TextEditor.js
DELETED
|
@@ -1,169 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
-
};
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.TextEditor = void 0;
|
|
10
|
-
const editor_1 = require("@leafer-in/editor");
|
|
11
|
-
const core_1 = require("@leafer-ui/core");
|
|
12
|
-
const _1 = require(".");
|
|
13
|
-
const utils_1 = require("./utils");
|
|
14
|
-
let TextEditor = class TextEditor extends editor_1.InnerEditor {
|
|
15
|
-
constructor() {
|
|
16
|
-
super(...arguments);
|
|
17
|
-
this.config = {
|
|
18
|
-
selectAll: false,
|
|
19
|
-
};
|
|
20
|
-
this.eventIds = [];
|
|
21
|
-
this.selectText = undefined;
|
|
22
|
-
this.inBody = undefined;
|
|
23
|
-
this.isHTMLText = undefined;
|
|
24
|
-
this._keyEvent = undefined;
|
|
25
|
-
this.quill = null;
|
|
26
|
-
this.isComposing = false;
|
|
27
|
-
this.misspelledWords = [];
|
|
28
|
-
this.overlay = null;
|
|
29
|
-
this.onSelectionChange = async (e) => {
|
|
30
|
-
e && localStorage.setItem("selection-change", JSON.stringify(e));
|
|
31
|
-
};
|
|
32
|
-
this.onInput = async () => {
|
|
33
|
-
const { editDom } = this;
|
|
34
|
-
console.log("onInput");
|
|
35
|
-
(0, utils_1.updataHtmlText)(this.editTarget);
|
|
36
|
-
};
|
|
37
|
-
this.isUpdatingPoints = false;
|
|
38
|
-
}
|
|
39
|
-
get tag() {
|
|
40
|
-
return "TextEditor";
|
|
41
|
-
}
|
|
42
|
-
get isOASystem() {
|
|
43
|
-
return window.location.host.includes("oa");
|
|
44
|
-
}
|
|
45
|
-
onLoad() {
|
|
46
|
-
const { editor } = this;
|
|
47
|
-
const { config } = editor.app;
|
|
48
|
-
const text = this.editTarget;
|
|
49
|
-
const { scaleX, scaleY } = text.worldTransform;
|
|
50
|
-
const zoomScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
|
|
51
|
-
this.isHTMLText = !(text instanceof Text);
|
|
52
|
-
this._keyEvent = config.keyEvent;
|
|
53
|
-
config.keyEvent = false;
|
|
54
|
-
const div = (this.editDom = document.querySelector("#textInnerEditor"));
|
|
55
|
-
const { style } = div;
|
|
56
|
-
style.visibility = "visible";
|
|
57
|
-
if (text.data.canChangeBox) {
|
|
58
|
-
style.width = text.parent.width * zoomScale + "px";
|
|
59
|
-
style.height = text.parent.height * zoomScale + "px";
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
style.width = "auto";
|
|
63
|
-
style.height = "auto";
|
|
64
|
-
}
|
|
65
|
-
style.outline = "solid #8499EF";
|
|
66
|
-
if (text.data.textData.fontSize) {
|
|
67
|
-
console.log(text.data.textData.fontSize);
|
|
68
|
-
div.style.fontSize = `${text.data.textData.fontSize}px`;
|
|
69
|
-
}
|
|
70
|
-
if (text.data.textData.fontFamily) {
|
|
71
|
-
div.style.fontFamily = `${text.data.textData.fontFamily}`;
|
|
72
|
-
}
|
|
73
|
-
if (text.data.textData.lineHeight) {
|
|
74
|
-
div.style.lineHeight = text.data.textData.lineHeight;
|
|
75
|
-
}
|
|
76
|
-
if (text.data.textData.letterSpacing) {
|
|
77
|
-
div.style.letterSpacing = `${text.data.textData.letterSpacing}px`;
|
|
78
|
-
}
|
|
79
|
-
if (text.data.textData.textShadow) {
|
|
80
|
-
div.style.textShadow = `${text.data.textData.textShadow}`;
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
div.style.textShadow = "none";
|
|
84
|
-
}
|
|
85
|
-
if (text.data.textData.alignContent) {
|
|
86
|
-
const qlEditor = div.querySelector(".ql-editor");
|
|
87
|
-
qlEditor.style.alignContent = `${text.data.textData.alignContent}`;
|
|
88
|
-
}
|
|
89
|
-
this.quill = _1.quillManager.getQuill();
|
|
90
|
-
this.quill.clipboard.dangerouslyPasteHTML(text.text);
|
|
91
|
-
if (text.parent.children[0].tag.includes("Shape")) {
|
|
92
|
-
style.width = text.parent.width * zoomScale + "px";
|
|
93
|
-
style.left = "0px";
|
|
94
|
-
this.quill.formatLine(0, this.quill.getLength(), "align", "center");
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
this.quill.setSelection(0, this.quill.getLength() - 1);
|
|
98
|
-
}
|
|
99
|
-
this.quill.on("text-change", this.onInput);
|
|
100
|
-
this.quill.on("selection-change", this.onSelectionChange);
|
|
101
|
-
localStorage.removeItem("selection-change");
|
|
102
|
-
this.eventIds = [
|
|
103
|
-
editor.app.on_(core_1.PointerEvent.DOWN, (e) => {
|
|
104
|
-
let { target } = e.origin, find = false;
|
|
105
|
-
while (target) {
|
|
106
|
-
if (target === div)
|
|
107
|
-
find = true;
|
|
108
|
-
target = target.parentElement;
|
|
109
|
-
}
|
|
110
|
-
if (!find) {
|
|
111
|
-
editor.closeInnerEditor();
|
|
112
|
-
editor.cancel();
|
|
113
|
-
}
|
|
114
|
-
}),
|
|
115
|
-
];
|
|
116
|
-
}
|
|
117
|
-
onUpdate() {
|
|
118
|
-
const { editTarget: text } = this;
|
|
119
|
-
const { scaleX, scaleY } = text.worldTransform;
|
|
120
|
-
const zoomScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
|
|
121
|
-
let { width, height } = text.parent.__local;
|
|
122
|
-
((width *= zoomScale), (height *= zoomScale));
|
|
123
|
-
const { x, y } = this.inBody
|
|
124
|
-
? text.app.clientBounds
|
|
125
|
-
: text.app.tree.clientBounds;
|
|
126
|
-
const { a, b, c, d, e, f } = new core_1.Matrix(text.worldTransform)
|
|
127
|
-
.scale(1 / zoomScale)
|
|
128
|
-
.translateInner(0, 0);
|
|
129
|
-
const { style } = this.editDom;
|
|
130
|
-
style.transform = `matrix(${a},${b},${c},${d},${e},${f})`;
|
|
131
|
-
style.left = x + "px";
|
|
132
|
-
style.top = y + "px";
|
|
133
|
-
text.set({
|
|
134
|
-
visible: false,
|
|
135
|
-
});
|
|
136
|
-
}
|
|
137
|
-
onUnload() {
|
|
138
|
-
const { editTarget: text, editor, editDom: dom } = this;
|
|
139
|
-
if (text) {
|
|
140
|
-
this.onInput();
|
|
141
|
-
if (editor.app)
|
|
142
|
-
editor.app.config.keyEvent = this._keyEvent;
|
|
143
|
-
editor.off_(this.eventIds);
|
|
144
|
-
this.editDom.style.visibility = "hidden";
|
|
145
|
-
this.eventIds = [];
|
|
146
|
-
}
|
|
147
|
-
if (text.parent &&
|
|
148
|
-
text.parent.name == "Text" &&
|
|
149
|
-
text.parent.children.some((e) => e.tag === "Box")) {
|
|
150
|
-
text.parent.findOne("Box").opacity = 1;
|
|
151
|
-
text.visible = false;
|
|
152
|
-
}
|
|
153
|
-
else {
|
|
154
|
-
text.set({
|
|
155
|
-
visible: true,
|
|
156
|
-
});
|
|
157
|
-
}
|
|
158
|
-
if (this.quill.getLength() === 1 && text.parent.name === "Text") {
|
|
159
|
-
text.parent.remove();
|
|
160
|
-
}
|
|
161
|
-
console.log("onUnload");
|
|
162
|
-
this.quill.off("text-change", this.onInput);
|
|
163
|
-
this.quill.off("selection-change", this.onSelectionChange);
|
|
164
|
-
}
|
|
165
|
-
};
|
|
166
|
-
exports.TextEditor = TextEditor;
|
|
167
|
-
exports.TextEditor = TextEditor = __decorate([
|
|
168
|
-
(0, editor_1.registerInnerEditor)()
|
|
169
|
-
], TextEditor);
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { EditTool } from "@leafer-in/editor";
|
|
2
|
-
export declare class TextEditTool extends EditTool {
|
|
3
|
-
get tag(): string;
|
|
4
|
-
quill: any;
|
|
5
|
-
private updateBoxDebounced;
|
|
6
|
-
constructor(editor: any);
|
|
7
|
-
private debounce;
|
|
8
|
-
addEvent(): void;
|
|
9
|
-
onLoad(): void;
|
|
10
|
-
private isUpdatingPoints;
|
|
11
|
-
private curveAmount;
|
|
12
|
-
updateChangeBoxBound(text: any): void;
|
|
13
|
-
onUpdate(): void;
|
|
14
|
-
onUnload(): void;
|
|
15
|
-
onDestroy(): void;
|
|
16
|
-
}
|
|
17
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/TextEditTool/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAGT,MAAM,mBAAmB,CAAC;AAK3B,qBAEa,YAAa,SAAQ,QAAQ;IAExC,IAAW,GAAG,WAEb;IACM,KAAK,EAAE,GAAG,CAAQ;IACzB,OAAO,CAAC,kBAAkB,CAAsB;gBAEpC,MAAM,EAAE,GAAG;IAQvB,OAAO,CAAC,QAAQ;IAgBT,QAAQ,IAAI,IAAI;IA2BhB,MAAM,IAAI,IAAI;IA4BrB,OAAO,CAAC,gBAAgB,CAAS;IACjC,OAAO,CAAC,WAAW,CAAK;IACjB,oBAAoB,CAAC,IAAI,EAAE,GAAG,GAAG,IAAI;IAQrC,QAAQ,IAAI,IAAI;IAgBhB,QAAQ,IAAI,IAAI;IAMhB,SAAS,IAAI,IAAI;CACzB"}
|