@chenyomi/leafer-htmltext-edit 2.0.2 → 2.1.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/README.md +394 -47
- package/dist/index.cjs +4 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +6 -4
- package/dist/index.d.ts +6 -4
- package/dist/index.mjs +4 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -7,15 +7,19 @@
|
|
|
7
7
|
<img src="https://img.shields.io/badge/TypeScript-Ready-blue.svg" alt="TypeScript">
|
|
8
8
|
</p>
|
|
9
9
|
|
|
10
|
-
一个强大的 Leafer UI
|
|
10
|
+
一个强大的 Leafer UI 富文本编辑器插件,集成 Quill 2.0,支持 HTML 文本编辑和丰富的文本样式控制。
|
|
11
|
+
|
|
12
|
+
[English](./README_EN.md) | 简体中文
|
|
11
13
|
|
|
12
14
|
## ✨ 特性
|
|
13
15
|
|
|
14
|
-
-
|
|
16
|
+
- 🎨 **富文本编辑** - 基于 Quill 2.0,支持完整的富文本编辑功能
|
|
17
|
+
- 🔤 **多语言字体** - 内置 20+ 种字体,支持中文、日文、韩文等多语言
|
|
15
18
|
- 📐 **文本样式** - 字体、大小、颜色、对齐、行高、字间距等全面控制
|
|
16
19
|
- 📝 **格式化工具** - 加粗、斜体、下划线、删除线、上下标
|
|
17
20
|
- 📋 **列表支持** - 有序列表、无序列表
|
|
18
21
|
- 🎯 **完美集成** - 无缝集成到 Leafer UI 生态系统
|
|
22
|
+
- 🔐 **授权管理** - 内置授权系统,支持商业使用
|
|
19
23
|
- 📦 **轻量级** - 代码混淆压缩,体积小,加载快
|
|
20
24
|
- 🔧 **TypeScript** - 完整的类型定义支持
|
|
21
25
|
- 🚀 **现代化构建** - ESM + CJS 双格式,支持 Tree Shaking
|
|
@@ -41,7 +45,7 @@ yarn add @chenyomi/leafer-htmltext-edit
|
|
|
41
45
|
本插件需要以下依赖(请确保已安装):
|
|
42
46
|
|
|
43
47
|
```bash
|
|
44
|
-
npm install leafer-ui @leafer-ui/core @leafer-in/editor @leafer-in/html
|
|
48
|
+
npm install leafer-ui @leafer-ui/core @leafer-in/editor @leafer-in/html quill
|
|
45
49
|
```
|
|
46
50
|
|
|
47
51
|
## 🚀 快速开始
|
|
@@ -60,10 +64,10 @@ const app = new App({
|
|
|
60
64
|
editor: {}
|
|
61
65
|
})
|
|
62
66
|
|
|
63
|
-
// 2.
|
|
67
|
+
// 2. 初始化编辑器
|
|
64
68
|
await HtmlTextManage.init(app)
|
|
65
69
|
|
|
66
|
-
// 3.
|
|
70
|
+
// 3. 创建编辑器实例
|
|
67
71
|
const editor = new Editor({ app })
|
|
68
72
|
|
|
69
73
|
// 现在可以在画布上编辑文本了!
|
|
@@ -126,22 +130,55 @@ function TextEditor() {
|
|
|
126
130
|
}
|
|
127
131
|
```
|
|
128
132
|
|
|
133
|
+
### 在 Angular 中使用
|
|
134
|
+
|
|
135
|
+
```typescript
|
|
136
|
+
import { Component, ElementRef, ViewChild, AfterViewInit } from '@angular/core'
|
|
137
|
+
import { App } from 'leafer-ui'
|
|
138
|
+
import { Editor } from '@leafer-in/editor'
|
|
139
|
+
import { HtmlTextManage } from '@chenyomi/leafer-htmltext-edit'
|
|
140
|
+
|
|
141
|
+
@Component({
|
|
142
|
+
selector: 'app-text-editor',
|
|
143
|
+
template: '<div #canvas style="width: 100vw; height: 100vh;"></div>'
|
|
144
|
+
})
|
|
145
|
+
export class TextEditorComponent implements AfterViewInit {
|
|
146
|
+
@ViewChild('canvas') canvasRef!: ElementRef
|
|
147
|
+
|
|
148
|
+
async ngAfterViewInit() {
|
|
149
|
+
const app = new App({
|
|
150
|
+
view: this.canvasRef.nativeElement,
|
|
151
|
+
tree: {},
|
|
152
|
+
editor: {}
|
|
153
|
+
})
|
|
154
|
+
|
|
155
|
+
await HtmlTextManage.init(app)
|
|
156
|
+
new Editor({ app })
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
```
|
|
160
|
+
|
|
129
161
|
## 📚 API 文档
|
|
130
162
|
|
|
131
163
|
### HtmlTextManage
|
|
132
164
|
|
|
133
|
-
|
|
165
|
+
单例模式的编辑器管理器,负责管理 Quill 实例和文本编辑。
|
|
134
166
|
|
|
135
|
-
####
|
|
167
|
+
#### 静态方法
|
|
136
168
|
|
|
137
169
|
##### `init(app: any): Promise<Quill>`
|
|
138
170
|
|
|
139
|
-
初始化 Quill
|
|
171
|
+
初始化 Quill 编辑器并绑定到 Leafer 应用。
|
|
140
172
|
|
|
141
173
|
```typescript
|
|
142
174
|
const quill = await HtmlTextManage.init(app)
|
|
143
175
|
```
|
|
144
176
|
|
|
177
|
+
**参数:**
|
|
178
|
+
- `app` - Leafer App 实例
|
|
179
|
+
|
|
180
|
+
**返回:** Promise<Quill> - Quill 编辑器实例
|
|
181
|
+
|
|
145
182
|
##### `getQuill(): Quill`
|
|
146
183
|
|
|
147
184
|
获取 Quill 实例。
|
|
@@ -150,6 +187,8 @@ const quill = await HtmlTextManage.init(app)
|
|
|
150
187
|
const quill = HtmlTextManage.getQuill()
|
|
151
188
|
```
|
|
152
189
|
|
|
190
|
+
**返回:** Quill - Quill 编辑器实例
|
|
191
|
+
|
|
153
192
|
##### `getCanvas(): any`
|
|
154
193
|
|
|
155
194
|
获取 Leafer App 实例。
|
|
@@ -158,9 +197,11 @@ const quill = HtmlTextManage.getQuill()
|
|
|
158
197
|
const app = HtmlTextManage.getCanvas()
|
|
159
198
|
```
|
|
160
199
|
|
|
200
|
+
**返回:** App - Leafer 应用实例
|
|
201
|
+
|
|
161
202
|
##### `isMultiSelect(): boolean`
|
|
162
203
|
|
|
163
|
-
|
|
204
|
+
判断是否为多选状态(选中了多个对象)。
|
|
164
205
|
|
|
165
206
|
```typescript
|
|
166
207
|
if (HtmlTextManage.isMultiSelect()) {
|
|
@@ -168,6 +209,8 @@ if (HtmlTextManage.isMultiSelect()) {
|
|
|
168
209
|
}
|
|
169
210
|
```
|
|
170
211
|
|
|
212
|
+
**返回:** boolean - 是否多选
|
|
213
|
+
|
|
171
214
|
##### `dateEdit(callback: (leaf: any) => void, level?: number, listNew?: any): void`
|
|
172
215
|
|
|
173
216
|
批量编辑选中的对象。
|
|
@@ -179,26 +222,97 @@ HtmlTextManage.dateEdit((leaf) => {
|
|
|
179
222
|
})
|
|
180
223
|
```
|
|
181
224
|
|
|
182
|
-
|
|
225
|
+
**参数:**
|
|
226
|
+
- `callback` - 编辑回调函数,接收每个选中的对象
|
|
227
|
+
- `level?` - 可选,编辑层级
|
|
228
|
+
- `listNew?` - 可选,新对象列表
|
|
229
|
+
|
|
230
|
+
### 授权管理
|
|
231
|
+
|
|
232
|
+
插件内置授权系统,支持商业使用。
|
|
233
|
+
|
|
234
|
+
#### `setLicense(licenseKey: string): boolean`
|
|
235
|
+
|
|
236
|
+
设置授权密钥。
|
|
237
|
+
|
|
238
|
+
```typescript
|
|
239
|
+
import { setLicense } from '@chenyomi/leafer-htmltext-edit'
|
|
240
|
+
|
|
241
|
+
const success = setLicense('your-license-key')
|
|
242
|
+
if (success) {
|
|
243
|
+
console.log('License activated successfully')
|
|
244
|
+
}
|
|
245
|
+
```
|
|
246
|
+
|
|
247
|
+
**参数:**
|
|
248
|
+
- `licenseKey` - 授权密钥字符串
|
|
249
|
+
|
|
250
|
+
**返回:** boolean - 是否成功激活
|
|
251
|
+
|
|
252
|
+
#### `checkLicense(): boolean`
|
|
253
|
+
|
|
254
|
+
检查授权状态。
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
import { checkLicense } from '@chenyomi/leafer-htmltext-edit'
|
|
258
|
+
|
|
259
|
+
if (checkLicense()) {
|
|
260
|
+
console.log('License is valid')
|
|
261
|
+
} else {
|
|
262
|
+
console.log('License is invalid or expired')
|
|
263
|
+
}
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
**返回:** boolean - 授权是否有效
|
|
183
267
|
|
|
184
|
-
|
|
268
|
+
#### `getLicenseInfo(): LicenseData | null`
|
|
269
|
+
|
|
270
|
+
获取授权信息。
|
|
185
271
|
|
|
186
272
|
```typescript
|
|
187
|
-
import {
|
|
273
|
+
import { getLicenseInfo } from '@chenyomi/leafer-htmltext-edit'
|
|
188
274
|
|
|
189
|
-
|
|
190
|
-
|
|
275
|
+
const info = getLicenseInfo()
|
|
276
|
+
if (info) {
|
|
277
|
+
console.log('License holder:', info.name)
|
|
278
|
+
console.log('Expires at:', info.expirationDate)
|
|
279
|
+
}
|
|
191
280
|
```
|
|
192
281
|
|
|
193
|
-
|
|
282
|
+
**返回:** LicenseData | null - 授权信息对象或 null
|
|
283
|
+
|
|
284
|
+
### HtmlText
|
|
194
285
|
|
|
195
|
-
|
|
286
|
+
自定义的 HTML 文本类,扩展自 Leafer 的文本对象。
|
|
196
287
|
|
|
197
288
|
```typescript
|
|
198
|
-
import {
|
|
289
|
+
import { HtmlText } from '@chenyomi/leafer-htmltext-edit'
|
|
199
290
|
|
|
200
|
-
//
|
|
201
|
-
|
|
291
|
+
// HtmlText 会自动注册到 Leafer 中
|
|
292
|
+
// 可以直接在 Leafer 中使用
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### 工具函数
|
|
296
|
+
|
|
297
|
+
#### `updataHtmlText(obj: any): void`
|
|
298
|
+
|
|
299
|
+
更新 HTML 文本对象。
|
|
300
|
+
|
|
301
|
+
```typescript
|
|
302
|
+
import { updataHtmlText } from '@chenyomi/leafer-htmltext-edit'
|
|
303
|
+
|
|
304
|
+
updataHtmlText(textObject)
|
|
305
|
+
```
|
|
306
|
+
|
|
307
|
+
#### `setHTMLText(type: string, value: any, inner: any, editor: any, multi: boolean): void`
|
|
308
|
+
|
|
309
|
+
设置 HTML 文本属性。
|
|
310
|
+
|
|
311
|
+
```typescript
|
|
312
|
+
import { setHTMLText } from '@chenyomi/leafer-htmltext-edit'
|
|
313
|
+
|
|
314
|
+
// 设置字体大小
|
|
315
|
+
setHTMLText('fontSize', 24, null, editor, false)
|
|
202
316
|
```
|
|
203
317
|
|
|
204
318
|
## 🎨 使用示例
|
|
@@ -230,6 +344,16 @@ HtmlTextManage.dateEdit((leaf) => {
|
|
|
230
344
|
HtmlTextManage.dateEdit((leaf) => {
|
|
231
345
|
leaf.textAlign = 'center' // 'left' | 'center' | 'right' | 'justify'
|
|
232
346
|
})
|
|
347
|
+
|
|
348
|
+
// 设置行高
|
|
349
|
+
HtmlTextManage.dateEdit((leaf) => {
|
|
350
|
+
leaf.lineHeight = 1.5
|
|
351
|
+
})
|
|
352
|
+
|
|
353
|
+
// 设置字间距
|
|
354
|
+
HtmlTextManage.dateEdit((leaf) => {
|
|
355
|
+
leaf.letterSpacing = 2
|
|
356
|
+
})
|
|
233
357
|
```
|
|
234
358
|
|
|
235
359
|
### 批量编辑多个对象
|
|
@@ -241,6 +365,7 @@ if (HtmlTextManage.isMultiSelect()) {
|
|
|
241
365
|
leaf.fontSize = 18
|
|
242
366
|
leaf.fontFamily = 'Inter'
|
|
243
367
|
leaf.fill = '#333333'
|
|
368
|
+
leaf.textAlign = 'center'
|
|
244
369
|
})
|
|
245
370
|
}
|
|
246
371
|
```
|
|
@@ -250,20 +375,83 @@ if (HtmlTextManage.isMultiSelect()) {
|
|
|
250
375
|
```typescript
|
|
251
376
|
const quill = HtmlTextManage.getQuill()
|
|
252
377
|
|
|
378
|
+
// 监听文本内容变化
|
|
253
379
|
quill.on('text-change', (delta, oldDelta, source) => {
|
|
254
380
|
console.log('Text changed:', delta)
|
|
381
|
+
console.log('Source:', source) // 'user' 或 'api'
|
|
255
382
|
})
|
|
256
383
|
|
|
384
|
+
// 监听选区变化
|
|
257
385
|
quill.on('selection-change', (range, oldRange, source) => {
|
|
258
386
|
if (range) {
|
|
259
387
|
console.log('Selection:', range.index, range.length)
|
|
388
|
+
} else {
|
|
389
|
+
console.log('Editor lost focus')
|
|
260
390
|
}
|
|
261
391
|
})
|
|
392
|
+
|
|
393
|
+
// 监听编辑器变化
|
|
394
|
+
quill.on('editor-change', (eventName, ...args) => {
|
|
395
|
+
console.log('Editor event:', eventName)
|
|
396
|
+
})
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
### 格式化文本
|
|
400
|
+
|
|
401
|
+
```typescript
|
|
402
|
+
const quill = HtmlTextManage.getQuill()
|
|
403
|
+
|
|
404
|
+
// 加粗
|
|
405
|
+
quill.format('bold', true)
|
|
406
|
+
|
|
407
|
+
// 斜体
|
|
408
|
+
quill.format('italic', true)
|
|
409
|
+
|
|
410
|
+
// 下划线
|
|
411
|
+
quill.format('underline', true)
|
|
412
|
+
|
|
413
|
+
// 删除线
|
|
414
|
+
quill.format('strike', true)
|
|
415
|
+
|
|
416
|
+
// 上标
|
|
417
|
+
quill.format('script', 'super')
|
|
418
|
+
|
|
419
|
+
// 下标
|
|
420
|
+
quill.format('script', 'sub')
|
|
421
|
+
|
|
422
|
+
// 列表
|
|
423
|
+
quill.format('list', 'ordered') // 有序列表
|
|
424
|
+
quill.format('list', 'bullet') // 无序列表
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### 插入内容
|
|
428
|
+
|
|
429
|
+
```typescript
|
|
430
|
+
const quill = HtmlTextManage.getQuill()
|
|
431
|
+
|
|
432
|
+
// 插入文本
|
|
433
|
+
quill.insertText(0, 'Hello World!')
|
|
434
|
+
|
|
435
|
+
// 插入带格式的文本
|
|
436
|
+
quill.insertText(0, 'Hello', { bold: true, color: 'red' })
|
|
437
|
+
|
|
438
|
+
// 获取文本内容
|
|
439
|
+
const text = quill.getText()
|
|
440
|
+
|
|
441
|
+
// 获取 HTML 内容
|
|
442
|
+
const html = quill.root.innerHTML
|
|
443
|
+
|
|
444
|
+
// 设置内容
|
|
445
|
+
quill.setContents([
|
|
446
|
+
{ insert: 'Hello ' },
|
|
447
|
+
{ insert: 'World', attributes: { bold: true } },
|
|
448
|
+
{ insert: '\n' }
|
|
449
|
+
])
|
|
262
450
|
```
|
|
263
451
|
|
|
264
452
|
## 🔤 支持的字体
|
|
265
453
|
|
|
266
|
-
|
|
454
|
+
插件内置以下字体支持,所有字体通过 Google Fonts CDN 加载:
|
|
267
455
|
|
|
268
456
|
### 西文字体
|
|
269
457
|
- **Roboto** - Google 设计的现代无衬线字体
|
|
@@ -285,14 +473,41 @@ quill.on('selection-change', (range, oldRange, source) => {
|
|
|
285
473
|
- **Dancing Script** - 手写风格
|
|
286
474
|
|
|
287
475
|
### 中日韩字体
|
|
288
|
-
- **Noto Sans
|
|
289
|
-
- **Noto Serif
|
|
290
|
-
- **Noto Sans
|
|
291
|
-
- **Noto Sans
|
|
292
|
-
- **Noto Serif
|
|
293
|
-
- **Noto Serif
|
|
294
|
-
- **Noto Sans
|
|
295
|
-
- **Noto Sans
|
|
476
|
+
- **Noto Sans SC** - 思源黑体简体中文
|
|
477
|
+
- **Noto Serif SC** - 思源宋体简体中文
|
|
478
|
+
- **Noto Sans TC** - 思源黑体繁体中文
|
|
479
|
+
- **Noto Sans HK** - 思源黑体香港
|
|
480
|
+
- **Noto Serif TC** - 思源宋体繁体中文
|
|
481
|
+
- **Noto Serif HK** - 思源宋体香港
|
|
482
|
+
- **Noto Sans JP** - 思源黑体日文
|
|
483
|
+
- **Noto Sans KR** - 思源黑体韩文
|
|
484
|
+
|
|
485
|
+
### 自定义字体
|
|
486
|
+
|
|
487
|
+
```typescript
|
|
488
|
+
import { HtmlTextManage } from '@chenyomi/leafer-htmltext-edit'
|
|
489
|
+
|
|
490
|
+
// 获取 Quill 实例
|
|
491
|
+
const quill = HtmlTextManage.getQuill()
|
|
492
|
+
|
|
493
|
+
// 注册自定义字体
|
|
494
|
+
const Font = quill.constructor.import('formats/font')
|
|
495
|
+
Font.whitelist = [...Font.whitelist, 'CustomFont']
|
|
496
|
+
quill.constructor.register(Font, true)
|
|
497
|
+
|
|
498
|
+
// 在 CSS 中定义字体
|
|
499
|
+
const style = document.createElement('style')
|
|
500
|
+
style.textContent = `
|
|
501
|
+
@font-face {
|
|
502
|
+
font-family: 'CustomFont';
|
|
503
|
+
src: url('/fonts/custom-font.woff2') format('woff2');
|
|
504
|
+
}
|
|
505
|
+
.ql-font-CustomFont {
|
|
506
|
+
font-family: 'CustomFont', sans-serif;
|
|
507
|
+
}
|
|
508
|
+
`
|
|
509
|
+
document.head.appendChild(style)
|
|
510
|
+
```
|
|
296
511
|
|
|
297
512
|
## ⚙️ 高级配置
|
|
298
513
|
|
|
@@ -322,19 +537,68 @@ export default defineConfig({
|
|
|
322
537
|
})
|
|
323
538
|
```
|
|
324
539
|
|
|
540
|
+
### Webpack 项目配置
|
|
541
|
+
|
|
542
|
+
```javascript
|
|
543
|
+
// webpack.config.js
|
|
544
|
+
module.exports = {
|
|
545
|
+
resolve: {
|
|
546
|
+
// 确保使用单一实例
|
|
547
|
+
alias: {
|
|
548
|
+
'quill': require.resolve('quill'),
|
|
549
|
+
'@leafer-ui/core': require.resolve('@leafer-ui/core'),
|
|
550
|
+
'@leafer-in/editor': require.resolve('@leafer-in/editor'),
|
|
551
|
+
'@leafer-in/html': require.resolve('@leafer-in/html'),
|
|
552
|
+
'leafer-ui': require.resolve('leafer-ui')
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
```
|
|
557
|
+
|
|
325
558
|
### 自定义样式
|
|
326
559
|
|
|
327
|
-
如果需要自定义编辑器样式,可以覆盖 CSS
|
|
560
|
+
如果需要自定义编辑器样式,可以覆盖 CSS:
|
|
328
561
|
|
|
329
562
|
```css
|
|
330
|
-
/*
|
|
563
|
+
/* 覆盖编辑器容器样式 */
|
|
331
564
|
#textInnerEditor {
|
|
332
|
-
|
|
565
|
+
border: 2px solid #e0e0e0;
|
|
566
|
+
border-radius: 4px;
|
|
567
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
|
|
333
568
|
}
|
|
334
569
|
|
|
335
|
-
/* Quill 编辑器样式 */
|
|
570
|
+
/* 覆盖 Quill 编辑器样式 */
|
|
336
571
|
.ql-editor {
|
|
337
|
-
|
|
572
|
+
font-family: 'Inter', sans-serif;
|
|
573
|
+
font-size: 16px;
|
|
574
|
+
line-height: 1.6;
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/* 占位符样式 */
|
|
578
|
+
.ql-editor.ql-blank::before {
|
|
579
|
+
color: #999;
|
|
580
|
+
content: attr(data-placeholder);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
/* 工具栏样式 */
|
|
584
|
+
.ql-toolbar {
|
|
585
|
+
background: #f5f5f5;
|
|
586
|
+
border-bottom: 1px solid #e0e0e0;
|
|
587
|
+
}
|
|
588
|
+
```
|
|
589
|
+
|
|
590
|
+
### TypeScript 配置
|
|
591
|
+
|
|
592
|
+
确保 `tsconfig.json` 包含正确的类型定义:
|
|
593
|
+
|
|
594
|
+
```json
|
|
595
|
+
{
|
|
596
|
+
"compilerOptions": {
|
|
597
|
+
"moduleResolution": "node",
|
|
598
|
+
"esModuleInterop": true,
|
|
599
|
+
"skipLibCheck": true,
|
|
600
|
+
"types": ["node"]
|
|
601
|
+
}
|
|
338
602
|
}
|
|
339
603
|
```
|
|
340
604
|
|
|
@@ -343,8 +607,8 @@ export default defineConfig({
|
|
|
343
607
|
### 克隆仓库
|
|
344
608
|
|
|
345
609
|
```bash
|
|
346
|
-
git clone https://github.com/
|
|
347
|
-
cd leafer-htmltext-
|
|
610
|
+
git clone https://github.com/chenyomi/leafer-htmltext-edit.git
|
|
611
|
+
cd leafer-htmltext-edit
|
|
348
612
|
```
|
|
349
613
|
|
|
350
614
|
### 安装依赖
|
|
@@ -362,7 +626,7 @@ npm run build
|
|
|
362
626
|
# 开发构建(不混淆)
|
|
363
627
|
npm run build:dev
|
|
364
628
|
|
|
365
|
-
#
|
|
629
|
+
# 监听模式(开发时使用)
|
|
366
630
|
npm run build:watch
|
|
367
631
|
```
|
|
368
632
|
|
|
@@ -376,6 +640,21 @@ npm link
|
|
|
376
640
|
npm link @chenyomi/leafer-htmltext-edit
|
|
377
641
|
```
|
|
378
642
|
|
|
643
|
+
### 发布到 npm
|
|
644
|
+
|
|
645
|
+
```bash
|
|
646
|
+
# 1. 更新版本号
|
|
647
|
+
npm version patch # 1.0.0 -> 1.0.1
|
|
648
|
+
npm version minor # 1.0.0 -> 1.1.0
|
|
649
|
+
npm version major # 1.0.0 -> 2.0.0
|
|
650
|
+
|
|
651
|
+
# 2. 构建
|
|
652
|
+
npm run build
|
|
653
|
+
|
|
654
|
+
# 3. 发布
|
|
655
|
+
npm publish
|
|
656
|
+
```
|
|
657
|
+
|
|
379
658
|
## 📝 常见问题
|
|
380
659
|
|
|
381
660
|
### Q: 如何导入 CSS 样式?
|
|
@@ -390,13 +669,20 @@ import 'quill/dist/quill.core.css'
|
|
|
390
669
|
|
|
391
670
|
A: 请确保:
|
|
392
671
|
1. 已正确安装所有 peer dependencies
|
|
393
|
-
2. 调用了 `HtmlTextManage.init(app)`
|
|
672
|
+
2. 调用了 `HtmlTextManage.init(app)` 并等待 Promise 完成
|
|
394
673
|
3. 创建了 `Editor` 实例
|
|
395
|
-
4. Vite 配置中添加了 `dedupe` 设置
|
|
674
|
+
4. Vite/Webpack 配置中添加了 `dedupe` 或 `alias` 设置
|
|
675
|
+
5. 检查浏览器控制台是否有错误信息
|
|
396
676
|
|
|
397
677
|
### Q: 支持哪些浏览器?
|
|
398
678
|
|
|
399
|
-
A:
|
|
679
|
+
A: 支持所有现代浏览器:
|
|
680
|
+
- Chrome 90+
|
|
681
|
+
- Firefox 88+
|
|
682
|
+
- Safari 14+
|
|
683
|
+
- Edge 90+
|
|
684
|
+
|
|
685
|
+
不支持 IE11 及更早版本。
|
|
400
686
|
|
|
401
687
|
### Q: 如何自定义字体?
|
|
402
688
|
|
|
@@ -404,48 +690,109 @@ A: 可以通过修改 Quill 的字体配置:
|
|
|
404
690
|
|
|
405
691
|
```typescript
|
|
406
692
|
const quill = HtmlTextManage.getQuill()
|
|
407
|
-
const Font = quill.constructor.import('
|
|
408
|
-
Font.whitelist = ['
|
|
693
|
+
const Font = quill.constructor.import('formats/font')
|
|
694
|
+
Font.whitelist = [...Font.whitelist, 'MyFont1', 'MyFont2']
|
|
409
695
|
quill.constructor.register(Font, true)
|
|
410
696
|
```
|
|
411
697
|
|
|
698
|
+
然后在 CSS 中定义字体样式。
|
|
699
|
+
|
|
412
700
|
### Q: 文本编辑器的位置不对?
|
|
413
701
|
|
|
414
|
-
A:
|
|
702
|
+
A: 这通常是由于画布缩放导致的。编辑器会自动处理缩放,如果仍有问题:
|
|
703
|
+
1. 检查 CSS transform 设置
|
|
704
|
+
2. 确保父容器没有 position: relative 之外的定位
|
|
705
|
+
3. 检查 z-index 层级
|
|
706
|
+
|
|
707
|
+
### Q: 如何获取授权?
|
|
708
|
+
|
|
709
|
+
A: 请联系开发者获取商业授权密钥:
|
|
710
|
+
- Email: chenyomi@example.com
|
|
711
|
+
- GitHub: [@chenyomi](https://github.com/chenyomi)
|
|
712
|
+
|
|
713
|
+
### Q: 性能优化建议?
|
|
714
|
+
|
|
715
|
+
A:
|
|
716
|
+
1. 使用 `build:watch` 模式开发,避免频繁重新构建
|
|
717
|
+
2. 大型文档建议分段加载
|
|
718
|
+
3. 避免在短时间内频繁调用 `dateEdit`
|
|
719
|
+
4. 使用防抖(debounce)处理高频事件
|
|
720
|
+
|
|
721
|
+
### Q: 如何处理中文输入法问题?
|
|
722
|
+
|
|
723
|
+
A: Quill 2.0 已经内置了对中文输入法的支持。如果遇到问题:
|
|
724
|
+
|
|
725
|
+
```typescript
|
|
726
|
+
const quill = HtmlTextManage.getQuill()
|
|
727
|
+
|
|
728
|
+
// 监听输入法组合
|
|
729
|
+
quill.keyboard.addBinding({
|
|
730
|
+
key: 'Enter',
|
|
731
|
+
handler: function(range, context) {
|
|
732
|
+
// 自定义处理逻辑
|
|
733
|
+
}
|
|
734
|
+
})
|
|
735
|
+
```
|
|
415
736
|
|
|
416
737
|
## 🤝 贡献
|
|
417
738
|
|
|
418
739
|
欢迎提交 Issue 和 Pull Request!
|
|
419
740
|
|
|
741
|
+
### 贡献指南
|
|
742
|
+
|
|
420
743
|
1. Fork 本仓库
|
|
421
744
|
2. 创建你的特性分支 (`git checkout -b feature/AmazingFeature`)
|
|
422
745
|
3. 提交你的改动 (`git commit -m 'Add some AmazingFeature'`)
|
|
423
746
|
4. 推送到分支 (`git push origin feature/AmazingFeature`)
|
|
424
747
|
5. 开启一个 Pull Request
|
|
425
748
|
|
|
749
|
+
### 开发规范
|
|
750
|
+
|
|
751
|
+
- 遵循 TypeScript 最佳实践
|
|
752
|
+
- 添加必要的类型定义
|
|
753
|
+
- 编写清晰的注释
|
|
754
|
+
- 更新相关文档
|
|
755
|
+
- 确保所有测试通过
|
|
756
|
+
|
|
426
757
|
## 📄 许可证
|
|
427
758
|
|
|
428
759
|
本项目采用 [MIT](./LICENSE) 许可证。
|
|
429
760
|
|
|
761
|
+
### 商业使用
|
|
762
|
+
|
|
763
|
+
本插件支持商业使用,但需要获取授权密钥。请联系开发者获取授权。
|
|
764
|
+
|
|
430
765
|
## 👤 作者
|
|
431
766
|
|
|
432
767
|
**chenyomi**
|
|
433
768
|
|
|
434
|
-
- GitHub: [@chenyomi](https://github.com/
|
|
769
|
+
- GitHub: [@chenyomi](https://github.com/chenyomi)
|
|
435
770
|
- npm: [@chenyomi](https://www.npmjs.com/~chenyomi)
|
|
771
|
+
- Email: chenyomi@example.com
|
|
436
772
|
|
|
437
773
|
## 🙏 致谢
|
|
438
774
|
|
|
439
775
|
- [Leafer UI](https://www.leaferjs.com/) - 强大的 Canvas 渲染引擎
|
|
440
776
|
- [Quill](https://quilljs.com/) - 现代化的富文本编辑器
|
|
441
777
|
- [TypeScript](https://www.typescriptlang.org/) - JavaScript 的超集
|
|
778
|
+
- [Google Fonts](https://fonts.google.com/) - 优质的开源字体
|
|
779
|
+
|
|
780
|
+
## 🔗 相关链接
|
|
781
|
+
|
|
782
|
+
- [在线演示](https://chenyomi.github.io/leafer-htmltext-edit-demo)
|
|
783
|
+
- [完整文档](https://chenyomi.github.io/leafer-htmltext-edit)
|
|
784
|
+
- [更新日志](./CHANGELOG.md)
|
|
785
|
+
- [快速开始](./QUICKSTART.md)
|
|
786
|
+
- [问题反馈](https://github.com/chenyomi/leafer-htmltext-edit/issues)
|
|
442
787
|
|
|
443
788
|
## 📊 统计
|
|
444
789
|
|
|
445
|
-

|
|
446
|
-

|
|
791
|
+

|
|
792
|
+

|
|
793
|
+

|
|
794
|
+

|
|
448
795
|
|
|
449
796
|
---
|
|
450
797
|
|
|
451
|
-
如果这个项目对你有帮助,请给个 ⭐️ Star
|
|
798
|
+
如果这个项目对你有帮助,请给个 ⭐️ Star!你的支持是我们最大的动力!
|