Skip to content

Commit

Permalink
docs: use useTemplateRef and #components
Browse files Browse the repository at this point in the history
  • Loading branch information
e-chan1007 committed Oct 19, 2024
1 parent 8a6eda1 commit d46bfbc
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions docs/content/2.references/1.monaco-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ interface Emits {
Emitted with an instance of [`IStandaloneCodeEditor`](https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.IStandaloneCodeEditor.html) when the editor is loaded

## `Ref` of `<MonacoEditor>`
You can access to the editor instanc by using `ref` and `$editor`.
You can access to the editor instance by using `useTemplateRef`(or `ref`) and `$editor`.
```vue
<template>
<MonacoEditor ref="editorRef" />
</template>
<script lang="ts" setup>
import { MonacoEditor } from '#build/components'
const editorRef = ref<InstanceType<typeof MonacoEditor>>()
import { MonacoEditor } from '#components'
const editorRef = useTemplateRef<InstanceType<typeof MonacoEditor>>('editorRef')
// For example, add greeting action to editor...
editorRef.value?.$editor.addAction({
Expand Down
6 changes: 3 additions & 3 deletions docs/content/2.references/2.monaco-diff-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,15 @@ interface Emits {
Emitted with an instance of [`IStandaloneDiffEditor`](https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.IStandaloneDiffEditor.html) when the editor is loaded

## `Ref` of `<MonacoDiffEditor>`
You can access to the editor instanc by using `ref` and `$editor`.
You can access to the editor instance by using `useTemplateRef`(or `ref`) and `$editor`.
```vue
<template>
<MonacoDiffEditor ref="editorRef" />
</template>
<script lang="ts" setup>
import { MonacoEditor } from '#build/components'
const editorRef = ref<InstanceType<typeof MonacoDiffEditor>>()
import { MonacoEditor } from '#components'
const editorRef = useTemplateRef<InstanceType<typeof MonacoDiffEditor>>('editorRef')
// For example, add greeting action to editor...
editorRef.value?.$editor.addAction({
Expand Down
2 changes: 1 addition & 1 deletion docs/content/2.references/3.use-monaco.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ import type { ISelection } from 'monaco-editor'
## Example
```ts
const monaco = useMonaco()!
const editorEl = ref<HTMLDivElement>()
const editorEl = useTemplateRef<HTMLDivElement>('editor')
monaco.editor.create(editorEl.value, { language: 'typescript' })
```
6 changes: 3 additions & 3 deletions docs/content/ja/2.references/1.monaco-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,15 @@ interface Emits {
エディタの読み込みが完了したときに、[`IStandaloneCodeEditor`](https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.IStandaloneCodeEditor.html)を引数として呼び出されます。

## `<MonacoEditor>``Ref`の使用
`ref``$editor` を用いることで、エディタのインスタンスに直接アクセスできます。
`useTemplateRef`(または`ref`)`$editor` を用いることで、エディタのインスタンスに直接アクセスできます。
```vue
<template>
<MonacoEditor ref="editorRef" />
</template>
<script lang="ts" setup>
import { MonacoEditor } from '#build/components'
const editorRef = ref<InstanceType<typeof MonacoEditor>>()
import { MonacoEditor } from '#components'
const editorRef = useTemplateRef<InstanceType<typeof MonacoEditor>>('editorRef')
// あいさつアクションを追加するには...
editorRef.value?.$editor.addAction({
Expand Down
6 changes: 3 additions & 3 deletions docs/content/ja/2.references/2.monaco-diff-editor.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ interface Emits {
エディタの読み込みが完了したときに、[`IStandaloneDiffEditor`](https://microsoft.github.io/monaco-editor/api/interfaces/monaco.editor.IStandaloneDiffEditor.html)を引数として呼び出されます。

## `<MonacoDiffEditor>``Ref`の使用
`ref``$editor` を用いることで、エディタのインスタンスに直接アクセスできます。
`useTemplateRef`(または`ref`)`$editor` を用いることで、エディタのインスタンスに直接アクセスできます。
```vue
<template>
<MonacoDiffEditor ref="editorRef" />
</template>
<script lang="ts" setup>
import { MonacoEditor } from '#build/components'
const editorRef = ref<InstanceType<typeof MonacoDiffEditor>>()
import { MonacoEditor } from '#components'
const editorRef = useTemplateRef<InstanceType<typeof MonacoDiffEditor>>('editorRef')
// あいさつアクションを追加するには...
editorRef.value?.$editor.addAction({
Expand Down
2 changes: 1 addition & 1 deletion docs/content/ja/2.references/3.use-monaco.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ import type { ISelection } from 'monaco-editor'
##
```ts
const monaco = useMonaco()!
const editorEl = ref<HTMLDivElement>()
const editorEl = useTemplateRef<HTMLDivElement>('editor')
monaco.editor.create(editorEl.value, { language: 'typescript' })
```

0 comments on commit d46bfbc

Please sign in to comment.