I am using ProseMirror showing a Markdown file. The content is simple:
Some paragraph here.
<div style='font-family: "Comic Sans MS", "Comic Sans", cursive;'>
It is a pity, but markdown does **not** work in here for most markdown parsers.
[Marked] handles it pretty well.
</div>
The following command is how I wrote SelectAll command when pressing mod+A:
If I run this, I get a selection that covers the document, and deleting it clears the document. You’ll have to show a minimal script that reproduces the problem.
import {EditorView} from "prosemirror-view"
import {EditorState, AllSelection} from "prosemirror-state"
import {schema} from "prosemirror-schema-basic"
let view = new EditorView(document.body, {state: EditorState.create({
doc: schema.node("doc", null, [
schema.node("paragraph", null, [schema.text("abc")]),
schema.node("horizontal_rule")
])
})})
view.focus()
view.dispatch(view.state.tr.setSelection(new AllSelection(view.state.doc)))
I think I know where the problem is. It seems like my problem is caused by the default behaviour from the browser when pressing Ctrl+A. I execute the following code right after the keypress event:
handleKeyDown is supposed to return true whenever it executes any command, which will automatically cause preventDefault to be called (as well as prevent any further built-in handling in the library).