diff of c4286f4a4de9ca725cd4deadc4c9f92036190233
c4286f4a4de9ca725cd4deadc4c9f92036190233
diff --git a/src/view/admin/components/editor.lisp b/src/view/admin/components/editor.lisp
index c45b70b..1e86be6 100644
--- a/src/view/admin/components/editor.lisp
+++ b/src/view/admin/components/editor.lisp
@@ -1,5 +1,5 @@
(defpackage murja.view.admin.components.editor
- (:use :cl :binding-arrows :spinneret )
+ (:use :cl :binding-arrows :spinneret :parenscript)
(:export :editor)
(:import-from :murja.view.admin.components.tag-script :tags-component-frontend)
(:import-from :murja.view.admin.components.previouslies-script :previouslies-component-frontend)
@@ -60,21 +60,22 @@
(tag-component post)
(previouslies post))))
+(defun editor-script (post)
+ (ps
+ (chain document
+ (add-event-listener "DOMContentLoaded"
+ (lambda (e)
+ (let ((editor (chain ace
+ (edit "editor-post-content"
+ (create theme "ace/theme/monokai"
+ mode "ace/mode/html")))))
+ (chain editor (set-keyboard-handler "ace/keyboard/emacs"))
+ (chain editor (set-value (lisp (article post))))))))))
+
+
(defun editor (post)
(with-html
- ;; TODO: throw this into parenscript?
- (:script (:raw
- (format nil "
-document.addEventListener('DOMContentLoaded', _ => {
- var editor = ace.edit('editor-post-content',
-{theme: 'ace/theme/monokai',
- mode: 'ace/mode/html'});
-
- editor.setKeyboardHandler('ace/keyboard/emacs');
-
- editor.setValue(~s);
-});" (article post))))
-
+ (:script (:raw (editor-script post)))
(header post)
(:div
(:div :id "editor-post-content"))))