bsw/jbe@1309: function ui.field.wysihtml(args) bsw/jbe@1309: bsw/jbe@1309: local toolbar = { bsw/jbe@1309: { command = "bold", title ="CTRL+B", icon = "format_bold" }, bsw/jbe@1309: { command = "italic", title ="CTRL+I", icon = "format_italic" }, bsw/jbe@1309: { command = "createLink", icon = "insert_link" }, bsw/jbe@1309: { command = "removeLink", icon = "insert_link", crossed = "\\" }, bsw@1562: -- { command = "insertImage", icon = "insert_image" }, bsw/jbe@1309: { command = "formatBlock", command_value = "h1", icon = "title", head_level = "1" }, bsw/jbe@1309: { command = "formatBlock", command_value = "h2", icon = "title", head_level = "2" }, bsw/jbe@1309: { command = "formatBlock", command_value = "h3", icon = "title", head_level = "3" }, bsw/jbe@1309: { command = "formatBlock", command_blank = "true", icon = "format_clear" }, bsw/jbe@1309: { command = "insertBlockQuote", icon = "format_quote" }, bsw/jbe@1309: { command = "insertUnorderedList", icon = "format_list_bulleted" }, bsw/jbe@1309: { command = "insertOrderedList", icon = "format_list_numbered" }, bsw/jbe@1309: { command = "outdentList", icon = "format_indent_decrease" }, bsw/jbe@1309: { command = "indentList", icon = "format_indent_increase" }, bsw/jbe@1309: -- { command = "alignLeftStyle", icon = "format_align_left" }, bsw/jbe@1309: -- { command = "alignRightStyle", icon = "format_align_right" }, bsw/jbe@1309: -- { command = "alignCenterStyle", icon = "format_align_center" }, bsw/jbe@1309: { command = "undo", icon = "undo" }, bsw/jbe@1309: { command = "redo", icon = "redo" } bsw/jbe@1309: } bsw/jbe@1309: bsw/jbe@1309: slot.put([[ bsw/jbe@1309: bsw/jbe@1309: ]]) bsw/jbe@1309: bsw/jbe@1309: ui.container{ attr = { id = "toolbar", class = "toolbar", style = "display: none;" }, content = function() bsw/jbe@1309: for i, t in ipairs(toolbar) do bsw/jbe@1309: ui.tag{ tag = "a", attr = { ["data-wysihtml-command"] = t.command, ["data-wysihtml-command-value"] = t.command_value, ["data-wysihtml-command-blank-value"] = t.command_blank, title = t.shortcut }, content = function() bsw/jbe@1309: ui.tag{ tag = "i", attr = { class = "material-icons" }, content = t.icon } bsw/jbe@1309: if t.crossed then bsw/jbe@1309: ui.tag{ attr = { class = "crossed" }, content = t.crossed } bsw/jbe@1309: end bsw/jbe@1309: if t.head_level then bsw/jbe@1309: ui.tag{ attr = { class = "head_level" }, content = t.head_level } bsw/jbe@1309: end bsw/jbe@1309: end } bsw/jbe@1309: end bsw/jbe@1309: slot.put([[ bsw/jbe@1309:
bsw/jbe@1309: bsw/jbe@1309: OK Cancel bsw/jbe@1309:
bsw@1502: bsw@1502:
bsw@1502: bsw@1502: bsw@1502: OK Cancel bsw@1502:
bsw@1502: bsw/jbe@1309: ]]) bsw/jbe@1309: slot.put([[ ]] .. _"expert editor (HTML)" .. [[ ]]) bsw/jbe@1309: end } bsw/jbe@1309: bsw/jbe@1309: ui.field.text(args) bsw/jbe@1309: bsw/jbe@1309: ui.tag{ tag = "script", attr = { src = request.get_absolute_baseurl() .. "static/wysihtml/wysihtml.js" }, content = "" } bsw/jbe@1309: ui.tag{ tag = "script", attr = { src = request.get_absolute_baseurl() .. "static/wysihtml/wysihtml.all-commands.js" }, content = "" } bsw/jbe@1309: ui.tag{ tag = "script", attr = { src = request.get_absolute_baseurl() .. "static/wysihtml/wysihtml.toolbar.js" }, content = "" } bsw/jbe@1309: ui.tag{ tag = "script", attr = { src = request.get_absolute_baseurl() .. "static/wysihtml/wysihtml_liquidfeedback_rules.js" }, content = "" } bsw/jbe@1309: ui.script{ script = [[ bsw/jbe@1309: function initEditor() { bsw/jbe@1309: var editor = new wysihtml.Editor("]] .. args.attr.id .. [[", { bsw/jbe@1309: toolbar: "toolbar", bsw/jbe@1309: parserRules: wysihtmlParserRules, bsw/jbe@1309: useLineBreaks: true bsw/jbe@1309: }); bsw/jbe@1309: } bsw/jbe@1309: if(window.addEventListener){ bsw/jbe@1309: window.addEventListener('load', initEditor, false); bsw/jbe@1309: } else { bsw/jbe@1309: window.attachEvent('onload', initEditor); bsw/jbe@1309: } bsw/jbe@1309: ]] } bsw/jbe@1309: bsw/jbe@1309: end bsw/jbe@1309: