@ebl-vue/editor-full 2.31.23 → 2.31.25
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 +0 -2
- package/dist/index.mjs +183 -168
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/components/Editor/EditorRender.vue +3 -3
- package/src/plugins/code/index.css +60 -4
- package/src/plugins/code/index.ts +52 -4
- package/src/plugins/outline/index.css +5 -2
- package/src/plugins/outline/index.ts +4 -11
package/package.json
CHANGED
|
@@ -50,7 +50,7 @@ interface Props {
|
|
|
50
50
|
data: OutputData,
|
|
51
51
|
locale: any,
|
|
52
52
|
showOutline?: boolean,
|
|
53
|
-
|
|
53
|
+
|
|
54
54
|
}
|
|
55
55
|
|
|
56
56
|
const props = withDefaults(defineProps<Props>(), {
|
|
@@ -59,7 +59,7 @@ const props = withDefaults(defineProps<Props>(), {
|
|
|
59
59
|
}),
|
|
60
60
|
locale: {},
|
|
61
61
|
showOutline: false,
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
});
|
|
64
64
|
let editorData=toRaw(props.data);
|
|
65
65
|
let editorIsReady = false;
|
|
@@ -202,7 +202,7 @@ onMounted(() => {
|
|
|
202
202
|
}
|
|
203
203
|
//文档大纲
|
|
204
204
|
if(props.showOutline){
|
|
205
|
-
outline = new Outline("holder",
|
|
205
|
+
outline = new Outline("holder",editor!);
|
|
206
206
|
outline.render(editorData);
|
|
207
207
|
}
|
|
208
208
|
|
|
@@ -3,13 +3,44 @@
|
|
|
3
3
|
display: flex;
|
|
4
4
|
flex-direction: column;
|
|
5
5
|
margin: 10px 0;
|
|
6
|
+
border: 2px solid transparent;
|
|
7
|
+
position: relative;
|
|
8
|
+
|
|
9
|
+
}
|
|
10
|
+
.ce-editorjs-x-shiki.editable:hover {
|
|
11
|
+
border:2px solid #C0C0C0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
.ce-editorjs-x-shiki__lang {
|
|
17
|
+
display: flex;
|
|
18
|
+
justify-content: space-between;
|
|
19
|
+
padding: 8px;
|
|
6
20
|
}
|
|
7
21
|
|
|
8
22
|
.ce-editorjs-x-shiki__code {
|
|
9
23
|
position: relative;
|
|
10
24
|
float: left;
|
|
11
25
|
min-width: 100%;
|
|
12
|
-
overflow
|
|
26
|
+
overflow: hidden;
|
|
27
|
+
height: auto;
|
|
28
|
+
}
|
|
29
|
+
.ce-editorjs-x-shiki__code__dragHandler {
|
|
30
|
+
position: absolute;
|
|
31
|
+
left:50%;
|
|
32
|
+
transform: translateX(-50%);
|
|
33
|
+
bottom: -5px;
|
|
34
|
+
cursor: ns-resize;
|
|
35
|
+
user-select:none;
|
|
36
|
+
height: 8px;
|
|
37
|
+
width: 60px;
|
|
38
|
+
background-color: #C0C0C0;
|
|
39
|
+
border-radius: 5px;
|
|
40
|
+
display: none;
|
|
41
|
+
}
|
|
42
|
+
.ce-editorjs-x-shiki:hover .ce-editorjs-x-shiki__code__dragHandler{
|
|
43
|
+
display: block;
|
|
13
44
|
}
|
|
14
45
|
|
|
15
46
|
.ce-editorjs-x-shiki__selector {
|
|
@@ -57,10 +88,9 @@
|
|
|
57
88
|
.ce-editorjs-x-shiki__textarea {
|
|
58
89
|
all:unset;
|
|
59
90
|
white-space: pre;
|
|
60
|
-
|
|
91
|
+
|
|
61
92
|
background-color: transparent;
|
|
62
|
-
position: absolute;
|
|
63
|
-
/* padding: 20px; */
|
|
93
|
+
position: absolute;
|
|
64
94
|
padding-top: 20px;
|
|
65
95
|
padding-bottom: 20px;
|
|
66
96
|
padding-right: 20px;
|
|
@@ -155,4 +185,30 @@
|
|
|
155
185
|
/* padding-left: 10px; */
|
|
156
186
|
position:absolute;
|
|
157
187
|
left: 0;
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
/* 滚动条整体部分 */
|
|
193
|
+
.ce-editorjs-x-shiki__code ::-webkit-scrollbar {
|
|
194
|
+
width: 8px; /* 滚动条的宽度 */
|
|
195
|
+
height: 8px; /* 滚动条的高度 */
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/* 滚动条轨道 */
|
|
199
|
+
.ce-editorjs-x-shiki__code ::-webkit-scrollbar-track {
|
|
200
|
+
background: #22272e; /* 轨道颜色 */
|
|
201
|
+
border-radius: 1px; /* 轨道圆角 */
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/* 滚动条滑块 */
|
|
205
|
+
.ce-editorjs-x-shiki__code ::-webkit-scrollbar-thumb {
|
|
206
|
+
background: #C0C0C0; /* 滑块颜色 */
|
|
207
|
+
border-radius: 10px; /* 滑块圆角 */
|
|
208
|
+
border: 2px solid #22272e;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/* 滑块悬停时 */
|
|
212
|
+
.ce-editorjs-x-shiki__code ::-webkit-scrollbar-thumb:hover {
|
|
213
|
+
background: #555555; /* 滑块悬停时的颜色 */
|
|
158
214
|
}
|
|
@@ -21,6 +21,7 @@ export type CodeData = BlockToolData<{
|
|
|
21
21
|
code: string;
|
|
22
22
|
lang: string;
|
|
23
23
|
theme: string;
|
|
24
|
+
resizeSize: number;
|
|
24
25
|
}>;
|
|
25
26
|
|
|
26
27
|
/**
|
|
@@ -157,6 +158,7 @@ export default class CodeTool implements BlockTool {
|
|
|
157
158
|
code: data.code ?? '',
|
|
158
159
|
lang: this._selectorLanguage,
|
|
159
160
|
theme: this._selectorTheme,
|
|
161
|
+
resizeSize: data.resizeSize || 0
|
|
160
162
|
};
|
|
161
163
|
|
|
162
164
|
this.nodes.holder = this.drawView()
|
|
@@ -179,7 +181,8 @@ export default class CodeTool implements BlockTool {
|
|
|
179
181
|
return {
|
|
180
182
|
code: codeWrapper.querySelector('textarea')!.value,
|
|
181
183
|
lang: this._selectorLanguage,
|
|
182
|
-
theme: this._selectorTheme
|
|
184
|
+
theme: this._selectorTheme,
|
|
185
|
+
resizeSize: this.data.resizeSize || 0
|
|
183
186
|
};
|
|
184
187
|
}
|
|
185
188
|
|
|
@@ -351,8 +354,14 @@ export default class CodeTool implements BlockTool {
|
|
|
351
354
|
const selectorTheme = document.createElement('select');
|
|
352
355
|
const span = document.createElement('span');
|
|
353
356
|
const textarea = document.createElement('textarea');
|
|
354
|
-
|
|
357
|
+
const dragHandle = document.createElement('div');
|
|
358
|
+
dragHandle.classList.add('ce-editorjs-x-shiki__code__dragHandler');
|
|
355
359
|
wrapper.classList.add(this.CSS.baseClass, this.CSS.wrapper);
|
|
360
|
+
if(this.readOnly){
|
|
361
|
+
wrapper.classList.add('read-only');
|
|
362
|
+
}else{
|
|
363
|
+
wrapper.classList.add('editable');
|
|
364
|
+
}
|
|
356
365
|
wrapperHolder.classList.add('ce-editorjs-x-shiki__code');
|
|
357
366
|
wrapperSelectorHolder.classList.add('ce-editorjs-x-shiki__selector');
|
|
358
367
|
wrapperLang.classList.add('ce-editorjs-x-shiki__lang');
|
|
@@ -397,7 +406,13 @@ export default class CodeTool implements BlockTool {
|
|
|
397
406
|
|
|
398
407
|
wrapperHolder.appendChild(span);
|
|
399
408
|
wrapperHolder.appendChild(textarea);
|
|
400
|
-
|
|
409
|
+
wrapper.appendChild(dragHandle);
|
|
410
|
+
|
|
411
|
+
|
|
412
|
+
if(this.data.resizeSize>0){
|
|
413
|
+
wrapperHolder.style.height = this.data.resizeSize + 'px';
|
|
414
|
+
}
|
|
415
|
+
|
|
401
416
|
if (!this.readOnly) {
|
|
402
417
|
wrapperSelectorHolder.appendChild(selectorLanguage);
|
|
403
418
|
//wrapperSelectorHolder.appendChild(selectorTheme);
|
|
@@ -466,15 +481,48 @@ export default class CodeTool implements BlockTool {
|
|
|
466
481
|
break;
|
|
467
482
|
}
|
|
468
483
|
});
|
|
484
|
+
textarea.addEventListener('scroll', () => {
|
|
485
|
+
//span.scrollTop = textarea.scrollTop
|
|
486
|
+
span.style=`display:block;transform: translateY(-${textarea.scrollTop}px)`
|
|
487
|
+
})
|
|
469
488
|
wrapperCopy.addEventListener('click', (event: MouseEvent) => {
|
|
470
489
|
this.copyCode(this.data.code, event);
|
|
471
490
|
});
|
|
472
|
-
|
|
491
|
+
//调整窗口大小
|
|
492
|
+
dragHandle.addEventListener('mousedown', (event: MouseEvent) => {
|
|
493
|
+
this.resizeClick(wrapperHolder, event);
|
|
494
|
+
});
|
|
473
495
|
this.nodes.textarea = textarea;
|
|
474
496
|
|
|
475
497
|
return wrapper;
|
|
476
498
|
}
|
|
499
|
+
private resizeClick(codeElement: HTMLElement, event: MouseEvent) {
|
|
500
|
+
|
|
501
|
+
let startY = event.clientY;
|
|
502
|
+
let startHeight = parseInt(window.getComputedStyle(codeElement).height, 10);
|
|
503
|
+
const mouseMoveHandler = (e: MouseEvent) => {
|
|
504
|
+
const dY = e.clientY - startY;
|
|
505
|
+
let newHeight = startHeight + dY;
|
|
506
|
+
|
|
477
507
|
|
|
508
|
+
if (newHeight < 100) {
|
|
509
|
+
newHeight = 100;
|
|
510
|
+
}
|
|
511
|
+
codeElement.style.height = newHeight + 'px';
|
|
512
|
+
};
|
|
513
|
+
const mouseUpHandler = () => {
|
|
514
|
+
const blockHeight = parseInt(
|
|
515
|
+
window.getComputedStyle(codeElement).height,
|
|
516
|
+
10,
|
|
517
|
+
);
|
|
518
|
+
this.data.resizeSize = blockHeight;
|
|
519
|
+
document.removeEventListener('mousemove', mouseMoveHandler);
|
|
520
|
+
document.removeEventListener('mouseup', mouseUpHandler);
|
|
521
|
+
};
|
|
522
|
+
|
|
523
|
+
document.addEventListener('mousemove', mouseMoveHandler);
|
|
524
|
+
document.addEventListener('mouseup', mouseUpHandler);
|
|
525
|
+
}
|
|
478
526
|
private async runShiki(): Promise<{ html: string, preStyle: string }> {
|
|
479
527
|
let preStyle = ''
|
|
480
528
|
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
.ebl-outline{
|
|
2
|
+
background-color: #fff;
|
|
3
|
+
box-sizing: border-box;
|
|
2
4
|
position:fixed;
|
|
3
|
-
top:
|
|
5
|
+
top:var(--header-height,84px);
|
|
6
|
+
|
|
4
7
|
right:0;
|
|
5
8
|
padding: 15px 12px;
|
|
6
9
|
width:280px;
|
|
@@ -10,7 +13,7 @@
|
|
|
10
13
|
color: #606266;
|
|
11
14
|
font-size: 14px;
|
|
12
15
|
padding-bottom: 50px;
|
|
13
|
-
height: calc(100vh - var(--header-height));
|
|
16
|
+
max-height: calc(100vh - var(--header-height,84px));
|
|
14
17
|
}
|
|
15
18
|
.ebl-outline:hover{
|
|
16
19
|
overflow: auto;
|
|
@@ -8,15 +8,15 @@ import { OutputData } from '@ebl-vue/editorjs';
|
|
|
8
8
|
export default class Outline{
|
|
9
9
|
private editor: EditorJS;
|
|
10
10
|
private holder: HTMLElement;
|
|
11
|
-
|
|
11
|
+
|
|
12
12
|
/**
|
|
13
13
|
* 初始化插件
|
|
14
14
|
* @param {EditorJS} editor - 编辑器实例
|
|
15
15
|
*/
|
|
16
|
-
constructor(holderId: string,
|
|
16
|
+
constructor(holderId: string,editor: EditorJS) {
|
|
17
17
|
this.editor = editor;
|
|
18
18
|
this.holder = document.getElementById(holderId) as HTMLElement;
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
public render(data: OutputData) {
|
|
@@ -26,7 +26,6 @@ export default class Outline{
|
|
|
26
26
|
this.holder.classList.add("outline");
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
|
|
30
29
|
private createUI(data: OutputData): HTMLElement {
|
|
31
30
|
|
|
32
31
|
const ui = document.createElement('div');
|
|
@@ -51,13 +50,7 @@ export default class Outline{
|
|
|
51
50
|
const block = document.querySelector<HTMLElement>('.codex-editor .ce-block[data-id="' + blockData.id + '"]');
|
|
52
51
|
if (block) {
|
|
53
52
|
const top = block.offsetTop;
|
|
54
|
-
|
|
55
|
-
if (!this.scrollWrap) {
|
|
56
|
-
document.querySelector<HTMLElement>('.codex-editor')?.scrollTo(0, top);
|
|
57
|
-
} else {
|
|
58
|
-
window.scrollTo(0,top)
|
|
59
|
-
//this.scrollWrap.scrollTo(0, top);
|
|
60
|
-
}
|
|
53
|
+
window.scrollTo(0, top);
|
|
61
54
|
}
|
|
62
55
|
|
|
63
56
|
});
|