Create placeholder when input is empty in CodeMirror 6

474 views Asked by At

Anyone know how create placeholder when input is empty in CodeMirror 6, i search docs but nothing special about this basic function like it

I search something but i found only to version 5 not 6

1

There are 1 answers

0
zag2art On BEST ANSWER
import { EditorView, placeholder } from '@codemirror/view'
import { EditorState } from "@codemirror/state"

const startState = EditorState.create({
  doc: 'Hello World',
  extensions: [placeholder('placeholder text')]
})

const view = new EditorView({
  state: startState,
  parent: document.body
})