@chenyomi/leafer-htmltext-editor 1.0.0 → 1.0.2
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/TextEditTool/index.d.ts +2 -2
- package/dist/TextEditTool/index.d.ts.map +1 -1
- package/dist/TextEditTool/index.js +44 -70
- package/dist/TextEditTool/utils.d.ts.map +1 -1
- package/dist/TextEditTool/utils.js +96 -13
- package/dist/TextEditor.d.ts +9 -6
- package/dist/TextEditor.d.ts.map +1 -1
- package/dist/TextEditor.js +66 -63
- package/dist/esm/TextEditTool/index.d.ts +2 -2
- package/dist/esm/TextEditTool/index.d.ts.map +1 -1
- package/dist/esm/TextEditTool/index.js +46 -72
- package/dist/esm/TextEditTool/utils.d.ts.map +1 -1
- package/dist/esm/TextEditTool/utils.js +96 -13
- package/dist/esm/TextEditor.d.ts +9 -6
- package/dist/esm/TextEditor.d.ts.map +1 -1
- package/dist/esm/TextEditor.js +66 -63
- package/dist/esm/index.d.ts +17 -5
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/utils.d.ts +1 -1
- package/dist/esm/utils.d.ts.map +1 -1
- package/dist/esm/utils.js +29 -48
- package/dist/index.d.ts +17 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/index.esm.js +130 -72
- package/dist/index.js +164 -83
- package/dist/utils.d.ts +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +29 -48
- package/package.json +3 -3
- package/src/TextEditTool/index.ts +77 -92
- package/src/TextEditTool/utils.ts +101 -29
- package/src/TextEditor.ts +104 -90
- package/src/index.ts +141 -79
- package/src/utils.ts +140 -178
package/dist/index.js
CHANGED
|
@@ -1,92 +1,173 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
5
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.
|
|
7
|
-
|
|
8
|
-
const TextEditor_1 = require("./TextEditor");
|
|
9
|
-
var TextEditor_2 = require("./TextEditor");
|
|
10
|
-
Object.defineProperty(exports, "TextEditor", { enumerable: true, get: function () { return TextEditor_2.TextEditor; } });
|
|
36
|
+
exports.quillManager = void 0;
|
|
37
|
+
const quill_1 = __importStar(require("quill"));
|
|
11
38
|
require("./TextEditTool");
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
core_1.Plugin.add("leafer-htmltext-editor", "editor");
|
|
24
|
-
function initTextEditorQuill(container) {
|
|
25
|
-
const textInner = document.getElementById("textInnerEditor");
|
|
26
|
-
if (!textInner) {
|
|
27
|
-
const el = document.createElement("div");
|
|
28
|
-
el.id = "textInnerEditor";
|
|
29
|
-
el.style.position = "fixed";
|
|
30
|
-
el.style.transformOrigin = "left top";
|
|
31
|
-
el.style.overflowWrap = "break-word";
|
|
32
|
-
el.style.wordBreak = "break-all";
|
|
33
|
-
el.style.visibility = "hidden";
|
|
34
|
-
document.body.appendChild(el);
|
|
39
|
+
require("./TextEditor");
|
|
40
|
+
class QuillManager {
|
|
41
|
+
constructor() {
|
|
42
|
+
this.quill = null;
|
|
43
|
+
this.app_ = null;
|
|
44
|
+
}
|
|
45
|
+
static getInstance() {
|
|
46
|
+
if (!QuillManager.instance) {
|
|
47
|
+
QuillManager.instance = new QuillManager();
|
|
48
|
+
}
|
|
49
|
+
return QuillManager.instance;
|
|
35
50
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
async init(app) {
|
|
52
|
+
this.app_ = app;
|
|
53
|
+
if (this.quill)
|
|
54
|
+
return this.quill;
|
|
55
|
+
let el = document.getElementById("textInnerEditor");
|
|
56
|
+
if (!el) {
|
|
57
|
+
el = document.createElement("div");
|
|
58
|
+
el.id = "textInnerEditor";
|
|
59
|
+
el.style.position = "fixed";
|
|
60
|
+
el.style.transformOrigin = "left top";
|
|
61
|
+
el.style.overflowWrap = "break-word";
|
|
62
|
+
el.style.wordBreak = "break-all";
|
|
63
|
+
el.style.visibility = "hidden";
|
|
64
|
+
document.body.appendChild(el);
|
|
65
|
+
}
|
|
66
|
+
this.quill = new quill_1.default("#textInnerEditor", {
|
|
67
|
+
theme: undefined,
|
|
68
|
+
modules: {
|
|
69
|
+
toolbar: false,
|
|
70
|
+
keyboard: {
|
|
71
|
+
bindings: {
|
|
72
|
+
enter: {
|
|
73
|
+
key: "Enter",
|
|
74
|
+
handler: (range) => {
|
|
75
|
+
const [line] = this.quill.getLine(range.index);
|
|
76
|
+
const BlockBlot = quill_1.default.import("blots/block");
|
|
77
|
+
if (!BlockBlot?.bubbleFormats)
|
|
78
|
+
return true;
|
|
79
|
+
const lineFormats = BlockBlot.bubbleFormats(line);
|
|
80
|
+
const delta = new quill_1.Delta()
|
|
81
|
+
.retain(range.index)
|
|
82
|
+
.delete(range.length)
|
|
83
|
+
.insert("\n", lineFormats);
|
|
84
|
+
this.quill.updateContents(delta, quill_1.default.sources.USER);
|
|
85
|
+
this.quill.setSelection(range.index + 1, quill_1.default.sources.SILENT);
|
|
86
|
+
return false;
|
|
87
|
+
},
|
|
57
88
|
},
|
|
58
89
|
},
|
|
59
90
|
},
|
|
60
91
|
},
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
"
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
});
|
|
93
|
+
this.app_.editor.quill = this.quill;
|
|
94
|
+
this.registerFonts();
|
|
95
|
+
return this.quill;
|
|
96
|
+
}
|
|
97
|
+
getQuill() {
|
|
98
|
+
if (!this.quill) {
|
|
99
|
+
throw new Error("Quill editor not initialized. Call init() first.");
|
|
100
|
+
}
|
|
101
|
+
return this.quill;
|
|
102
|
+
}
|
|
103
|
+
getCanvas() {
|
|
104
|
+
if (!this.app_) {
|
|
105
|
+
throw new Error("app_ editor not initialized. Call init() first.");
|
|
106
|
+
}
|
|
107
|
+
return this.app_;
|
|
108
|
+
}
|
|
109
|
+
registerFonts() {
|
|
110
|
+
const FontAttributor = quill_1.default.import("attributors/class/font");
|
|
111
|
+
FontAttributor.whitelist = [
|
|
112
|
+
"Roboto",
|
|
113
|
+
"RobotoMono",
|
|
114
|
+
"Inter",
|
|
115
|
+
"OpenSans",
|
|
116
|
+
"Montserrat",
|
|
117
|
+
"RobotoCondensed",
|
|
118
|
+
"Arimo",
|
|
119
|
+
"NotoSans",
|
|
120
|
+
"NotoSansSymbols",
|
|
121
|
+
"Merriweather",
|
|
122
|
+
"PlayfairDisplay",
|
|
123
|
+
"NotoSerif",
|
|
124
|
+
"Lato",
|
|
125
|
+
"Spectral",
|
|
126
|
+
"DancingScript",
|
|
127
|
+
"NotoSansSimplifiedChinese",
|
|
128
|
+
"NotoSerifSimplifiedChinese",
|
|
129
|
+
"NotoSansTraditionalChinese",
|
|
130
|
+
"NotoSansHongKong",
|
|
131
|
+
"NotoSerifTraditionalChinese",
|
|
132
|
+
"NotoSerifHongKong",
|
|
133
|
+
"NotoSansJapanese",
|
|
134
|
+
"NotoSansKorean",
|
|
135
|
+
"Poppins",
|
|
136
|
+
];
|
|
137
|
+
quill_1.default.register(FontAttributor, true);
|
|
138
|
+
}
|
|
139
|
+
isMultiSelect() {
|
|
140
|
+
if (!this.app_.editor)
|
|
141
|
+
return false;
|
|
142
|
+
if (this.app_.editor.multiple === true) {
|
|
143
|
+
return true;
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
return false;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
dateEdit(callback, level = 0, listNew) {
|
|
150
|
+
const { editor } = this.app_;
|
|
151
|
+
const list = listNew ? listNew : editor.leafList.list;
|
|
152
|
+
const applyCallback = (leaf) => {
|
|
153
|
+
if (level && (leaf.tag === "Box" || leaf.name === "Text")) {
|
|
154
|
+
callback(leaf.children?.[0] || leaf);
|
|
155
|
+
}
|
|
156
|
+
else {
|
|
157
|
+
callback(leaf);
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
if (!list.length)
|
|
161
|
+
return;
|
|
162
|
+
if (Array.isArray(list) && list.length > 1) {
|
|
163
|
+
this.app_.lockLayout();
|
|
164
|
+
list.forEach(applyCallback);
|
|
165
|
+
this.app_.unlockLayout();
|
|
166
|
+
editor.updateEditBox();
|
|
167
|
+
}
|
|
168
|
+
else {
|
|
169
|
+
applyCallback(list[0]);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
92
172
|
}
|
|
173
|
+
exports.quillManager = QuillManager.getInstance();
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export declare const updataHtmlText: (e?: any, base64font?: any, fontObj?: any) => Promise<void>;
|
|
2
|
-
export declare const setHTMLText: (key: string, value?: any, base64font?: any
|
|
2
|
+
export declare const setHTMLText: (key: string, value?: any, base64font?: any) => void;
|
|
3
3
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,cAAc,GAAU,IAAI,GAAG,EAAE,aAAa,GAAG,EAAE,UAAU,GAAG,kBAgG5E,CAAA;AAmED,eAAO,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,QAAQ,GAAG,EAAE,aAAa,GAAG,SA+HrE,CAAA"}
|
package/dist/utils.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.setHTMLText = exports.updataHtmlText = void 0;
|
|
4
|
-
const
|
|
5
|
-
function getEditorContext() {
|
|
6
|
-
const quill = TextEditor_1.TextEditor.quill;
|
|
7
|
-
return { quill };
|
|
8
|
-
}
|
|
4
|
+
const _1 = require(".");
|
|
9
5
|
const updataHtmlText = async (e, base64font, fontObj) => {
|
|
10
6
|
const { scaleX, scaleY } = e.worldTransform;
|
|
11
7
|
const zoomScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
|
|
@@ -25,18 +21,14 @@ const updataHtmlText = async (e, base64font, fontObj) => {
|
|
|
25
21
|
if (dom && e.data.textData?.textShadow) {
|
|
26
22
|
dom.style.textShadow = e.data.textData.textShadow;
|
|
27
23
|
}
|
|
28
|
-
else
|
|
24
|
+
else {
|
|
29
25
|
dom.style.textShadow = 'none';
|
|
30
26
|
}
|
|
31
27
|
if (dom && e.data.textData?.alignContent) {
|
|
32
28
|
const qlEditor = dom.querySelector('.ql-editor');
|
|
33
|
-
|
|
34
|
-
qlEditor.style.alignContent = e.data.textData.alignContent;
|
|
35
|
-
}
|
|
29
|
+
qlEditor.style.alignContent = e.data.textData.alignContent;
|
|
36
30
|
}
|
|
37
|
-
const
|
|
38
|
-
if (!quill)
|
|
39
|
-
return;
|
|
31
|
+
const quill = _1.quillManager.getQuill();
|
|
40
32
|
const html = quill.getSemanticHTML();
|
|
41
33
|
if (html === '<p></p>') {
|
|
42
34
|
if (e.text.includes('<style>@font-face')) {
|
|
@@ -76,9 +68,6 @@ const updataHtmlText = async (e, base64font, fontObj) => {
|
|
|
76
68
|
};
|
|
77
69
|
exports.updataHtmlText = updataHtmlText;
|
|
78
70
|
const addFontSizeToP = (e, html, fontSize = 16, lineHeight = '1.5', letterSpacing = '0', textShadow = 'none', alignContent = 'start') => {
|
|
79
|
-
const { quill } = getEditorContext();
|
|
80
|
-
if (!quill)
|
|
81
|
-
return html;
|
|
82
71
|
const { scaleX, scaleY } = e.worldTransform;
|
|
83
72
|
const zoomScale = Math.max(Math.abs(scaleX), Math.abs(scaleY));
|
|
84
73
|
const wrapper = document.createElement('div');
|
|
@@ -98,6 +87,7 @@ const addFontSizeToP = (e, html, fontSize = 16, lineHeight = '1.5', letterSpacin
|
|
|
98
87
|
}
|
|
99
88
|
let height;
|
|
100
89
|
const div = document.querySelector('#textInnerEditor');
|
|
90
|
+
const quill = _1.quillManager.getQuill();
|
|
101
91
|
const actualHeight = Number((quill.scroll.domNode.scrollHeight / zoomScale).toFixed(0));
|
|
102
92
|
const actualWidth = Number((quill.scroll.domNode.scrollWidth / zoomScale).toFixed(0));
|
|
103
93
|
if (['center', 'end'].includes(e.data.textData.alignContent)) {
|
|
@@ -117,7 +107,7 @@ const addFontSizeToP = (e, html, fontSize = 16, lineHeight = '1.5', letterSpacin
|
|
|
117
107
|
height = `${e.parent.height}px`;
|
|
118
108
|
}
|
|
119
109
|
}
|
|
120
|
-
const style = `<style>sub,sup{font-size:63%;}.ql-ui{position:absolute}ol,ul{counter-reset:list-0;padding-left:1.5em;margin:0}ol>li,ul>li{counter-increment:list-0;list-style-type:none;position:relative;padding-left:0;margin:0}ol>li::before{content:counter(list-0,decimal) '. ';position:absolute;left:-1.5em;width:1.2em;text-align:right}ul>li::before{content:'
|
|
110
|
+
const style = `<style>sub,sup{font-size:63%;}.ql-ui{position:absolute}ol,ul{counter-reset:list-0;padding-left:1.5em;margin:0}ol>li,ul>li{counter-increment:list-0;list-style-type:none;position:relative;padding-left:0;margin:0}ol>li::before{content:counter(list-0,decimal) '. ';position:absolute;left:-1.5em;width:1.2em;text-align:right}ul>li::before{content:'\u2022';position:absolute;left:-1.5em;width:1.2em;text-align:right}li[data-list]{counter-set:list-1 list-2 list-3 list-4 list-5 list-6 list-7 list-8 list-9}.ql-align-center{text-align:center}.ql-align-right{text-align:right}.ql-align-left{text-align:left}.ql-align-justify{text-align:justify}</style>`;
|
|
121
111
|
let divBox = '';
|
|
122
112
|
if (e.parent.children[0].tag.includes('Shape')) {
|
|
123
113
|
divBox =
|
|
@@ -140,25 +130,18 @@ const addFontSizeToP = (e, html, fontSize = 16, lineHeight = '1.5', letterSpacin
|
|
|
140
130
|
console.log(divBox, '最终的html内容');
|
|
141
131
|
return divBox;
|
|
142
132
|
};
|
|
143
|
-
const setHTMLText = (key, value, base64font
|
|
144
|
-
const
|
|
133
|
+
const setHTMLText = (key, value, base64font) => {
|
|
134
|
+
const quill = _1.quillManager.getQuill();
|
|
135
|
+
const { editor, canvas } = _1.quillManager.getCanvas();
|
|
136
|
+
console.log(editor, _1.quillManager.getCanvas(), 'editor');
|
|
145
137
|
if (!quill) {
|
|
146
|
-
console.error('Quill editor not initialized');
|
|
147
138
|
return;
|
|
148
139
|
}
|
|
149
|
-
const
|
|
150
|
-
|
|
151
|
-
if (range && isInnerEditor) {
|
|
152
|
-
quill.setSelection(range.index, range.length);
|
|
153
|
-
}
|
|
154
|
-
if (!editor || !editor.dateEdit) {
|
|
155
|
-
console.warn('Editor context not available for dateEdit');
|
|
156
|
-
return;
|
|
157
|
-
}
|
|
158
|
-
editor.dateEdit(async (e) => {
|
|
140
|
+
const range = JSON.parse(localStorage.getItem('selection-change') || '{}');
|
|
141
|
+
_1.quillManager.dateEdit(async (e) => {
|
|
159
142
|
if (key === 'font') {
|
|
160
143
|
const fontSimpleName = value.code.replace(/\s+/g, '');
|
|
161
|
-
if (
|
|
144
|
+
if (editor.innerEditing) {
|
|
162
145
|
if (range && range.length) {
|
|
163
146
|
quill.formatText(range.index, range.length, key, fontSimpleName);
|
|
164
147
|
}
|
|
@@ -168,18 +151,18 @@ const setHTMLText = (key, value, base64font, editor, isInnerEditor) => {
|
|
|
168
151
|
(0, exports.updataHtmlText)(e, base64font ?? null, value ?? null);
|
|
169
152
|
}
|
|
170
153
|
else {
|
|
171
|
-
|
|
154
|
+
_1.quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
172
155
|
quill.formatText(0, quill.getLength() - 1, key, fontSimpleName);
|
|
173
156
|
(0, exports.updataHtmlText)(e, base64font ?? null, value ?? null);
|
|
174
157
|
}
|
|
175
158
|
}
|
|
176
159
|
else if (key === 'fontSize') {
|
|
177
160
|
e.data.textData[key] = value;
|
|
178
|
-
|
|
161
|
+
_1.quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
179
162
|
(0, exports.updataHtmlText)(e, base64font ?? null);
|
|
180
163
|
}
|
|
181
164
|
else if (key === 'textCase') {
|
|
182
|
-
if (
|
|
165
|
+
if (editor.innerEditing) {
|
|
183
166
|
const text = quill.getText(range.index, range.length);
|
|
184
167
|
const formats = quill.getFormat(range.index, range.length);
|
|
185
168
|
quill.deleteText(range.index, range.length);
|
|
@@ -194,16 +177,14 @@ const setHTMLText = (key, value, base64font, editor, isInnerEditor) => {
|
|
|
194
177
|
convertedText = text.toUpperCase();
|
|
195
178
|
}
|
|
196
179
|
quill.insertText(range.index, convertedText, formats);
|
|
197
|
-
|
|
198
|
-
quill.setSelection(range.index, range.length);
|
|
199
|
-
}
|
|
180
|
+
range && editor.innerEditing && quill.setSelection(range.index, range.length);
|
|
200
181
|
}
|
|
201
182
|
}
|
|
202
183
|
else if (key === 'script') {
|
|
203
184
|
let val = 'sub';
|
|
204
185
|
if (value === 'super')
|
|
205
186
|
val = 'sup';
|
|
206
|
-
if (
|
|
187
|
+
if (editor.innerEditing) {
|
|
207
188
|
if (range && range.length) {
|
|
208
189
|
quill.formatText(range.index, range.length, key, quill.getFormat(range).script === value ? false : val);
|
|
209
190
|
}
|
|
@@ -212,14 +193,14 @@ const setHTMLText = (key, value, base64font, editor, isInnerEditor) => {
|
|
|
212
193
|
}
|
|
213
194
|
}
|
|
214
195
|
else {
|
|
215
|
-
|
|
196
|
+
_1.quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
216
197
|
quill.formatText(0, quill.getLength() - 1, key, quill.getFormat().script === value ? false : val);
|
|
217
198
|
(0, exports.updataHtmlText)(e);
|
|
218
199
|
}
|
|
219
200
|
}
|
|
220
201
|
else if (key === 'align') {
|
|
221
|
-
|
|
222
|
-
if (
|
|
202
|
+
_1.quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
203
|
+
if (editor.innerEditing) {
|
|
223
204
|
quill.format(key, value);
|
|
224
205
|
}
|
|
225
206
|
else {
|
|
@@ -228,28 +209,28 @@ const setHTMLText = (key, value, base64font, editor, isInnerEditor) => {
|
|
|
228
209
|
(0, exports.updataHtmlText)(e);
|
|
229
210
|
}
|
|
230
211
|
else if (key === 'alignContent') {
|
|
231
|
-
|
|
212
|
+
_1.quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
232
213
|
e.data.textData[key] = value;
|
|
233
214
|
(0, exports.updataHtmlText)(e);
|
|
234
215
|
}
|
|
235
216
|
else if (key === 'color') {
|
|
236
|
-
|
|
217
|
+
_1.quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
237
218
|
quill.formatText(0, quill.getLength() - 1, key, value);
|
|
238
219
|
if (e.tag === 'HTMLText') {
|
|
239
220
|
(0, exports.updataHtmlText)(e);
|
|
240
221
|
}
|
|
241
|
-
else if (e.parent.findOne
|
|
222
|
+
else if (e.parent.findOne('HTMLText')) {
|
|
242
223
|
(0, exports.updataHtmlText)(e.parent.findOne('HTMLText'));
|
|
243
224
|
}
|
|
244
225
|
}
|
|
245
226
|
else if (key === 'textShadow') {
|
|
246
|
-
|
|
227
|
+
_1.quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
247
228
|
e.data.textData[key] = value;
|
|
248
229
|
(0, exports.updataHtmlText)(e);
|
|
249
230
|
}
|
|
250
231
|
else if (key === 'list') {
|
|
251
|
-
|
|
252
|
-
if (
|
|
232
|
+
_1.quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
233
|
+
if (editor.innerEditing) {
|
|
253
234
|
const [line] = quill.getLine(range?.index || 0);
|
|
254
235
|
if (line.formats().list) {
|
|
255
236
|
quill.format(key, false);
|
|
@@ -270,7 +251,7 @@ const setHTMLText = (key, value, base64font, editor, isInnerEditor) => {
|
|
|
270
251
|
(0, exports.updataHtmlText)(e);
|
|
271
252
|
}
|
|
272
253
|
else {
|
|
273
|
-
if (
|
|
254
|
+
if (editor.innerEditing) {
|
|
274
255
|
if (range && range.length) {
|
|
275
256
|
quill.formatText(range.index, range.length, key, !quill.getFormat(range)[key]);
|
|
276
257
|
}
|
|
@@ -279,7 +260,7 @@ const setHTMLText = (key, value, base64font, editor, isInnerEditor) => {
|
|
|
279
260
|
}
|
|
280
261
|
}
|
|
281
262
|
else {
|
|
282
|
-
|
|
263
|
+
_1.quillManager.isMultiSelect() && quill.clipboard.dangerouslyPasteHTML(e.text);
|
|
283
264
|
quill.formatText(0, quill.getLength() - 1, key, !quill.getFormat()[key]);
|
|
284
265
|
(0, exports.updataHtmlText)(e);
|
|
285
266
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chenyomi/leafer-htmltext-editor",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "A text editor plugin for Leafer UI with HTML text support and Quill integration",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.esm.js",
|
|
@@ -32,14 +32,14 @@
|
|
|
32
32
|
},
|
|
33
33
|
"homepage": "https://github.com/yourusername/leafer-htmltext-editor#readme",
|
|
34
34
|
"peerDependencies": {
|
|
35
|
-
"@leafer-ui/core": ">=1.0.0",
|
|
36
35
|
"@leafer-in/editor": ">=1.0.0",
|
|
37
|
-
"@leafer-in/interface": ">=1.0.0",
|
|
38
36
|
"@leafer-in/html": ">=1.0.0",
|
|
37
|
+
"@leafer-ui/core": ">=1.0.0",
|
|
39
38
|
"leafer-ui": ">=1.0.0",
|
|
40
39
|
"quill": ">=2.0.0"
|
|
41
40
|
},
|
|
42
41
|
"devDependencies": {
|
|
42
|
+
"@types/lodash": "^4.17.23",
|
|
43
43
|
"@types/node": "^20.0.0",
|
|
44
44
|
"typescript": "^5.0.0"
|
|
45
45
|
},
|