Skip to content

Instantly share code, notes, and snippets.

@nitaku
Last active February 12, 2022 19:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nitaku/abd46708a9f038da6c9a47008408c7c9 to your computer and use it in GitHub Desktop.
Save nitaku/abd46708a9f038da6c9a47008408c7c9 to your computer and use it in GitHub Desktop.
Chinese text editor
window.AppView = class AppView extends View
constructor: (conf) ->
super(conf)
new Editor
parent: this
// Generated by CoffeeScript 1.10.0
(function() {
var AppView,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
window.AppView = AppView = (function(superClass) {
extend(AppView, superClass);
function AppView(conf) {
AppView.__super__.constructor.call(this, conf);
new Editor({
parent: this
});
}
return AppView;
})(View);
}).call(this);
window.Editor = class Editor extends View
constructor: (conf) ->
super(conf)
# Chrome bug workaround (https://github.com/codemirror/CodeMirror/issues/3679)
editor_div = @d3el.append 'div'
.attrs
class: 'editor_div'
.styles
position: 'relative'
wrapper = editor_div.append 'div'
.styles
position: 'absolute'
height: '100%'
width: '100%'
# create the CodeMirror editor
@cm_editor = CodeMirror wrapper.node(), {
#lineNumbers: true,
lineWrapping: true,
value: '''
義、禮、說、選
义、礼、说、选
㡛、㬐、㖧、䵍
𣚣、䶅、𪘆、𦞕
𪢨、𪪖、𫔺、𫜴
𫝀、𫞂、𫝻、𫠝
𫠫、𬚚、𬳕、𬺡
'''
}
@cm_editor.refresh()
_.defer () => @cm_editor.setSize() # FIXME hack for CodeMirror's linewrapping bug https://github.com/codemirror/CodeMirror/issues/1642
@cm_editor.focus()
// Generated by CoffeeScript 1.10.0
(function() {
var Editor,
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
hasProp = {}.hasOwnProperty;
window.Editor = Editor = (function(superClass) {
extend(Editor, superClass);
function Editor(conf) {
var editor_div, wrapper;
Editor.__super__.constructor.call(this, conf);
editor_div = this.d3el.append('div').attrs({
"class": 'editor_div'
}).styles({
position: 'relative'
});
wrapper = editor_div.append('div').styles({
position: 'absolute',
height: '100%',
width: '100%'
});
this.cm_editor = CodeMirror(wrapper.node(), {
lineWrapping: true,
value: '義、禮、說、選\n义、礼、说、选\n㡛、㬐、㖧、䵍\n𣚣、䶅、𪘆、𦞕\n𪢨、𪪖、𫔺、𫜴\n𫝀、𫞂、𫝻、𫠝\n𫠫、𬚚、𬳕、𬺡'
});
this.cm_editor.refresh();
_.defer((function(_this) {
return function() {
return _this.cm_editor.setSize();
};
})(this));
this.cm_editor.focus();
}
return Editor;
})(View);
}).call(this);
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

This file has been truncated, but you can view the full file.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment