BlockNote icon indicating copy to clipboard operation
BlockNote copied to clipboard

Get plain text from editor

Open wondering639 opened this issue 11 months ago • 1 comments

Is your feature request related to a problem? Please describe. Need to send text content to a search engine, like Typesense. According to docs, there are only HTML exports, markdown exports... https://www.blocknotejs.org/examples/interoperability/converting-blocks-to-html

Describe the solution you'd like A function that returns the complete plain text of the editor, including line breaks and spaces.

Describe alternatives you've considered Export to HTML, strip HTML. Might work.

Additional context n/a

wondering639 avatar Jan 01 '25 22:01 wondering639

@wondering639 if you have editor object, you can use editor._tiptapEditor.getText();

For example

const handleOnChangeEditorContent = (editor: BlockNoteEditor) => {
    const document = editor.document;
    const contentText = editor._tiptapEditor.getText();
    console.log(contentText);
  };

<Editor
  ref={editorRef}
  editable={true}
  initialContent={getInitialContent()}
  onChange={handleOnChangeEditorContent}
  uploadFile={uploadFile}
/>

runnabledev avatar Jan 16 '25 07:01 runnabledev

tracking here: https://github.com/TypeCellOS/BlockNote/issues/1530

YousefED avatar Jun 20 '25 07:06 YousefED