summaryrefslogtreecommitdiff
path: root/management
diff options
context:
space:
mode:
Diffstat (limited to 'management')
-rw-r--r--management/editor/elements.go24
-rw-r--r--management/manager/manager.go7
2 files changed, 21 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>`
diff --git a/management/manager/manager.go b/management/manager/manager.go
index 75092c0..7fd78ff 100644
--- a/management/manager/manager.go
+++ b/management/manager/manager.go
@@ -15,6 +15,13 @@ const managerHTML = `
<input type="hidden" name="type" value="{{.Kind}}"/>
{{ .Editor }}
</form>
+ <script>
+ // remove all bad chars from all inputs in the form
+ $('form input, form textarea').on('blur', function(e) {
+ var val = e.target.value;
+ e.target.value = replaceBadChars(val);
+ });
+ </script>
</div>
`