[Libreoffice-commits] dev-tools.git: help3/html

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Fri Aug 3 14:03:08 UTC 2018


 help3/html/autocomplete.js |   74 ++++++++++++
 help3/html/index.html      |  268 +++++++++++++--------------------------------
 help3/html/snippets.js     |  175 +++++++++++++++++++++++++++++
 help3/html/xhpeditor.css   |   21 +++
 4 files changed, 349 insertions(+), 189 deletions(-)

New commits:
commit 1f547ea9cdcaeddc156735f77c714703ade09db1
Author:     Olivier Hallot <olivier.hallot at libreoffice.org>
AuthorDate: Thu Aug 2 20:50:21 2018 -0300
Commit:     Olivier Hallot <olivier.hallot at libreoffice.org>
CommitDate: Fri Aug 3 16:02:50 2018 +0200

    XHP online editor enhancements (WIP)
    
    Changes:
    * Split javascript from html in the files
       + added snippets.js for xhp snippets
       + added autocomplete.js with autocomplete stuff
       + added xhpeditor.css for css-specifics
    
    * JS's on the bottom because they need html rendering first.
    * Fixed randomizer that assign unique id's to XHP.
    * Some snippets work better if text is selected (e.g. emph,
    paragraph...)
    * more to come on snippets later
    
    To see it working: point http server to html/ folder.
    
    Change-Id: Ic8d73fd3e3f905224ea35035a77256ac1c97586f
    Reviewed-on: https://gerrit.libreoffice.org/58500
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Reviewed-by: Olivier Hallot <olivier.hallot at libreoffice.org>
    Tested-by: Olivier Hallot <olivier.hallot at libreoffice.org>

