diff options
author | Steve Manuel <nilslice@gmail.com> | 2016-10-03 15:57:20 -0700 |
---|---|---|
committer | Steve Manuel <nilslice@gmail.com> | 2016-10-03 15:57:20 -0700 |
commit | 09e3416b9b6576ad03750caa7c7d095f940e2448 (patch) | |
tree | 80b5ebe2433fa2c2989461fd82463e891da27df0 /management/editor/elements.go | |
parent | 245651a21c9f9b398a90f4331e36eb14bcddef45 (diff) |
adding deps and implementation for uploading encoded html content, replacing bad input chars, and retriving content into editor
Diffstat (limited to 'management/editor/elements.go')
-rw-r--r-- | management/editor/elements.go | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/management/editor/elements.go b/management/editor/elements.go index d48c1c8..53f7146 100644 --- a/management/editor/elements.go +++ b/management/editor/elements.go @@ -96,21 +96,25 @@ func Richtext(fieldName string, p interface{}, attrs map[string]string) []byte { ] }); - // initialize hidden input with escaped value - _editor.on('materialnote.init', function() { - hidden.val(_.escape(hidden.val())); - }) + // inject content into editor + if (hidden.val() !== "") { + console.log('content injected'); + _editor.code(Base64.decode(hidden.val())); + } - // update hidden input with escaped value + // update hidden input with encoded value on different events _editor.on('materialnote.change', function(e, content, $editable) { - hidden.val(_.escape(content)); - }) + console.log('content changed'); + hidden.val(Base64.encode(replaceBadChars(content))); + }); - // insert existing value into text editor - _editor.code(_.unescape(hidden.val())); + _editor.on('materialnote.paste', function(e) { + console.log('content pasted'); + hidden.val(Base64.encode(replaceBadChars(_editor.code()))); + }); // bit of a hack to stop the editor buttons from causing a refresh when clicked - $('.note-toolbar').find('button, i, a').on('click', function(e) { e.preventDefault(); }) + $('.note-toolbar').find('button, i, a').on('click', function(e) { e.preventDefault(); }); }); </script>` |