From a2014826e3499025f4aec6dd34dc50f8d0d4e1c8 Mon Sep 17 00:00:00 2001 From: or-else Date: Mon, 5 Dec 2022 09:58:38 -0800 Subject: [PATCH] rebuilt, does not work --- umd/tinode.dev.js | 175 +++++++++++++++++---------------------------- umd/tinode.prod.js | 2 +- 2 files changed, 65 insertions(+), 112 deletions(-) diff --git a/umd/tinode.dev.js b/umd/tinode.dev.js index 150167d8..27946b7c 100644 --- a/umd/tinode.dev.js +++ b/umd/tinode.dev.js @@ -704,7 +704,7 @@ function _init_lp2() { _classPrivateMethodGet(this, _boffStop, _boffStop2).call(this); this.connect(null, force); }; - this.disconnect = _ => { + this.disconnect = () => { _classPrivateFieldSet(this, _boffClosed, true); _classPrivateMethodGet(this, _boffStop, _boffStop2).call(this); if (_sender) { @@ -730,7 +730,7 @@ function _init_lp2() { throw new Error("Long poller failed to connect"); } }; - this.isConnected = _ => { + this.isConnected = () => { return _poller && true; }; } @@ -755,7 +755,7 @@ function _init_ws2() { conn.onerror = err => { reject(err); }; - conn.onopen = _ => { + conn.onopen = evt => { if (this.autoreconnect) { _classPrivateMethodGet(this, _boffStop, _boffStop2).call(this); } @@ -764,7 +764,7 @@ function _init_ws2() { } resolve(); }; - conn.onclose = _ => { + conn.onclose = evt => { _classPrivateFieldSet(this, _socket, null); if (this.onDisconnect) { const code = _classPrivateFieldGet(this, _boffClosed) ? NETWORK_USER : NETWORK_ERROR; @@ -786,7 +786,7 @@ function _init_ws2() { _classPrivateMethodGet(this, _boffStop, _boffStop2).call(this); this.connect(null, force); }; - this.disconnect = _ => { + this.disconnect = () => { _classPrivateFieldSet(this, _boffClosed, true); _classPrivateMethodGet(this, _boffStop, _boffStop2).call(this); if (!_classPrivateFieldGet(this, _socket)) { @@ -802,7 +802,7 @@ function _init_ws2() { throw new Error("Websocket is not connected"); } }; - this.isConnected = _ => { + this.isConnected = () => { return _classPrivateFieldGet(this, _socket) && _classPrivateFieldGet(this, _socket).readyState == _classPrivateFieldGet(this, _socket).OPEN; }; } @@ -1426,95 +1426,77 @@ const ENTITY_TYPES = [ re: /\B#([\p{L}\p{N}][._\p{L}\p{N}]*[\p{L}\p{N}])/ug }]; -const FORMAT_TAGS = { +const HTML_TAGS = { AU: { - html_tag: 'audio', - md_tag: undefined, + name: 'audio', isVoid: false }, BN: { - html_tag: 'button', - md_tag: undefined, + name: 'button', isVoid: false }, BR: { - html_tag: 'br', - md_tag: '\n', + name: 'br', isVoid: true }, CO: { - html_tag: 'tt', - md_tag: '`', + name: 'tt', isVoid: false }, DL: { - html_tag: 'del', - md_tag: '~', + name: 'del', isVoid: false }, EM: { - html_tag: 'i', - md_tag: '_', + name: 'i', isVoid: false }, EX: { - html_tag: '', - md_tag: undefined, + name: '', isVoid: true }, FM: { - html_tag: 'div', - md_tag: undefined, + name: 'div', isVoid: false }, HD: { - html_tag: '', - md_tag: undefined, + name: '', isVoid: false }, HL: { - html_tag: 'span', - md_tag: undefined, + name: 'span', isVoid: false }, HT: { - html_tag: 'a', - md_tag: undefined, + name: 'a', isVoid: false }, IM: { - html_tag: 'img', - md_tag: undefined, + name: 'img', isVoid: false }, LN: { - html_tag: 'a', - md_tag: undefined, + name: 'a', isVoid: false }, MN: { - html_tag: 'a', - md_tag: undefined, + name: 'a', isVoid: false }, RW: { - html_tag: 'div', - md_tag: undefined, + name: 'div', isVoid: false }, QQ: { - html_tag: 'div', - md_tag: undefined, + name: 'div', isVoid: false }, ST: { - html_tag: 'b', - md_tag: '*', + name: 'b', isVoid: false }, VC: { - html_tag: 'div', - md_tag: undefined, + name: 'div', isVoid: false } }; @@ -2058,7 +2040,7 @@ Drafty.attachFile = function (content, attachmentDesc) { attachmentDesc.urlPromise.then(url => { ex.data.ref = url; ex.data._processing = undefined; - }, _ => { + }, err => { ex.data._processing = undefined; }); } @@ -2163,7 +2145,7 @@ Drafty.appendLineBreak = function (content) { return content; }; Drafty.UNSAFE_toHTML = function (doc) { - const tree = draftyToTree(doc); + let tree = draftyToTree(doc); const htmlFormatter = function (type, data, values) { const tag = DECORATORS[type]; let result = values ? values.join('') : ''; @@ -2272,23 +2254,6 @@ Drafty.isPlainText = function (content) { return typeof content == 'string' || !(content.fmt || content.ent); }; -Drafty.toMarkdown = function (content) { - let tree = draftyToTree(content); - const mdFormatter = function (type, _, values) { - const def = FORMAT_TAGS[type]; - let result = values ? values.join('') : ''; - if (def) { - if (def.isVoid) { - result = def.md_tag || ''; - } else if (def.md_tag) { - result = def.md_tag + result + def.md_tag; - } - } - return result; - }; - return treeBottomUp(tree, mdFormatter, 0); -}; - Drafty.isValid = function (content) { if (!content) { return false; @@ -2401,7 +2366,7 @@ Drafty.getEntityMimeType = function (entData) { }; Drafty.tagName = function (style) { - return FORMAT_TAGS[style] && FORMAT_TAGS[style].html_tag; + return HTML_TAGS[style] && HTML_TAGS[style].name; }; Drafty.attrValue = function (style, data) { @@ -2686,7 +2651,7 @@ function spansToTree(parent, text, start, end, spans) { break; } else if (inner.start < span.end) { if (inner.end <= span.end) { - const tag = FORMAT_TAGS[inner.tp] || {}; + const tag = HTML_TAGS[inner.tp] || {}; if (inner.start < inner.end || tag.isVoid) { subspans.push(inner); } @@ -3360,24 +3325,24 @@ function _get_subs_ims2() { * ... *