Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions docs/examples/vue3-demo/App.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<script setup lang="ts">
import { ref } from 'vue'
import { Editor } from '@floatboat/nexus-vue'
import { createGfmPreset } from '@floatboat/nexus-preset-gfm'

const markdown = ref<string>('# Hello, Nexus 👋\n\nStart typing...')

function handleChange(doc: string) {
console.log('markdown changed:', doc)
}

function handleReady(editor: any) {
console.log('editor ready:', editor)
}
</script>

<template>
<div class="editor-wrapper">
<Editor
v-model="markdown"
:plugins="[createGfmPreset()]"
:live-preview="true"
@change="handleChange"
@ready="handleReady"
/>
</div>
</template>

<style scoped>
.editor-wrapper {
min-height: 400px;
border: 1px solid #e5e7eb;
border-radius: 8px;
padding: 8px;
}
</style>
38 changes: 38 additions & 0 deletions docs/examples/vue3-demo/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Vue 3 `v-model` 示例

本示例演示如何在 Vue 3 项目中使用 `@floatboat/nexus-vue` 的 `<Editor />` 组件,并通过 `v-model` 实现 Markdown 内容与组件状态的双向绑定。

## 完整代码

```vue
<script setup lang="ts">
import { ref } from 'vue'
import { Editor } from '@floatboat/nexus-vue'
import { createGfmPreset } from '@floatboat/nexus-preset-gfm'

const markdown = ref<string>('# Hello, Nexus 👋\n\nStart typing...')

function handleChange(doc: string) {
console.log('markdown changed:', doc)
}
</script>

<template>
<div class="editor-wrapper">
<Editor
v-model="markdown"
:plugins="[createGfmPreset()]"
:live-preview="true"
@change="handleChange"
/>
</div>
</template>

<style scoped>
.editor-wrapper {
min-height: 400px;
border: 1px solid #e5e7eb;
border-radius: 8px;
padding: 8px;
}
</style>