dragon-editor 3.6.1 → 3.7.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 -2
- package/dist/module.json +3 -3
- package/dist/module.mjs +4 -12
- package/dist/runtime/components/DragonEditor.vue +173 -206
- package/dist/runtime/components/DragonEditor.vue.d.ts +31 -0
- package/dist/runtime/components/DragonEditorViewer.vue +16 -24
- package/dist/runtime/components/DragonEditorViewer.vue.d.ts +8 -0
- package/dist/runtime/{type.d.ts → type.d.mts} +1 -0
- package/dist/runtime/utils/event/block.d.ts +1 -1
- package/dist/runtime/utils/event/cursor.d.ts +1 -1
- package/dist/runtime/utils/event/data.d.ts +2 -1
- package/dist/runtime/utils/event/data.js +31 -0
- package/dist/runtime/utils/event/keyboard.d.ts +1 -1
- package/dist/runtime/utils/event/mouse.d.ts +1 -1
- package/dist/runtime/utils/event/scroll.d.ts +1 -1
- package/dist/runtime/utils/event/touch.d.ts +1 -1
- package/dist/runtime/utils/event/window.d.ts +1 -1
- package/dist/runtime/utils/event/window.js +1 -0
- package/dist/runtime/utils/layout/block.d.ts +1 -1
- package/dist/runtime/utils/layout/block.js +16 -4
- package/dist/runtime/utils/layout/body.d.ts +4 -0
- package/dist/runtime/utils/layout/controlbar.d.ts +1 -1
- package/dist/runtime/utils/layout/icon.d.ts +1 -1
- package/dist/runtime/utils/layout/menuBar.d.ts +1 -1
- package/dist/runtime/utils/node/block.d.ts +1 -1
- package/dist/runtime/utils/style/anchor.d.ts +1 -1
- package/dist/runtime/utils/style/decoration.d.ts +1 -1
- package/dist/types.d.mts +2 -2
- package/package.json +21 -21
- package/dist/module.cjs +0 -5
- package/dist/module.d.ts +0 -5
- package/dist/types.d.ts +0 -7
package/README.md
CHANGED
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
|
|
28
28
|
I just made the DragonEditor because I needed the WYSIWYG Editor to write on my [blog](https://dico.me).
|
|
29
29
|
|
|
30
|
-
This module support only
|
|
30
|
+
This module support only Nuxt.
|
|
31
31
|
|
|
32
32
|
# Font
|
|
33
33
|
|
|
@@ -83,4 +83,4 @@ Done!
|
|
|
83
83
|
</script>
|
|
84
84
|
```
|
|
85
85
|
|
|
86
|
-
More information is here
|
|
86
|
+
More information is [here](https://lovefields.github.io/dragonEditor-doc/)
|
package/dist/module.json
CHANGED
package/dist/module.mjs
CHANGED
|
@@ -1,14 +1,5 @@
|
|
|
1
1
|
import { defineNuxtModule, createResolver, addComponent, addTypeTemplate } from '@nuxt/kit';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
// -- Unbuild CommonJS Shims --
|
|
6
|
-
import __cjs_url__ from 'url';
|
|
7
|
-
import __cjs_path__ from 'path';
|
|
8
|
-
import __cjs_mod__ from 'module';
|
|
9
|
-
const __filename = __cjs_url__.fileURLToPath(import.meta.url);
|
|
10
|
-
const __dirname = __cjs_path__.dirname(__filename);
|
|
11
|
-
const require = __cjs_mod__.createRequire(import.meta.url);
|
|
12
3
|
const module = defineNuxtModule({
|
|
13
4
|
meta: {
|
|
14
5
|
name: "dragon-editor",
|
|
@@ -18,7 +9,7 @@ const module = defineNuxtModule({
|
|
|
18
9
|
},
|
|
19
10
|
async setup(options, nuxt) {
|
|
20
11
|
const resolver = createResolver(import.meta.url);
|
|
21
|
-
const typeContent = await readFile(`${__dirname}/runtime/type.d.
|
|
12
|
+
const typeContent = await readFile(`${__dirname}/runtime/type.d.mts`);
|
|
22
13
|
addComponent({
|
|
23
14
|
name: "DragonEditor",
|
|
24
15
|
filePath: resolver.resolve(__dirname, "./runtime/components/DragonEditor")
|
|
@@ -45,9 +36,10 @@ async function readFile(path) {
|
|
|
45
36
|
if (typeof Bun !== "undefined" && Bun.file) {
|
|
46
37
|
const file = Bun.file(path);
|
|
47
38
|
return await file.text();
|
|
39
|
+
} else {
|
|
40
|
+
const { promises: fs } = await import('fs');
|
|
41
|
+
return await fs.readFile(path, "utf-8");
|
|
48
42
|
}
|
|
49
|
-
const { promises: fs } = await import('fs');
|
|
50
|
-
return await fs.readFile(path, "utf-8");
|
|
51
43
|
}
|
|
52
44
|
|
|
53
45
|
export { module as default };
|
|
@@ -2,231 +2,198 @@
|
|
|
2
2
|
<component :is="mainStrucutre"></component>
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
|
-
<script setup
|
|
5
|
+
<script setup>
|
|
6
6
|
import { ref, h, onMounted, onBeforeUnmount, watch } from "vue";
|
|
7
7
|
import { _getBodyVNodeStructure, _getMenuBarVNodeStructure, _getControlbarVNodeStructure, _updateBodyStructure } from "../utils/layout";
|
|
8
|
-
import { _eidtorMountEvent, _eidtorUnmountEvent, _editorMousemoveEvent, _editorMouseupEvent, _editorMouseleaveEvent, _editorTouchmoveEvent, _editorTouchendEvent, _checkOthersideClick, _parentWrapScollEvent, _editorContextMenuEvent, _windowResizeEvent } from "../utils/event";
|
|
8
|
+
import { _eidtorMountEvent, _eidtorUnmountEvent, _editorMousemoveEvent, _editorMouseupEvent, _editorMouseleaveEvent, _editorTouchmoveEvent, _editorTouchendEvent, _checkOthersideClick, _parentWrapScollEvent, _editorContextMenuEvent, _windowResizeEvent, _checkDataEmpty } from "../utils/event";
|
|
9
9
|
import { _addBlock } from "../utils/node";
|
|
10
10
|
import { _setDecoration, _setTextAlign } from "../utils/style";
|
|
11
|
-
import type { VNode } from "vue";
|
|
12
11
|
import { codeToHtml } from "shiki";
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
imageHostURL?: string;
|
|
19
|
-
screenChangePoint?: number;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const props = withDefaults(defineProps<DEOption>(), {
|
|
23
|
-
useMenuBar: true,
|
|
24
|
-
imageHostURL: "",
|
|
25
|
-
screenChangePoint: 1200,
|
|
12
|
+
const props = defineProps({
|
|
13
|
+
modelValue: { type: null, required: true },
|
|
14
|
+
useMenuBar: { type: Boolean, required: false, default: true },
|
|
15
|
+
imageHostURL: { type: String, required: false, default: "" },
|
|
16
|
+
screenChangePoint: { type: Number, required: false, default: 1200 }
|
|
26
17
|
});
|
|
27
|
-
const emit = defineEmits
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
18
|
+
const emit = defineEmits(["update:modelValue", "uploadImageEvent"]);
|
|
19
|
+
const editorStore = ref({
|
|
20
|
+
cursorData: null,
|
|
21
|
+
message: {
|
|
22
|
+
linkTextNoStyle: "Link text can't set any style."
|
|
23
|
+
},
|
|
24
|
+
controlBar: {
|
|
25
|
+
active: false,
|
|
26
|
+
x: 0,
|
|
27
|
+
y: 0,
|
|
28
|
+
$element: null
|
|
29
|
+
},
|
|
30
|
+
useMenuBar: props.useMenuBar,
|
|
31
|
+
imageHostURL: props.imageHostURL,
|
|
32
|
+
firstData: props.modelValue,
|
|
33
|
+
screenChangePoint: props.screenChangePoint,
|
|
34
|
+
menuBarTop: 0,
|
|
35
|
+
activeStatus: {
|
|
36
|
+
addBlockMenu: false,
|
|
37
|
+
anchorInputArea: false,
|
|
38
|
+
imageResizeEvent: false
|
|
39
|
+
},
|
|
40
|
+
eventStatus: {
|
|
41
|
+
imageResizeEventStartX: 0,
|
|
42
|
+
imageResizeEventType: "left",
|
|
43
|
+
imageResizeEventEndX: 0,
|
|
44
|
+
imageResizeCurrentWidth: 0
|
|
45
|
+
},
|
|
46
|
+
controlStatus: {
|
|
47
|
+
isMobile: false,
|
|
48
|
+
currentBlockType: "text",
|
|
49
|
+
codeBlockTheme: "github-light",
|
|
50
|
+
codeBlockLang: "text",
|
|
51
|
+
listBlockStyle: "disc",
|
|
52
|
+
anchorTabType: "url",
|
|
53
|
+
anchorHeadingList: [],
|
|
54
|
+
anchorHref: "",
|
|
55
|
+
anchorValidation: false,
|
|
56
|
+
previousCorsorData: null,
|
|
57
|
+
$anchorInput: null,
|
|
58
|
+
$currentBlock: null
|
|
59
|
+
},
|
|
60
|
+
codeBlockTheme: [
|
|
61
|
+
{
|
|
62
|
+
text: "GitHub Ligth",
|
|
63
|
+
code: "github-light"
|
|
51
64
|
},
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
codeBlockTheme: "github-light",
|
|
62
|
-
codeBlockLang: "text",
|
|
63
|
-
listBlockStyle: "disc",
|
|
64
|
-
anchorTabType: "url",
|
|
65
|
-
anchorHeadingList: [],
|
|
66
|
-
anchorHref: "",
|
|
67
|
-
anchorValidation: false,
|
|
68
|
-
previousCorsorData: null,
|
|
69
|
-
$anchorInput: null,
|
|
70
|
-
$currentBlock: null,
|
|
65
|
+
{
|
|
66
|
+
text: "GitHub Dark Dimmed",
|
|
67
|
+
code: "github-dark-dimmed"
|
|
68
|
+
}
|
|
69
|
+
],
|
|
70
|
+
listUlType: [
|
|
71
|
+
{
|
|
72
|
+
text: "Disc",
|
|
73
|
+
code: "disc"
|
|
71
74
|
},
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
],
|
|
82
|
-
listUlType: [
|
|
83
|
-
{
|
|
84
|
-
text: "Disc",
|
|
85
|
-
code: "disc",
|
|
86
|
-
},
|
|
87
|
-
{
|
|
88
|
-
text: "Square",
|
|
89
|
-
code: "square",
|
|
90
|
-
},
|
|
91
|
-
],
|
|
92
|
-
listOlType: [
|
|
93
|
-
{
|
|
94
|
-
text: "Decimal",
|
|
95
|
-
code: "decimal",
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
text: "Lower-Alpha",
|
|
99
|
-
code: "lower-alpha",
|
|
100
|
-
},
|
|
101
|
-
{
|
|
102
|
-
text: "Upper-Alpha",
|
|
103
|
-
code: "upper-alpha",
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
text: "Lower-Roman",
|
|
107
|
-
code: "lower-roman",
|
|
108
|
-
},
|
|
109
|
-
{
|
|
110
|
-
text: "Upper-Roman",
|
|
111
|
-
code: "upper-roman",
|
|
112
|
-
},
|
|
113
|
-
],
|
|
114
|
-
$editor: null,
|
|
115
|
-
$body: null,
|
|
116
|
-
$controlBar: null,
|
|
117
|
-
$parentWrap: null,
|
|
118
|
-
codeToHtml: codeToHtml,
|
|
119
|
-
emit: emit,
|
|
120
|
-
windowClickEvent: function (event: MouseEvent) {
|
|
121
|
-
_checkOthersideClick(event, editorStore);
|
|
75
|
+
{
|
|
76
|
+
text: "Square",
|
|
77
|
+
code: "square"
|
|
78
|
+
}
|
|
79
|
+
],
|
|
80
|
+
listOlType: [
|
|
81
|
+
{
|
|
82
|
+
text: "Decimal",
|
|
83
|
+
code: "decimal"
|
|
122
84
|
},
|
|
123
|
-
|
|
124
|
-
|
|
85
|
+
{
|
|
86
|
+
text: "Lower-Alpha",
|
|
87
|
+
code: "lower-alpha"
|
|
125
88
|
},
|
|
126
|
-
|
|
127
|
-
|
|
89
|
+
{
|
|
90
|
+
text: "Upper-Alpha",
|
|
91
|
+
code: "upper-alpha"
|
|
128
92
|
},
|
|
129
|
-
|
|
130
|
-
|
|
93
|
+
{
|
|
94
|
+
text: "Lower-Roman",
|
|
95
|
+
code: "lower-roman"
|
|
131
96
|
},
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const childList: VNode[] = [];
|
|
136
|
-
|
|
137
|
-
if (editorStore.value.useMenuBar === true) {
|
|
138
|
-
childList.push(_getMenuBarVNodeStructure(editorStore));
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
childList.push(_getBodyVNodeStructure(editorStore));
|
|
142
|
-
|
|
143
|
-
if (editorStore.value.controlBar.active === true) {
|
|
144
|
-
childList.push(_getControlbarVNodeStructure(editorStore));
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return h(
|
|
148
|
-
"div",
|
|
149
|
-
{
|
|
150
|
-
class: ["dragon-editor", "js-dragon-editor", { "--has-menu": editorStore.value.useMenuBar === true }, { "--mobile": editorStore.value.controlStatus.isMobile === true }],
|
|
151
|
-
onMousemove: (event: MouseEvent) => _editorMousemoveEvent(event, editorStore),
|
|
152
|
-
onMouseup: (event: MouseEvent) => _editorMouseupEvent(event, editorStore),
|
|
153
|
-
onMouseleave: (event: MouseEvent) => _editorMouseleaveEvent(event, editorStore),
|
|
154
|
-
onTouchmove: (event: TouchEvent) => _editorTouchmoveEvent(event, editorStore),
|
|
155
|
-
onTouchend: (event: TouchEvent) => _editorTouchendEvent(event, editorStore),
|
|
156
|
-
onContextmenu: (event: MouseEvent) => _editorContextMenuEvent(event, editorStore),
|
|
157
|
-
},
|
|
158
|
-
childList
|
|
159
|
-
);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
// 외부용 블럭 추가 함수
|
|
163
|
-
function addBlock(data: DEBlockData): void {
|
|
164
|
-
let type: DEBlockMenutype = "text";
|
|
165
|
-
|
|
166
|
-
switch (data.type) {
|
|
167
|
-
case "heading":
|
|
168
|
-
if (data.level === 1) {
|
|
169
|
-
type = "heading1";
|
|
170
|
-
} else if (data.level === 2) {
|
|
171
|
-
type = "heading2";
|
|
172
|
-
} else {
|
|
173
|
-
type = "heading3";
|
|
174
|
-
}
|
|
175
|
-
break;
|
|
176
|
-
|
|
177
|
-
case "list":
|
|
178
|
-
if (data.element === "ol") {
|
|
179
|
-
type = "ol";
|
|
180
|
-
} else {
|
|
181
|
-
type = "ul";
|
|
182
|
-
}
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
_addBlock(type, editorStore, data);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// 외부용 스타일 적용 함수
|
|
190
|
-
function setDecoration(style: DEDecoration): void {
|
|
191
|
-
_setDecoration(`de-${style}`, editorStore);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
// 외부용 정렬 함수
|
|
195
|
-
function setAlign(align: DETextalign): void {
|
|
196
|
-
_setTextAlign(align, editorStore);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
// 데이터 변경용 함수
|
|
200
|
-
function changeEditorData(data: DEContentData): void {
|
|
201
|
-
if (editorStore.value.$body !== null) {
|
|
202
|
-
editorStore.value.$body.innerHTML = "";
|
|
203
|
-
_updateBodyStructure(data, editorStore);
|
|
97
|
+
{
|
|
98
|
+
text: "Upper-Roman",
|
|
99
|
+
code: "upper-roman"
|
|
204
100
|
}
|
|
101
|
+
],
|
|
102
|
+
$editor: null,
|
|
103
|
+
$body: null,
|
|
104
|
+
$controlBar: null,
|
|
105
|
+
$parentWrap: null,
|
|
106
|
+
codeToHtml,
|
|
107
|
+
emit,
|
|
108
|
+
windowClickEvent: function(event) {
|
|
109
|
+
_checkOthersideClick(event, editorStore);
|
|
110
|
+
},
|
|
111
|
+
windowResizeEvent: function(event) {
|
|
112
|
+
_windowResizeEvent(event, editorStore);
|
|
113
|
+
},
|
|
114
|
+
windowMouseUpEvent: function(event) {
|
|
115
|
+
_editorMouseupEvent(event, editorStore);
|
|
116
|
+
},
|
|
117
|
+
parentWrapScollEvent: function(event) {
|
|
118
|
+
_parentWrapScollEvent(event, editorStore);
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
function mainStrucutre() {
|
|
122
|
+
const childList = [];
|
|
123
|
+
if (editorStore.value.useMenuBar === true) {
|
|
124
|
+
childList.push(_getMenuBarVNodeStructure(editorStore));
|
|
125
|
+
}
|
|
126
|
+
childList.push(_getBodyVNodeStructure(editorStore));
|
|
127
|
+
if (editorStore.value.controlBar.active === true) {
|
|
128
|
+
childList.push(_getControlbarVNodeStructure(editorStore));
|
|
129
|
+
}
|
|
130
|
+
return h(
|
|
131
|
+
"div",
|
|
132
|
+
{
|
|
133
|
+
class: ["dragon-editor", "js-dragon-editor", { "--has-menu": editorStore.value.useMenuBar === true }, { "--mobile": editorStore.value.controlStatus.isMobile === true }],
|
|
134
|
+
onMousemove: (event) => _editorMousemoveEvent(event, editorStore),
|
|
135
|
+
onMouseup: (event) => _editorMouseupEvent(event, editorStore),
|
|
136
|
+
onMouseleave: (event) => _editorMouseleaveEvent(event, editorStore),
|
|
137
|
+
onTouchmove: (event) => _editorTouchmoveEvent(event, editorStore),
|
|
138
|
+
onTouchend: (event) => _editorTouchendEvent(event, editorStore),
|
|
139
|
+
onContextmenu: (event) => _editorContextMenuEvent(event, editorStore)
|
|
140
|
+
},
|
|
141
|
+
childList
|
|
142
|
+
);
|
|
143
|
+
}
|
|
144
|
+
function addBlock(data) {
|
|
145
|
+
let type = "text";
|
|
146
|
+
switch (data.type) {
|
|
147
|
+
case "heading":
|
|
148
|
+
if (data.level === 1) {
|
|
149
|
+
type = "heading1";
|
|
150
|
+
} else if (data.level === 2) {
|
|
151
|
+
type = "heading2";
|
|
152
|
+
} else {
|
|
153
|
+
type = "heading3";
|
|
154
|
+
}
|
|
155
|
+
break;
|
|
156
|
+
case "list":
|
|
157
|
+
if (data.element === "ol") {
|
|
158
|
+
type = "ol";
|
|
159
|
+
} else {
|
|
160
|
+
type = "ul";
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
_addBlock(type, editorStore, data);
|
|
165
|
+
}
|
|
166
|
+
function setDecoration(style) {
|
|
167
|
+
_setDecoration(`de-${style}`, editorStore);
|
|
168
|
+
}
|
|
169
|
+
function setAlign(align) {
|
|
170
|
+
_setTextAlign(align, editorStore);
|
|
171
|
+
}
|
|
172
|
+
function changeEditorData(data) {
|
|
173
|
+
if (editorStore.value.$body !== null) {
|
|
174
|
+
editorStore.value.$body.innerHTML = "";
|
|
175
|
+
_updateBodyStructure(data, editorStore);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
function updateLayout() {
|
|
179
|
+
_eidtorUnmountEvent(editorStore);
|
|
180
|
+
setTimeout(() => {
|
|
181
|
+
_eidtorMountEvent(editorStore);
|
|
182
|
+
}, 500);
|
|
205
183
|
}
|
|
206
|
-
|
|
207
|
-
// 레이아웃 변경시 리마운트
|
|
208
|
-
function updateLayout(): void {
|
|
209
|
-
_eidtorUnmountEvent(editorStore);
|
|
210
|
-
|
|
211
|
-
setTimeout(() => {
|
|
212
|
-
_eidtorMountEvent(editorStore);
|
|
213
|
-
}, 250);
|
|
214
|
-
}
|
|
215
|
-
|
|
216
184
|
onMounted(() => {
|
|
217
|
-
|
|
185
|
+
_eidtorMountEvent(editorStore);
|
|
218
186
|
});
|
|
219
|
-
|
|
220
187
|
onBeforeUnmount(() => {
|
|
221
|
-
|
|
188
|
+
_eidtorUnmountEvent(editorStore);
|
|
222
189
|
});
|
|
223
|
-
|
|
224
190
|
defineExpose({
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
191
|
+
addBlock,
|
|
192
|
+
setDecoration,
|
|
193
|
+
setAlign,
|
|
194
|
+
changeEditorData,
|
|
195
|
+
updateLayout,
|
|
196
|
+
checkDataEmpty: () => _checkDataEmpty(props.modelValue)
|
|
230
197
|
});
|
|
231
198
|
</script>
|
|
232
199
|
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { DEBlockData, DEContentData, DEDecoration, DETextalign } from "../type.d.ts.js";
|
|
2
|
+
interface DEOption {
|
|
3
|
+
modelValue: DEContentData;
|
|
4
|
+
useMenuBar?: boolean;
|
|
5
|
+
imageHostURL?: string;
|
|
6
|
+
screenChangePoint?: number;
|
|
7
|
+
}
|
|
8
|
+
declare function addBlock(data: DEBlockData): void;
|
|
9
|
+
declare function setDecoration(style: DEDecoration): void;
|
|
10
|
+
declare function setAlign(align: DETextalign): void;
|
|
11
|
+
declare function changeEditorData(data: DEContentData): void;
|
|
12
|
+
declare function updateLayout(): void;
|
|
13
|
+
declare const _default: import("vue").DefineComponent<DEOption, {
|
|
14
|
+
addBlock: typeof addBlock;
|
|
15
|
+
setDecoration: typeof setDecoration;
|
|
16
|
+
setAlign: typeof setAlign;
|
|
17
|
+
changeEditorData: typeof changeEditorData;
|
|
18
|
+
updateLayout: typeof updateLayout;
|
|
19
|
+
checkDataEmpty: () => boolean;
|
|
20
|
+
}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {} & {
|
|
21
|
+
"update:modelValue": (data: DEContentData) => any;
|
|
22
|
+
uploadImageEvent: (file: File) => any;
|
|
23
|
+
}, string, import("vue").PublicProps, Readonly<DEOption> & Readonly<{
|
|
24
|
+
"onUpdate:modelValue"?: ((data: DEContentData) => any) | undefined;
|
|
25
|
+
onUploadImageEvent?: ((file: File) => any) | undefined;
|
|
26
|
+
}>, {
|
|
27
|
+
imageHostURL: string;
|
|
28
|
+
useMenuBar: boolean;
|
|
29
|
+
screenChangePoint: number;
|
|
30
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
31
|
+
export default _default;
|
|
@@ -2,33 +2,25 @@
|
|
|
2
2
|
<component :is="structure()"></component>
|
|
3
3
|
</template>
|
|
4
4
|
|
|
5
|
-
<script setup
|
|
5
|
+
<script setup>
|
|
6
6
|
import { h } from "vue";
|
|
7
|
-
import type { VNode } from "vue";
|
|
8
7
|
import { _createBlockList } from "../utils/layout";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
8
|
+
const props = defineProps({
|
|
9
|
+
content: { type: null, required: true },
|
|
10
|
+
imageHostURL: { type: String, required: false, default: "" }
|
|
11
|
+
});
|
|
12
|
+
function structure() {
|
|
13
|
+
return h(
|
|
14
|
+
"div",
|
|
15
15
|
{
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
class: ["dragon-editor-viewer"],
|
|
25
|
-
},
|
|
26
|
-
_createBlockList({
|
|
27
|
-
blockList: props.content,
|
|
28
|
-
isEditable: false,
|
|
29
|
-
imageHostURL: props.imageHostURL,
|
|
30
|
-
})
|
|
31
|
-
);
|
|
16
|
+
class: ["dragon-editor-viewer"]
|
|
17
|
+
},
|
|
18
|
+
_createBlockList({
|
|
19
|
+
blockList: props.content,
|
|
20
|
+
isEditable: false,
|
|
21
|
+
imageHostURL: props.imageHostURL
|
|
22
|
+
})
|
|
23
|
+
);
|
|
32
24
|
}
|
|
33
25
|
</script>
|
|
34
26
|
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
type __VLS_Props = {
|
|
2
|
+
content: DEContentData;
|
|
3
|
+
imageHostURL?: string;
|
|
4
|
+
};
|
|
5
|
+
declare const _default: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {
|
|
6
|
+
imageHostURL: string;
|
|
7
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
8
|
+
export default _default;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Ref } from "vue";
|
|
2
|
-
import type { DragonEditorStore } from "../../type.js";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.d.mts.js";
|
|
3
3
|
export declare function _imageResizeEventStart(event: Event, store: Ref<DragonEditorStore>): void;
|
|
4
4
|
export declare function _imageResizeEvent(event: Event, store: Ref<DragonEditorStore>): void;
|
|
5
5
|
export declare function _imageResizeEventEnd(event: Event, store: Ref<DragonEditorStore>): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Ref } from "vue";
|
|
2
|
-
import type { DEArrangeCursorData, DEditorCursor, DragonEditorStore } from "../../type.js";
|
|
2
|
+
import type { DEArrangeCursorData, DEditorCursor, DragonEditorStore } from "../../type.d.mts.js";
|
|
3
3
|
export declare function _updateCursorData(store: Ref<DragonEditorStore>): void;
|
|
4
4
|
export declare function _setCursor($target: Node, startIdx: number): void;
|
|
5
5
|
export declare function _setRangeCursor($startTarget: Element, $endTarget: Element, startIdx: number, endIdx: number): void;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import type { Ref } from "vue";
|
|
2
|
-
import type { DECodeItem, DECodeblockLang, DragonEditorStore, DEBlockData, DEBlockMenutype } from "../../type.js";
|
|
2
|
+
import type { DECodeItem, DECodeblockLang, DragonEditorStore, DEBlockData, DEBlockMenutype, DEContentData } from "../../type.d.mts.js";
|
|
3
3
|
export declare const CODEBLOCKLANG: DECodeItem<DECodeblockLang>[];
|
|
4
4
|
export declare function _updateModelData(store: Ref<DragonEditorStore>): void;
|
|
5
5
|
export declare function _getDefaultBlockData(type: DEBlockMenutype): DEBlockData;
|
|
6
6
|
export declare function _generateId(): string;
|
|
7
7
|
export declare function _updateControlBarStatus(store: Ref<DragonEditorStore>): void;
|
|
8
|
+
export declare function _checkDataEmpty(data: DEContentData): boolean;
|
|
@@ -346,3 +346,34 @@ function __updateListBlockStyle(store) {
|
|
|
346
346
|
store.value.controlStatus.listBlockStyle = $block.dataset["style"] ?? "disc";
|
|
347
347
|
}
|
|
348
348
|
}
|
|
349
|
+
export function _checkDataEmpty(data) {
|
|
350
|
+
let suitable = true;
|
|
351
|
+
data.forEach((item) => {
|
|
352
|
+
switch (item.type) {
|
|
353
|
+
case "heading":
|
|
354
|
+
case "text":
|
|
355
|
+
if (item.textContent !== "") {
|
|
356
|
+
suitable = false;
|
|
357
|
+
}
|
|
358
|
+
break;
|
|
359
|
+
case "list":
|
|
360
|
+
item.child.forEach((listChild) => {
|
|
361
|
+
if (listChild.textContent !== "") {
|
|
362
|
+
suitable = false;
|
|
363
|
+
}
|
|
364
|
+
});
|
|
365
|
+
break;
|
|
366
|
+
case "code":
|
|
367
|
+
if (item.filename !== "" || item.textContent !== "") {
|
|
368
|
+
suitable = false;
|
|
369
|
+
}
|
|
370
|
+
break;
|
|
371
|
+
case "image":
|
|
372
|
+
case "divider":
|
|
373
|
+
case "custom":
|
|
374
|
+
suitable = false;
|
|
375
|
+
break;
|
|
376
|
+
}
|
|
377
|
+
});
|
|
378
|
+
return suitable;
|
|
379
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Ref } from "vue";
|
|
2
|
-
import type { DragonEditorStore } from "../../type.js";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.d.mts.js";
|
|
3
3
|
export declare function _contentKeydownEvent(event: KeyboardEvent, store: Ref<DragonEditorStore>): void;
|
|
4
4
|
export declare function _contentPasteEvent(event: ClipboardEvent, store: Ref<DragonEditorStore>): Promise<void>;
|
|
5
5
|
export declare function _setIndent(store: Ref<DragonEditorStore>, type: "plus" | "minus"): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Ref } from "vue";
|
|
2
|
-
import type { DragonEditorStore } from "../../type.js";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.d.mts.js";
|
|
3
3
|
export declare function _contentMouseupEvent(event: MouseEvent, store: Ref<DragonEditorStore>): void;
|
|
4
4
|
export declare function _contentMousedownEvnet(event: MouseEvent, store: Ref<DragonEditorStore>): void;
|
|
5
5
|
export declare function _editorMousemoveEvent(event: MouseEvent, store: Ref<DragonEditorStore>): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Ref } from "vue";
|
|
2
|
-
import type { DragonEditorStore } from "../../type.js";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.d.mts.js";
|
|
3
3
|
export declare function _contentTouchstartEvent(event: TouchEvent, store: Ref<DragonEditorStore>): void;
|
|
4
4
|
export declare function _editorTouchmoveEvent(event: TouchEvent, store: Ref<DragonEditorStore>): void;
|
|
5
5
|
export declare function _editorTouchendEvent(event: TouchEvent, store: Ref<DragonEditorStore>): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Ref } from "vue";
|
|
2
|
-
import type { DragonEditorStore } from "../../type.js";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.d.mts.js";
|
|
3
3
|
export declare function _eidtorMountEvent(store: Ref<DragonEditorStore>): void;
|
|
4
4
|
export declare function _eidtorUnmountEvent(store: Ref<DragonEditorStore>): void;
|
|
5
5
|
export declare function _windowResizeEvent(event: Event, store: Ref<DragonEditorStore>): void;
|
|
@@ -19,6 +19,7 @@ export function _eidtorUnmountEvent(store) {
|
|
|
19
19
|
window.removeEventListener("resize", store.value.windowResizeEvent);
|
|
20
20
|
window.removeEventListener("mouseup", store.value.windowMouseUpEvent);
|
|
21
21
|
store.value.$parentWrap?.removeEventListener("scroll", store.value.parentWrapScollEvent);
|
|
22
|
+
store.value.menuBarTop = 0;
|
|
22
23
|
}
|
|
23
24
|
export function _windowResizeEvent(event, store) {
|
|
24
25
|
__checkAndSetUpMobile(store);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { VNode } from "vue";
|
|
2
|
-
import type { DEContentData } from "../../type.js";
|
|
2
|
+
import type { DEContentData } from "../../type.d.mts.js";
|
|
3
3
|
export declare function _createBlockList({ blockList, isEditable, imageHostURL }?: {
|
|
4
4
|
blockList: DEContentData;
|
|
5
5
|
isEditable: boolean;
|
|
@@ -34,6 +34,9 @@ export function _createBlockList({ blockList, isEditable, imageHostURL } = { blo
|
|
|
34
34
|
}
|
|
35
35
|
function __createTextBlock(data, isEditable) {
|
|
36
36
|
const option = { class: ["de-block", "de-text-block", ...data.classList], innerHTML: data.textContent };
|
|
37
|
+
if (data.depth !== void 0) {
|
|
38
|
+
option["data-depth"] = data.depth;
|
|
39
|
+
}
|
|
37
40
|
if (isEditable === true) {
|
|
38
41
|
option.contenteditable = true;
|
|
39
42
|
}
|
|
@@ -41,6 +44,9 @@ function __createTextBlock(data, isEditable) {
|
|
|
41
44
|
}
|
|
42
45
|
function __createHeadingBlock(data, isEditable) {
|
|
43
46
|
const option = { class: ["de-block", "de-heading-block", ...data.classList], "data-level": data.level, innerHTML: data.textContent };
|
|
47
|
+
if (data.depth !== void 0) {
|
|
48
|
+
option["data-depth"] = data.depth;
|
|
49
|
+
}
|
|
44
50
|
if (isEditable === true) {
|
|
45
51
|
option.contenteditable = true;
|
|
46
52
|
}
|
|
@@ -60,6 +66,8 @@ function __createImageBlock(data, isEditable, imageHostURL) {
|
|
|
60
66
|
})
|
|
61
67
|
);
|
|
62
68
|
if (isEditable === true) {
|
|
69
|
+
areaChild.push(h("button", { class: ["de-btn", "de-btn-left"] }));
|
|
70
|
+
areaChild.push(h("button", { class: ["de-btn", "de-btn-right"] }));
|
|
63
71
|
}
|
|
64
72
|
imageChild.push(h("div", { class: ["de-image-area"], "data-maxwidth": data.maxWidth }, areaChild));
|
|
65
73
|
if (data.caption !== "") {
|
|
@@ -73,14 +81,18 @@ function __createImageBlock(data, isEditable, imageHostURL) {
|
|
|
73
81
|
}
|
|
74
82
|
function __createListBlock(data, isEditable) {
|
|
75
83
|
const liList = [];
|
|
84
|
+
const option = { class: ["de-block", "de-list-block"], "data-style": data.style };
|
|
85
|
+
if (data.depth !== void 0) {
|
|
86
|
+
option["data-depth"] = data.depth;
|
|
87
|
+
}
|
|
76
88
|
data.child.forEach((child) => {
|
|
77
|
-
const
|
|
89
|
+
const option2 = { class: ["de-item", ...child.classList], innerHTML: child.textContent };
|
|
78
90
|
if (isEditable === true) {
|
|
79
|
-
|
|
91
|
+
option2.contenteditable = true;
|
|
80
92
|
}
|
|
81
|
-
liList.push(h("li",
|
|
93
|
+
liList.push(h("li", option2));
|
|
82
94
|
});
|
|
83
|
-
return h(data.element,
|
|
95
|
+
return h(data.element, option, liList);
|
|
84
96
|
}
|
|
85
97
|
function __createCodeBlock(data, isEditable) {
|
|
86
98
|
const childList = [];
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { VNode, Ref } from "vue";
|
|
2
|
+
import type { DragonEditorStore, DEContentData } from "../../type.d.mts.js";
|
|
3
|
+
export declare function _getBodyVNodeStructure(store: Ref<DragonEditorStore>): VNode;
|
|
4
|
+
export declare function _updateBodyStructure(bodyData: DEContentData, store: Ref<DragonEditorStore>): void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Ref } from "vue";
|
|
2
|
-
import type { DEBlockMenutype, DragonEditorStore, DEBlockData, DETextBlock, DEBlock, DEHeadingBlock, DEListBlock, DEListItem, DEImageBlock, DECodeBlock, DECustomBlock, DECodeblockTheme, DECodeblockLang, DEListStyle } from "../../type.js";
|
|
2
|
+
import type { DEBlockMenutype, DragonEditorStore, DEBlockData, DETextBlock, DEBlock, DEHeadingBlock, DEListBlock, DEListItem, DEImageBlock, DECodeBlock, DECustomBlock, DECodeblockTheme, DECodeblockLang, DEListStyle } from "../../type.d.mts.js";
|
|
3
3
|
export declare function _addBlock(type: DEBlockMenutype, store: Ref<DragonEditorStore>, data?: DEBlockData): void;
|
|
4
4
|
export declare function _getCurrentBlock($target: EventTarget): {
|
|
5
5
|
type: DEBlock;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Ref } from "vue";
|
|
2
|
-
import type { DragonEditorStore } from "../../type.js";
|
|
2
|
+
import type { DragonEditorStore } from "../../type.d.mts.js";
|
|
3
3
|
export declare function _setAnchorTag(url: string, isOutsideLink: boolean, store: Ref<DragonEditorStore>): void;
|
|
4
4
|
export declare function _unsetAnchorTag(store: Ref<DragonEditorStore>): false | undefined;
|
|
5
5
|
export declare function _updateAnchorTagValue(event: MouseEvent, store: Ref<DragonEditorStore>, previous?: boolean): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import type { Ref } from "vue";
|
|
2
|
-
import type { DragonEditorStore, DETextalign } from "../../type.js";
|
|
2
|
+
import type { DragonEditorStore, DETextalign } from "../../type.d.mts.js";
|
|
3
3
|
export declare function _setDecoration(className: string, store: Ref<DragonEditorStore>): void;
|
|
4
4
|
export declare function _setTextAlign(type: DETextalign, store: Ref<DragonEditorStore>): void;
|
package/dist/types.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { NuxtModule } from '@nuxt/schema'
|
|
2
2
|
|
|
3
|
-
import type { default as Module } from './module.
|
|
3
|
+
import type { default as Module } from './module.mjs'
|
|
4
4
|
|
|
5
5
|
export type ModuleOptions = typeof Module extends NuxtModule<infer O> ? Partial<O> : Record<string, any>
|
|
6
6
|
|
|
7
|
-
export { default } from './module.
|
|
7
|
+
export { default } from './module.mjs'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dragon-editor",
|
|
3
|
-
"version": "3.
|
|
4
|
-
"description": "Javascript WYSIWYG editor in
|
|
3
|
+
"version": "3.7.0",
|
|
4
|
+
"description": "Javascript WYSIWYG editor in Nuxt!",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "git+https://github.com/lovefields/dragonEditor.git"
|
|
@@ -10,18 +10,16 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"exports": {
|
|
12
12
|
".": {
|
|
13
|
-
"types": "./dist/module.d.
|
|
14
|
-
"import": "./dist/module.mjs"
|
|
15
|
-
"require": "./dist/module.cjs"
|
|
13
|
+
"types": "./dist/module.d.mts",
|
|
14
|
+
"import": "./dist/module.mjs"
|
|
16
15
|
}
|
|
17
16
|
},
|
|
18
|
-
"main": "./dist/module.
|
|
19
|
-
"types": "./dist/types.d.ts",
|
|
17
|
+
"main": "./dist/module.mjs",
|
|
20
18
|
"files": [
|
|
21
19
|
"dist"
|
|
22
20
|
],
|
|
23
21
|
"scripts": {
|
|
24
|
-
"prepack": "nuxt-module-build",
|
|
22
|
+
"prepack": "nuxt-module-build build",
|
|
25
23
|
"dev": "nuxi dev playground",
|
|
26
24
|
"dev:build": "nuxi build playground",
|
|
27
25
|
"dev:prepare": "nuxt-module-build build --stub && nuxi prepare playground",
|
|
@@ -31,21 +29,23 @@
|
|
|
31
29
|
"test:watch": "vitest watch"
|
|
32
30
|
},
|
|
33
31
|
"dependencies": {
|
|
34
|
-
"@nuxt/kit": "^
|
|
35
|
-
"shiki": "^3.
|
|
32
|
+
"@nuxt/kit": "^4.0.3",
|
|
33
|
+
"shiki": "^3.12.1"
|
|
36
34
|
},
|
|
37
35
|
"devDependencies": {
|
|
38
|
-
"@nuxt/eslint-config": "^1.
|
|
39
|
-
"@nuxt/module-builder": "^0.
|
|
40
|
-
"@nuxt/schema": "^
|
|
41
|
-
"@nuxt/test-utils": "^3.
|
|
42
|
-
"@types/bun": "^1.2.
|
|
43
|
-
"changelogen": "^0.6.
|
|
44
|
-
"eslint": "^9.
|
|
45
|
-
"nuxt": "^
|
|
46
|
-
"sass": "^1.
|
|
47
|
-
"sass-embedded": "^1.
|
|
48
|
-
"
|
|
36
|
+
"@nuxt/eslint-config": "^1.9.0",
|
|
37
|
+
"@nuxt/module-builder": "^1.0.2",
|
|
38
|
+
"@nuxt/schema": "^4.0.3",
|
|
39
|
+
"@nuxt/test-utils": "^3.19.2",
|
|
40
|
+
"@types/bun": "^1.2.21",
|
|
41
|
+
"changelogen": "^0.6.2",
|
|
42
|
+
"eslint": "^9.34.0",
|
|
43
|
+
"nuxt": "^4.0.3",
|
|
44
|
+
"sass": "^1.91.0",
|
|
45
|
+
"sass-embedded": "^1.91.0",
|
|
46
|
+
"typescript": "^5.1.6",
|
|
47
|
+
"vitest": "^3.2.4",
|
|
48
|
+
"vue-tsc": "^3.0.6"
|
|
49
49
|
},
|
|
50
50
|
"keywords": [
|
|
51
51
|
"editor",
|
package/dist/module.cjs
DELETED
package/dist/module.d.ts
DELETED
package/dist/types.d.ts
DELETED