@ebl-vue/editor-full 2.31.25 → 2.31.28
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.d.ts +1 -28
- package/dist/index.mjs +549 -727
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
- package/types/index.d.ts +5 -1
- package/.postcssrc.yml +0 -33
- package/postcss.config.js +0 -15
- package/src/components/Editor/Editor.vue +0 -293
- package/src/components/Editor/EditorRender.vue +0 -274
- package/src/components/index.ts +0 -29
- package/src/constants/index.ts +0 -1
- package/src/i18n/zh-cn.ts +0 -158
- package/src/icons/index.ts +0 -93
- package/src/index.ts +0 -22
- package/src/installer.ts +0 -21
- package/src/plugins/alert/index.css +0 -150
- package/src/plugins/alert/index.ts +0 -456
- package/src/plugins/block-alignment/index.css +0 -9
- package/src/plugins/block-alignment/index.ts +0 -117
- package/src/plugins/block-alignment/readme.md +0 -1
- package/src/plugins/code/LICENSE +0 -21
- package/src/plugins/code/index.css +0 -214
- package/src/plugins/code/index.ts +0 -621
- package/src/plugins/code/utils/string.ts +0 -34
- package/src/plugins/color-picker/index.ts +0 -130
- package/src/plugins/color-picker/styles.css +0 -27
- package/src/plugins/delimiter/index.css +0 -14
- package/src/plugins/delimiter/index.ts +0 -121
- package/src/plugins/drag-drop/index.css +0 -19
- package/src/plugins/drag-drop/index.ts +0 -151
- package/src/plugins/drag-drop/readme.md +0 -1
- package/src/plugins/header/H1.ts +0 -404
- package/src/plugins/header/H2.ts +0 -403
- package/src/plugins/header/H3.ts +0 -404
- package/src/plugins/header/H4.ts +0 -404
- package/src/plugins/header/H5.ts +0 -403
- package/src/plugins/header/H6.ts +0 -404
- package/src/plugins/header/index.css +0 -20
- package/src/plugins/header/index.ts +0 -15
- package/src/plugins/header/types.d.ts +0 -46
- package/src/plugins/imageResizeCrop/ImageTune.ts +0 -916
- package/src/plugins/imageResizeCrop/index.css +0 -230
- package/src/plugins/imageResizeCrop/index.ts +0 -5
- package/src/plugins/imageResizeCrop/types.d.ts +0 -23
- package/src/plugins/imageTool/index.css +0 -156
- package/src/plugins/imageTool/index.ts +0 -538
- package/src/plugins/imageTool/types/codexteam__ajax.d.ts +0 -89
- package/src/plugins/imageTool/types/types.ts +0 -236
- package/src/plugins/imageTool/ui.ts +0 -313
- package/src/plugins/imageTool/uploader.ts +0 -272
- package/src/plugins/imageTool/utils/dom.ts +0 -24
- package/src/plugins/imageTool/utils/index.ts +0 -73
- package/src/plugins/imageTool/utils/isPromise.ts +0 -10
- package/src/plugins/indent/index.css +0 -86
- package/src/plugins/indent/index.ts +0 -695
- package/src/plugins/inline-code/index.css +0 -11
- package/src/plugins/inline-code/index.ts +0 -202
- package/src/plugins/list/ListRenderer/ChecklistRenderer.ts +0 -208
- package/src/plugins/list/ListRenderer/ListRenderer.ts +0 -73
- package/src/plugins/list/ListRenderer/OrderedListRenderer.ts +0 -123
- package/src/plugins/list/ListRenderer/UnorderedListRenderer.ts +0 -123
- package/src/plugins/list/ListRenderer/index.ts +0 -6
- package/src/plugins/list/ListTabulator/index.ts +0 -1179
- package/src/plugins/list/index.ts +0 -480
- package/src/plugins/list/styles/CssPrefix.ts +0 -4
- package/src/plugins/list/styles/input.css +0 -36
- package/src/plugins/list/styles/list.css +0 -165
- package/src/plugins/list/types/Elements.ts +0 -14
- package/src/plugins/list/types/ItemMeta.ts +0 -40
- package/src/plugins/list/types/ListParams.ts +0 -102
- package/src/plugins/list/types/ListRenderer.ts +0 -6
- package/src/plugins/list/types/OlCounterType.ts +0 -63
- package/src/plugins/list/types/index.ts +0 -14
- package/src/plugins/list/utils/focusItem.ts +0 -18
- package/src/plugins/list/utils/getChildItems.ts +0 -40
- package/src/plugins/list/utils/getItemChildWrapper.ts +0 -10
- package/src/plugins/list/utils/getItemContentElement.ts +0 -10
- package/src/plugins/list/utils/getSiblings.ts +0 -52
- package/src/plugins/list/utils/isLastItem.ts +0 -9
- package/src/plugins/list/utils/itemHasSublist.ts +0 -10
- package/src/plugins/list/utils/normalizeData.ts +0 -83
- package/src/plugins/list/utils/removeChildWrapperIfEmpty.ts +0 -31
- package/src/plugins/list/utils/renderToolboxInput.ts +0 -105
- package/src/plugins/list/utils/stripNumbers.ts +0 -7
- package/src/plugins/list/utils/type-guards.ts +0 -8
- package/src/plugins/marker/index.css +0 -4
- package/src/plugins/marker/index.ts +0 -199
- package/src/plugins/outline/index.css +0 -52
- package/src/plugins/outline/index.ts +0 -63
- package/src/plugins/paragraph/index.css +0 -23
- package/src/plugins/paragraph/index.ts +0 -381
- package/src/plugins/paragraph/types/icons.d.ts +0 -4
- package/src/plugins/paragraph/utils/makeFragment.ts +0 -17
- package/src/plugins/quote/index.css +0 -26
- package/src/plugins/quote/index.ts +0 -203
- package/src/plugins/table/index.ts +0 -4
- package/src/plugins/table/plugin.ts +0 -254
- package/src/plugins/table/style.css +0 -388
- package/src/plugins/table/table.ts +0 -1195
- package/src/plugins/table/toolbox.ts +0 -166
- package/src/plugins/table/utils/dom.ts +0 -130
- package/src/plugins/table/utils/popover.ts +0 -185
- package/src/plugins/table/utils/throttled.ts +0 -22
- package/src/plugins/underline/index.css +0 -3
- package/src/plugins/underline/index.ts +0 -214
- package/src/plugins/undo/index.ts +0 -524
- package/src/plugins/undo/observer.ts +0 -101
- package/src/style.css +0 -114
- package/src/types.ts +0 -3
- package/src/utils/AxiosService.ts +0 -87
- package/src/utils/index.ts +0 -15
- package/src/utils/install.ts +0 -19
- package/tsconfig.json +0 -37
- package/vite.config.ts +0 -81
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { API } from '@ebl-vue/editorjs';
|
|
2
|
-
import { IconColor } from "../../icons";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import './styles.css';
|
|
6
|
-
|
|
7
|
-
import {type InlineToolConstructorOptions} from "@ebl-vue/editorjs/types/tools/inline-tool";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
export default class ColorPicker {
|
|
12
|
-
private api: API;
|
|
13
|
-
|
|
14
|
-
tag = 'SPAN';
|
|
15
|
-
class = 'cdx-text-color';
|
|
16
|
-
defaultColor = '#2644FF';
|
|
17
|
-
|
|
18
|
-
lastRange: Range | null = null;
|
|
19
|
-
|
|
20
|
-
colors: string[] = [
|
|
21
|
-
'#182a4e',
|
|
22
|
-
'#0055cc',
|
|
23
|
-
'#1f6a83',
|
|
24
|
-
'#206e4e',
|
|
25
|
-
'#e56910',
|
|
26
|
-
'#ae2e24',
|
|
27
|
-
'#5e4db2',
|
|
28
|
-
'#758195',
|
|
29
|
-
'#1e7afd',
|
|
30
|
-
'#2998bd',
|
|
31
|
-
'#23a06b',
|
|
32
|
-
'#fea363',
|
|
33
|
-
'#c9372c',
|
|
34
|
-
'#8270db',
|
|
35
|
-
];
|
|
36
|
-
columns = 7;
|
|
37
|
-
|
|
38
|
-
static get title() {
|
|
39
|
-
return 'Color';
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
static get isInline() {
|
|
43
|
-
return true;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
constructor(args:InlineToolConstructorOptions) {
|
|
47
|
-
const { api, config } = args;
|
|
48
|
-
this.api = api;
|
|
49
|
-
|
|
50
|
-
if (config.colors) {
|
|
51
|
-
this.colors = config.colors;
|
|
52
|
-
}
|
|
53
|
-
if (config.columns) {
|
|
54
|
-
this.columns = config.columns;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
render() {
|
|
59
|
-
const button = document.createElement('button');
|
|
60
|
-
|
|
61
|
-
button.type = 'button';
|
|
62
|
-
button.innerHTML = IconColor;
|
|
63
|
-
button.classList.add(this.api.styles.inlineToolButton);
|
|
64
|
-
|
|
65
|
-
button.addEventListener('mousedown', (e) => {
|
|
66
|
-
// prevent text deselection when clicking the button
|
|
67
|
-
e.preventDefault();
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
return button;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
surround(range: Range | null) {
|
|
74
|
-
this.lastRange = range;
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
wrapAndColor(range: Range | null, color: string) {
|
|
78
|
-
if (!range) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
const selectedText = range.extractContents();
|
|
82
|
-
const span = document.createElement(this.tag);
|
|
83
|
-
span.classList.add(this.class);
|
|
84
|
-
span.appendChild(selectedText);
|
|
85
|
-
span.style.color = color;
|
|
86
|
-
span.innerHTML = span.textContent || '';
|
|
87
|
-
range.insertNode(span);
|
|
88
|
-
|
|
89
|
-
this.api.selection.expandToTag(span);
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
renderActions() {
|
|
93
|
-
const container = document.createElement('div');
|
|
94
|
-
container.classList.add('editorjs__color-selector-container');
|
|
95
|
-
container.style.gridTemplateColumns = `repeat(${this.columns}, 1fr)`;
|
|
96
|
-
|
|
97
|
-
this.colors.forEach((colorValue) => {
|
|
98
|
-
const color = document.createElement('div');
|
|
99
|
-
color.classList.add('editorjs__color-selector__container-item');
|
|
100
|
-
color.style.backgroundColor = colorValue;
|
|
101
|
-
color.onclick = () => {
|
|
102
|
-
this.wrapAndColor(this.lastRange, colorValue);
|
|
103
|
-
};
|
|
104
|
-
container.append(color);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
return container;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
/**
|
|
111
|
-
* Sanitizer rules
|
|
112
|
-
*
|
|
113
|
-
* @returns {object}
|
|
114
|
-
*/
|
|
115
|
-
static get sanitize(): any {
|
|
116
|
-
return {
|
|
117
|
-
span: {
|
|
118
|
-
style: {
|
|
119
|
-
color: true,
|
|
120
|
-
},
|
|
121
|
-
},
|
|
122
|
-
};
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
export class ColorPickerWithoutSanitize extends ColorPicker {
|
|
127
|
-
static override get sanitize() {
|
|
128
|
-
return undefined;
|
|
129
|
-
}
|
|
130
|
-
}
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
.ce-popover--inline .ce-popover--nested .ce-popover__container {
|
|
2
|
-
width: min-content !important;
|
|
3
|
-
min-width: unset !important;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
.ce-popover--inline .ce-popover--nested .ce-popover__items {
|
|
7
|
-
width: max-content;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
.editorjs__color-selector-container {
|
|
11
|
-
display: grid;
|
|
12
|
-
gap: 10px;
|
|
13
|
-
padding: 4px;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
.editorjs__color-selector__container-item {
|
|
17
|
-
width: 30px;
|
|
18
|
-
height: 30px;
|
|
19
|
-
display: block;
|
|
20
|
-
cursor: pointer;
|
|
21
|
-
border-radius: 100%;
|
|
22
|
-
transition: transform 0.2s ease;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
.editorjs__color-selector__container-item:hover {
|
|
26
|
-
transform: scale(1.1);
|
|
27
|
-
}
|
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Build styles
|
|
3
|
-
*/
|
|
4
|
-
import './index.css';
|
|
5
|
-
import {API, BlockTool, BlockToolConstructorOptions, BlockToolData, ToolboxConfig, PasteConfig, PasteEvent} from "@ebl-vue/editorjs";
|
|
6
|
-
|
|
7
|
-
import {IconDelimiter} from '../../icons';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
export default class Delimiter implements BlockTool {
|
|
13
|
-
|
|
14
|
-
static get isReadOnlySupported(): boolean {
|
|
15
|
-
return true;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
static get contentless(): boolean {
|
|
20
|
-
return true;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
private api: API
|
|
24
|
-
|
|
25
|
-
private _CSS: {
|
|
26
|
-
block: string
|
|
27
|
-
wrapper: string
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
private _element: HTMLDivElement
|
|
33
|
-
private data: any;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
constructor({data, config, api}: BlockToolConstructorOptions) {
|
|
37
|
-
this.api = api;
|
|
38
|
-
|
|
39
|
-
this._CSS = {
|
|
40
|
-
block: this.api.styles.block,
|
|
41
|
-
wrapper: 'ce-delimiter'
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
this._element = this.drawView();
|
|
45
|
-
this.data = data;
|
|
46
|
-
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Create Tool's view
|
|
51
|
-
* @return {HTMLDivElement}
|
|
52
|
-
* @private
|
|
53
|
-
*/
|
|
54
|
-
drawView(): HTMLDivElement {
|
|
55
|
-
let wrapper = document.createElement('div');
|
|
56
|
-
let lineWrapper = document.createElement('div');
|
|
57
|
-
let lineDiv = document.createElement('div');
|
|
58
|
-
|
|
59
|
-
wrapper.classList.add(this._CSS.wrapper, this._CSS.block);
|
|
60
|
-
lineWrapper.classList.add('ce-delimiter__line__wrapper');
|
|
61
|
-
lineDiv.classList.add('ce-delimiter__line');
|
|
62
|
-
|
|
63
|
-
lineWrapper.appendChild(lineDiv);
|
|
64
|
-
wrapper.appendChild(lineWrapper);
|
|
65
|
-
|
|
66
|
-
return wrapper;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Return Tool's view
|
|
71
|
-
* @returns {HTMLDivElement}
|
|
72
|
-
* @public
|
|
73
|
-
*/
|
|
74
|
-
render(): HTMLDivElement {
|
|
75
|
-
console.log(this.data);
|
|
76
|
-
return this._element;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* Extract Tool's data from the view
|
|
81
|
-
* @param {HTMLDivElement} toolsContent - Paragraph tools rendered view
|
|
82
|
-
* @returns {DelimiterData} - saved data
|
|
83
|
-
* @public
|
|
84
|
-
*/
|
|
85
|
-
save(toolsContent: HTMLElement): BlockToolData {
|
|
86
|
-
return {};
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
/**
|
|
90
|
-
* Get Tool toolbox settings
|
|
91
|
-
* icon - Tool icon's SVG
|
|
92
|
-
* title - title to show in toolbox
|
|
93
|
-
*
|
|
94
|
-
* @return {{icon: string, title: string}}
|
|
95
|
-
*/
|
|
96
|
-
static get toolbox(): ToolboxConfig {
|
|
97
|
-
return {
|
|
98
|
-
icon: IconDelimiter,
|
|
99
|
-
title: 'Delimiter'
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Delimiter onPaste configuration
|
|
105
|
-
*
|
|
106
|
-
* @public
|
|
107
|
-
*/
|
|
108
|
-
static get pasteConfig(): PasteConfig {
|
|
109
|
-
return { tags: ['HR'] };
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
/**
|
|
113
|
-
* On paste callback that is fired from Editor
|
|
114
|
-
*
|
|
115
|
-
* @param {PasteEvent} event - event with pasted data
|
|
116
|
-
*/
|
|
117
|
-
onPaste(event: PasteEvent): void {
|
|
118
|
-
this.data = {};
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
.ce-block--drop-target .ce-block__content:before {
|
|
2
|
-
content: "";
|
|
3
|
-
position: absolute;
|
|
4
|
-
top: 50%;
|
|
5
|
-
left: -20px;
|
|
6
|
-
margin-top: -1px;
|
|
7
|
-
height: 8px;
|
|
8
|
-
width: 8px;
|
|
9
|
-
border: solid #a0a0a0;
|
|
10
|
-
border-width: 1px 1px 0 0;
|
|
11
|
-
-webkit-transform-origin: right;
|
|
12
|
-
transform-origin: right;
|
|
13
|
-
-webkit-transform: rotate(45deg);
|
|
14
|
-
transform: rotate(45deg);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
.ce-block--drop-target .ce-block__content:after {
|
|
18
|
-
background: none;
|
|
19
|
-
}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import './index.css';
|
|
2
|
-
|
|
3
|
-
import type EditorJS from '@ebl-vue/editorjs/types';
|
|
4
|
-
|
|
5
|
-
export default class DragDrop {
|
|
6
|
-
private toolbar: any;
|
|
7
|
-
private borderStyle: string;
|
|
8
|
-
private api: any;
|
|
9
|
-
private holder: HTMLElement;
|
|
10
|
-
private readOnly: boolean | undefined;
|
|
11
|
-
private startBlock: number | null;
|
|
12
|
-
private endBlock: number | null;
|
|
13
|
-
|
|
14
|
-
constructor(
|
|
15
|
-
holderId: string,
|
|
16
|
-
readonly: boolean,
|
|
17
|
-
editor: EditorJS,
|
|
18
|
-
borderStyle: string) {
|
|
19
|
-
const {
|
|
20
|
-
blocks,
|
|
21
|
-
toolbar,
|
|
22
|
-
} = editor;
|
|
23
|
-
this.toolbar = toolbar;
|
|
24
|
-
this.borderStyle = borderStyle || '1px dashed #aaa';
|
|
25
|
-
this.api = blocks;
|
|
26
|
-
this.holder = document.getElementById(holderId) as HTMLElement;
|
|
27
|
-
this.readOnly =readonly;
|
|
28
|
-
this.startBlock = null;
|
|
29
|
-
this.endBlock = null;
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
this.setDragListener();
|
|
33
|
-
this.setDropListener();
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
setElementCursor(element: HTMLElement|null) {
|
|
38
|
-
if (!element) return;
|
|
39
|
-
const range = document.createRange();
|
|
40
|
-
const selection = window.getSelection();
|
|
41
|
-
|
|
42
|
-
range.setStart(element.childNodes[0], 0);
|
|
43
|
-
range.collapse(true);
|
|
44
|
-
selection?.removeAllRanges();
|
|
45
|
-
selection?.addRange(range);
|
|
46
|
-
element.focus();
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
setDragListener() {
|
|
51
|
-
if (!this.readOnly) {
|
|
52
|
-
const settingsButton = this.holder?.querySelector<HTMLElement>('.ce-toolbar__settings-btn');
|
|
53
|
-
if (settingsButton) {
|
|
54
|
-
this.initializeDragListener(settingsButton);
|
|
55
|
-
} else {
|
|
56
|
-
const observer = new MutationObserver((mutations, obs) => {
|
|
57
|
-
const settingsButton = this.holder?.querySelector<HTMLElement>(
|
|
58
|
-
".ce-toolbar__settings-btn"
|
|
59
|
-
);
|
|
60
|
-
if (settingsButton) {
|
|
61
|
-
this.initializeDragListener(settingsButton);
|
|
62
|
-
obs.disconnect();
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
observer.observe(this.holder, {
|
|
67
|
-
childList: true,
|
|
68
|
-
subtree: true,
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
initializeDragListener(settingsButton: HTMLElement) {
|
|
75
|
-
settingsButton.setAttribute("draggable", "true");
|
|
76
|
-
settingsButton.addEventListener("dragstart", () => {
|
|
77
|
-
this.startBlock = this.api.getCurrentBlockIndex();
|
|
78
|
-
});
|
|
79
|
-
settingsButton.addEventListener('drag', () => {
|
|
80
|
-
this.toolbar.close();
|
|
81
|
-
if (!this.isTheOnlyBlock()) {
|
|
82
|
-
const allBlocks = this.holder.querySelectorAll('.ce-block') as NodeListOf<HTMLElement>;
|
|
83
|
-
const blockFocused = this.holder.querySelector<HTMLElement>('.ce-block--drop-target');
|
|
84
|
-
this.setElementCursor(blockFocused);
|
|
85
|
-
this.setBorderBlocks(allBlocks, blockFocused);
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
setBorderBlocks(allBlocks: NodeListOf<HTMLElement>, blockFocused: HTMLElement|null) {
|
|
93
|
-
Object.values(allBlocks).forEach((block: HTMLElement) => {
|
|
94
|
-
const blockContent = block.querySelector<HTMLElement>('.ce-block__content');
|
|
95
|
-
if (block !== blockFocused) {
|
|
96
|
-
blockContent?.style.removeProperty('border-top');
|
|
97
|
-
blockContent?.style.removeProperty('border-bottom');
|
|
98
|
-
} else {
|
|
99
|
-
const index = Object.keys(allBlocks).find((key) => allBlocks[Number(key)] === blockFocused);
|
|
100
|
-
if (index && Number(index) > this.startBlock!) blockContent!.style.borderBottom = this.borderStyle;
|
|
101
|
-
else blockContent!.style.borderTop = this.borderStyle;
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
setDropListener() {
|
|
108
|
-
document.addEventListener('drop', (event: DragEvent) => {
|
|
109
|
-
const { target } = event;
|
|
110
|
-
if (this.holder.contains(target as HTMLElement) && this.startBlock !== null) {
|
|
111
|
-
const dropTarget = this.getDropTarget(target as HTMLElement);
|
|
112
|
-
if (dropTarget) {
|
|
113
|
-
const blockContent = dropTarget.querySelector<HTMLElement>('.ce-block__content');
|
|
114
|
-
blockContent?.style.removeProperty('border-top');
|
|
115
|
-
blockContent?.style.removeProperty('border-bottom');
|
|
116
|
-
this.endBlock = this.getTargetPosition(dropTarget as HTMLElement);
|
|
117
|
-
this.moveBlocks();
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
this.startBlock = null;
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
static get isReadOnlySupported() {
|
|
126
|
-
return true;
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
getDropTarget(target: HTMLElement) {
|
|
131
|
-
return target.classList.contains('ce-block')
|
|
132
|
-
? target
|
|
133
|
-
: target.closest('.ce-block');
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
getTargetPosition(target: HTMLElement) {
|
|
138
|
-
return Array.from(target.parentNode!.children).indexOf(target);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
isTheOnlyBlock() {
|
|
142
|
-
return this.api.getBlocksCount() === 1;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
moveBlocks() {
|
|
147
|
-
if (!this.isTheOnlyBlock()) {
|
|
148
|
-
this.api.move(this.endBlock, this.startBlock);
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
# 拖拽块插件
|