liquid_feedback_frontend

view env/ui/field/wysihtml.lua @ 1847:bcfa66dd8980

Added version numbers
author bsw
date Thu Feb 03 16:07:59 2022 +0100 (2022-02-03)
parents 71916d0badca
children
line source
1 function ui.field.wysihtml(args)
3 local toolbar = {
4 { command = "formatBlock", command_blank = "true", icon = "view_headline" },
5 { command = "formatBlock", command_value = "h1", icon = "title", head_level = "1" },
6 { command = "formatBlock", command_value = "h2", icon = "title", head_level = "2" },
7 { command = "formatBlock", command_value = "h3", icon = "title", head_level = "3" },
8 { command = "formatBlock", command_value = "pre", icon = "code" },
9 { },
10 { command = "bold", title ="CTRL+B", icon = "format_bold" },
11 { command = "italic", title ="CTRL+I", icon = "format_italic" },
12 { },
13 { command = "insertUnorderedList", icon = "format_list_bulleted" },
14 { command = "insertOrderedList", icon = "format_list_numbered" },
15 { },
16 { command = "outdentList", icon = "format_indent_decrease" },
17 { command = "indentList", icon = "format_indent_increase" },
18 { },
19 { command = "insertBlockQuote", icon = "format_quote" },
20 { },
21 { command = "createLink", icon = "insert_link" },
22 { command = "removeLink", icon = "link_off" },
23 { },
24 { command = "undo", icon = "undo" },
25 { command = "redo", icon = "redo" }
26 }
28 slot.put([[
29 <style>
30 #wysihtml-html-button {
31 padding: 2px;
32 vertical-align: bottom;
33 }
34 #wysihtml-html-button.wysihtml-action-active {
35 color: #fff;
36 background: #000;
37 }
38 </style>
39 ]])
41 ui.container{ attr = { id = "toolbar", class = "toolbar", style = "display: none;" }, content = function()
42 for i, t in ipairs(toolbar) do
43 if t.command then
44 ui.tag{ tag = "a", attr = {
45 class = "mdl-button mdl-button--raised",
46 ["data-wysihtml-command"] = t.command,
47 ["data-wysihtml-command-value"] = t.command_value,
48 ["data-wysihtml-command-blank-value"] = t.command_blank,
49 title = t.shortcut
50 }, content = function()
51 ui.tag{ tag = "i", attr = { class = "material-icons" }, content = t.icon }
52 if t.head_level then
53 ui.tag{ attr = { class = "head_level" }, content = t.head_level }
54 end
55 end }
56 else
57 slot.put(" &nbsp; ")
58 end
59 end
60 slot.put([[
61 <div data-wysihtml-dialog="createLink" style="display: none;">
62 <label>
63 Link:
64 <input data-wysihtml-dialog-field="href" value="http://">
65 </label>
66 <a data-wysihtml-dialog-action="save">OK</a>&nbsp;<a data-wysihtml-dialog-action="cancel">Cancel</a>
67 </div>
69 <div data-wysihtml-dialog="insertImage" style="display: none;">
70 <label>
71 Image:
72 <input data-wysihtml-dialog-field="src" value="http://">
73 </label>
74 <label>
75 Align:
76 <select data-wysihtml-dialog-field="className">
77 <option value="">default</option>
78 <option value="wysiwyg-float-left">left</option>
79 <option value="wysiwyg-float-right">right</option>
80 </select>
81 </label>
82 <a data-wysihtml-dialog-action="save">OK</a>&nbsp;<a data-wysihtml-dialog-action="cancel">Cancel</a>
83 </div>
85 ]])
86 slot.put([[ <a id="wysihtml-html-button" data-wysihtml-action="change_view">]] .. _"expert editor (HTML)" .. [[</a> ]])
87 end }
89 ui.field.text(args)
91 ui.tag{ tag = "script", attr = { src = request.get_absolute_baseurl() .. "static/wysihtml/wysihtml.js?version=1" }, content = "" }
92 ui.tag{ tag = "script", attr = { src = request.get_absolute_baseurl() .. "static/wysihtml/wysihtml.all-commands.js?version=1" }, content = "" }
93 ui.tag{ tag = "script", attr = { src = request.get_absolute_baseurl() .. "static/wysihtml/wysihtml.toolbar.js?version=1" }, content = "" }
94 ui.tag{ tag = "script", attr = { src = request.get_absolute_baseurl() .. "static/wysihtml/wysihtml_liquidfeedback_rules.js?version=2" }, content = "" }
95 ui.script{ script = [[
96 function initEditor() {
97 var editor = new wysihtml.Editor("]] .. args.attr.id .. [[", {
98 toolbar: "toolbar",
99 parserRules: wysihtmlParserRules,
100 useLineBreaks: true,
101 stylesheets: "]] .. request.get_absolute_baseurl() .. [[static/lf4.css?version=3",
102 name: "draft"
103 });
104 }
105 if(window.addEventListener){
106 window.addEventListener('load', initEditor, false);
107 } else {
108 window.attachEvent('onload', initEditor);
109 }
110 ]] }
112 end

Impressum / About Us