pxx-vue-quill 1.0.0
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 +2 -0
- package/dist/vue-quill.bubble.css +490 -0
- package/dist/vue-quill.bubble.prod.css +1 -0
- package/dist/vue-quill.cjs.js +423 -0
- package/dist/vue-quill.cjs.prod.js +12 -0
- package/dist/vue-quill.core.css +391 -0
- package/dist/vue-quill.core.prod.css +1 -0
- package/dist/vue-quill.esm-browser.js +20332 -0
- package/dist/vue-quill.esm-browser.prod.js +12 -0
- package/dist/vue-quill.esm-bundler.js +413 -0
- package/dist/vue-quill.esm-bundler.prod.js +12 -0
- package/dist/vue-quill.global.js +20350 -0
- package/dist/vue-quill.global.prod.js +12 -0
- package/dist/vue-quill.snow.css +913 -0
- package/dist/vue-quill.snow.prod.css +1 -0
- package/index.js +7 -0
- package/package.json +45 -0
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* PxxVueQuill pxx-vue-quill v0.0.0-development
|
|
3
|
+
* https://vueup.github.io/vue-quill/
|
|
4
|
+
*
|
|
5
|
+
* Includes quill v1.3.7
|
|
6
|
+
* https://quilljs.com/
|
|
7
|
+
*
|
|
8
|
+
* Copyright (c) 2025 Pxx-Team
|
|
9
|
+
* Released under the MIT license
|
|
10
|
+
* Date: 2025-08-20T07:28:26.289Z
|
|
11
|
+
*/
|
|
12
|
+
'use strict';
|
|
13
|
+
|
|
14
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
15
|
+
|
|
16
|
+
var Quill = require('quill');
|
|
17
|
+
var Delta = require('quill-delta');
|
|
18
|
+
var vue = require('vue');
|
|
19
|
+
var BlotFormatter = require('quill-blot-formatter');
|
|
20
|
+
|
|
21
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
22
|
+
|
|
23
|
+
var Quill__default = /*#__PURE__*/_interopDefaultLegacy(Quill);
|
|
24
|
+
var Delta__default = /*#__PURE__*/_interopDefaultLegacy(Delta);
|
|
25
|
+
var BlotFormatter__default = /*#__PURE__*/_interopDefaultLegacy(BlotFormatter);
|
|
26
|
+
|
|
27
|
+
const toolbarOptions = {
|
|
28
|
+
full: [
|
|
29
|
+
// ['bold', 'italic', 'underline', 'strike'], // toggled buttons
|
|
30
|
+
['bold', 'italic', 'underline'],
|
|
31
|
+
[{ list: 'ordered' }, { list: 'bullet' }],
|
|
32
|
+
// [{ direction: 'rtl' }], // text direction
|
|
33
|
+
// [{ size: ['small', false, 'large', 'huge'] }], // custom dropdown
|
|
34
|
+
// [{ header: [1, 2, 3, 4, 5, 6, false] }],
|
|
35
|
+
[{ color: [] }, { background: [] }],
|
|
36
|
+
// [{ font: [] }],
|
|
37
|
+
// [{ align: [] }],
|
|
38
|
+
['image'],
|
|
39
|
+
// ['clean'], // remove formatting button
|
|
40
|
+
],
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const QuillEditor = vue.defineComponent({
|
|
44
|
+
name: 'QuillEditor',
|
|
45
|
+
inheritAttrs: false,
|
|
46
|
+
props: {
|
|
47
|
+
content: {
|
|
48
|
+
type: [String, Object],
|
|
49
|
+
},
|
|
50
|
+
contentType: {
|
|
51
|
+
type: String,
|
|
52
|
+
default: 'delta',
|
|
53
|
+
validator: (value) => {
|
|
54
|
+
return ['delta', 'html', 'text'].includes(value);
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
enable: {
|
|
58
|
+
type: Boolean,
|
|
59
|
+
default: true,
|
|
60
|
+
},
|
|
61
|
+
readOnly: {
|
|
62
|
+
type: Boolean,
|
|
63
|
+
default: false,
|
|
64
|
+
},
|
|
65
|
+
placeholder: {
|
|
66
|
+
type: String,
|
|
67
|
+
required: false,
|
|
68
|
+
},
|
|
69
|
+
theme: {
|
|
70
|
+
type: String,
|
|
71
|
+
default: 'snow',
|
|
72
|
+
validator: (value) => {
|
|
73
|
+
return ['snow', 'bubble', ''].includes(value);
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
toolbar: {
|
|
77
|
+
type: [String, Array, Object, Boolean],
|
|
78
|
+
required: false,
|
|
79
|
+
validator: (value) => {
|
|
80
|
+
if (!value)
|
|
81
|
+
return false;
|
|
82
|
+
if (typeof value === 'string' && value !== '') {
|
|
83
|
+
return value.charAt(0) === '#'
|
|
84
|
+
? true
|
|
85
|
+
: Object.keys(toolbarOptions).indexOf(value) !== -1;
|
|
86
|
+
}
|
|
87
|
+
return true;
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
modules: {
|
|
91
|
+
type: Object,
|
|
92
|
+
required: false,
|
|
93
|
+
default: () => {
|
|
94
|
+
return {
|
|
95
|
+
name: 'blotFormatter',
|
|
96
|
+
module: BlotFormatter__default,
|
|
97
|
+
};
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
options: {
|
|
101
|
+
type: Object,
|
|
102
|
+
required: false,
|
|
103
|
+
},
|
|
104
|
+
globalOptions: {
|
|
105
|
+
type: Object,
|
|
106
|
+
required: false,
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
emits: [
|
|
110
|
+
'textChange',
|
|
111
|
+
'selectionChange',
|
|
112
|
+
'editorChange',
|
|
113
|
+
'update:content',
|
|
114
|
+
'focus',
|
|
115
|
+
'blur',
|
|
116
|
+
'ready',
|
|
117
|
+
'ocr',
|
|
118
|
+
'math',
|
|
119
|
+
],
|
|
120
|
+
setup: (props, ctx) => {
|
|
121
|
+
vue.onMounted(() => {
|
|
122
|
+
initialize();
|
|
123
|
+
});
|
|
124
|
+
vue.onBeforeUnmount(() => {
|
|
125
|
+
quill = null;
|
|
126
|
+
});
|
|
127
|
+
let quill;
|
|
128
|
+
let options;
|
|
129
|
+
const editor = vue.ref();
|
|
130
|
+
// Register Module if not already registered
|
|
131
|
+
const registerModule = (moduleName, module) => {
|
|
132
|
+
// For Quill 1.x, we can't check if module is already registered
|
|
133
|
+
// So we'll just register it directly
|
|
134
|
+
Quill__default.register(moduleName, module);
|
|
135
|
+
};
|
|
136
|
+
// Initialize Quill
|
|
137
|
+
const initialize = () => {
|
|
138
|
+
var _a, _b;
|
|
139
|
+
if (!editor.value)
|
|
140
|
+
return;
|
|
141
|
+
// Create new Quill instance
|
|
142
|
+
quill = new Quill__default(editor.value, options);
|
|
143
|
+
// 初始隐藏toolbar
|
|
144
|
+
const toolbar = (_a = quill === null || quill === void 0 ? void 0 : quill.getModule('toolbar')) === null || _a === void 0 ? void 0 : _a.container;
|
|
145
|
+
if (toolbar) {
|
|
146
|
+
toolbar.style.display = 'none';
|
|
147
|
+
}
|
|
148
|
+
const icons = Quill__default.import('ui/icons');
|
|
149
|
+
icons['ocr'] = `
|
|
150
|
+
<svg viewBox="0 0 18 18">
|
|
151
|
+
<path d="M3 3h12v12H3z" fill="none" stroke="currentColor" stroke-width="1.5"/>
|
|
152
|
+
<path d="M6 7h6M6 9h6M6 11h4" stroke="currentColor" stroke-width="1"/>
|
|
153
|
+
</svg>
|
|
154
|
+
`;
|
|
155
|
+
icons['custom-button'] = `
|
|
156
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="18" height="18" viewBox="0 0 18 18"><defs><clipPath id="master_svg0_6759_139354"><rect x="0" y="0" width="18" height="18" rx="0"/></clipPath></defs><g clip-path="url(#master_svg0_6759_139354)"><g><path d="M15.423694,15.049834L15.424264,15.049264Q15.508656,14.964872,15.554328,14.85461Q15.6,14.744348,15.6,14.625Q15.6,14.565905,15.58847,14.507944Q15.576942,14.449986,15.554328,14.395388Q15.531713,14.340792,15.498882,14.291656Q15.466051,14.242521,15.424265,14.200735Q15.382479,14.158949,15.333343,14.126117Q15.284206,14.093286,15.229609,14.070671Q15.175013,14.048058,15.117053,14.036528Q15.059094,14.025,15,14.025Q14.880652,14.025,14.77039,14.070672Q14.660128,14.116344,14.575736,14.200736L13.626472,15.150001L4.4485275,15.150001L10.174264,9.424264Q10.2160501,9.3824773,10.2488813,9.3333416Q10.281712500000001,9.2842059,10.304327,9.229609499999999Q10.3269415,9.175012599999999,10.3384705,9.117054Q10.349999,9.0590944,10.349999,8.999999500000001Q10.349999,8.9409046,10.3384705,8.8829451Q10.3269415,8.8249855,10.304327,8.7703896Q10.281712500000001,8.715793099999999,10.2488813,8.6666574Q10.2160501,8.6175222,10.174264,8.575736L4.4485282,2.85000002L13.626472,2.85000002L14.575395,3.7989223L14.575736,3.7992642Q14.660127,3.8836554999999997,14.77039,3.9293277Q14.880651,3.9749999000000003,15,3.975Q15.059094,3.9749999000000003,15.117054,3.9634712Q15.175013,3.9519422,15.229609,3.9293275999999997Q15.284206,3.906713,15.333342,3.8738817Q15.382478,3.8410504000000003,15.424264,3.7992641000000003Q15.466051,3.7574776,15.498882,3.7083421000000003Q15.531713,3.6592064,15.554328,3.60461Q15.576942,3.5500134,15.588472,3.4920541Q15.6,3.4340948,15.6,3.375Q15.6,3.2556524,15.554328,3.1453898000000002Q15.508656,3.03512704,15.424264,2.9507357499999998L15.423856,2.9503274L14.299264,1.82573593Q14.214872,1.7413445699999999,14.10461,1.69567227Q13.994347,1.64999998,13.875,1.64999998L3,1.64999998Q2.88065257,1.64999998,2.77038994,1.69567227Q2.66012731,1.7413445699999999,2.57573593,1.82573593Q2.53394958,1.8675223,2.50111824,1.91665789Q2.46828693,1.96579346,2.44567233,2.02038996Q2.42305773,2.07498647,2.41152894,2.13294582Q2.4000000999999997,2.190905161,2.40000004,2.25Q2.4000000999999997,2.309094839,2.41152889,2.36705418Q2.42305773,2.42501353,2.44567233,2.47961004Q2.46828693,2.53420654,2.50111827,2.58334213Q2.53394958,2.6324777,2.57573593,2.67426407L8.9014721,9L2.57573593,15.325736Q2.49134457,15.410126,2.44567227,15.520389Q2.39999998,15.630651,2.39999998,15.75Q2.39999998,15.809094,2.41152883,15.867053Q2.42305768,15.925013,2.44567233,15.979609Q2.46828693,16.034204000000003,2.50111827,16.08334Q2.53394958,16.132476,2.57573593,16.174263Q2.6175223,16.216048999999998,2.66665787,16.24888Q2.71579343,16.281712,2.77038994,16.304327Q2.82498646,16.326940999999998,2.88294581,16.33847Q2.940905157,16.349998,3,16.349999L13.875,16.349999Q13.994347,16.349998,14.104609,16.304326Q14.214872,16.258654,14.299264,16.174264L15.423694,15.049834Z" fill-rule="evenodd" fill="#333333" fill-opacity="1" style="mix-blend-mode:passthrough"/></g></g></svg>
|
|
157
|
+
`;
|
|
158
|
+
options = composeOptions();
|
|
159
|
+
// Register modules
|
|
160
|
+
if (props.modules) {
|
|
161
|
+
if (Array.isArray(props.modules)) {
|
|
162
|
+
for (const module of props.modules) {
|
|
163
|
+
registerModule(`modules/${module.name}`, module.module);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else {
|
|
167
|
+
registerModule(`modules/${props.modules.name}`, props.modules.module);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
// Create new Quill instance
|
|
171
|
+
quill = new Quill__default(editor.value, options);
|
|
172
|
+
// Set editor content
|
|
173
|
+
setContents(props.content);
|
|
174
|
+
// Set event handlers
|
|
175
|
+
quill.on('text-change', handleTextChange);
|
|
176
|
+
quill.on('selection-change', handleSelectionChange);
|
|
177
|
+
quill.on('editor-change', handleEditorChange);
|
|
178
|
+
// Remove editor class when theme changes
|
|
179
|
+
if (props.theme !== 'bubble')
|
|
180
|
+
editor.value.classList.remove('ql-bubble');
|
|
181
|
+
if (props.theme !== 'snow')
|
|
182
|
+
editor.value.classList.remove('ql-snow');
|
|
183
|
+
// Fix clicking the quill toolbar is detected as blur event
|
|
184
|
+
(_b = quill
|
|
185
|
+
.getModule('toolbar')) === null || _b === void 0 ? void 0 : _b.container.addEventListener('mousedown', (e) => {
|
|
186
|
+
e.preventDefault();
|
|
187
|
+
});
|
|
188
|
+
// Emit ready event
|
|
189
|
+
ctx.emit('ready', quill);
|
|
190
|
+
};
|
|
191
|
+
// Compose Options
|
|
192
|
+
const composeOptions = () => {
|
|
193
|
+
const clientOptions = {};
|
|
194
|
+
if (props.theme !== '')
|
|
195
|
+
clientOptions.theme = props.theme;
|
|
196
|
+
if (props.readOnly)
|
|
197
|
+
clientOptions.readOnly = props.readOnly;
|
|
198
|
+
if (props.placeholder)
|
|
199
|
+
clientOptions.placeholder = props.placeholder;
|
|
200
|
+
if (props.toolbar && props.toolbar !== '') {
|
|
201
|
+
clientOptions.modules = {
|
|
202
|
+
toolbar: {
|
|
203
|
+
container: [
|
|
204
|
+
...toolbarOptions.full,
|
|
205
|
+
['ocr'],
|
|
206
|
+
[{ 'custom-button': true }], // 自定义按钮
|
|
207
|
+
],
|
|
208
|
+
handlers: {
|
|
209
|
+
ocr: function () {
|
|
210
|
+
// 按钮点击逻辑
|
|
211
|
+
console.log('ocr');
|
|
212
|
+
ctx.emit('ocr');
|
|
213
|
+
},
|
|
214
|
+
math: function () {
|
|
215
|
+
// 按钮点击逻辑
|
|
216
|
+
ctx.emit('math');
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
if (props.modules) {
|
|
223
|
+
const modules = (() => {
|
|
224
|
+
var _a, _b;
|
|
225
|
+
const modulesOption = {};
|
|
226
|
+
if (Array.isArray(props.modules)) {
|
|
227
|
+
for (const module of props.modules) {
|
|
228
|
+
modulesOption[module.name] = (_a = module.options) !== null && _a !== void 0 ? _a : {};
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
else {
|
|
232
|
+
modulesOption[props.modules.name] = (_b = props.modules.options) !== null && _b !== void 0 ? _b : {};
|
|
233
|
+
}
|
|
234
|
+
return modulesOption;
|
|
235
|
+
})();
|
|
236
|
+
clientOptions.modules = Object.assign({}, clientOptions.modules, modules);
|
|
237
|
+
}
|
|
238
|
+
return Object.assign({}, props.globalOptions, props.options, clientOptions);
|
|
239
|
+
};
|
|
240
|
+
const maybeClone = (delta) => {
|
|
241
|
+
return typeof delta === 'object' && delta ? delta.slice() : delta;
|
|
242
|
+
};
|
|
243
|
+
const deltaHasValuesOtherThanRetain = (delta) => {
|
|
244
|
+
return Object.values(delta.ops).some((v) => !v.retain || Object.keys(v).length !== 1);
|
|
245
|
+
};
|
|
246
|
+
// Doesn't need reactivity, but does need to be cloned to avoid deep mutations always registering as equal
|
|
247
|
+
let internalModel;
|
|
248
|
+
const internalModelEquals = (against) => {
|
|
249
|
+
if (typeof internalModel === typeof against) {
|
|
250
|
+
if (against === internalModel) {
|
|
251
|
+
return true;
|
|
252
|
+
}
|
|
253
|
+
// Ref/Proxy does not support instanceof, so do a loose check
|
|
254
|
+
if (typeof against === 'object' &&
|
|
255
|
+
against &&
|
|
256
|
+
typeof internalModel === 'object' &&
|
|
257
|
+
internalModel) {
|
|
258
|
+
return !deltaHasValuesOtherThanRetain(internalModel.diff(against));
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return false;
|
|
262
|
+
};
|
|
263
|
+
const handleTextChange = (delta, oldContents, source) => {
|
|
264
|
+
internalModel = maybeClone(getContents());
|
|
265
|
+
// Update v-model:content when text changes
|
|
266
|
+
if (!internalModelEquals(props.content)) {
|
|
267
|
+
ctx.emit('update:content', internalModel);
|
|
268
|
+
}
|
|
269
|
+
ctx.emit('textChange', { delta, oldContents, source });
|
|
270
|
+
};
|
|
271
|
+
const isEditorFocus = vue.ref();
|
|
272
|
+
const handleSelectionChange = (range, oldRange, source) => {
|
|
273
|
+
var _a;
|
|
274
|
+
// Set isEditorFocus if quill.hasFocus()
|
|
275
|
+
isEditorFocus.value = !!(quill === null || quill === void 0 ? void 0 : quill.hasFocus());
|
|
276
|
+
// 动态显示/隐藏toolbar
|
|
277
|
+
const toolbar = (_a = quill === null || quill === void 0 ? void 0 : quill.getModule('toolbar')) === null || _a === void 0 ? void 0 : _a.container;
|
|
278
|
+
if (toolbar) {
|
|
279
|
+
if (isEditorFocus.value) {
|
|
280
|
+
toolbar.style.display = 'block';
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
toolbar.style.display = 'none';
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
ctx.emit('selectionChange', { range, oldRange, source });
|
|
287
|
+
};
|
|
288
|
+
vue.watch(isEditorFocus, (focus) => {
|
|
289
|
+
if (focus)
|
|
290
|
+
ctx.emit('focus', editor);
|
|
291
|
+
else
|
|
292
|
+
ctx.emit('blur', editor);
|
|
293
|
+
});
|
|
294
|
+
const handleEditorChange = (...args) => {
|
|
295
|
+
if (args[0] === 'text-change')
|
|
296
|
+
ctx.emit('editorChange', {
|
|
297
|
+
name: args[0],
|
|
298
|
+
delta: args[1],
|
|
299
|
+
oldContents: args[2],
|
|
300
|
+
source: args[3],
|
|
301
|
+
});
|
|
302
|
+
if (args[0] === 'selection-change')
|
|
303
|
+
ctx.emit('editorChange', {
|
|
304
|
+
name: args[0],
|
|
305
|
+
range: args[1],
|
|
306
|
+
oldRange: args[2],
|
|
307
|
+
source: args[3],
|
|
308
|
+
});
|
|
309
|
+
};
|
|
310
|
+
const getEditor = () => {
|
|
311
|
+
return editor.value;
|
|
312
|
+
};
|
|
313
|
+
const getToolbar = () => {
|
|
314
|
+
var _a;
|
|
315
|
+
return (_a = quill === null || quill === void 0 ? void 0 : quill.getModule('toolbar')) === null || _a === void 0 ? void 0 : _a.container;
|
|
316
|
+
};
|
|
317
|
+
const getQuill = () => {
|
|
318
|
+
if (quill)
|
|
319
|
+
return quill;
|
|
320
|
+
else
|
|
321
|
+
throw `The quill editor hasn't been instantiated yet,
|
|
322
|
+
make sure to call this method when the editor ready
|
|
323
|
+
or use v-on:ready="onReady(quill)" event instead.`;
|
|
324
|
+
};
|
|
325
|
+
const getContents = (index, length) => {
|
|
326
|
+
if (props.contentType === 'html') {
|
|
327
|
+
return getHTML();
|
|
328
|
+
}
|
|
329
|
+
else if (props.contentType === 'text') {
|
|
330
|
+
return getText(index, length);
|
|
331
|
+
}
|
|
332
|
+
return quill === null || quill === void 0 ? void 0 : quill.getContents(index, length);
|
|
333
|
+
};
|
|
334
|
+
const setContents = (content, source = 'api') => {
|
|
335
|
+
const normalizedContent = !content
|
|
336
|
+
? props.contentType === 'delta'
|
|
337
|
+
? new Delta__default()
|
|
338
|
+
: ''
|
|
339
|
+
: content;
|
|
340
|
+
if (props.contentType === 'html') {
|
|
341
|
+
setHTML(normalizedContent);
|
|
342
|
+
}
|
|
343
|
+
else if (props.contentType === 'text') {
|
|
344
|
+
setText(normalizedContent, source);
|
|
345
|
+
}
|
|
346
|
+
else {
|
|
347
|
+
quill === null || quill === void 0 ? void 0 : quill.setContents(normalizedContent, source);
|
|
348
|
+
}
|
|
349
|
+
internalModel = maybeClone(normalizedContent);
|
|
350
|
+
};
|
|
351
|
+
const getText = (index, length) => {
|
|
352
|
+
var _a;
|
|
353
|
+
return (_a = quill === null || quill === void 0 ? void 0 : quill.getText(index, length)) !== null && _a !== void 0 ? _a : '';
|
|
354
|
+
};
|
|
355
|
+
const setText = (text, source = 'api') => {
|
|
356
|
+
quill === null || quill === void 0 ? void 0 : quill.setText(text, source);
|
|
357
|
+
};
|
|
358
|
+
const getHTML = () => {
|
|
359
|
+
var _a;
|
|
360
|
+
return (_a = quill === null || quill === void 0 ? void 0 : quill.root.innerHTML) !== null && _a !== void 0 ? _a : '';
|
|
361
|
+
};
|
|
362
|
+
const setHTML = (html) => {
|
|
363
|
+
if (quill)
|
|
364
|
+
quill.root.innerHTML = html;
|
|
365
|
+
};
|
|
366
|
+
const pasteHTML = (html, source = 'api') => {
|
|
367
|
+
const delta = quill === null || quill === void 0 ? void 0 : quill.clipboard.convert(html);
|
|
368
|
+
if (delta)
|
|
369
|
+
quill === null || quill === void 0 ? void 0 : quill.setContents(delta, source);
|
|
370
|
+
};
|
|
371
|
+
const focus = () => {
|
|
372
|
+
quill === null || quill === void 0 ? void 0 : quill.focus();
|
|
373
|
+
};
|
|
374
|
+
const reinit = () => {
|
|
375
|
+
vue.nextTick(() => {
|
|
376
|
+
var _a;
|
|
377
|
+
if (!ctx.slots.toolbar && quill)
|
|
378
|
+
(_a = quill.getModule('toolbar')) === null || _a === void 0 ? void 0 : _a.container.remove();
|
|
379
|
+
initialize();
|
|
380
|
+
});
|
|
381
|
+
};
|
|
382
|
+
vue.watch(() => props.content, (newContent) => {
|
|
383
|
+
if (!quill || !newContent || internalModelEquals(newContent))
|
|
384
|
+
return;
|
|
385
|
+
// Restore the selection and cursor position after updating the content
|
|
386
|
+
const selection = quill.getSelection();
|
|
387
|
+
if (selection) {
|
|
388
|
+
vue.nextTick(() => quill === null || quill === void 0 ? void 0 : quill.setSelection(selection));
|
|
389
|
+
}
|
|
390
|
+
setContents(newContent);
|
|
391
|
+
}, { deep: true });
|
|
392
|
+
vue.watch(() => props.enable, (newValue) => {
|
|
393
|
+
if (quill)
|
|
394
|
+
quill.enable(newValue);
|
|
395
|
+
});
|
|
396
|
+
return {
|
|
397
|
+
editor,
|
|
398
|
+
getEditor,
|
|
399
|
+
getToolbar,
|
|
400
|
+
getQuill,
|
|
401
|
+
getContents,
|
|
402
|
+
setContents,
|
|
403
|
+
getHTML,
|
|
404
|
+
setHTML,
|
|
405
|
+
pasteHTML,
|
|
406
|
+
focus,
|
|
407
|
+
getText,
|
|
408
|
+
setText,
|
|
409
|
+
reinit,
|
|
410
|
+
};
|
|
411
|
+
},
|
|
412
|
+
render() {
|
|
413
|
+
var _a, _b;
|
|
414
|
+
return [
|
|
415
|
+
(_b = (_a = this.$slots).toolbar) === null || _b === void 0 ? void 0 : _b.call(_a),
|
|
416
|
+
vue.h('div', { ref: 'editor', ...this.$attrs }),
|
|
417
|
+
];
|
|
418
|
+
},
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
exports.Quill = Quill__default;
|
|
422
|
+
exports.Delta = Delta__default;
|
|
423
|
+
exports.QuillEditor = QuillEditor;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* PxxVueQuill pxx-vue-quill v0.0.0-development
|
|
3
|
+
* https://vueup.github.io/vue-quill/
|
|
4
|
+
*
|
|
5
|
+
* Includes quill v1.3.7
|
|
6
|
+
* https://quilljs.com/
|
|
7
|
+
*
|
|
8
|
+
* Copyright (c) 2025 Pxx-Team
|
|
9
|
+
* Released under the MIT license
|
|
10
|
+
* Date: 2025-08-20T07:28:26.289Z
|
|
11
|
+
*/
|
|
12
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("quill"),t=require("quill-delta"),o=require("vue"),n=require("quill-blot-formatter");function l(e){return e&&"object"==typeof e&&"default"in e?e.default:e}var r=l(e),i=l(t),a=l(n);const s={full:[["bold","italic","underline"],[{list:"ordered"},{list:"bullet"}],[{color:[]},{background:[]}],["image"]]},u=o.defineComponent({name:"QuillEditor",inheritAttrs:!1,props:{content:{type:[String,Object]},contentType:{type:String,default:"delta",validator:e=>["delta","html","text"].includes(e)},enable:{type:Boolean,default:!0},readOnly:{type:Boolean,default:!1},placeholder:{type:String,required:!1},theme:{type:String,default:"snow",validator:e=>["snow","bubble",""].includes(e)},toolbar:{type:[String,Array,Object,Boolean],required:!1,validator:e=>!!e&&("string"!=typeof e||""===e||("#"===e.charAt(0)||-1!==Object.keys(s).indexOf(e)))},modules:{type:Object,required:!1,default:()=>({name:"blotFormatter",module:a})},options:{type:Object,required:!1},globalOptions:{type:Object,required:!1}},emits:["textChange","selectionChange","editorChange","update:content","focus","blur","ready","ocr","math"],setup:(e,t)=>{let n,l;o.onMounted((()=>{d()})),o.onBeforeUnmount((()=>{n=null}));const a=o.ref(),u=(e,t)=>{r.register(e,t)},d=()=>{var o,i;if(!a.value)return;n=new r(a.value,l);const s=null===(o=null==n?void 0:n.getModule("toolbar"))||void 0===o?void 0:o.container;s&&(s.style.display="none");const d=r.import("ui/icons");if(d.ocr='\n <svg viewBox="0 0 18 18">\n <path d="M3 3h12v12H3z" fill="none" stroke="currentColor" stroke-width="1.5"/>\n <path d="M6 7h6M6 9h6M6 11h4" stroke="currentColor" stroke-width="1"/>\n </svg>\n ',d["custom-button"]='\n <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill="none" version="1.1" width="18" height="18" viewBox="0 0 18 18"><defs><clipPath id="master_svg0_6759_139354"><rect x="0" y="0" width="18" height="18" rx="0"/></clipPath></defs><g clip-path="url(#master_svg0_6759_139354)"><g><path d="M15.423694,15.049834L15.424264,15.049264Q15.508656,14.964872,15.554328,14.85461Q15.6,14.744348,15.6,14.625Q15.6,14.565905,15.58847,14.507944Q15.576942,14.449986,15.554328,14.395388Q15.531713,14.340792,15.498882,14.291656Q15.466051,14.242521,15.424265,14.200735Q15.382479,14.158949,15.333343,14.126117Q15.284206,14.093286,15.229609,14.070671Q15.175013,14.048058,15.117053,14.036528Q15.059094,14.025,15,14.025Q14.880652,14.025,14.77039,14.070672Q14.660128,14.116344,14.575736,14.200736L13.626472,15.150001L4.4485275,15.150001L10.174264,9.424264Q10.2160501,9.3824773,10.2488813,9.3333416Q10.281712500000001,9.2842059,10.304327,9.229609499999999Q10.3269415,9.175012599999999,10.3384705,9.117054Q10.349999,9.0590944,10.349999,8.999999500000001Q10.349999,8.9409046,10.3384705,8.8829451Q10.3269415,8.8249855,10.304327,8.7703896Q10.281712500000001,8.715793099999999,10.2488813,8.6666574Q10.2160501,8.6175222,10.174264,8.575736L4.4485282,2.85000002L13.626472,2.85000002L14.575395,3.7989223L14.575736,3.7992642Q14.660127,3.8836554999999997,14.77039,3.9293277Q14.880651,3.9749999000000003,15,3.975Q15.059094,3.9749999000000003,15.117054,3.9634712Q15.175013,3.9519422,15.229609,3.9293275999999997Q15.284206,3.906713,15.333342,3.8738817Q15.382478,3.8410504000000003,15.424264,3.7992641000000003Q15.466051,3.7574776,15.498882,3.7083421000000003Q15.531713,3.6592064,15.554328,3.60461Q15.576942,3.5500134,15.588472,3.4920541Q15.6,3.4340948,15.6,3.375Q15.6,3.2556524,15.554328,3.1453898000000002Q15.508656,3.03512704,15.424264,2.9507357499999998L15.423856,2.9503274L14.299264,1.82573593Q14.214872,1.7413445699999999,14.10461,1.69567227Q13.994347,1.64999998,13.875,1.64999998L3,1.64999998Q2.88065257,1.64999998,2.77038994,1.69567227Q2.66012731,1.7413445699999999,2.57573593,1.82573593Q2.53394958,1.8675223,2.50111824,1.91665789Q2.46828693,1.96579346,2.44567233,2.02038996Q2.42305773,2.07498647,2.41152894,2.13294582Q2.4000000999999997,2.190905161,2.40000004,2.25Q2.4000000999999997,2.309094839,2.41152889,2.36705418Q2.42305773,2.42501353,2.44567233,2.47961004Q2.46828693,2.53420654,2.50111827,2.58334213Q2.53394958,2.6324777,2.57573593,2.67426407L8.9014721,9L2.57573593,15.325736Q2.49134457,15.410126,2.44567227,15.520389Q2.39999998,15.630651,2.39999998,15.75Q2.39999998,15.809094,2.41152883,15.867053Q2.42305768,15.925013,2.44567233,15.979609Q2.46828693,16.034204000000003,2.50111827,16.08334Q2.53394958,16.132476,2.57573593,16.174263Q2.6175223,16.216048999999998,2.66665787,16.24888Q2.71579343,16.281712,2.77038994,16.304327Q2.82498646,16.326940999999998,2.88294581,16.33847Q2.940905157,16.349998,3,16.349999L13.875,16.349999Q13.994347,16.349998,14.104609,16.304326Q14.214872,16.258654,14.299264,16.174264L15.423694,15.049834Z" fill-rule="evenodd" fill="#333333" fill-opacity="1" style="mix-blend-mode:passthrough"/></g></g></svg>\n ',l=c(),e.modules)if(Array.isArray(e.modules))for(const t of e.modules)u(`modules/${t.name}`,t.module);else u(`modules/${e.modules.name}`,e.modules.module);n=new r(a.value,l),y(e.content),n.on("text-change",p),n.on("selection-change",Q),n.on("editor-change",f),"bubble"!==e.theme&&a.value.classList.remove("ql-bubble"),"snow"!==e.theme&&a.value.classList.remove("ql-snow"),null===(i=n.getModule("toolbar"))||void 0===i||i.container.addEventListener("mousedown",(e=>{e.preventDefault()})),t.emit("ready",n)},c=()=>{const o={};if(""!==e.theme&&(o.theme=e.theme),e.readOnly&&(o.readOnly=e.readOnly),e.placeholder&&(o.placeholder=e.placeholder),e.toolbar&&""!==e.toolbar&&(o.modules={toolbar:{container:[...s.full,["ocr"],[{"custom-button":!0}]],handlers:{ocr:function(){console.log("ocr"),t.emit("ocr")},math:function(){t.emit("math")}}}}),e.modules){const t=(()=>{var t,o;const n={};if(Array.isArray(e.modules))for(const l of e.modules)n[l.name]=null!==(t=l.options)&&void 0!==t?t:{};else n[e.modules.name]=null!==(o=e.modules.options)&&void 0!==o?o:{};return n})();o.modules=Object.assign({},o.modules,t)}return Object.assign({},e.globalOptions,e.options,o)},m=e=>"object"==typeof e&&e?e.slice():e;let v;const h=e=>{if(typeof v==typeof e){if(e===v)return!0;if("object"==typeof e&&e&&"object"==typeof v&&v)return t=v.diff(e),!Object.values(t.ops).some((e=>!e.retain||1!==Object.keys(e).length))}var t;return!1},p=(o,n,l)=>{v=m(b()),h(e.content)||t.emit("update:content",v),t.emit("textChange",{delta:o,oldContents:n,source:l})},g=o.ref(),Q=(e,o,l)=>{var r;g.value=!!(null==n?void 0:n.hasFocus());const i=null===(r=null==n?void 0:n.getModule("toolbar"))||void 0===r?void 0:r.container;i&&(i.style.display=g.value?"block":"none"),t.emit("selectionChange",{range:e,oldRange:o,source:l})};o.watch(g,(e=>{t.emit(e?"focus":"blur",a)}));const f=(...e)=>{"text-change"===e[0]&&t.emit("editorChange",{name:e[0],delta:e[1],oldContents:e[2],source:e[3]}),"selection-change"===e[0]&&t.emit("editorChange",{name:e[0],range:e[1],oldRange:e[2],source:e[3]})},b=(t,o)=>"html"===e.contentType?L():"text"===e.contentType?w(t,o):null==n?void 0:n.getContents(t,o),y=(t,o="api")=>{const l=t||("delta"===e.contentType?new i:"");"html"===e.contentType?T(l):"text"===e.contentType?x(l,o):null==n||n.setContents(l,o),v=m(l)},w=(e,t)=>{var o;return null!==(o=null==n?void 0:n.getText(e,t))&&void 0!==o?o:""},x=(e,t="api")=>{null==n||n.setText(e,t)},L=()=>{var e;return null!==(e=null==n?void 0:n.root.innerHTML)&&void 0!==e?e:""},T=e=>{n&&(n.root.innerHTML=e)};return o.watch((()=>e.content),(e=>{if(!n||!e||h(e))return;const t=n.getSelection();t&&o.nextTick((()=>null==n?void 0:n.setSelection(t))),y(e)}),{deep:!0}),o.watch((()=>e.enable),(e=>{n&&n.enable(e)})),{editor:a,getEditor:()=>a.value,getToolbar:()=>{var e;return null===(e=null==n?void 0:n.getModule("toolbar"))||void 0===e?void 0:e.container},getQuill:()=>{if(n)return n;throw'The quill editor hasn\'t been instantiated yet,\n make sure to call this method when the editor ready\n or use v-on:ready="onReady(quill)" event instead.'},getContents:b,setContents:y,getHTML:L,setHTML:T,pasteHTML:(e,t="api")=>{const o=null==n?void 0:n.clipboard.convert(e);o&&(null==n||n.setContents(o,t))},focus:()=>{null==n||n.focus()},getText:w,setText:x,reinit:()=>{o.nextTick((()=>{var e;!t.slots.toolbar&&n&&(null===(e=n.getModule("toolbar"))||void 0===e||e.container.remove()),d()}))}}},render(){var e,t;return[null===(t=(e=this.$slots).toolbar)||void 0===t?void 0:t.call(e),o.h("div",{ref:"editor",...this.$attrs})]}});exports.Quill=r,exports.Delta=i,exports.QuillEditor=u;
|