Commit a261c388 authored by Romain Courteaud's avatar Romain Courteaud

[erp5_officejs] Reuse code mirror gadget

parent b4e5cb0e
......@@ -105,27 +105,45 @@
<item>
<key> <string>text_content</string> </key>
<value> <string>CACHE MANIFEST\n
# generated on Fri, 09 Jun 2016 11:45:33 +0000\n
# XXX + fonts\n
# images/ajax-loader.gif\n
# generated on Fri, 13 Oct 2017 16:00:00 +0000\n
CACHE:\n
renderjs.js\n
rsvp.js\n
jiodev.js\n
gadget_officejs_codemirror.js\n
codemirror/lib/codemirror.js\n
codemirror/lib/codemirror.css\n
codemirror/addon/cm_edit/matchbrackets.js\n
codemirror/addon/cm_edit/trailingspace.js\n
codemirror/addon/dialog/dialog.css\n
codemirror/addon/search/matchesonscrollbar.css\n
codemirror/mode/css/css.js\n
codemirror/mode/xml/xml.js\n
codemirror/mode/htmlmixed/htmlmixed.js\n
codemirror/mode/javascript/javascript.js\n
codemirror/addon/dialog/dialog.js\n
codemirror/addon/display/fullscreen.css\n
codemirror/addon/display/fullscreen.js\n
codemirror/addon/display/rulers.js\n
codemirror/addon/search/searchcursor.js\n
codemirror/addon/search/search.js\n
codemirror/addon/scroll/annotatescrollbar.js\n
codemirror/addon/search/matchesonscrollbar.js\n
codemirror/addon/search/jump-to-line.js\n
codemirror/addon/selection/active-line.js\n
codemirror/addon/hint/show-hint.css\n
codemirror/addon/hint/show-hint.js\n
codemirror/addon/hint/anyword-hint.js\n
codemirror/addon/fold/foldgutter.css\n
codemirror/addon/fold/foldcode.js\n
codemirror/addon/fold/foldgutter.js\n
codemirror/addon/fold/indent-fold.js\n
codemirror/addon/fold/comment-fold.js\n
codemirror/addon/merge/merge.css\n
diff_match_patch/javascript/diff_match_patch_uncompressed.js\n
codemirror/addon/merge/merge.js\n
codemirror/addon/lint/lint.css\n
codemirror/addon/lint/lint.js\n
jshint.js\n
codemirror/addon/lint/javascript-lint.js\n
csslint.js\n
codemirror/addon/lint/css-lint.js\n
codemirror/mode/xml/xml.js\n
codemirror/mode/javascript/javascript.js\n
codemirror/mode/css/css.js\n
codemirror/mode/htmlmixed/htmlmixed.js\n
codemirror.gadget.js\n
NETWORK:\n
*</string> </value>
</item>
......@@ -268,7 +286,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>958.44217.46814.8652</string> </value>
<value> <string>962.48895.14326.63948</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -286,7 +304,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1495033658.39</float>
<float>1507908439.82</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -3,29 +3,79 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Codemirror Gadget</title>
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<link rel="stylesheet" href="codemirror/lib/codemirror.css">
<link rel="stylesheet" href="codemirror/addon/dialog/dialog.css">
<link rel="stylesheet" href="codemirror/addon/search/matchesonscrollbar.css">
<script src="codemirror/lib/codemirror.js"></script>
<script src="codemirror/mode/css/css.js"></script>
<script src="codemirror/mode/xml/xml.js"></script>
<script src="codemirror/mode/javascript/javascript.js"></script>
<script src="codemirror/mode/htmlmixed/htmlmixed.js"></script>
<script src="codemirror/addon/dialog/dialog.js"></script>
<script src="codemirror/addon/search/searchcursor.js"></script>
<script src="codemirror/addon/search/search.js"></script>
<script src="codemirror/addon/scroll/annotatescrollbar.js"></script>
<script src="codemirror/addon/search/matchesonscrollbar.js"></script>
<script src="gadget_officejs_codemirror.js" type="text/javascript"></script>
<title>Codemirror</title>
<script src="rsvp.js"></script>
<script src="renderjs.js"></script>
<script src="codemirror/lib/codemirror.js"></script>
<link rel="stylesheet" href="codemirror/lib/codemirror.css" />
<!--script src="codemirror/mode/&dtml-mode;/&dtml-mode;.js"></script-->
<script src="codemirror/addon/cm_edit/matchbrackets.js"></script>
<!-- Trailing spaces -->
<script src="codemirror/addon/cm_edit/trailingspace.js"></script>
<style type="text/css">
.cm-trailingspace {
background-color: gray;
}
body {
padding: 0;
margin: 0;
}
</style>
<!-- Rulers -->
<script src="codemirror/addon/display/rulers.js"></script>
<!-- Search addons -->
<link rel="stylesheet" href="codemirror/addon/dialog/dialog.css">
<script src="codemirror/addon/dialog/dialog.js"></script>
<script src="codemirror/addon/search/searchcursor.js"></script>
<script src="codemirror/addon/search/search.js"></script>
<script src="codemirror/addon/search/jump-to-line.js"></script>
<script src="codemirror/addon/selection/active-line.js"></script>
<!-- Python autocomplete (Ctrl-Space, see below)
TODO-arnau: Add ERP5 autocompletion?
-->
<link rel="stylesheet" href="codemirror/addon/hint/show-hint.css" />
<script src="codemirror/addon/hint/show-hint.js"></script>
<script src="codemirror/addon/hint/anyword-hint.js"></script>
<!-- Code folding -->
<link rel="stylesheet" href="codemirror/addon/fold/foldgutter.css" />
<script src="codemirror/addon/fold/foldcode.js"></script>
<script src="codemirror/addon/fold/foldgutter.js"></script>
<script src="codemirror/addon/fold/indent-fold.js"></script>
<script src="codemirror/addon/fold/comment-fold.js"></script>
<!-- Merge -->
<link rel="stylesheet" href="codemirror/addon/merge/merge.css" />
<script src="diff_match_patch/javascript/diff_match_patch_uncompressed.js"></script>
<script src="codemirror/addon/merge/merge.js"></script>
<!-- Linter -->
<link rel="stylesheet" href="codemirror/addon/lint/lint.css" />
<script src="codemirror/addon/lint/lint.js"></script>
<script type="text/javascript" src="jshint.js"></script>
<script type="text/javascript" src="codemirror/addon/lint/javascript-lint.js"></script>
<script type="text/javascript" src="csslint.js"></script>
<script type="text/javascript" src="codemirror/addon/lint/css-lint.js"></script>
<script type="text/javascript" src="codemirror/mode/xml/xml.js"></script>
<script type="text/javascript" src="codemirror/mode/javascript/javascript.js"></script>
<script type="text/javascript" src="codemirror/mode/css/css.js"></script>
<script type="text/javascript" src="codemirror/mode/htmlmixed/htmlmixed.js"></script>
<link rel="stylesheet" href="codemirror/addon/display/fullscreen.css" />
<script src="codemirror/addon/display/fullscreen.js"></script>
<script src="codemirror.gadget.js"></script>
</head>
<body>
<div class="codemirror_gadget"><textarea name="code"></textarea></div>
<textarea></textarea>
</body>
</html>
\ No newline at end of file
</html>
......@@ -274,7 +274,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>957.30669.28687.29849</string> </value>
<value> <string>962.24071.53498.34082</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -292,7 +292,7 @@
</tuple>
<state>
<tuple>
<float>1487777231.91</float>
<float>1507908370.86</float>
<string>UTC</string>
</tuple>
</state>
......
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*global window, rJS, CodeMirror, RSVP */
(function (window, rJS, CodeMirror, RSVP) {
"use strict";
rJS(window)
.declareAcquiredMethod("saveContent", "triggerSubmit")
.declareMethod('render', function (options) {
this.props.key = options.key || {};
this.props.editor.setOption("mode", options.mode || "htmlmixed");
this.props.editor.setValue(options.value || "");
})
.declareMethod('getContent', function () {
var result = {};
result[this.props.key || "text_content"] = this.props.editor.getValue();
return result;
})
.declareService(function () {
this.props.editor.refresh();
this.props.editor.focus();
})
.ready(function (g) {
g.props = {};
return g.getElement()
.push(function (element) {
g.props.element = element;
CodeMirror.commands.save = function () {
return new RSVP.Queue()
.push(function () {
return g.saveContent();
});
};
g.props.editor = CodeMirror.fromTextArea(g.props.element.querySelector("textarea"), {
lineNumbers: true,
mode: "text/html",
matchBrackets: true,
showCursorWhenSelecting: true,
extraKeys: {"Alt-F": "findPersistent"}
});
// XXX custom styling for CribJS, should be put somewhere else-
g.props.element.querySelector('.CodeMirror').setAttribute('style', 'min-height: 800px;');
});
});
}(window, rJS, CodeMirror, RSVP));
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment