@tailor-cms/ce-quill-html-edit 0.0.6 → 0.1.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/dist/components/Edit.vue.d.ts +5 -7
- package/dist/components/QuillEditor.vue.d.ts +1 -71
- package/dist/components/TopToolbar.vue.d.ts +1 -1
- package/dist/components/theme/index.d.ts +2 -1
- package/dist/index.cjs +364 -472
- package/dist/index.css +6 -7
- package/dist/index.js +364 -472
- package/package.json +19 -16
- package/dist/components/Edit.vue.js +0 -106
- package/dist/components/QuillEditor.vue.js +0 -117
- package/dist/components/TopToolbar.vue.js +0 -214
- package/dist/components/theme/index.js +0 -157
- package/dist/components/theme/modules/image-embed.js +0 -18
- package/dist/components/theme/toolbar-icons.js +0 -69
- package/dist/components/theme/ui/color-picker.js +0 -54
- package/dist/components/theme/ui/image-embed-tooltip.js +0 -84
- package/dist/components/theme/ui/tooltip.js +0 -31
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
const isString = (arg) => typeof arg === 'string';
|
|
2
|
-
const mdiIcons = {
|
|
3
|
-
undo: 'undo',
|
|
4
|
-
redo: 'redo',
|
|
5
|
-
align: {
|
|
6
|
-
'': 'format-align-left',
|
|
7
|
-
center: 'format-align-center',
|
|
8
|
-
right: 'format-align-right',
|
|
9
|
-
justify: 'format-align-justify',
|
|
10
|
-
},
|
|
11
|
-
background: 'format-color-highlight',
|
|
12
|
-
blockquote: 'format-quote-close',
|
|
13
|
-
bold: 'format-bold',
|
|
14
|
-
clean: 'format-clear',
|
|
15
|
-
code: 'code-tags',
|
|
16
|
-
'code-block': 'code-tags',
|
|
17
|
-
color: 'format-color-text',
|
|
18
|
-
direction: {
|
|
19
|
-
'': 'format-pilcrow-arrow-right',
|
|
20
|
-
rtl: 'format-pilcrow-arrow-left',
|
|
21
|
-
},
|
|
22
|
-
formula: 'function-variant',
|
|
23
|
-
header: {
|
|
24
|
-
1: 'format-header-1',
|
|
25
|
-
2: 'format-header-2',
|
|
26
|
-
},
|
|
27
|
-
italic: 'format-italic',
|
|
28
|
-
image: 'image-plus',
|
|
29
|
-
indent: {
|
|
30
|
-
'+1': 'format-indent-increase',
|
|
31
|
-
'-1': 'format-indent-decrease',
|
|
32
|
-
},
|
|
33
|
-
link: 'link',
|
|
34
|
-
list: {
|
|
35
|
-
bullet: 'format-list-bulleted',
|
|
36
|
-
check: 'format-list-checks',
|
|
37
|
-
ordered: 'format-list-numbered',
|
|
38
|
-
},
|
|
39
|
-
script: {
|
|
40
|
-
sub: 'format-subscript',
|
|
41
|
-
super: 'format-superscript',
|
|
42
|
-
},
|
|
43
|
-
strike: 'format-strikethrough',
|
|
44
|
-
table: 'table-plus',
|
|
45
|
-
underline: 'format-underline',
|
|
46
|
-
video: 'video-plus',
|
|
47
|
-
};
|
|
48
|
-
export default mdiIcons;
|
|
49
|
-
const textColor = `
|
|
50
|
-
<span style="position: relative;">
|
|
51
|
-
<i class="icon mdi-format-color-text mdi v-icon notranslate v-theme--default"></i>
|
|
52
|
-
<i class="icon mdi-color-helper mdi v-icon notranslate v-theme--default" style="position: absolute; top: 0; left: 0;"></i>
|
|
53
|
-
</span>
|
|
54
|
-
`;
|
|
55
|
-
const bgColor = `
|
|
56
|
-
<span style="position: relative;">
|
|
57
|
-
<i class="icon mdi-format-color-highlight mdi v-icon notranslate v-theme--default"></i>
|
|
58
|
-
<i class="icon mdi-color-helper mdi v-icon notranslate v-theme--default" style="position: absolute; top:0; left: 0;"></i>
|
|
59
|
-
</span>
|
|
60
|
-
`;
|
|
61
|
-
export function getMdiIcon(name, value = '') {
|
|
62
|
-
if (name === 'color')
|
|
63
|
-
return textColor;
|
|
64
|
-
if (name === 'background')
|
|
65
|
-
return bgColor;
|
|
66
|
-
const icon = mdiIcons[name];
|
|
67
|
-
const code = isString(icon) ? icon : icon[value];
|
|
68
|
-
return `<span class="icon mdi mdi-${code}"></span>`;
|
|
69
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import './color-picker.scss';
|
|
2
|
-
import ColorPicker from 'quill/ui/color-picker';
|
|
3
|
-
import Quill from 'quill';
|
|
4
|
-
const className = (...names) => names.join(' ');
|
|
5
|
-
export default class ExtendedColorPicker extends ColorPicker {
|
|
6
|
-
constructor(quill, options) {
|
|
7
|
-
super(options.select, options.label);
|
|
8
|
-
Object.defineProperty(this, "quill", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: void 0
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(this, "type", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: void 0
|
|
19
|
-
});
|
|
20
|
-
this.quill = quill;
|
|
21
|
-
this.type = options.type;
|
|
22
|
-
}
|
|
23
|
-
buildPicker() {
|
|
24
|
-
super.buildPicker();
|
|
25
|
-
const btnReset = createButton({ icon: 'mdi-water-off', text: 'None' });
|
|
26
|
-
btnReset.className = className('picker-item__none');
|
|
27
|
-
btnReset.addEventListener('click', () => {
|
|
28
|
-
this.quill.format(this.type, null, Quill.sources.USER);
|
|
29
|
-
this.close();
|
|
30
|
-
});
|
|
31
|
-
const colorOptions = wrapOptions(this.options);
|
|
32
|
-
colorOptions.className = className('picker-colors');
|
|
33
|
-
this.options.appendChild(btnReset);
|
|
34
|
-
this.options.appendChild(colorOptions);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
function wrapOptions({ children }) {
|
|
38
|
-
const container = document.createElement('div');
|
|
39
|
-
Array.from(children).forEach((option) => container.appendChild(option));
|
|
40
|
-
return container;
|
|
41
|
-
}
|
|
42
|
-
function createButton({ icon, text }) {
|
|
43
|
-
const btn = document.createElement('span');
|
|
44
|
-
btn.tabIndex = 0;
|
|
45
|
-
btn.setAttribute('role', 'button');
|
|
46
|
-
btn.appendChild(createIcon(icon));
|
|
47
|
-
btn.innerHTML += text;
|
|
48
|
-
return btn;
|
|
49
|
-
}
|
|
50
|
-
function createIcon(name) {
|
|
51
|
-
const icon = document.createElement('span');
|
|
52
|
-
icon.className = className('icon', 'mdi', name);
|
|
53
|
-
return icon;
|
|
54
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import './image-embed-tooltip.scss';
|
|
2
|
-
import Keyboard from 'quill/modules/keyboard';
|
|
3
|
-
import Quill from 'quill';
|
|
4
|
-
import Tooltip from './tooltip.ts';
|
|
5
|
-
class ImageEmbedTooltip extends Tooltip {
|
|
6
|
-
constructor(quill, bounds, { spacing = 0 } = {}) {
|
|
7
|
-
super(quill, bounds);
|
|
8
|
-
Object.defineProperty(this, "padding", {
|
|
9
|
-
enumerable: true,
|
|
10
|
-
configurable: true,
|
|
11
|
-
writable: true,
|
|
12
|
-
value: void 0
|
|
13
|
-
});
|
|
14
|
-
Object.defineProperty(this, "textbox", {
|
|
15
|
-
enumerable: true,
|
|
16
|
-
configurable: true,
|
|
17
|
-
writable: true,
|
|
18
|
-
value: void 0
|
|
19
|
-
});
|
|
20
|
-
Object.defineProperty(this, "btnAction", {
|
|
21
|
-
enumerable: true,
|
|
22
|
-
configurable: true,
|
|
23
|
-
writable: true,
|
|
24
|
-
value: void 0
|
|
25
|
-
});
|
|
26
|
-
this.padding = ' '.repeat(spacing);
|
|
27
|
-
this.textbox = this.root.querySelector('input.url');
|
|
28
|
-
this.btnAction = this.root.querySelector('a.action');
|
|
29
|
-
this.listen();
|
|
30
|
-
}
|
|
31
|
-
listen() {
|
|
32
|
-
this.btnAction?.addEventListener('click', () => this.embedImage());
|
|
33
|
-
this.textbox?.addEventListener('keydown', (e) => {
|
|
34
|
-
if (Keyboard.match(e, { key: 'enter' })) {
|
|
35
|
-
this.embedImage();
|
|
36
|
-
e.preventDefault();
|
|
37
|
-
}
|
|
38
|
-
else if (Keyboard.match(e, { key: 'escape' })) {
|
|
39
|
-
this.hide();
|
|
40
|
-
e.preventDefault();
|
|
41
|
-
}
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
show() {
|
|
45
|
-
super.show();
|
|
46
|
-
this.root.classList.add('ql-image-embed');
|
|
47
|
-
this.textbox?.select();
|
|
48
|
-
}
|
|
49
|
-
embedImage() {
|
|
50
|
-
const url = this.textbox?.value;
|
|
51
|
-
if (!url)
|
|
52
|
-
return;
|
|
53
|
-
const { quill } = this;
|
|
54
|
-
const range = quill.getSelection(true);
|
|
55
|
-
if (range) {
|
|
56
|
-
const { padding } = this;
|
|
57
|
-
const source = Quill.sources.USER;
|
|
58
|
-
let offset = range.index + range.length;
|
|
59
|
-
quill.insertText(offset, padding, source);
|
|
60
|
-
offset += padding.length;
|
|
61
|
-
quill.insertEmbed(offset, 'image', url, source);
|
|
62
|
-
offset += 1;
|
|
63
|
-
quill.insertText(offset, padding, source);
|
|
64
|
-
offset += padding.length;
|
|
65
|
-
quill.setSelection(offset, source);
|
|
66
|
-
}
|
|
67
|
-
if (this.textbox)
|
|
68
|
-
this.textbox.value = '';
|
|
69
|
-
this.hide();
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
Object.defineProperty(ImageEmbedTooltip, "TEMPLATE", {
|
|
73
|
-
enumerable: true,
|
|
74
|
-
configurable: true,
|
|
75
|
-
writable: true,
|
|
76
|
-
value: `
|
|
77
|
-
<div class="controls">
|
|
78
|
-
<label>Enter image url:</label>
|
|
79
|
-
<input class="url" type="text">
|
|
80
|
-
<a class="action">Save</a>
|
|
81
|
-
</div>
|
|
82
|
-
`
|
|
83
|
-
});
|
|
84
|
-
export default ImageEmbedTooltip;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import Tooltip from 'quill/ui/tooltip';
|
|
2
|
-
export default class ExtendedTooltip extends Tooltip {
|
|
3
|
-
constructor(quill, bounds) {
|
|
4
|
-
super(quill, bounds);
|
|
5
|
-
Object.defineProperty(this, "isOpen", {
|
|
6
|
-
enumerable: true,
|
|
7
|
-
configurable: true,
|
|
8
|
-
writable: true,
|
|
9
|
-
value: void 0
|
|
10
|
-
});
|
|
11
|
-
this._onClick = this._onClick.bind(this);
|
|
12
|
-
this.isOpen = false;
|
|
13
|
-
}
|
|
14
|
-
show() {
|
|
15
|
-
super.show();
|
|
16
|
-
this.isOpen = true;
|
|
17
|
-
setTimeout(() => document.body.addEventListener('mousedown', (e) => this._onClick(e)), 0);
|
|
18
|
-
const bounds = this.quill.getBounds(this.quill.selection.savedRange);
|
|
19
|
-
if (bounds)
|
|
20
|
-
this.position(bounds);
|
|
21
|
-
}
|
|
22
|
-
hide() {
|
|
23
|
-
super.hide();
|
|
24
|
-
this.isOpen = false;
|
|
25
|
-
document.body.removeEventListener('mousedown', (e) => this._onClick(e));
|
|
26
|
-
}
|
|
27
|
-
_onClick(e) {
|
|
28
|
-
if (this.isOpen && e.target && !this.root.contains(e.target))
|
|
29
|
-
this.hide();
|
|
30
|
-
}
|
|
31
|
-
}
|