|
4 | 4 | <k-bar class="k-block-type-code-highlighter-toolbar"> |
5 | 5 | <div> |
6 | 6 | <!-- Language Picker --> |
7 | | - <k-button icon="code" :dropdown="true" @click="$refs.languages.toggle()"> |
| 7 | + <k-button icon="code" :dropdown="true" @click="$refs.language.toggle()"> |
8 | 8 | {{ languageLabel }} |
9 | 9 | </k-button> |
10 | 10 | <k-picklist-dropdown |
11 | | - ref="languages" |
| 11 | + ref="language" |
12 | 12 | :multiple="false" |
13 | 13 | :options="languages" |
14 | 14 | :search="{ placeholder: 'Select a language...'}" |
|
17 | 17 | /> |
18 | 18 |
|
19 | 19 | <!-- Theme Picker --> |
20 | | - <k-button icon="palette" :dropdown="true" @click="$refs.themes.toggle()"> |
| 20 | + <k-button icon="palette" :dropdown="true" @click="$refs.theme.toggle()"> |
21 | 21 | {{ themeLabel }} |
22 | 22 | </k-button> |
23 | 23 | <k-picklist-dropdown |
24 | | - ref="themes" |
| 24 | + ref="theme" |
25 | 25 | :multiple="false" |
26 | 26 | :options="themes" |
27 | 27 | :search="{ placeholder: 'Select a theme...'}" |
|
42 | 42 | <span v-html="highlightedCode"></span> |
43 | 43 |
|
44 | 44 | <k-textarea-input |
45 | | - v-model="content.code" |
46 | | - spellcheck="false" |
| 45 | + ref="code" |
47 | 46 | :buttons="false" |
| 47 | + :disabled="disabled" |
48 | 48 | :placeholder="placeholder" |
49 | | - @input="highlightCode" |
| 49 | + :spellcheck="false" |
| 50 | + :value="content.code" |
| 51 | + font="monospace" |
| 52 | + @input="handleInput" |
50 | 53 | /> |
51 | 54 | </div> |
52 | 55 | </div> |
@@ -136,12 +139,17 @@ export default { |
136 | 139 | highlightCode() { |
137 | 140 | if (!this.highlighter) return; |
138 | 141 |
|
139 | | - this.highlightedCode = this.highlighter.codeToHtml(this.content.code || " ", { |
| 142 | + this.highlightedCode = this.highlighter.codeToHtml(this.content.code + " ", { |
140 | 143 | lang: this.content.language, |
141 | 144 | theme: this.content.theme, |
142 | 145 | }); |
143 | 146 | }, |
144 | 147 |
|
| 148 | + handleInput(event) { |
| 149 | + this.update({ code: event }); |
| 150 | + this.highlightCode(); |
| 151 | + }, |
| 152 | +
|
145 | 153 | getLabel(options, value) { |
146 | 154 | const option = options.find((option) => option.value === value); |
147 | 155 | return option ? option.text : value; |
@@ -192,11 +200,9 @@ export default { |
192 | 200 | &-editor { |
193 | 201 | position: relative; |
194 | 202 | min-width: 100%; |
195 | | - min-height: 4.25rem; |
196 | 203 |
|
197 | 204 | .shiki, |
198 | 205 | .k-textarea-input { |
199 | | - font-family: var(--font-mono); |
200 | 206 | line-height: 1.5; |
201 | 207 | padding: .75rem; |
202 | 208 | } |
|
0 commit comments