var ws = new WebSocket("ws://localhost:8080/test"); var handles = get_handles(ws); ws.onopen = function () { // ws.send("Hello, world"); }; ws.onmessage = function (evt) { console.log(">>>", evt.data); var msg = JSON.parse(evt.data); handles[msg.command](msg.spec, msg.coro_id); }; var input_item = { html: '', set_invalid: msg => { }, set_valid: msg => { }, }; function InputItem(ele, name) { this.ele = ele; this.name = name; this.set_invalid; this.set_valid; this.set_attr; // 设置input的tag属性 } function get_handles(ws) { var md_parser = new Mditor.Parser(); var output_container = $('#markdown-body'); var input_container = $('#input-container'); var handles = { text_input: function (spec, coro_id) { var html = `