@moda-editor/vue2 0.2.0 → 0.2.2
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/EditorView.vue +19 -2
- package/package.json +2 -2
package/dist/EditorView.vue
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
computed,
|
|
4
|
+
nextTick,
|
|
5
|
+
onBeforeUnmount,
|
|
6
|
+
onMounted,
|
|
7
|
+
onUpdated,
|
|
8
|
+
ref,
|
|
9
|
+
watch,
|
|
10
|
+
} from "vue";
|
|
3
11
|
import type { Component, PropType } from "vue";
|
|
4
12
|
import {
|
|
5
13
|
bindEditorInput,
|
|
@@ -55,8 +63,17 @@ onMounted(() => {
|
|
|
55
63
|
if (editableEl.value)
|
|
56
64
|
binding = bindEditorInput(props.editor, editableEl.value);
|
|
57
65
|
});
|
|
58
|
-
// 리렌더 후 DOM에 doc 셀렉션
|
|
66
|
+
// 리렌더 후 DOM에 doc 셀렉션 복원.
|
|
67
|
+
// 셀렉션만 바뀐 디스패치(Tab 셀 이동 등)는 nodes가 같은 배열이라
|
|
68
|
+
// computed가 리렌더를 생략하고 onUpdated도 안 뜬다 — state watcher로
|
|
69
|
+
// 리렌더 유무와 무관하게 복원한다. 단 Vue 2.7의 post watcher는 플러시
|
|
70
|
+
// 안에서 컴포넌트 렌더보다 먼저 뜨는 경우가 있어 stale DOM에 복원하면
|
|
71
|
+
// selectionchange가 클램프된 위치를 doc에 역기록한다 — nextTick으로
|
|
72
|
+
// 한 틱 뒤, 커밋된 DOM에 복원한다 (Vue 3의 flush:post와 같은 의도)
|
|
59
73
|
onUpdated(() => binding?.restoreSelection());
|
|
74
|
+
watch(state, () => {
|
|
75
|
+
void nextTick(() => binding?.restoreSelection());
|
|
76
|
+
});
|
|
60
77
|
onBeforeUnmount(() => binding?.unbind());
|
|
61
78
|
</script>
|
|
62
79
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moda-editor/vue2",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Vue 2.7 adapter for @moda-editor — useWidget + WidgetView",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"library"
|
|
29
29
|
],
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@moda-editor/core": "0.2.
|
|
31
|
+
"@moda-editor/core": "0.2.2"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
34
|
"vue": "^2.7.0"
|