Skip to content

Commit

Permalink
chore: upgrade deps and refactor repo
Browse files Browse the repository at this point in the history
  • Loading branch information
farnabaz committed Dec 16, 2024
1 parent 85b9b94 commit 5fd00a3
Show file tree
Hide file tree
Showing 23 changed files with 9,223 additions and 3,626 deletions.
2 changes: 0 additions & 2 deletions .eslintignore

This file was deleted.

10 changes: 0 additions & 10 deletions .eslintrc

This file was deleted.

8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import * as monaco from 'monaco-editor'
import { language as markdownLanguage } from '@nuxtlabs/monarch-mdc'

// Register language
monaco.languages.register({ id: 'docus-markdown' })
monaco.languages.setMonarchTokensProvider('docus-markdown', markdownLanguage);
monaco.languages.register({ id: 'mdc' })
monaco.languages.setMonarchTokensProvider('mdc', markdownLanguage);


const code = `
Expand All @@ -34,7 +34,7 @@ Your **awesome** markdown
// Create monaco model
const model = monaco.editor.createModel(
code,
'docus-markdown'
'mdc'
)

// Create your editor
Expand All @@ -46,6 +46,8 @@ const editor = monaco.editor.create(el, {
})
```

Checkout the [Editor.vue](./playground/components/Editor.vue) for a complete example.



<!-- Badges -->
Expand Down
26 changes: 26 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// @ts-check
import { createConfigForNuxt } from '@nuxt/eslint-config/flat'

// Run `npx @eslint/config-inspector` to inspect the resolved config interactively
export default createConfigForNuxt({
features: {
// Rules for module authors
tooling: true,
// Rules for formatting
stylistic: true,
},
dirs: {
src: [
'./playground',
'./examples/blog',
],
},
})
.append(
{
rules: {
'vue/multi-word-component-names': 'off',
'@typescript-eslint/no-empty-object-type': 'off',
},
},
)
12 changes: 0 additions & 12 deletions index.html

This file was deleted.

21 changes: 7 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,19 @@
"dist"
],
"scripts": {
"dev": "vite -c playground/vite.config.js",
"dev": "nuxi dev playground",
"lint": "eslint .",
"build": "unbuild",
"release": "release-it"
},
"devDependencies": {
"@antfu/utils": "^0.7.6",
"@nuxt/eslint-config": "^0.2.0",
"@vitejs/plugin-vue": "^4.3.4",
"@vue/compiler-sfc": "^3.3.4",
"@vueuse/core": "^10.4.1",
"eslint": "^8.48.0",
"monaco-editor": "^0.41.0",
"monaco-editor-core": "^0.41.0",
"release-it": "^16.1.5",
"unbuild": "^2.0.0",
"vite": "^4.4.9",
"vue": "^3.3.4"
"@nuxt/eslint-config": "^0.7.3",
"eslint": "^9.17.0",
"monaco-editor-core": "^0.52.2",
"release-it": "^17.10.0",
"unbuild": "^3.0.1"
},
"packageManager": "pnpm@8.7.4",
"packageManager": "pnpm@9.15.0",
"release-it": {
"git": {
"commitMessage": "chore(release): release v${version}"
Expand Down
24 changes: 24 additions & 0 deletions playground/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Nuxt dev/build outputs
.output
.data
.nuxt
.nitro
.cache
dist

# Node dependencies
node_modules

# Logs
logs
*.log

# Misc
.DS_Store
.fleet
.idea

# Local env files
.env
.env.*
!.env.example
33 changes: 14 additions & 19 deletions playground/src/App.vue → playground/app.vue
Original file line number Diff line number Diff line change
@@ -1,20 +1,5 @@
<template>
<div
class="h-full default-theme"
:push-other-panes="false"
>
<Editor
class="editor"
:file="currentFile"
/>
</div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import Editor from './components/Editor.vue'
const currentFile = ref(`---
const source = ref(`---
key: value
---
<!--
Expand Down Expand Up @@ -130,7 +115,17 @@ This is **default slot**
The content
::
`
)
`)
</script>

<template>
<Editor
v-model:code="source"
class="h-screen w-screen"
/>
</template>

<style>
@import "tailwindcss";
@import "@nuxt/ui";
</style>
81 changes: 81 additions & 0 deletions playground/components/Editor.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<template>
<div
ref="editorContainer"
class="h-full w-full"
/>
</template>

<script setup>
import { ref, onMounted, watch } from 'vue'
import loader from '@monaco-editor/loader'
import { language as mdc } from '../../src/index'
const props = defineProps({
code: {
type: String,
required: true,
},
language: {
type: String,
default: 'mdc',
},
readOnly: {
type: Boolean,
default: false,
},
})
const emit = defineEmits(['update:code'])
const editorContainer = ref(null)
let editor = null
onMounted(async () => {
const monaco = await loader.init()
// Register the MDC language
monaco.languages.register({ id: 'mdc' })
monaco.languages.setMonarchTokensProvider('mdc', mdc)
editor = monaco.editor.create(editorContainer.value, {
value: props.code,
language: props.language,
theme: 'vs-dark',
automaticLayout: true,
readOnly: props.readOnly,
minimap: {
enabled: false,
},
fontSize: 14,
lineNumbers: 'on',
scrollBeyondLastLine: false,
roundedSelection: false,
padding: {
top: 8,
},
bracketPairColorization: {
enabled: true,
},
formatOnPaste: true,
formatOnType: true,
})
editor.onDidChangeModelContent(() => {
emit('update:code', editor.getValue())
})
})
watch(() => props.code, (newCode) => {
if (editor && editor.getValue() !== newCode) {
editor.setValue(newCode)
}
})
watch(() => props.language, (newLanguage) => {
if (editor) {
const model = editor.getModel()
if (model) {
monaco.editor.setModelLanguage(model, newLanguage === 'vue' ? 'mdc' : newLanguage)
}
}
})
</script>
6 changes: 6 additions & 0 deletions playground/nuxt.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// https://nuxt.com/docs/api/configuration/nuxt-config
export default defineNuxtConfig({
modules: ['@nuxt/ui'],
devtools: { enabled: true },
compatibilityDate: '2024-11-01',
})
19 changes: 19 additions & 0 deletions playground/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "monarch-mdc-playground",
"private": true,
"type": "module",
"scripts": {
"build": "nuxt build",
"dev": "nuxt dev",
"generate": "nuxt generate",
"preview": "nuxt preview",
"postinstall": "nuxt prepare"
},
"dependencies": {
"@monaco-editor/loader": "^1.4.0",
"@nuxt/ui": "3.0.0-alpha.10",
"nuxt": "^3.14.1592",
"vue": "latest",
"vue-router": "latest"
}
}
Binary file added playground/public/favicon.ico
Binary file not shown.
1 change: 1 addition & 0 deletions playground/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

20 changes: 0 additions & 20 deletions playground/src/components/Editor.vue

This file was deleted.

28 changes: 0 additions & 28 deletions playground/src/components/Monaco.vue

This file was deleted.

Loading

0 comments on commit 5fd00a3

Please sign in to comment.