diff --git a/help3/html/autocomplete.js b/help3/html/autocomplete.js
new file mode 100644
index 0000000..ed00af7
--- /dev/null
+++ b/help3/html/autocomplete.js
@@ -0,0 +1,74 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+
+// Here we define the schema for XHP, for the auto-completion
+
+var tags = {
+    "!top": ["helpdocument"],
+    helpdocument: {
+        children: ["meta", "body"],
+        attrs: {version: ["1.0"]},
+    },
+    meta: {
+        attrs: {localise: ["false"]},
+        children: ["topic", "history"]
+    },
+    body: {
+        attrs: {name: null},
+        children: ["section", "paragraph", "table", "comment", "bookmark", "switch", "embed", "list", "sort"]
+    },
+    section: {
+        attrs: {id: null, localise: ["false"]},
+        children: ["section", "paragraph", "table", "list", "comment", "embed", "switch", "sort"]
+    },
+};
+
+// And here's the code that provides the auto-completion in the editor
+
+function completeAfter(cm, pred) {
+    var cur = cm.getCursor();
+    if (!pred || pred()) setTimeout(function() {
+        if (!cm.state.completionActive)
+            cm.showHint({completeSingle: false});
+    }, 100);
+    return CodeMirror.Pass;
+}
+
+function completeIfAfterLt(cm) {
+    return completeAfter(cm, function() {
+        var cur = cm.getCursor();
+        return cm.getRange(CodeMirror.Pos(cur.line, cur.ch - 1), cur) == "<";
+    });
+}
+
+function completeIfInTag(cm) {
+    return completeAfter(cm, function() {
+        var tok = cm.getTokenAt(cm.getCursor());
+        if (tok.type == "string" && (!/['"]/.test(tok.string.charAt(tok.string.length - 1)) || tok.string.length == 1)) return false;
+                         var inner = CodeMirror.innerMode(cm.getMode(), tok.state).state;
+        return inner.tagName;
+    });
+}
+
+var editor = CodeMirror.fromTextArea(document.getElementById("xhpeditor"), {
+    lineNumbers: true,
+    mode: "text/html",
+    matchBrackets: true,
+    theme: "default",
+    extraKeys: {
+        "'<'": completeAfter,
+        "'/'": completeIfAfterLt,
+        "' '": completeIfInTag,
+        "'='": completeIfInTag,
+        "Ctrl-Space": "autocomplete"
+    },
+    hintOptions: {schemaInfo: tags}
+});
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/help3/html/index.html b/help3/html/index.html
index 9fea238..49c0963 100644
--- a/help3/html/index.html
+++ b/help3/html/index.html
@@ -1,200 +1,90 @@
 <!DOCTYPE html>
+<!--
+* This file is part of the LibreOffice project.
+*
+* This Source Code Form is subject to the terms of the Mozilla Public
+* License, v. 2.0. If a copy of the MPL was not distributed with this
+* file, You can obtain one at http://mozilla.org/MPL/2.0/.
+-->
 
 <html>
+<meta charset="utf-8"/>
 <head>
-<title>LibreOffice Documentation XHP Editor</title>
-<link rel="stylesheet" href="lib/codemirror.css">
-<link rel="stylesheet" href="addon/hint/show-hint.css">
-<script src="lib/codemirror.js"></script>
-<script src="addon/hint/show-hint.js"></script>
-<script src="addon/hint/xml-hint.js"></script>
-<script src="mode/xml/xml.js"></script>
+    <title>LibreOffice Documentation XHP Editor</title>
+    <link rel="stylesheet" href="xhpeditor.css">
+    <link rel="stylesheet" href="lib/codemirror.css">
+    <link rel="stylesheet" href="addon/hint/show-hint.css">
+    <script type="text/javascript" src="lib/codemirror.js"></script>
+    <script type="text/javascript" src="addon/hint/show-hint.js"></script>
+    <script type="text/javascript" src="addon/hint/xml-hint.js"></script>
+    <script type="text/javascript" src="mode/xml/xml.js"></script>
 </head>
 
 <body style="font-family:sans-serif;">
-
-<h2>LibreOffice Documentation XHP Editor</h2>
-<form style="border:1px solid grey;"><textarea id="xhpeditor">
-</textarea>
-</form>
-
-<br />
-
-<div><div style="display:inline-block;width:5em;">Actions:</div>
-<button onclick="editor.undo()">Undo</button>
-<button onclick="editor.redo()">Redo</button>
-<button onclick="alert('Not yet implemented...')">Save changes</button>
-<button onclick="startNewXHPDoc()">Start new XHP document</button>
+<div class="leftside">
+    <h2>LibreOffice Documentation XHP Editor</h2>
+    <form class="form_area">
+        <textarea id="xhpeditor"></textarea>
+    </form>
+
+    <br />
+
+    <div><div class="snip_div">Actions:</div>
+        <button onclick="editor.undo()">Undo</button>
+        <button onclick="editor.redo()">Redo</button>
+        <button onclick="alert('Not yet implemented...')">Save changes</button>
+    </div>
+    <div style="margin-top:10px;"><div class="snip_div">Document:</div>
+        <button onclick="startNewXHPDoc()" class="snip_buttons">Start new XHP document</button>
+        <button onclick="docHeading()" class="snip_buttons">DocHeading</button>
+        <button onclick="snippet7()" class="snip_buttons">ahelp</button>
+    </div>
+    <div style="margin-top:10px;"><div class="snip_div">Bookmarks:</div>
+        <button onclick="bookmarkValue()" class="snip_buttons">bookmark-value</button>
+        <button onclick="bookmarkBranch()" class="snip_buttons">bookmark-hid</button>
+        <button onclick="bookmarkIndex()" class="snip_buttons">bookmark-index</button>
+    </div>
+    <div style="margin-top:10px;"><div class="snip_div">Sections:</div>
+        <button onclick="related_topics()" class="snip_buttons">Related Topics</button>
+        <button onclick="howtoget()" class="snip_buttons">How to get</button>
+        <button onclick="bascode_div()" class="snip_buttons">bascode div</button>
+    </div>
+    <div style="margin-top:10px;"><div class="snip_div">Tables:</div>
+        <button onclick="table2R3C()" class="snip_buttons">Table Full</button>
+        <button onclick="tableRow()" class="snip_buttons">TableRow</button>
+        <button onclick="tableCell()" class="snip_buttons">Table Cell</button>
+        <button onclick="iconTable()" class="snip_buttons">Icon Table</button>
+    </div>
+    <div style="margin-top:10px;"><div class="snip_div">Paragraph:</div>
+        <button onclick="paragraph('paragraph')" class="snip_buttons">paragraph</button>
+        <button onclick="paragraph('note')" class="snip_buttons">note</button>
+        <button onclick="paragraph('warning')" class="snip_buttons">warning</button>
+        <button onclick="paragraph('tip')" class="snip_buttons">tip</button>
+        <button onclick="bascode_par()" class="snip_buttons">bascode-par</button>
+    </div>
+    <div style="margin-top:10px;"><div class="snip_div">Characters:</div>
+        <button onclick="emph()" class="snip_buttons">emph</button>
+        <button onclick="item('menuitem')" class="snip_buttons">item menuitem</button>
+        <button onclick="item('input')" class="snip_buttons">item input</button>
+        <button onclick="item('literal')" class="snip_buttons">item literal</button>
+    </div>
+    <div style="margin-top:10px;"><div class="snip_div">Headings:</div>
+        <button onclick="heading('1')" class="snip_buttons">H1</button>
+        <button onclick="heading('2')" class="snip_buttons">H2</button>
+        <button onclick="heading('3')" class="snip_buttons">H3</button>
+        <button onclick="heading('4')" class="snip_buttons">H4</button>
+    </div>
+    <div style="margin-top:10px;"><div class="snip_div">Switches:</div>
+        <button onclick="switchXHP('appl')" class="snip_buttons">Switch appl</button>
+        <button onclick="switchXHP('sys')" class="snip_buttons">Switch sys</button>
+        <button onclick="switchInline('appl')" class="snip_buttons">Switchinline appl</button>
+        <button onclick="switchInline('sys')" class="snip_buttons">Switchinline sys</button>
+    </div>
 </div>
-
-<div style="margin-top:10px;"><div style="display:inline-block;width:5em;">Snippets:</div>
-<button onclick="snippet1()" style="margin-top:5px;">DocHeading</button>
-<button onclick="snippet2()" style="margin-top:5px;">Icon Table</button>
-<button onclick="snippet3()" style="margin-top:5px;">Table Cell</button>
-<button onclick="snippet4()" style="margin-top:5px;">Related Topics</button>
-<button onclick="snippet5()" style="margin-top:5px;">TableFull</button>
-<button onclick="snippet6()" style="margin-top:5px;">TableRow</button>
-<button onclick="snippet7()" style="margin-top:5px;">ahelp</button>
-<button onclick="snippet8()" style="margin-top:5px;">bascode-div</button>
-<button onclick="snippet9()" style="margin-top:5px;">bascode-par</button>
-<button onclick="snippet10()" style="margin-top:5px;">bookmark-contents</button>
-<button onclick="snippet11()" style="margin-top:5px;">bookmark-hid</button>
-<button onclick="snippet12()" style="margin-top:5px;">bookmark-index</button>
+<div class="rightside">
+<!--     will put the xml transformed here -->
 </div>
-
-
-  <script>
-    // Code for buttons underneath the editor
-
-    function startNewXHPDoc() {
-        if (confirm('Lose all changes and start fresh?')) {
-            editor.doc.setValue('<?xml version="1.0" encoding="UTF-8"?>\n<helpdocument version="1.0">\n<!--\n * This file is part of the LibreOffice project.\n *\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/.\n *\n-->\n\n<meta>\n  <topic id="${page_topic}" indexer="include" status="PUBLISH">\n    <title id="tit" xml-lang="en-US">${page_ttile}</title>\n    <filename>/${helpFile()}</filename>\n  </topic>\n</meta>\n<body>\n${cursor}\n</body>\n</helpdocument>');
-        }
-    }
-
-    function snippet1() {
-        editor.replaceRange('<section id="${id_name=\'section identification\'}">\n    <bookmark id="${tmp1=random(\'bm\')}" xml-lang="en-US" branch="${br=\'hid/zzzz\'}" localize="false"/>\n    <paragraph id="${tmp2=random(\'hd\')}" role="heading" level="1" xml-lang="en-US"><link href="${tmp3=helpFile()}" name="${command_name}">${command_name}</link></paragraph>\n    <paragraph id="${tmp4=random(\'par\')}" role="paragraph" xml-lang="en-US"><variable id="${variable name}"><ahelp hid="${hid path or command}">${ahelp contents}</ahelp></variable></paragraph>\n    ${cursor}\n</section>\n', editor.doc.getCursor());
-    }
-
-    function snippet2() {
-        editor.replaceRange('<table id="${random(\'tab\')}">\n    <tablerow>\n        <tablecell>\n            <paragraph id="${random(\'par\')}" lang="en-US" localize="false">\n                <image ></image>\n            </paragraph>\n        </tablecell>\n        <tablecell>\n            <paragraph id="${random(\'par\')}" role="paragraph" xml-lang="en-US" ></paragraph>\n        </tablecell>\n    </tablerow>\n</table>\n', editor.doc.getCursor());
-    }
-
-    function snippet3() {
-        editor.replaceRange('<tablecell>\n            <paragraph id="${random(\'par\')}" role="tablecontents" xml-lang="en-US" >${selection()}</paragraph>\n        </tablecell>\n', editor.doc.getCursor());
-    }
-
-    function snippet4() {
-        editor.replaceRange('<section id="relatedtopics">\n   \n</section>\n', editor.doc.getCursor());
-    }
-
-    function snippet5() {
-        editor.replaceRange('<table id="${random(\'tab\')}">\n    <tablerow>\n        <tablecell>\n            <paragraph id="${random(\'par\')}" role="tablehead" xml-lang="en-US" localize="false"></paragraph>\n        </tablecell>\n        <tablecell>\n            <paragraph id="${random(\'par\')}" role="tablehead" xml-lang="en-US" localize="false"></paragraph>\n        </tablecell>\n        <tablecell>\n            <paragraph id="${random(\'par\')}" role="tablehead" xml-lang="en-US" localize="false"></paragraph>\n        </tablecell>\n    </tablerow>\n    <tablerow>\n        <tablecell>\n            <paragraph id="${random(\'par\')}" role="tablecontent" xml-lang="en-US"></paragraph>\n        </tablecell>\n        <tablecell>\n            <paragraph id="${random(\'par\')}" role="tablecontent" xml-lang="en-US"></paragraph>\n        </tablecell>\n        <tablecell>\n            <paragraph id="${random(\'par\')}" role="tablecontent" xml-lang="en-US"></paragraph>\n        </tablecell>
 \n   </tablerow>\n</table>\n', editor.doc.getCursor());
-    }
-
-    function snippet6() {
-        editor.replaceRange('<tablerow>\n        <tablecell>\n            <paragraph id="${random(\'par\')}" role="tablehead" xml-lang="en-US" >Table cell contents</paragraph>\n        </tablecell>\n    </tablerow>\n', editor.doc.getCursor());
-    }
-
-    function snippet7() {
-        editor.replaceRange('<ahelp hid="${hid path}" visibility="hidden">${selection()}</ahelp>', editor.doc.getCursor());
-    }
-
-    function snippet8() {
-        editor.replaceRange('<bascode>\n   \n</bascode>\n', editor.doc.getCursor());
-    }
-
-    function snippet9() {
-        editor.replaceRange('<paragraph role="bascode" id="${random(\'par\')}" xml-lang="en-US" localize="false">${selection()}</paragraph>', editor.doc.getCursor());
-    }
-
-    function snippet10() {
-        editor.replaceRange('<bookmark xml-lang="en-US" branch="contents" id="${random(\'bm\')}">\n    <bookmark_value>${path to contents}</bookmark_value>\n</bookmark>', editor.doc.getCursor());
-    }
-
-    function snippet11() {
-        editor.replaceRange('<bookmark xml-lang="en-US" branch="${field_name=\'hid//path/to/dialog/widget\'}" id="${random(\'bm\')}" localize="false"/>\n', editor.doc.getCursor());
-    }
-
-    function snippet12() {
-        editor.replaceRange('<bookmark xml-lang="en-US" branch="index" id="${random(\'bm\')}">\n    <bookmark_value>${level1};${level2}</bookmark_value>\n</bookmark>\n', editor.doc.getCursor());
-    }
-
-    function snippet13() {
-        editor.replaceRange('', editor.doc.getCursor());
-    }
-
-    function snippet14() {
-        editor.replaceRange('', editor.doc.getCursor());
-    }
-
-    function snippet15() {
-        editor.replaceRange('', editor.doc.getCursor());
-    }
-
-    function snippet16() {
-        editor.replaceRange('', editor.doc.getCursor());
-    }
-
-    function snippet17() {
-        editor.replaceRange('', editor.doc.getCursor());
-    }
-
-    function snippet18() {
-        editor.replaceRange('', editor.doc.getCursor());
-    }
-
-    function snippet19() {
-        editor.replaceRange('', editor.doc.getCursor());
-    }
-
-    function snippet20() {
-        editor.replaceRange('', editor.doc.getCursor());
-    }
-
-      // Here we define the schema for XHP, for the auto-completion
-
-      var tags = {
-        "!top": ["helpdocument"],
-        helpdocument: {
-          children: ["meta", "body"],
-          attrs: {version: ["1.0"]},
-        },
-        meta: {
-          attrs: {localise: ["false"]},
-          children: ["topic", "history"]
-        },
-        body: {
-          attrs: {name: null},
-          children: ["section", "paragraph", "table", "comment", "bookmark", "switch", "embed", "list", "sort"]
-        },
-        section: {
-          attrs: {id: null, localise: ["false"]},
-          children: ["section", "paragraph", "table", "list", "comment", "embed", "switch", "sort"]
-        },
-      };
-
-      // And here's the code that provides the auto-completion in the editor
-
-      function completeAfter(cm, pred) {
-        var cur = cm.getCursor();
-        if (!pred || pred()) setTimeout(function() {
-          if (!cm.state.completionActive)
-            cm.showHint({completeSingle: false});
-        }, 100);
-        return CodeMirror.Pass;
-      }
-
-      function completeIfAfterLt(cm) {
-        return completeAfter(cm, function() {
-          var cur = cm.getCursor();
-          return cm.getRange(CodeMirror.Pos(cur.line, cur.ch - 1), cur) == "<";
-        });
-      }
-
-      function completeIfInTag(cm) {
-        return completeAfter(cm, function() {
-          var tok = cm.getTokenAt(cm.getCursor());
-          if (tok.type == "string" && (!/['"]/.test(tok.string.charAt(tok.string.length - 1)) || tok.string.length == 1)) return false;
-          var inner = CodeMirror.innerMode(cm.getMode(), tok.state).state;
-          return inner.tagName;
-        });
-      }
-
-    var editor = CodeMirror.fromTextArea(document.getElementById("xhpeditor"), {
-      lineNumbers: true,
-      mode: "text/html",
-      matchBrackets: true,
-      theme: "default",
-      extraKeys: {
-          "'<'": completeAfter,
-          "'/'": completeIfAfterLt,
-          "' '": completeIfInTag,
-          "'='": completeIfInTag,
-          "Ctrl-Space": "autocomplete"
-        },
-      hintOptions: {schemaInfo: tags}
-    });
-  </script>
 </body>
+<script type="text/javascript" src="autocomplete.js"></script>
+<script type="text/javascript" src="snippets.js"></script>
 </html>
diff --git a/help3/html/snippets.js b/help3/html/snippets.js
new file mode 100644
index 0000000..93b3fc1
--- /dev/null
+++ b/help3/html/snippets.js
@@ -0,0 +1,175 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+
+// Code for buttons underneath the editor
+
+// Global document snippets
+
+function startNewXHPDoc() {
+    if (confirm('Lose all changes and start fresh?')) {
+        var a1 =
+        editor.doc.setValue('<?xml version="1.0" encoding="UTF-8"?>\n<helpdocument version="1.0">\n<!--\n * This file is part of the LibreOffice project.\n *\n * This Source Code Form is subject to the terms of the Mozilla Public\n * License, v. 2.0. If a copy of the MPL was not distributed with this\n * file, You can obtain one at http://mozilla.org/MPL/2.0/.\n *\n-->\n\n<meta>\n  <topic id="CHANGE ME" indexer="include" status="PUBLISH">\n    <title id="tit" xml-lang="en-US">TITLE ME</title>\n    <filename>FILE NAME ME</filename>\n  </topic>\n</meta>\n<body>\n\n</body>\n</helpdocument>');
+    }
+}
+function docHeading() {
+    var a1 = '<section id="CHANGE ME">\n    <bookmark id="' + random('bm') + '" xml-lang="en-US" branch="hid/CHANGE ME" localize="false"/>\n';
+    var a2 = '    <paragraph id="' + random('hd') + '" role="heading" level="1" xml-lang="en-US"><link href="HELP FILE URL" name="CHANGE ME">CHANGE ME</link></paragraph>\n';
+    var a3 = '    <paragraph id="' + random('par') + '" role="paragraph" xml-lang="en-US"><variable id="CHANGE ME"><ahelp hid="CHANGE ME">CHANGE ME</ahelp></variable></paragraph>\n\n</section>\n';
+    editor.replaceRange(a1 + a2 + a3 , editor.doc.getCursor());
+}
+
+// Paragraph
+function paragraph(role) {
+    var a0 = '<paragraph role="'+ role + '" id="' + random('par') + '" xml-lang="en-US">'
+    var a1 = '</paragraph>\n';
+    editor.replaceSelection(a0 + editor.doc.getSelection() + a1,'');
+}
+
+function heading(level) {
+    var a0 = '<paragraph level="'+ level +'" role="heading" id="' + random('hd') + '" xml-lang="en-US">'
+    var a1 = '</paragraph>\n';
+    editor.replaceSelection(a0 + editor.doc.getSelection() + a1,'');
+}
+
+function bascode_par() {
+    var a1 = '<paragraph role="bascode" id="' + random('bas') + '" xml-lang="en-US">';
+    var a2 = '</paragraph>\n';
+    editor.replaceSelection(a1 + editor.doc.getSelection() + a2,'');
+}
+
+// Tables
+// simple table cell
+function tCell (){
+    return '       <tablecell>\n           <paragraph id="' + random('par') + '" role="tablecontent" xml-lang="en-US" ></paragraph>\n       </tablecell>';
+}
+
+function iconTable() {
+    var a1 = '<table id="' + random('tab') + '">\n    <tablerow>\n        <tablecell>\n            ';
+    var a2 = '<paragraph id=" ' + random('par')+ '" lang="en-US" localize="false">\n                ';
+    var a3 = '<image >CHANGE ME</image>\n            </paragraph>\n        </tablecell>\n' + tCell();
+    var a4 = '\n    </tablerow>\n</table>\n';
+    editor.replaceRange(a1 + a2 + a3 + a4, editor.doc.getCursor());
+}
+
+function tableCell() {
+    editor.replaceRange(tCell(), editor.doc.getCursor());
+}
+
+function table2R3C() {
+    var a1 = '<table id="' + random('tab') + '">\n';
+    var a2 = '   <tablerow>\n';
+    var a3 = '       <tablecell>\n           <paragraph id="' + random('par') + '" role="tablehead" xml-lang="en-US" localize="false"></paragraph>\n       </tablecell>\n';
+    var a4 = '   </tablerow>\n';
+    var a5 = a4 + '\n</table>';
+    editor.replaceRange(a1 + a2 + a3 + a3 + a3 + a4 + a2 + tCell() + tCell() + tCell() + a5, editor.doc.getCursor());
+}
+
+function tableRow() {
+    editor.replaceRange('<tablerow>\n' + tCell() + '\n    </tablerow>\n', editor.doc.getCursor());
+}
+
+// Sections
+function related_topics() {
+    editor.replaceRange('<section id="relatedtopics">\n   \n</section>\n', editor.doc.getCursor());
+}
+
+function howtoget() {
+    editor.replaceRange('<section id="howtoget">\n   \n</section>\n', editor.doc.getCursor());
+}
+
+function bascode_div() {
+    editor.replaceRange('<bascode>\n   \n</bascode>\n', editor.doc.getCursor());
+}
+
+// Bookmarks
+function aHelp() {
+    editor.replaceRange('<ahelp hid="HID PATH ME" visibility="hidden">'+ editor.doc.getSelection() +'</ahelp>', editor.doc.getCursor());
+}
+
+function bookmarkValue() {
+    var a1 = '<bookmark_value>CHANGE ME;CHANGE ME TOO</bookmark_value>\n';
+    editor.replaceRange(a1, editor.doc.getCursor());
+}
+
+function bookmarkBranch() {
+    var a1 = '<bookmark xml-lang="en-US" branch="hid/CHANGE ME(path/to/dialog/widget)" id="' + random('bm') + '" localize="false"/>\n';
+    editor.replaceRange(a1, editor.doc.getCursor());
+}
+
+function bookmarkNoWidget() {
+    var a1 = '<bookmark xml-lang="en-US" branch="hid/CHANGE ME(/path/to/dialog)/@@nowidget@@" id="' + random('bm') + '" localize="false"/>\n';
+    editor.replaceRange(a1, editor.doc.getCursor());
+}
+
+function bookmarkIndex() {
+    var a1 = '<bookmark xml-lang="en-US" branch="index" id="' + random('bm') + '">\n    <bookmark_value>CHANGE ME;CHANGE ME TOO</bookmark_value>\n\n</bookmark>\n';
+    editor.replaceRange(a1, editor.doc.getCursor());
+}
+
+//characters snippets
+
+function emph() {
+    editor.replaceSelection('<emph>'+ editor.doc.getSelection() +'</emph>','');
+}
+
+function item(type) {
+    editor.replaceSelection('<item type="'+ type + '">'+ editor.doc.getSelection() +'</item>','');
+}
+
+// switches
+
+function switchXHP(type) {
+    var a1 = '<switch select="' + type + '">\n';
+    var a2 = '<case select="APPLICATION OR SYSTEM">CHANGE ME</case>\n';
+    var a3 = '<default>DEFAULT STUFF</default>\n';
+    var a4 = '</switch>\n';
+    editor.replaceRange(a1 + a2 + a3 + a4, editor.doc.getCursor());
+}
+
+function switchInline(type) {
+    var a1 = '<switchinline select="' + type + '">';
+    var a2 = '<caseinline  select="APPLICATION OR SYSTEM">CHANGE ME</caseinline>';
+    var a3 = '<defaultinline>DEFAULT STUFF</defaultinline>';
+    var a4 = '</switchinline>';
+    editor.replaceRange(a1 + a2 + a3 + a4, editor.doc.getCursor());
+}
+
+function snippet16() {
+    editor.replaceRange('', editor.doc.getCursor());
+}
+
+function snippet17() {
+    editor.replaceRange('', editor.doc.getCursor());
+}
+
+function snippet18() {
+    editor.replaceRange('', editor.doc.getCursor());
+}
+
+function snippet19() {
+    editor.replaceRange('', editor.doc.getCursor());
+}
+
+function snippet20() {
+    editor.replaceRange('', editor.doc.getCursor());
+}
+
+/* javascript code for snippets (orignially for KDE kate)*/
+function fileName() { return document.fileName(); }
+function fileUrl() { return document.url(); }
+function encoding() { return document.encoding(); }
+function selection() { return view.selectedText(); }
+function year() { return new Date().getFullYear(); }
+function upper(x) { return x.toUpperCase(); }
+function lower(x) { return x.toLowerCase(); }
+function random(x) {var d = new Date(); return x +'_id'+(Math.floor(Math.random() * 100) + 1) + d.getTime(); }
+function helpFile() {var d = document.url(); var t = d.search("text/"); return d.substr(t); }
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/help3/html/xhpeditor.css b/help3/html/xhpeditor.css
new file mode 100644
index 0000000..935c9bb
--- /dev/null
+++ b/help3/html/xhpeditor.css
@@ -0,0 +1,21 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * This file is part of the LibreOffice project.
+ *
+ * This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ */
+
+/* css for the man editor  web page */
+
+.form_area{
+    border:1px solid grey;
+}
+.snip_buttons{
+    margin-top:5px;
+}
+.snip_div{
+    display:inline-block;
+    width:5em;
+}


More information about the Libreoffice-commits mailing list