@deot/vc-components 1.0.54 → 1.0.56
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 +68 -49
- package/dist/index.d.ts +40 -4
- package/dist/index.iife.js +68 -49
- package/dist/index.js +68 -49
- package/dist/index.umd.cjs +68 -49
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -75,6 +75,7 @@ const defaults$2 = {
|
|
|
75
75
|
line: nil
|
|
76
76
|
},
|
|
77
77
|
Snapshot: {
|
|
78
|
+
options: nil,
|
|
78
79
|
source: nil,
|
|
79
80
|
download: nil
|
|
80
81
|
}
|
|
@@ -10090,23 +10091,16 @@ const insertFontSizeStyle = (value, id) => {
|
|
|
10090
10091
|
.ql-snow .ql-font-size.ql-picker .ql-picker-label[data-value="${fontSize}"]:before {
|
|
10091
10092
|
content: "${fontSize}"
|
|
10092
10093
|
}`;
|
|
10093
|
-
pre += `.ql-editor .ql-font-size-${fontSize} {
|
|
10094
|
-
font-size: ${fontSize};
|
|
10095
|
-
}`;
|
|
10096
10094
|
return pre;
|
|
10097
10095
|
}, "");
|
|
10098
10096
|
return Load__namespace.style(code, { id });
|
|
10099
10097
|
};
|
|
10100
10098
|
const insertLineHeightStyle = (value, id) => {
|
|
10101
10099
|
const code = value.reduce((pre, lineHeight) => {
|
|
10102
|
-
|
|
10103
|
-
|
|
10104
|
-
.ql-snow .ql-line-height.ql-picker .ql-picker-label[data-value="${classLineHeightValue}"]:before {
|
|
10100
|
+
pre += `.ql-snow .ql-line-height.ql-picker .ql-picker-item[data-value="${lineHeight}"]:before,
|
|
10101
|
+
.ql-snow .ql-line-height.ql-picker .ql-picker-label[data-value="${lineHeight}"]:before {
|
|
10105
10102
|
content: "${+lineHeight}"
|
|
10106
10103
|
}`;
|
|
10107
|
-
pre += `.ql-editor .ql-line-height-${classLineHeightValue} {
|
|
10108
|
-
line-height: ${+lineHeight};
|
|
10109
|
-
}`;
|
|
10110
10104
|
return pre;
|
|
10111
10105
|
}, "");
|
|
10112
10106
|
return Load__namespace.style(code, { id });
|
|
@@ -10117,9 +10111,6 @@ const insertLetterSpacingStyle = (value, id) => {
|
|
|
10117
10111
|
.ql-snow .ql-letter-spacing.ql-picker .ql-picker-label[data-value="${letterSpacing}"]:before {
|
|
10118
10112
|
content: "${letterSpacing}"
|
|
10119
10113
|
}`;
|
|
10120
|
-
pre += `.ql-editor .ql-letter-spacing-${letterSpacing} {
|
|
10121
|
-
letter-spacing: ${letterSpacing};
|
|
10122
|
-
}`;
|
|
10123
10114
|
return pre;
|
|
10124
10115
|
}, "");
|
|
10125
10116
|
return Load__namespace.style(code, { id });
|
|
@@ -10307,9 +10298,8 @@ const EditorToolbar = /* @__PURE__ */ vue.defineComponent({
|
|
|
10307
10298
|
"selected": true
|
|
10308
10299
|
}, null);
|
|
10309
10300
|
}
|
|
10310
|
-
const v = key === 'line-height' ? +it * 10 : it;
|
|
10311
10301
|
return vue.createVNode("option", {
|
|
10312
|
-
"value": `${
|
|
10302
|
+
"value": `${it}`
|
|
10313
10303
|
}, null);
|
|
10314
10304
|
})]);
|
|
10315
10305
|
}
|
|
@@ -10322,16 +10312,18 @@ const EditorToolbar = /* @__PURE__ */ vue.defineComponent({
|
|
|
10322
10312
|
if (Array.isArray(item)) {
|
|
10323
10313
|
return insertStyle(item);
|
|
10324
10314
|
}
|
|
10315
|
+
let key = item;
|
|
10316
|
+
let value = [];
|
|
10325
10317
|
if (typeof item === 'object') {
|
|
10326
|
-
|
|
10327
|
-
|
|
10328
|
-
|
|
10329
|
-
|
|
10330
|
-
|
|
10331
|
-
|
|
10332
|
-
|
|
10333
|
-
|
|
10334
|
-
|
|
10318
|
+
[key, value] = Object.entries(item)[0];
|
|
10319
|
+
}
|
|
10320
|
+
value = value.length && value || toolbarDefaultsMap[key];
|
|
10321
|
+
if (key === 'font-size' && Array.isArray(value)) {
|
|
10322
|
+
insertFontSizeStyle(value, styleId);
|
|
10323
|
+
} else if (key === 'line-height') {
|
|
10324
|
+
insertLineHeightStyle(value, lineHeightStyleId);
|
|
10325
|
+
} else if (key === 'letter-spacing') {
|
|
10326
|
+
insertLetterSpacingStyle(value, letterSpacingStyleId);
|
|
10335
10327
|
}
|
|
10336
10328
|
});
|
|
10337
10329
|
};
|
|
@@ -10412,21 +10404,20 @@ const registerAudioBlot = (quillInstance) => {
|
|
|
10412
10404
|
|
|
10413
10405
|
const registerLineHeight = (quillInstance) => {
|
|
10414
10406
|
const lineHeight = toolbarDefaultsMap["line-height"];
|
|
10415
|
-
const whitelist = lineHeight.map((i) => String(+i * 10));
|
|
10416
10407
|
const Parchment = quillInstance.import("parchment");
|
|
10417
|
-
const lineHeightStyle = new Parchment.
|
|
10408
|
+
const lineHeightStyle = new Parchment.StyleAttributor(
|
|
10409
|
+
"line-height",
|
|
10418
10410
|
"line-height",
|
|
10419
|
-
|
|
10420
|
-
{ scope: Parchment.Scope.INLINE, whitelist }
|
|
10411
|
+
{ scope: Parchment.Scope.INLINE, whitelist: lineHeight }
|
|
10421
10412
|
);
|
|
10422
10413
|
quillInstance.register({ "formats/line-height": lineHeightStyle }, true);
|
|
10423
10414
|
};
|
|
10424
10415
|
|
|
10425
10416
|
const registerLetterSpacing = (quillInstance) => {
|
|
10426
10417
|
const Parchment = quillInstance.import("parchment");
|
|
10427
|
-
const letterSpacingStyle = new Parchment.
|
|
10418
|
+
const letterSpacingStyle = new Parchment.StyleAttributor(
|
|
10419
|
+
"letter-spacing",
|
|
10428
10420
|
"letter-spacing",
|
|
10429
|
-
"ql-letter-spacing",
|
|
10430
10421
|
{
|
|
10431
10422
|
scope: Parchment.Scope.INLINE,
|
|
10432
10423
|
whitelist: toolbarDefaultsMap["letter-spacing"]
|
|
@@ -11110,18 +11101,12 @@ const registerEventModule = (QuillClass) => {
|
|
|
11110
11101
|
const registerFontSize = (editor) => {
|
|
11111
11102
|
const Parchment = editor.import("parchment");
|
|
11112
11103
|
const fontSize = toolbarDefaultsMap["font-size"];
|
|
11113
|
-
const SizeClass = new Parchment.ClassAttributor("font-size", "ql-font-size", {
|
|
11114
|
-
scope: Parchment.Scope.INLINE,
|
|
11115
|
-
whitelist: fontSize
|
|
11116
|
-
});
|
|
11117
11104
|
const SizeStyle = new Parchment.StyleAttributor("font-size", "font-size", {
|
|
11118
11105
|
scope: Parchment.Scope.INLINE,
|
|
11119
11106
|
whitelist: fontSize
|
|
11120
11107
|
});
|
|
11121
11108
|
editor.register({
|
|
11122
|
-
"formats/font-size":
|
|
11123
|
-
"attributors/class/font-size": SizeClass,
|
|
11124
|
-
"attributors/style/font-size": SizeStyle
|
|
11109
|
+
"formats/font-size": SizeStyle
|
|
11125
11110
|
}, true);
|
|
11126
11111
|
};
|
|
11127
11112
|
|
|
@@ -11179,6 +11164,7 @@ const COMPONENT_NAME$14 = 'vc-editor';
|
|
|
11179
11164
|
const Editor = /* @__PURE__ */ vue.defineComponent({
|
|
11180
11165
|
name: COMPONENT_NAME$14,
|
|
11181
11166
|
props: props$M,
|
|
11167
|
+
defaults,
|
|
11182
11168
|
emits: ['ready', 'blur', 'focus', 'input', 'update:modelValue', 'change'],
|
|
11183
11169
|
setup(props, {
|
|
11184
11170
|
slots,
|
|
@@ -12132,6 +12118,14 @@ const props$H = {
|
|
|
12132
12118
|
},
|
|
12133
12119
|
source: Function,
|
|
12134
12120
|
download: Function,
|
|
12121
|
+
lazy: {
|
|
12122
|
+
type: Boolean,
|
|
12123
|
+
default: true
|
|
12124
|
+
},
|
|
12125
|
+
showLoading: {
|
|
12126
|
+
type: Boolean,
|
|
12127
|
+
default: true
|
|
12128
|
+
},
|
|
12135
12129
|
// 传递给snap-dom的配置项
|
|
12136
12130
|
options: {
|
|
12137
12131
|
type: Object,
|
|
@@ -12154,34 +12148,59 @@ const Snapshot = /* @__PURE__ */ vue.defineComponent({
|
|
|
12154
12148
|
let snapDOM;
|
|
12155
12149
|
const instance = vue.getCurrentInstance();
|
|
12156
12150
|
const current = vue.ref();
|
|
12157
|
-
const
|
|
12151
|
+
const snapshot = vue.ref();
|
|
12158
12152
|
const refresh = async () => {
|
|
12159
12153
|
await vue.nextTick();
|
|
12160
|
-
|
|
12161
|
-
|
|
12154
|
+
snapshot.value = await snapDOM(current.value, {
|
|
12155
|
+
fast: false,
|
|
12156
|
+
// dom太大时会卡死一会儿
|
|
12157
|
+
...VcInstance.options.Snapshot?.options,
|
|
12158
|
+
...props.options
|
|
12159
|
+
});
|
|
12160
|
+
return snapshot.value;
|
|
12161
|
+
};
|
|
12162
|
+
const onLoad = () => {
|
|
12163
|
+
return props.showLoading && Message.loading('正在生成...');
|
|
12164
|
+
};
|
|
12165
|
+
const onLoaded = ctx => {
|
|
12166
|
+
ctx?.destroy?.();
|
|
12162
12167
|
};
|
|
12163
12168
|
const toDataURL = async () => {
|
|
12169
|
+
const loadContext = onLoad();
|
|
12170
|
+
try {
|
|
12171
|
+
await refresh();
|
|
12172
|
+
return snapshot.value.toRaw();
|
|
12173
|
+
} finally {
|
|
12174
|
+
onLoaded(loadContext);
|
|
12175
|
+
}
|
|
12176
|
+
};
|
|
12177
|
+
const downloadByDefault = async options => {
|
|
12164
12178
|
await refresh();
|
|
12165
|
-
return
|
|
12179
|
+
return snapshot.value.download(options);
|
|
12166
12180
|
};
|
|
12167
12181
|
const download = async options => {
|
|
12168
|
-
|
|
12169
|
-
const
|
|
12170
|
-
const skip =
|
|
12182
|
+
const loadContext = onLoad();
|
|
12183
|
+
const downloadByUser = props.download || VcInstance.options.Snapshot?.download || (() => false);
|
|
12184
|
+
const skip = downloadByUser(instance, options);
|
|
12185
|
+
const done = async v => {
|
|
12186
|
+
try {
|
|
12187
|
+
v || (await downloadByDefault(options));
|
|
12188
|
+
} finally {
|
|
12189
|
+
onLoaded(loadContext);
|
|
12190
|
+
}
|
|
12191
|
+
};
|
|
12171
12192
|
if (skip && skip.then) {
|
|
12172
12193
|
let skip$ = false;
|
|
12173
12194
|
skip.then(v => {
|
|
12174
12195
|
skip$ = typeof v === 'undefined' ? true : !!v;
|
|
12175
12196
|
return v;
|
|
12176
|
-
}).finally(() =>
|
|
12177
|
-
skip$ || snapdom.value.download(options);
|
|
12178
|
-
});
|
|
12197
|
+
}).finally(() => done(skip$));
|
|
12179
12198
|
return;
|
|
12180
12199
|
}
|
|
12181
|
-
skip
|
|
12200
|
+
done(skip);
|
|
12182
12201
|
};
|
|
12183
12202
|
expose({
|
|
12184
|
-
|
|
12203
|
+
snapshot,
|
|
12185
12204
|
refresh,
|
|
12186
12205
|
toDataURL,
|
|
12187
12206
|
download
|
|
@@ -12190,7 +12209,7 @@ const Snapshot = /* @__PURE__ */ vue.defineComponent({
|
|
|
12190
12209
|
try {
|
|
12191
12210
|
snapDOM = window.snapdom || (await import('@zumer/snapdom'));
|
|
12192
12211
|
snapDOM = snapDOM.snapdom || snapDOM;
|
|
12193
|
-
await refresh();
|
|
12212
|
+
!props.lazy && (await refresh());
|
|
12194
12213
|
emit('ready', {
|
|
12195
12214
|
instance,
|
|
12196
12215
|
dependencies: {
|
package/dist/index.d.ts
CHANGED
|
@@ -8425,10 +8425,18 @@ default: string;
|
|
|
8425
8425
|
crossOrigin: {
|
|
8426
8426
|
type: StringConstructor;
|
|
8427
8427
|
default: string;
|
|
8428
|
-
validator: (v:
|
|
8428
|
+
validator: (v: string) => boolean;
|
|
8429
8429
|
};
|
|
8430
8430
|
source: FunctionConstructor;
|
|
8431
8431
|
download: FunctionConstructor;
|
|
8432
|
+
lazy: {
|
|
8433
|
+
type: BooleanConstructor;
|
|
8434
|
+
default: boolean;
|
|
8435
|
+
};
|
|
8436
|
+
showLoading: {
|
|
8437
|
+
type: BooleanConstructor;
|
|
8438
|
+
default: boolean;
|
|
8439
|
+
};
|
|
8432
8440
|
options: {
|
|
8433
8441
|
type: ObjectConstructor;
|
|
8434
8442
|
default: () => {};
|
|
@@ -8441,10 +8449,18 @@ default: string;
|
|
|
8441
8449
|
crossOrigin: {
|
|
8442
8450
|
type: StringConstructor;
|
|
8443
8451
|
default: string;
|
|
8444
|
-
validator: (v:
|
|
8452
|
+
validator: (v: string) => boolean;
|
|
8445
8453
|
};
|
|
8446
8454
|
source: FunctionConstructor;
|
|
8447
8455
|
download: FunctionConstructor;
|
|
8456
|
+
lazy: {
|
|
8457
|
+
type: BooleanConstructor;
|
|
8458
|
+
default: boolean;
|
|
8459
|
+
};
|
|
8460
|
+
showLoading: {
|
|
8461
|
+
type: BooleanConstructor;
|
|
8462
|
+
default: boolean;
|
|
8463
|
+
};
|
|
8448
8464
|
options: {
|
|
8449
8465
|
type: ObjectConstructor;
|
|
8450
8466
|
default: () => {};
|
|
@@ -8454,7 +8470,9 @@ onReady?: ((...args: any[]) => any) | undefined;
|
|
|
8454
8470
|
}>, {
|
|
8455
8471
|
tag: string;
|
|
8456
8472
|
options: Record<string, any>;
|
|
8473
|
+
showLoading: boolean;
|
|
8457
8474
|
crossOrigin: string;
|
|
8475
|
+
lazy: boolean;
|
|
8458
8476
|
}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
8459
8477
|
|
|
8460
8478
|
export declare const MSortList: DefineComponent<ExtractPropTypes< {
|
|
@@ -13308,10 +13326,18 @@ default: string;
|
|
|
13308
13326
|
crossOrigin: {
|
|
13309
13327
|
type: StringConstructor;
|
|
13310
13328
|
default: string;
|
|
13311
|
-
validator: (v:
|
|
13329
|
+
validator: (v: string) => boolean;
|
|
13312
13330
|
};
|
|
13313
13331
|
source: FunctionConstructor;
|
|
13314
13332
|
download: FunctionConstructor;
|
|
13333
|
+
lazy: {
|
|
13334
|
+
type: BooleanConstructor;
|
|
13335
|
+
default: boolean;
|
|
13336
|
+
};
|
|
13337
|
+
showLoading: {
|
|
13338
|
+
type: BooleanConstructor;
|
|
13339
|
+
default: boolean;
|
|
13340
|
+
};
|
|
13315
13341
|
options: {
|
|
13316
13342
|
type: ObjectConstructor;
|
|
13317
13343
|
default: () => {};
|
|
@@ -13324,10 +13350,18 @@ default: string;
|
|
|
13324
13350
|
crossOrigin: {
|
|
13325
13351
|
type: StringConstructor;
|
|
13326
13352
|
default: string;
|
|
13327
|
-
validator: (v:
|
|
13353
|
+
validator: (v: string) => boolean;
|
|
13328
13354
|
};
|
|
13329
13355
|
source: FunctionConstructor;
|
|
13330
13356
|
download: FunctionConstructor;
|
|
13357
|
+
lazy: {
|
|
13358
|
+
type: BooleanConstructor;
|
|
13359
|
+
default: boolean;
|
|
13360
|
+
};
|
|
13361
|
+
showLoading: {
|
|
13362
|
+
type: BooleanConstructor;
|
|
13363
|
+
default: boolean;
|
|
13364
|
+
};
|
|
13331
13365
|
options: {
|
|
13332
13366
|
type: ObjectConstructor;
|
|
13333
13367
|
default: () => {};
|
|
@@ -13337,7 +13371,9 @@ onReady?: ((...args: any[]) => any) | undefined;
|
|
|
13337
13371
|
}>, {
|
|
13338
13372
|
tag: string;
|
|
13339
13373
|
options: Record<string, any>;
|
|
13374
|
+
showLoading: boolean;
|
|
13340
13375
|
crossOrigin: string;
|
|
13376
|
+
lazy: boolean;
|
|
13341
13377
|
}, {}, {}, {}, string, ComponentProvideOptions, true, {}, any>;
|
|
13342
13378
|
|
|
13343
13379
|
export declare const SortList: DefineComponent<ExtractPropTypes< {
|
package/dist/index.iife.js
CHANGED
|
@@ -37,6 +37,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
37
37
|
line: nil
|
|
38
38
|
},
|
|
39
39
|
Snapshot: {
|
|
40
|
+
options: nil,
|
|
40
41
|
source: nil,
|
|
41
42
|
download: nil
|
|
42
43
|
}
|
|
@@ -16543,23 +16544,16 @@ var VcComponents = (function (exports, vue) {
|
|
|
16543
16544
|
.ql-snow .ql-font-size.ql-picker .ql-picker-label[data-value="${fontSize}"]:before {
|
|
16544
16545
|
content: "${fontSize}"
|
|
16545
16546
|
}`;
|
|
16546
|
-
pre += `.ql-editor .ql-font-size-${fontSize} {
|
|
16547
|
-
font-size: ${fontSize};
|
|
16548
|
-
}`;
|
|
16549
16547
|
return pre;
|
|
16550
16548
|
}, "");
|
|
16551
16549
|
return style(code, { id });
|
|
16552
16550
|
};
|
|
16553
16551
|
const insertLineHeightStyle = (value, id) => {
|
|
16554
16552
|
const code = value.reduce((pre, lineHeight) => {
|
|
16555
|
-
|
|
16556
|
-
|
|
16557
|
-
.ql-snow .ql-line-height.ql-picker .ql-picker-label[data-value="${classLineHeightValue}"]:before {
|
|
16553
|
+
pre += `.ql-snow .ql-line-height.ql-picker .ql-picker-item[data-value="${lineHeight}"]:before,
|
|
16554
|
+
.ql-snow .ql-line-height.ql-picker .ql-picker-label[data-value="${lineHeight}"]:before {
|
|
16558
16555
|
content: "${+lineHeight}"
|
|
16559
16556
|
}`;
|
|
16560
|
-
pre += `.ql-editor .ql-line-height-${classLineHeightValue} {
|
|
16561
|
-
line-height: ${+lineHeight};
|
|
16562
|
-
}`;
|
|
16563
16557
|
return pre;
|
|
16564
16558
|
}, "");
|
|
16565
16559
|
return style(code, { id });
|
|
@@ -16570,9 +16564,6 @@ var VcComponents = (function (exports, vue) {
|
|
|
16570
16564
|
.ql-snow .ql-letter-spacing.ql-picker .ql-picker-label[data-value="${letterSpacing}"]:before {
|
|
16571
16565
|
content: "${letterSpacing}"
|
|
16572
16566
|
}`;
|
|
16573
|
-
pre += `.ql-editor .ql-letter-spacing-${letterSpacing} {
|
|
16574
|
-
letter-spacing: ${letterSpacing};
|
|
16575
|
-
}`;
|
|
16576
16567
|
return pre;
|
|
16577
16568
|
}, "");
|
|
16578
16569
|
return style(code, { id });
|
|
@@ -16760,9 +16751,8 @@ var VcComponents = (function (exports, vue) {
|
|
|
16760
16751
|
"selected": true
|
|
16761
16752
|
}, null);
|
|
16762
16753
|
}
|
|
16763
|
-
const v = key === 'line-height' ? +it * 10 : it;
|
|
16764
16754
|
return vue.createVNode("option", {
|
|
16765
|
-
"value": `${
|
|
16755
|
+
"value": `${it}`
|
|
16766
16756
|
}, null);
|
|
16767
16757
|
})]);
|
|
16768
16758
|
}
|
|
@@ -16775,16 +16765,18 @@ var VcComponents = (function (exports, vue) {
|
|
|
16775
16765
|
if (Array.isArray(item)) {
|
|
16776
16766
|
return insertStyle(item);
|
|
16777
16767
|
}
|
|
16768
|
+
let key = item;
|
|
16769
|
+
let value = [];
|
|
16778
16770
|
if (typeof item === 'object') {
|
|
16779
|
-
|
|
16780
|
-
|
|
16781
|
-
|
|
16782
|
-
|
|
16783
|
-
|
|
16784
|
-
|
|
16785
|
-
|
|
16786
|
-
|
|
16787
|
-
|
|
16771
|
+
[key, value] = Object.entries(item)[0];
|
|
16772
|
+
}
|
|
16773
|
+
value = value.length && value || toolbarDefaultsMap[key];
|
|
16774
|
+
if (key === 'font-size' && Array.isArray(value)) {
|
|
16775
|
+
insertFontSizeStyle(value, styleId);
|
|
16776
|
+
} else if (key === 'line-height') {
|
|
16777
|
+
insertLineHeightStyle(value, lineHeightStyleId);
|
|
16778
|
+
} else if (key === 'letter-spacing') {
|
|
16779
|
+
insertLetterSpacingStyle(value, letterSpacingStyleId);
|
|
16788
16780
|
}
|
|
16789
16781
|
});
|
|
16790
16782
|
};
|
|
@@ -16865,21 +16857,20 @@ var VcComponents = (function (exports, vue) {
|
|
|
16865
16857
|
|
|
16866
16858
|
const registerLineHeight = (quillInstance) => {
|
|
16867
16859
|
const lineHeight = toolbarDefaultsMap["line-height"];
|
|
16868
|
-
const whitelist = lineHeight.map((i) => String(+i * 10));
|
|
16869
16860
|
const Parchment = quillInstance.import("parchment");
|
|
16870
|
-
const lineHeightStyle = new Parchment.
|
|
16861
|
+
const lineHeightStyle = new Parchment.StyleAttributor(
|
|
16862
|
+
"line-height",
|
|
16871
16863
|
"line-height",
|
|
16872
|
-
|
|
16873
|
-
{ scope: Parchment.Scope.INLINE, whitelist }
|
|
16864
|
+
{ scope: Parchment.Scope.INLINE, whitelist: lineHeight }
|
|
16874
16865
|
);
|
|
16875
16866
|
quillInstance.register({ "formats/line-height": lineHeightStyle }, true);
|
|
16876
16867
|
};
|
|
16877
16868
|
|
|
16878
16869
|
const registerLetterSpacing = (quillInstance) => {
|
|
16879
16870
|
const Parchment = quillInstance.import("parchment");
|
|
16880
|
-
const letterSpacingStyle = new Parchment.
|
|
16871
|
+
const letterSpacingStyle = new Parchment.StyleAttributor(
|
|
16872
|
+
"letter-spacing",
|
|
16881
16873
|
"letter-spacing",
|
|
16882
|
-
"ql-letter-spacing",
|
|
16883
16874
|
{
|
|
16884
16875
|
scope: Parchment.Scope.INLINE,
|
|
16885
16876
|
whitelist: toolbarDefaultsMap["letter-spacing"]
|
|
@@ -19521,18 +19512,12 @@ var VcComponents = (function (exports, vue) {
|
|
|
19521
19512
|
const registerFontSize = (editor) => {
|
|
19522
19513
|
const Parchment = editor.import("parchment");
|
|
19523
19514
|
const fontSize = toolbarDefaultsMap["font-size"];
|
|
19524
|
-
const SizeClass = new Parchment.ClassAttributor("font-size", "ql-font-size", {
|
|
19525
|
-
scope: Parchment.Scope.INLINE,
|
|
19526
|
-
whitelist: fontSize
|
|
19527
|
-
});
|
|
19528
19515
|
const SizeStyle = new Parchment.StyleAttributor("font-size", "font-size", {
|
|
19529
19516
|
scope: Parchment.Scope.INLINE,
|
|
19530
19517
|
whitelist: fontSize
|
|
19531
19518
|
});
|
|
19532
19519
|
editor.register({
|
|
19533
|
-
"formats/font-size":
|
|
19534
|
-
"attributors/class/font-size": SizeClass,
|
|
19535
|
-
"attributors/style/font-size": SizeStyle
|
|
19520
|
+
"formats/font-size": SizeStyle
|
|
19536
19521
|
}, true);
|
|
19537
19522
|
};
|
|
19538
19523
|
|
|
@@ -19590,6 +19575,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
19590
19575
|
const Editor$1 = /* @__PURE__ */ vue.defineComponent({
|
|
19591
19576
|
name: COMPONENT_NAME$14,
|
|
19592
19577
|
props: props$M,
|
|
19578
|
+
defaults: defaults$1,
|
|
19593
19579
|
emits: ['ready', 'blur', 'focus', 'input', 'update:modelValue', 'change'],
|
|
19594
19580
|
setup(props, {
|
|
19595
19581
|
slots,
|
|
@@ -20675,6 +20661,14 @@ var VcComponents = (function (exports, vue) {
|
|
|
20675
20661
|
},
|
|
20676
20662
|
source: Function,
|
|
20677
20663
|
download: Function,
|
|
20664
|
+
lazy: {
|
|
20665
|
+
type: Boolean,
|
|
20666
|
+
default: true
|
|
20667
|
+
},
|
|
20668
|
+
showLoading: {
|
|
20669
|
+
type: Boolean,
|
|
20670
|
+
default: true
|
|
20671
|
+
},
|
|
20678
20672
|
// 传递给snap-dom的配置项
|
|
20679
20673
|
options: {
|
|
20680
20674
|
type: Object,
|
|
@@ -20697,34 +20691,59 @@ var VcComponents = (function (exports, vue) {
|
|
|
20697
20691
|
let snapDOM;
|
|
20698
20692
|
const instance = vue.getCurrentInstance();
|
|
20699
20693
|
const current = vue.ref();
|
|
20700
|
-
const
|
|
20694
|
+
const snapshot = vue.ref();
|
|
20701
20695
|
const refresh = async () => {
|
|
20702
20696
|
await vue.nextTick();
|
|
20703
|
-
|
|
20704
|
-
|
|
20697
|
+
snapshot.value = await snapDOM(current.value, {
|
|
20698
|
+
fast: false,
|
|
20699
|
+
// dom太大时会卡死一会儿
|
|
20700
|
+
...VcInstance.options.Snapshot?.options,
|
|
20701
|
+
...props.options
|
|
20702
|
+
});
|
|
20703
|
+
return snapshot.value;
|
|
20704
|
+
};
|
|
20705
|
+
const onLoad = () => {
|
|
20706
|
+
return props.showLoading && Message.loading('正在生成...');
|
|
20707
|
+
};
|
|
20708
|
+
const onLoaded = ctx => {
|
|
20709
|
+
ctx?.destroy?.();
|
|
20705
20710
|
};
|
|
20706
20711
|
const toDataURL = async () => {
|
|
20712
|
+
const loadContext = onLoad();
|
|
20713
|
+
try {
|
|
20714
|
+
await refresh();
|
|
20715
|
+
return snapshot.value.toRaw();
|
|
20716
|
+
} finally {
|
|
20717
|
+
onLoaded(loadContext);
|
|
20718
|
+
}
|
|
20719
|
+
};
|
|
20720
|
+
const downloadByDefault = async options => {
|
|
20707
20721
|
await refresh();
|
|
20708
|
-
return
|
|
20722
|
+
return snapshot.value.download(options);
|
|
20709
20723
|
};
|
|
20710
20724
|
const download = async options => {
|
|
20711
|
-
|
|
20712
|
-
const
|
|
20713
|
-
const skip =
|
|
20725
|
+
const loadContext = onLoad();
|
|
20726
|
+
const downloadByUser = props.download || VcInstance.options.Snapshot?.download || (() => false);
|
|
20727
|
+
const skip = downloadByUser(instance, options);
|
|
20728
|
+
const done = async v => {
|
|
20729
|
+
try {
|
|
20730
|
+
v || (await downloadByDefault(options));
|
|
20731
|
+
} finally {
|
|
20732
|
+
onLoaded(loadContext);
|
|
20733
|
+
}
|
|
20734
|
+
};
|
|
20714
20735
|
if (skip && skip.then) {
|
|
20715
20736
|
let skip$ = false;
|
|
20716
20737
|
skip.then(v => {
|
|
20717
20738
|
skip$ = typeof v === 'undefined' ? true : !!v;
|
|
20718
20739
|
return v;
|
|
20719
|
-
}).finally(() =>
|
|
20720
|
-
skip$ || snapdom.value.download(options);
|
|
20721
|
-
});
|
|
20740
|
+
}).finally(() => done(skip$));
|
|
20722
20741
|
return;
|
|
20723
20742
|
}
|
|
20724
|
-
skip
|
|
20743
|
+
done(skip);
|
|
20725
20744
|
};
|
|
20726
20745
|
expose({
|
|
20727
|
-
|
|
20746
|
+
snapshot,
|
|
20728
20747
|
refresh,
|
|
20729
20748
|
toDataURL,
|
|
20730
20749
|
download
|
|
@@ -20733,7 +20752,7 @@ var VcComponents = (function (exports, vue) {
|
|
|
20733
20752
|
try {
|
|
20734
20753
|
snapDOM = window.snapdom || (await Promise.resolve().then(() => snapdom$1));
|
|
20735
20754
|
snapDOM = snapDOM.snapdom || snapDOM;
|
|
20736
|
-
await refresh();
|
|
20755
|
+
!props.lazy && (await refresh());
|
|
20737
20756
|
emit('ready', {
|
|
20738
20757
|
instance,
|
|
20739
20758
|
dependencies: {
|
package/dist/index.js
CHANGED
|
@@ -53,6 +53,7 @@ const defaults$2 = {
|
|
|
53
53
|
line: nil
|
|
54
54
|
},
|
|
55
55
|
Snapshot: {
|
|
56
|
+
options: nil,
|
|
56
57
|
source: nil,
|
|
57
58
|
download: nil
|
|
58
59
|
}
|
|
@@ -10068,23 +10069,16 @@ const insertFontSizeStyle = (value, id) => {
|
|
|
10068
10069
|
.ql-snow .ql-font-size.ql-picker .ql-picker-label[data-value="${fontSize}"]:before {
|
|
10069
10070
|
content: "${fontSize}"
|
|
10070
10071
|
}`;
|
|
10071
|
-
pre += `.ql-editor .ql-font-size-${fontSize} {
|
|
10072
|
-
font-size: ${fontSize};
|
|
10073
|
-
}`;
|
|
10074
10072
|
return pre;
|
|
10075
10073
|
}, "");
|
|
10076
10074
|
return Load.style(code, { id });
|
|
10077
10075
|
};
|
|
10078
10076
|
const insertLineHeightStyle = (value, id) => {
|
|
10079
10077
|
const code = value.reduce((pre, lineHeight) => {
|
|
10080
|
-
|
|
10081
|
-
|
|
10082
|
-
.ql-snow .ql-line-height.ql-picker .ql-picker-label[data-value="${classLineHeightValue}"]:before {
|
|
10078
|
+
pre += `.ql-snow .ql-line-height.ql-picker .ql-picker-item[data-value="${lineHeight}"]:before,
|
|
10079
|
+
.ql-snow .ql-line-height.ql-picker .ql-picker-label[data-value="${lineHeight}"]:before {
|
|
10083
10080
|
content: "${+lineHeight}"
|
|
10084
10081
|
}`;
|
|
10085
|
-
pre += `.ql-editor .ql-line-height-${classLineHeightValue} {
|
|
10086
|
-
line-height: ${+lineHeight};
|
|
10087
|
-
}`;
|
|
10088
10082
|
return pre;
|
|
10089
10083
|
}, "");
|
|
10090
10084
|
return Load.style(code, { id });
|
|
@@ -10095,9 +10089,6 @@ const insertLetterSpacingStyle = (value, id) => {
|
|
|
10095
10089
|
.ql-snow .ql-letter-spacing.ql-picker .ql-picker-label[data-value="${letterSpacing}"]:before {
|
|
10096
10090
|
content: "${letterSpacing}"
|
|
10097
10091
|
}`;
|
|
10098
|
-
pre += `.ql-editor .ql-letter-spacing-${letterSpacing} {
|
|
10099
|
-
letter-spacing: ${letterSpacing};
|
|
10100
|
-
}`;
|
|
10101
10092
|
return pre;
|
|
10102
10093
|
}, "");
|
|
10103
10094
|
return Load.style(code, { id });
|
|
@@ -10285,9 +10276,8 @@ const EditorToolbar = /* @__PURE__ */ defineComponent({
|
|
|
10285
10276
|
"selected": true
|
|
10286
10277
|
}, null);
|
|
10287
10278
|
}
|
|
10288
|
-
const v = key === 'line-height' ? +it * 10 : it;
|
|
10289
10279
|
return createVNode("option", {
|
|
10290
|
-
"value": `${
|
|
10280
|
+
"value": `${it}`
|
|
10291
10281
|
}, null);
|
|
10292
10282
|
})]);
|
|
10293
10283
|
}
|
|
@@ -10300,16 +10290,18 @@ const EditorToolbar = /* @__PURE__ */ defineComponent({
|
|
|
10300
10290
|
if (Array.isArray(item)) {
|
|
10301
10291
|
return insertStyle(item);
|
|
10302
10292
|
}
|
|
10293
|
+
let key = item;
|
|
10294
|
+
let value = [];
|
|
10303
10295
|
if (typeof item === 'object') {
|
|
10304
|
-
|
|
10305
|
-
|
|
10306
|
-
|
|
10307
|
-
|
|
10308
|
-
|
|
10309
|
-
|
|
10310
|
-
|
|
10311
|
-
|
|
10312
|
-
|
|
10296
|
+
[key, value] = Object.entries(item)[0];
|
|
10297
|
+
}
|
|
10298
|
+
value = value.length && value || toolbarDefaultsMap[key];
|
|
10299
|
+
if (key === 'font-size' && Array.isArray(value)) {
|
|
10300
|
+
insertFontSizeStyle(value, styleId);
|
|
10301
|
+
} else if (key === 'line-height') {
|
|
10302
|
+
insertLineHeightStyle(value, lineHeightStyleId);
|
|
10303
|
+
} else if (key === 'letter-spacing') {
|
|
10304
|
+
insertLetterSpacingStyle(value, letterSpacingStyleId);
|
|
10313
10305
|
}
|
|
10314
10306
|
});
|
|
10315
10307
|
};
|
|
@@ -10390,21 +10382,20 @@ const registerAudioBlot = (quillInstance) => {
|
|
|
10390
10382
|
|
|
10391
10383
|
const registerLineHeight = (quillInstance) => {
|
|
10392
10384
|
const lineHeight = toolbarDefaultsMap["line-height"];
|
|
10393
|
-
const whitelist = lineHeight.map((i) => String(+i * 10));
|
|
10394
10385
|
const Parchment = quillInstance.import("parchment");
|
|
10395
|
-
const lineHeightStyle = new Parchment.
|
|
10386
|
+
const lineHeightStyle = new Parchment.StyleAttributor(
|
|
10387
|
+
"line-height",
|
|
10396
10388
|
"line-height",
|
|
10397
|
-
|
|
10398
|
-
{ scope: Parchment.Scope.INLINE, whitelist }
|
|
10389
|
+
{ scope: Parchment.Scope.INLINE, whitelist: lineHeight }
|
|
10399
10390
|
);
|
|
10400
10391
|
quillInstance.register({ "formats/line-height": lineHeightStyle }, true);
|
|
10401
10392
|
};
|
|
10402
10393
|
|
|
10403
10394
|
const registerLetterSpacing = (quillInstance) => {
|
|
10404
10395
|
const Parchment = quillInstance.import("parchment");
|
|
10405
|
-
const letterSpacingStyle = new Parchment.
|
|
10396
|
+
const letterSpacingStyle = new Parchment.StyleAttributor(
|
|
10397
|
+
"letter-spacing",
|
|
10406
10398
|
"letter-spacing",
|
|
10407
|
-
"ql-letter-spacing",
|
|
10408
10399
|
{
|
|
10409
10400
|
scope: Parchment.Scope.INLINE,
|
|
10410
10401
|
whitelist: toolbarDefaultsMap["letter-spacing"]
|
|
@@ -11088,18 +11079,12 @@ const registerEventModule = (QuillClass) => {
|
|
|
11088
11079
|
const registerFontSize = (editor) => {
|
|
11089
11080
|
const Parchment = editor.import("parchment");
|
|
11090
11081
|
const fontSize = toolbarDefaultsMap["font-size"];
|
|
11091
|
-
const SizeClass = new Parchment.ClassAttributor("font-size", "ql-font-size", {
|
|
11092
|
-
scope: Parchment.Scope.INLINE,
|
|
11093
|
-
whitelist: fontSize
|
|
11094
|
-
});
|
|
11095
11082
|
const SizeStyle = new Parchment.StyleAttributor("font-size", "font-size", {
|
|
11096
11083
|
scope: Parchment.Scope.INLINE,
|
|
11097
11084
|
whitelist: fontSize
|
|
11098
11085
|
});
|
|
11099
11086
|
editor.register({
|
|
11100
|
-
"formats/font-size":
|
|
11101
|
-
"attributors/class/font-size": SizeClass,
|
|
11102
|
-
"attributors/style/font-size": SizeStyle
|
|
11087
|
+
"formats/font-size": SizeStyle
|
|
11103
11088
|
}, true);
|
|
11104
11089
|
};
|
|
11105
11090
|
|
|
@@ -11157,6 +11142,7 @@ const COMPONENT_NAME$14 = 'vc-editor';
|
|
|
11157
11142
|
const Editor = /* @__PURE__ */ defineComponent({
|
|
11158
11143
|
name: COMPONENT_NAME$14,
|
|
11159
11144
|
props: props$M,
|
|
11145
|
+
defaults,
|
|
11160
11146
|
emits: ['ready', 'blur', 'focus', 'input', 'update:modelValue', 'change'],
|
|
11161
11147
|
setup(props, {
|
|
11162
11148
|
slots,
|
|
@@ -12110,6 +12096,14 @@ const props$H = {
|
|
|
12110
12096
|
},
|
|
12111
12097
|
source: Function,
|
|
12112
12098
|
download: Function,
|
|
12099
|
+
lazy: {
|
|
12100
|
+
type: Boolean,
|
|
12101
|
+
default: true
|
|
12102
|
+
},
|
|
12103
|
+
showLoading: {
|
|
12104
|
+
type: Boolean,
|
|
12105
|
+
default: true
|
|
12106
|
+
},
|
|
12113
12107
|
// 传递给snap-dom的配置项
|
|
12114
12108
|
options: {
|
|
12115
12109
|
type: Object,
|
|
@@ -12132,34 +12126,59 @@ const Snapshot = /* @__PURE__ */ defineComponent({
|
|
|
12132
12126
|
let snapDOM;
|
|
12133
12127
|
const instance = getCurrentInstance();
|
|
12134
12128
|
const current = ref();
|
|
12135
|
-
const
|
|
12129
|
+
const snapshot = ref();
|
|
12136
12130
|
const refresh = async () => {
|
|
12137
12131
|
await nextTick();
|
|
12138
|
-
|
|
12139
|
-
|
|
12132
|
+
snapshot.value = await snapDOM(current.value, {
|
|
12133
|
+
fast: false,
|
|
12134
|
+
// dom太大时会卡死一会儿
|
|
12135
|
+
...VcInstance.options.Snapshot?.options,
|
|
12136
|
+
...props.options
|
|
12137
|
+
});
|
|
12138
|
+
return snapshot.value;
|
|
12139
|
+
};
|
|
12140
|
+
const onLoad = () => {
|
|
12141
|
+
return props.showLoading && Message.loading('正在生成...');
|
|
12142
|
+
};
|
|
12143
|
+
const onLoaded = ctx => {
|
|
12144
|
+
ctx?.destroy?.();
|
|
12140
12145
|
};
|
|
12141
12146
|
const toDataURL = async () => {
|
|
12147
|
+
const loadContext = onLoad();
|
|
12148
|
+
try {
|
|
12149
|
+
await refresh();
|
|
12150
|
+
return snapshot.value.toRaw();
|
|
12151
|
+
} finally {
|
|
12152
|
+
onLoaded(loadContext);
|
|
12153
|
+
}
|
|
12154
|
+
};
|
|
12155
|
+
const downloadByDefault = async options => {
|
|
12142
12156
|
await refresh();
|
|
12143
|
-
return
|
|
12157
|
+
return snapshot.value.download(options);
|
|
12144
12158
|
};
|
|
12145
12159
|
const download = async options => {
|
|
12146
|
-
|
|
12147
|
-
const
|
|
12148
|
-
const skip =
|
|
12160
|
+
const loadContext = onLoad();
|
|
12161
|
+
const downloadByUser = props.download || VcInstance.options.Snapshot?.download || (() => false);
|
|
12162
|
+
const skip = downloadByUser(instance, options);
|
|
12163
|
+
const done = async v => {
|
|
12164
|
+
try {
|
|
12165
|
+
v || (await downloadByDefault(options));
|
|
12166
|
+
} finally {
|
|
12167
|
+
onLoaded(loadContext);
|
|
12168
|
+
}
|
|
12169
|
+
};
|
|
12149
12170
|
if (skip && skip.then) {
|
|
12150
12171
|
let skip$ = false;
|
|
12151
12172
|
skip.then(v => {
|
|
12152
12173
|
skip$ = typeof v === 'undefined' ? true : !!v;
|
|
12153
12174
|
return v;
|
|
12154
|
-
}).finally(() =>
|
|
12155
|
-
skip$ || snapdom.value.download(options);
|
|
12156
|
-
});
|
|
12175
|
+
}).finally(() => done(skip$));
|
|
12157
12176
|
return;
|
|
12158
12177
|
}
|
|
12159
|
-
skip
|
|
12178
|
+
done(skip);
|
|
12160
12179
|
};
|
|
12161
12180
|
expose({
|
|
12162
|
-
|
|
12181
|
+
snapshot,
|
|
12163
12182
|
refresh,
|
|
12164
12183
|
toDataURL,
|
|
12165
12184
|
download
|
|
@@ -12168,7 +12187,7 @@ const Snapshot = /* @__PURE__ */ defineComponent({
|
|
|
12168
12187
|
try {
|
|
12169
12188
|
snapDOM = window.snapdom || (await import('@zumer/snapdom'));
|
|
12170
12189
|
snapDOM = snapDOM.snapdom || snapDOM;
|
|
12171
|
-
await refresh();
|
|
12190
|
+
!props.lazy && (await refresh());
|
|
12172
12191
|
emit('ready', {
|
|
12173
12192
|
instance,
|
|
12174
12193
|
dependencies: {
|
package/dist/index.umd.cjs
CHANGED
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
line: nil
|
|
41
41
|
},
|
|
42
42
|
Snapshot: {
|
|
43
|
+
options: nil,
|
|
43
44
|
source: nil,
|
|
44
45
|
download: nil
|
|
45
46
|
}
|
|
@@ -16546,23 +16547,16 @@
|
|
|
16546
16547
|
.ql-snow .ql-font-size.ql-picker .ql-picker-label[data-value="${fontSize}"]:before {
|
|
16547
16548
|
content: "${fontSize}"
|
|
16548
16549
|
}`;
|
|
16549
|
-
pre += `.ql-editor .ql-font-size-${fontSize} {
|
|
16550
|
-
font-size: ${fontSize};
|
|
16551
|
-
}`;
|
|
16552
16550
|
return pre;
|
|
16553
16551
|
}, "");
|
|
16554
16552
|
return style(code, { id });
|
|
16555
16553
|
};
|
|
16556
16554
|
const insertLineHeightStyle = (value, id) => {
|
|
16557
16555
|
const code = value.reduce((pre, lineHeight) => {
|
|
16558
|
-
|
|
16559
|
-
|
|
16560
|
-
.ql-snow .ql-line-height.ql-picker .ql-picker-label[data-value="${classLineHeightValue}"]:before {
|
|
16556
|
+
pre += `.ql-snow .ql-line-height.ql-picker .ql-picker-item[data-value="${lineHeight}"]:before,
|
|
16557
|
+
.ql-snow .ql-line-height.ql-picker .ql-picker-label[data-value="${lineHeight}"]:before {
|
|
16561
16558
|
content: "${+lineHeight}"
|
|
16562
16559
|
}`;
|
|
16563
|
-
pre += `.ql-editor .ql-line-height-${classLineHeightValue} {
|
|
16564
|
-
line-height: ${+lineHeight};
|
|
16565
|
-
}`;
|
|
16566
16560
|
return pre;
|
|
16567
16561
|
}, "");
|
|
16568
16562
|
return style(code, { id });
|
|
@@ -16573,9 +16567,6 @@
|
|
|
16573
16567
|
.ql-snow .ql-letter-spacing.ql-picker .ql-picker-label[data-value="${letterSpacing}"]:before {
|
|
16574
16568
|
content: "${letterSpacing}"
|
|
16575
16569
|
}`;
|
|
16576
|
-
pre += `.ql-editor .ql-letter-spacing-${letterSpacing} {
|
|
16577
|
-
letter-spacing: ${letterSpacing};
|
|
16578
|
-
}`;
|
|
16579
16570
|
return pre;
|
|
16580
16571
|
}, "");
|
|
16581
16572
|
return style(code, { id });
|
|
@@ -16763,9 +16754,8 @@
|
|
|
16763
16754
|
"selected": true
|
|
16764
16755
|
}, null);
|
|
16765
16756
|
}
|
|
16766
|
-
const v = key === 'line-height' ? +it * 10 : it;
|
|
16767
16757
|
return vue.createVNode("option", {
|
|
16768
|
-
"value": `${
|
|
16758
|
+
"value": `${it}`
|
|
16769
16759
|
}, null);
|
|
16770
16760
|
})]);
|
|
16771
16761
|
}
|
|
@@ -16778,16 +16768,18 @@
|
|
|
16778
16768
|
if (Array.isArray(item)) {
|
|
16779
16769
|
return insertStyle(item);
|
|
16780
16770
|
}
|
|
16771
|
+
let key = item;
|
|
16772
|
+
let value = [];
|
|
16781
16773
|
if (typeof item === 'object') {
|
|
16782
|
-
|
|
16783
|
-
|
|
16784
|
-
|
|
16785
|
-
|
|
16786
|
-
|
|
16787
|
-
|
|
16788
|
-
|
|
16789
|
-
|
|
16790
|
-
|
|
16774
|
+
[key, value] = Object.entries(item)[0];
|
|
16775
|
+
}
|
|
16776
|
+
value = value.length && value || toolbarDefaultsMap[key];
|
|
16777
|
+
if (key === 'font-size' && Array.isArray(value)) {
|
|
16778
|
+
insertFontSizeStyle(value, styleId);
|
|
16779
|
+
} else if (key === 'line-height') {
|
|
16780
|
+
insertLineHeightStyle(value, lineHeightStyleId);
|
|
16781
|
+
} else if (key === 'letter-spacing') {
|
|
16782
|
+
insertLetterSpacingStyle(value, letterSpacingStyleId);
|
|
16791
16783
|
}
|
|
16792
16784
|
});
|
|
16793
16785
|
};
|
|
@@ -16868,21 +16860,20 @@
|
|
|
16868
16860
|
|
|
16869
16861
|
const registerLineHeight = (quillInstance) => {
|
|
16870
16862
|
const lineHeight = toolbarDefaultsMap["line-height"];
|
|
16871
|
-
const whitelist = lineHeight.map((i) => String(+i * 10));
|
|
16872
16863
|
const Parchment = quillInstance.import("parchment");
|
|
16873
|
-
const lineHeightStyle = new Parchment.
|
|
16864
|
+
const lineHeightStyle = new Parchment.StyleAttributor(
|
|
16865
|
+
"line-height",
|
|
16874
16866
|
"line-height",
|
|
16875
|
-
|
|
16876
|
-
{ scope: Parchment.Scope.INLINE, whitelist }
|
|
16867
|
+
{ scope: Parchment.Scope.INLINE, whitelist: lineHeight }
|
|
16877
16868
|
);
|
|
16878
16869
|
quillInstance.register({ "formats/line-height": lineHeightStyle }, true);
|
|
16879
16870
|
};
|
|
16880
16871
|
|
|
16881
16872
|
const registerLetterSpacing = (quillInstance) => {
|
|
16882
16873
|
const Parchment = quillInstance.import("parchment");
|
|
16883
|
-
const letterSpacingStyle = new Parchment.
|
|
16874
|
+
const letterSpacingStyle = new Parchment.StyleAttributor(
|
|
16875
|
+
"letter-spacing",
|
|
16884
16876
|
"letter-spacing",
|
|
16885
|
-
"ql-letter-spacing",
|
|
16886
16877
|
{
|
|
16887
16878
|
scope: Parchment.Scope.INLINE,
|
|
16888
16879
|
whitelist: toolbarDefaultsMap["letter-spacing"]
|
|
@@ -19524,18 +19515,12 @@
|
|
|
19524
19515
|
const registerFontSize = (editor) => {
|
|
19525
19516
|
const Parchment = editor.import("parchment");
|
|
19526
19517
|
const fontSize = toolbarDefaultsMap["font-size"];
|
|
19527
|
-
const SizeClass = new Parchment.ClassAttributor("font-size", "ql-font-size", {
|
|
19528
|
-
scope: Parchment.Scope.INLINE,
|
|
19529
|
-
whitelist: fontSize
|
|
19530
|
-
});
|
|
19531
19518
|
const SizeStyle = new Parchment.StyleAttributor("font-size", "font-size", {
|
|
19532
19519
|
scope: Parchment.Scope.INLINE,
|
|
19533
19520
|
whitelist: fontSize
|
|
19534
19521
|
});
|
|
19535
19522
|
editor.register({
|
|
19536
|
-
"formats/font-size":
|
|
19537
|
-
"attributors/class/font-size": SizeClass,
|
|
19538
|
-
"attributors/style/font-size": SizeStyle
|
|
19523
|
+
"formats/font-size": SizeStyle
|
|
19539
19524
|
}, true);
|
|
19540
19525
|
};
|
|
19541
19526
|
|
|
@@ -19593,6 +19578,7 @@
|
|
|
19593
19578
|
const Editor$1 = /* @__PURE__ */ vue.defineComponent({
|
|
19594
19579
|
name: COMPONENT_NAME$14,
|
|
19595
19580
|
props: props$M,
|
|
19581
|
+
defaults: defaults$1,
|
|
19596
19582
|
emits: ['ready', 'blur', 'focus', 'input', 'update:modelValue', 'change'],
|
|
19597
19583
|
setup(props, {
|
|
19598
19584
|
slots,
|
|
@@ -20678,6 +20664,14 @@
|
|
|
20678
20664
|
},
|
|
20679
20665
|
source: Function,
|
|
20680
20666
|
download: Function,
|
|
20667
|
+
lazy: {
|
|
20668
|
+
type: Boolean,
|
|
20669
|
+
default: true
|
|
20670
|
+
},
|
|
20671
|
+
showLoading: {
|
|
20672
|
+
type: Boolean,
|
|
20673
|
+
default: true
|
|
20674
|
+
},
|
|
20681
20675
|
// 传递给snap-dom的配置项
|
|
20682
20676
|
options: {
|
|
20683
20677
|
type: Object,
|
|
@@ -20700,34 +20694,59 @@
|
|
|
20700
20694
|
let snapDOM;
|
|
20701
20695
|
const instance = vue.getCurrentInstance();
|
|
20702
20696
|
const current = vue.ref();
|
|
20703
|
-
const
|
|
20697
|
+
const snapshot = vue.ref();
|
|
20704
20698
|
const refresh = async () => {
|
|
20705
20699
|
await vue.nextTick();
|
|
20706
|
-
|
|
20707
|
-
|
|
20700
|
+
snapshot.value = await snapDOM(current.value, {
|
|
20701
|
+
fast: false,
|
|
20702
|
+
// dom太大时会卡死一会儿
|
|
20703
|
+
...VcInstance.options.Snapshot?.options,
|
|
20704
|
+
...props.options
|
|
20705
|
+
});
|
|
20706
|
+
return snapshot.value;
|
|
20707
|
+
};
|
|
20708
|
+
const onLoad = () => {
|
|
20709
|
+
return props.showLoading && Message.loading('正在生成...');
|
|
20710
|
+
};
|
|
20711
|
+
const onLoaded = ctx => {
|
|
20712
|
+
ctx?.destroy?.();
|
|
20708
20713
|
};
|
|
20709
20714
|
const toDataURL = async () => {
|
|
20715
|
+
const loadContext = onLoad();
|
|
20716
|
+
try {
|
|
20717
|
+
await refresh();
|
|
20718
|
+
return snapshot.value.toRaw();
|
|
20719
|
+
} finally {
|
|
20720
|
+
onLoaded(loadContext);
|
|
20721
|
+
}
|
|
20722
|
+
};
|
|
20723
|
+
const downloadByDefault = async options => {
|
|
20710
20724
|
await refresh();
|
|
20711
|
-
return
|
|
20725
|
+
return snapshot.value.download(options);
|
|
20712
20726
|
};
|
|
20713
20727
|
const download = async options => {
|
|
20714
|
-
|
|
20715
|
-
const
|
|
20716
|
-
const skip =
|
|
20728
|
+
const loadContext = onLoad();
|
|
20729
|
+
const downloadByUser = props.download || VcInstance.options.Snapshot?.download || (() => false);
|
|
20730
|
+
const skip = downloadByUser(instance, options);
|
|
20731
|
+
const done = async v => {
|
|
20732
|
+
try {
|
|
20733
|
+
v || (await downloadByDefault(options));
|
|
20734
|
+
} finally {
|
|
20735
|
+
onLoaded(loadContext);
|
|
20736
|
+
}
|
|
20737
|
+
};
|
|
20717
20738
|
if (skip && skip.then) {
|
|
20718
20739
|
let skip$ = false;
|
|
20719
20740
|
skip.then(v => {
|
|
20720
20741
|
skip$ = typeof v === 'undefined' ? true : !!v;
|
|
20721
20742
|
return v;
|
|
20722
|
-
}).finally(() =>
|
|
20723
|
-
skip$ || snapdom.value.download(options);
|
|
20724
|
-
});
|
|
20743
|
+
}).finally(() => done(skip$));
|
|
20725
20744
|
return;
|
|
20726
20745
|
}
|
|
20727
|
-
skip
|
|
20746
|
+
done(skip);
|
|
20728
20747
|
};
|
|
20729
20748
|
expose({
|
|
20730
|
-
|
|
20749
|
+
snapshot,
|
|
20731
20750
|
refresh,
|
|
20732
20751
|
toDataURL,
|
|
20733
20752
|
download
|
|
@@ -20736,7 +20755,7 @@
|
|
|
20736
20755
|
try {
|
|
20737
20756
|
snapDOM = window.snapdom || (await Promise.resolve().then(() => snapdom$1));
|
|
20738
20757
|
snapDOM = snapDOM.snapdom || snapDOM;
|
|
20739
|
-
await refresh();
|
|
20758
|
+
!props.lazy && (await refresh());
|
|
20740
20759
|
emit('ready', {
|
|
20741
20760
|
instance,
|
|
20742
20761
|
dependencies: {
|