Skip to content

Commit 61ddeb9

Browse files
committed
Add support for Prosemirror editor
Fixes #20
1 parent 98d09ee commit 61ddeb9

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

script.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,17 @@
7878
/**
7979
* Inserts the given ID into the current editor
8080
*
81-
* @todo add suppprt for other editors like Prosemirror or CKEditor
81+
* @todo add support for other editors like CKEditor
8282
* @param {string} id The newly uploaded file ID
8383
*/
8484
function insertSyntax(id) {
85-
insertAtCarret('wiki__text', '{{:' + id + '}}');
85+
if (proseMirrorIsActive) {
86+
const pm = window.Prosemirror.view;
87+
const imageNode = pm.state.schema.nodes.image.create({id: id});
88+
pm.dispatch(pm.state.tr.replaceSelectionWith(imageNode));
89+
} else {
90+
insertAtCarret('wiki__text', '{{:' + id + '}}');
91+
}
8692
}
8793

8894
// main

0 commit comments

Comments
 (0)