Trying to add Vditor to Trilium as editor: steps and problems #4133
Unanswered
shutaozhenzhen
asked this question in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Want to use Markdown in Trilium. ckeditor do not support lots of features, like keybinding to make header, code block within list block, etc. The problem is just, ckeditor is a rich text editor, not a Markdown editor.
#3891 use draw.io to render svg, which make me thinking can I render Markdown using online Makedown editor.
Find Vditor seems like a good choice, because it has multi modes, for both WYSIWYG (Rich Text), Instant Rendering (Typora-like) and Split View modes. And it can use in html page by refer to https://unpkg.com/vditor/dist/index.min.js.
Also, there is a office viewer extension for VSCode, which use Vditor.
Here's my progress so far. I'm working offline.
download index.min.js from https://unpkg.com/vditor/dist/index.min.js.
create a render note connect with index.html (~renderNote=index.html, link file can use @ . Only put file in subtree and input filename render nothing)
html content:
<div id="vditor" class="vditor-content"></div>
(Refer from [Feature request] Run webapps inside nodes / scripting API #1168)new Vditor(id)
, Vditor auto find element with id, and, if this element has classvditor-content
, it will render to a Vditor editor.issues 1168
example callx_spreadsheet
directly. But put index.min.js in subtree of js with codex_spreadsheet
function to js global varwindow
, but Vditor will first check if module.export or export exists. So Vditor need to use as module.export js file, call by parent js note by its filename. After change index.min.js to Vditor and add const to js, things go right.But render note still empty. Open debug panel find that Vditor download language file and lute.min.js from cdn. In offline envirment, I need to download and provide them to Vditor.
lute can be refered by set _lutePath, but path in Trilium is useless.
By setting cdn to localhost, Vditor can get file in local. But in Trilium, get Note by url can only use etapi, which use noteid, not the file's path
Beta Was this translation helpful? Give feedback.
All reactions