Skip to content

Commit 36cc8e7

Browse files
committed
fix: remove unused monaco-editor dependency
1 parent f639b80 commit 36cc8e7

File tree

3 files changed

+30
-48
lines changed

3 files changed

+30
-48
lines changed

playground/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
},
1414
"dependencies": {
1515
"ant-design-vue": "^4.2.6",
16-
"monaco-editor": "^0.36.1",
1716
"vue-use-monaco": "^0.0.7"
1817
},
1918
"devDependencies": {

playground/src/App.vue

Lines changed: 30 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import 'vivid-typing/dist/index.css'
1515
1616
const { t, locale } = useI18n()
1717
const input = ref('')
18-
let pre: any
19-
= '<template>\n <button>button</button>\n</template>\n\n<style scoped>\n button {\n height: 32px;\n display: flex;\n justify-content: center;\n align-items: center;\n font-size: 14px;\n cursor: pointer;\n user-select: none;\n padding: 8px 15px;\n border-radius: 4px;\n border: none;\n box-sizing: border-box;\n color: #fff;\n background-color: #409eff;\n margin: auto;\n }\n button:hover{\n background-color: #67c23a ;\n }\n</style>\n'
18+
let pre: any =
19+
'<template>\n <button>button</button>\n</template>\n\n<style scoped>\n button {\n height: 32px;\n display: flex;\n justify-content: center;\n align-items: center;\n font-size: 14px;\n cursor: pointer;\n user-select: none;\n padding: 8px 15px;\n border-radius: 4px;\n border: none;\n box-sizing: border-box;\n color: #fff;\n background-color: #409eff;\n margin: auto;\n }\n button:hover{\n background-color: #67c23a ;\n }\n</style>\n'
2020
2121
const editor = ref(null)
2222
const editorResult = ref<HTMLElement>()
@@ -27,8 +27,7 @@ const isChecked = ref(false)
2727
const transform = computed(() => {
2828
try {
2929
return toUnocss(input.value, isChecked.value)
30-
}
31-
catch (err) {
30+
} catch (err) {
3231
return ''
3332
}
3433
})
@@ -72,7 +71,7 @@ const cssCompletionProvider = {
7271
}
7372
7473
return {
75-
suggestions: cssSuggestions.map(prop => ({
74+
suggestions: cssSuggestions.map((prop) => ({
7675
label: prop,
7776
kind: monaco.languages.CompletionItemKind.Property,
7877
insertText: prop,
@@ -85,7 +84,7 @@ const { createEditor, getEditorView } = useMonaco({
8584
onBeforeCreate(monaco) {
8685
return [
8786
monaco.languages.registerCompletionItemProvider('html', {
88-
triggerCharacters: ['<', ' ', ':', '"', '\'', '.'],
87+
triggerCharacters: ['<', ' ', ':', '"', "'", '.'],
8988
provideCompletionItems(model, position) {
9089
const textUntilPosition = model.getValueInRange({
9190
startLineNumber: 1,
@@ -95,9 +94,9 @@ const { createEditor, getEditorView } = useMonaco({
9594
})
9695
9796
// Check if we're in a style section
98-
const isInStyleSection
99-
= /<style\b/.test(textUntilPosition)
100-
&& !/<\/style>/.test(textUntilPosition.split(/<style\b/)[1] || '')
97+
const isInStyleSection =
98+
/<style\b/.test(textUntilPosition) &&
99+
!/<\/style>/.test(textUntilPosition.split(/<style\b/)[1] || '')
101100
102101
// Check if we're in a style attribute
103102
const isInStyleAttribute = /style\s*=\s*["'][^"']*$/.test(
@@ -167,7 +166,7 @@ const { createEditor, getEditorView } = useMonaco({
167166
]
168167
169168
return {
170-
suggestions: htmlTags.map(tag => ({
169+
suggestions: htmlTags.map((tag) => ({
171170
label: tag,
172171
kind: monaco.languages.CompletionItemKind.Keyword,
173172
insertText: `${tag}$0></${tag}>`,
@@ -261,7 +260,7 @@ const { createEditor: createEditor1, updateCode: updateCode1 } = useMonaco({
261260
onBeforeCreate(monaco) {
262261
return [
263262
monaco.languages.registerCompletionItemProvider('html', {
264-
triggerCharacters: ['<', ' ', ':', '"', '\'', '.'],
263+
triggerCharacters: ['<', ' ', ':', '"', "'", '.'],
265264
provideCompletionItems(model, position) {
266265
const textUntilPosition = model.getValueInRange({
267266
startLineNumber: 1,
@@ -271,9 +270,9 @@ const { createEditor: createEditor1, updateCode: updateCode1 } = useMonaco({
271270
})
272271
273272
// Check if we're in a style section
274-
const isInStyleSection
275-
= /<style\b/.test(textUntilPosition)
276-
&& !/<\/style>/.test(textUntilPosition.split(/<style\b/)[1] || '')
273+
const isInStyleSection =
274+
/<style\b/.test(textUntilPosition) &&
275+
!/<\/style>/.test(textUntilPosition.split(/<style\b/)[1] || '')
277276
278277
// Check if we're in a style attribute
279278
const isInStyleAttribute = /style\s*=\s*["'][^"']*$/.test(
@@ -343,7 +342,7 @@ const { createEditor: createEditor1, updateCode: updateCode1 } = useMonaco({
343342
]
344343
345344
return {
346-
suggestions: htmlTags.map(tag => ({
345+
suggestions: htmlTags.map((tag) => ({
347346
label: tag,
348347
kind: monaco.languages.CompletionItemKind.Keyword,
349348
insertText: `${tag}$0></${tag}>`,
@@ -433,8 +432,7 @@ const { createEditor: createEditor1, updateCode: updateCode1 } = useMonaco({
433432
})
434433
435434
onMounted(() => {
436-
if (editor.value)
437-
createEditor(editor.value, editorInput.value, 'vue')
435+
if (editor.value) createEditor(editor.value, editorInput.value, 'vue')
438436
if (editorResult.value) {
439437
createEditor1(
440438
editorResult.value,
@@ -453,8 +451,7 @@ onMounted(() => {
453451
document.addEventListener('keydown', (e) => {
454452
if ((e.metaKey || e.ctrlKey) && e.key === 'c') {
455453
const selection = document.getSelection()
456-
if (!selection || !selection.toString())
457-
return
454+
if (!selection || !selection.toString()) return
458455
const text = selection.toString()
459456
window.parent.postMessage({ eventType: 'copy', text }, '*')
460457
}
@@ -466,12 +463,9 @@ onMounted(() => {
466463
467464
const stop = useRaf(
468465
async () => {
469-
console.log()
470466
const newInput = getEditorView().getValue()
471-
if (!newInput)
472-
return
473-
if (!editorResult.value)
474-
return
467+
if (!newInput) return
468+
if (!editorResult.value) return
475469
let code
476470
if ((!pre && newInput) || pre !== newInput) {
477471
pre = newInput
@@ -480,15 +474,13 @@ const stop = useRaf(
480474
code = await fetch('https://localhost/.netlify/functions/server', {
481475
method: 'POST',
482476
body: newInput,
483-
}).then(res => res.text())
484-
}
485-
catch (error) {
477+
}).then((res) => res.text())
478+
} catch (error) {
486479
try {
487480
code = await transformVue(newInput, {
488481
isRem: isChecked.value,
489482
})
490-
}
491-
catch (e) {
483+
} catch (e) {
492484
// eslint-disable-next-line no-alert
493485
alert(`Error: ${e}`)
494486
return
@@ -514,17 +506,18 @@ function codeToHtml(code: string) {
514506
classReg,
515507
(_: any, match: any) => `[data-v-display]${match} {`,
516508
),
517-
))
509+
),
510+
)
518511
.replace('<template>', '')
519512
.replace('<\/template>', '')
520513
}
521-
const options = ref(cssSuggestions.map(i => ({ value: i })))
514+
const options = ref(cssSuggestions.map((i) => ({ value: i })))
522515
function onSearch(searchText: string) {
523516
options.value = !searchText
524-
? cssSuggestions.map(i => ({ value: i }))
517+
? cssSuggestions.map((i) => ({ value: i }))
525518
: cssSuggestions
526-
.map(i => ({ value: i }))
527-
.filter(i => i.value.includes(searchText))
519+
.map((i) => ({ value: i }))
520+
.filter((i) => i.value.includes(searchText))
528521
.sort(
529522
(a, b) => a.value.indexOf(searchText) - b.value.indexOf(searchText),
530523
)
@@ -543,8 +536,7 @@ function copyStyle() {
543536
}
544537
545538
function changelanguage() {
546-
if (locale.value === 'en')
547-
locale.value = 'zh'
539+
if (locale.value === 'en') locale.value = 'zh'
548540
else locale.value = 'en'
549541
}
550542
@@ -554,8 +546,7 @@ onUnmounted(() => {
554546
document.removeEventListener('keydown', (e) => {
555547
if ((e.metaKey || e.ctrlKey) && e.key === 'c') {
556548
const selection = document.getSelection()
557-
if (!selection || !selection.toString())
558-
return
549+
if (!selection || !selection.toString()) return
559550
const text = selection.toString()
560551
window.parent.postMessage({ eventType: 'copy', text }, '*')
561552
}
@@ -626,7 +617,7 @@ function onSelect(value: any) {
626617
@select="onSelect"
627618
/>
628619
<div flex items-center my3>
629-
<input v-model="isChecked" type="checkbox" w4 h4 mr1> isRem
620+
<input v-model="isChecked" type="checkbox" w4 h4 mr1 /> isRem
630621
</div>
631622
<div min-h-20 flex items-center justify-center>
632623
<div v-if="transform" flex="~ gap-4" items-center>

pnpm-lock.yaml

Lines changed: 0 additions & 8 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)