Skip to content

How to get the editor top level node only on demand ? #61

Answered by Saul-Mirone
Xuffasch asked this question in Q&A
Discussion options

You must be logged in to vote

In fact you can get the prosemirror view:

const editor = new Editor()

editor.use(...).create()

const view = editor.view

The version 4.6 has been released and you can use following code:

BTW, I still need to update doc about this

import { Editor, editorViewOptionsCtx, editorViewCtx } from '@milkdown/core';

async function createEditor() {
    const newEditor = await new Editor()
        .config(ctx => {
            ctx.update(editorViewOptionsCtx, prev => ({ ...prev, root: root2, defaultValue: content2 }))
        })
        .use([directiveRemarkPlugin, titleNode])
        .use(commonmark)
        .create();

    const view = newEditor.action(ctx => ctx.get(editorViewCtx));

    // do…

Replies: 2 comments 7 replies

Comment options

You must be logged in to vote
1 reply
@Xuffasch
Comment options

Comment options

You must be logged in to vote
6 replies
@Saul-Mirone
Comment options

@Saul-Mirone
Comment options

@Saul-Mirone
Comment options

@adaboese
Comment options

@adaboese
Comment options

Answer selected by Saul-Mirone
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants