@@ -42,21 +42,21 @@ function saveCaretPosition(context) {
42
42
}
43
43
}
44
44
45
- function nextCaretPosition(context ) {
46
- const selection = window .getSelection ()
47
- const range = selection .getRangeAt (0 )
48
- range .setStart (context , 0 )
49
- const len = range .toString ().length
50
-
51
- return function restore() {
52
- const pos = getTextNodeAtPosition (context , len )
53
- selection .removeAllRanges ()
54
-
55
- const range = new Range ()
56
- range .setStart (pos .node , pos .position )
57
- selection .addRange (range )
58
- }
59
- }
45
+ // function nextCaretPosition(context) {
46
+ // const selection = window.getSelection()
47
+ // const range = selection.getRangeAt(0)
48
+ // range.setStart(context, 0)
49
+ // const len = range.toString().length
50
+
51
+ // return function restore() {
52
+ // const pos = getTextNodeAtPosition(context, len)
53
+ // selection.removeAllRanges()
54
+
55
+ // const range = new Range()
56
+ // range.setStart(pos.node, pos.position)
57
+ // selection.addRange(range)
58
+ // }
59
+ // }
60
60
61
61
function getTextNodeAtPosition(root , index ) {
62
62
const NODE_TYPE = NodeFilter .SHOW_TEXT
@@ -113,12 +113,12 @@ const execute = async () => {
113
113
})
114
114
}
115
115
116
- watch (isDark , (isDark ) => {
116
+ watch (isDark , (value ) => {
117
117
const editor = document .querySelector <HTMLElement >(' pre.elysia-editor' );
118
118
119
119
editor .innerHTML = highlighter .codeToHtml (
120
120
editor .innerText , {
121
- theme: isDark ? ' github-dark' : ' github-light' ,
121
+ theme: value ? ' github-dark' : ' github-light' ,
122
122
lang: ' javascript' ,
123
123
})
124
124
})
@@ -127,7 +127,7 @@ onMounted(() => {
127
127
const editor = document .querySelector <HTMLElement >(' pre.elysia-editor' )
128
128
129
129
editor .innerHTML = highlighter .codeToHtml (code , {
130
- theme: isDark ? ' github-dark' : ' github-light' ,
130
+ theme: isDark . value ? ' github-dark' : ' github-light' ,
131
131
lang: ' javascript' ,
132
132
})
133
133
@@ -136,7 +136,7 @@ onMounted(() => {
136
136
137
137
editor .innerHTML = highlighter .codeToHtml (
138
138
event .currentTarget .innerText , {
139
- theme: isDark ? ' github-dark' : ' github-light' ,
139
+ theme: isDark . value ? ' github-dark' : ' github-light' ,
140
140
lang: ' javascript' ,
141
141
})
142
142
@@ -194,7 +194,8 @@ onMounted(() => {
194
194
</p >
195
195
196
196
<aside class =" flex flex-col md:flex-row justify-center items-center w-full max-w-6xl gap-8 my-8" >
197
- <section class =" flex flex-col w-full h-96 border dark:border-slate-700 bg-white dark:bg-slate-800 rounded-2xl" >
197
+ <section
198
+ class =" flex flex-col w-full h-96 border dark:border-slate-700 bg-white dark:bg-slate-800 rounded-2xl" >
198
199
<div class =" mockup-window flex relative w-full h-full shadow-xl" >
199
200
<pre class =" elysia-editor block !bg-transparent !text-base !font-mono rounded-xl w-full max-w-xl h-full !pt-0 !px-2 outline-none"
200
201
contenteditable =" true" >
0 commit comments