Skip to content

Commit 735b311

Browse files
committed
feat(util): util .showCode
1 parent e3c5b13 commit 735b311

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/src/util/ui.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,23 @@ define([
2323

2424
var $dialog;
2525

26+
exports.showCode = function(opts) {
27+
var opts = Object.assign({
28+
mode: 'json',
29+
content: '',
30+
width: 800,
31+
height: 600
32+
}, opts);
33+
require(['ace/ace'], function (ace) {
34+
var id = Util.getNextUniqueId(true);
35+
exports.dialog($(`<div style="width: 100%; height: 100%;" id="${id}"></div>`), opts);
36+
var editor = ace.edit(id);
37+
var mode = './mode/' + opts.mode;
38+
editor.getSession().setMode(mode);
39+
editor.setValue(opts.content, -1);
40+
});
41+
};
42+
2643
exports.enterValue = function (opts) {
2744
opts = opts || {};
2845
const defaultOptions = {

0 commit comments

Comments
 (0)