solid-ui 2.4.27-2ebac088 → 2.4.27-3652e5cb
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/670.solid-ui.min.js +1 -0
- package/dist/805.solid-ui.min.js +3 -0
- package/dist/805.solid-ui.min.js.LICENSE.txt +58 -0
- package/dist/805.solid-ui.min.js.map +1 -0
- package/dist/_2b19.solid-ui.js +14 -0
- package/dist/_2b19.solid-ui.js.map +1 -0
- package/dist/solid-ui.js +8215 -16513
- package/dist/solid-ui.js.map +1 -1
- package/dist/solid-ui.min.js +1 -1
- package/dist/solid-ui.min.js.LICENSE.txt +4 -59
- package/dist/solid-ui.min.js.map +1 -1
- package/dist/vendors-node_modules_jsonld_lib_jsonld_js.solid-ui.js +12134 -0
- package/dist/vendors-node_modules_jsonld_lib_jsonld_js.solid-ui.js.map +1 -0
- package/lib/chat/bookmarks.js +7 -6
- package/lib/chat/bookmarks.js.map +1 -1
- package/lib/chat/chatLogic.js +103 -248
- package/lib/chat/chatLogic.js.map +1 -1
- package/lib/chat/infinite.js +426 -604
- package/lib/chat/infinite.js.map +1 -1
- package/lib/chat/keys.d.ts +5 -0
- package/lib/chat/keys.d.ts.map +1 -0
- package/lib/chat/keys.js +290 -0
- package/lib/chat/keys.js.map +1 -0
- package/lib/chat/message.js +191 -285
- package/lib/chat/message.js.map +1 -1
- package/lib/chat/messageTools.js +276 -464
- package/lib/chat/messageTools.js.map +1 -1
- package/lib/chat/signature.d.ts +27 -0
- package/lib/chat/signature.d.ts.map +1 -0
- package/lib/chat/signature.js +110 -0
- package/lib/chat/signature.js.map +1 -0
- package/lib/chat/thread.js +144 -166
- package/lib/chat/thread.js.map +1 -1
- package/lib/preferences.js +0 -4
- package/lib/preferences.js.map +1 -1
- package/lib/utils/cryptoKeyHelpers.d.ts +5 -0
- package/lib/utils/cryptoKeyHelpers.d.ts.map +1 -0
- package/lib/utils/cryptoKeyHelpers.js +157 -0
- package/lib/utils/cryptoKeyHelpers.js.map +1 -0
- package/lib/versionInfo.js +2 -2
- package/lib/versionInfo.js.map +1 -1
- package/package.json +9 -6
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"keys.js","names":["debug","_interopRequireWildcard","require","_secp256k","_utils","_signature","_solidLogic","$rdf","_cryptoKeyHelpers","_getRequireWildcardCache","nodeInterop","WeakMap","cacheBabelInterop","cacheNodeInterop","obj","__esModule","_typeof","cache","has","get","newObj","hasPropertyDescriptor","Object","defineProperty","getOwnPropertyDescriptor","key","prototype","hasOwnProperty","call","desc","set","generatePrivateKey","bytesToHex","schnorr","utils","randomPrivateKey","generatePublicKey","privateKey","getPublicKey","_x","_getPublicKey","apply","arguments","_asyncToGenerator2","_regenerator","mark","_callee","webId","publicKeyDoc","wrap","_callee$","_context","prev","next","store","fetcher","load","pubKeyUrl","any","sym","CERT","abrupt","value","t0","undefined","stop","getPrivateKey","_x2","_getPrivateKey","_callee2","privateKeyDoc","publicKey","validPublicKey","del","add","newPublicKey","keyContainer","_callee2$","_context2","privKeyUrl","publicKeyExists","sent","privateKeyExists","confirm","st","literal","saveKey","lit","log","substring","lastIndexOf","setAcl","keyContainerAclBody","me","aclBody","concat","keyAclBody","keyDoc","keyAgent","length","split","pop","_x3","_x4","_setAcl","_callee3","keyAclDoc","response","aclResponse","_callee3$","_context3","statementsMatching","Error","webOperation","status","data","contentType","_x5","_x6","_x7","_saveKey","_callee4","_callee4$","_context4","updater","updateMany","t1"],"sources":["../../src/chat/keys.ts"],"sourcesContent":["import * as debug from '../debug'\r\nimport { schnorr } from '@noble/curves/secp256k1'\r\nimport { bytesToHex } from '@noble/hashes/utils'\r\nimport { CERT } from './signature'\r\nimport { store } from 'solid-logic'\r\nimport * as $rdf from 'rdflib'\r\nimport { publicKeyExists, pubKeyUrl, privKeyUrl, privateKeyExists } from '../utils/cryptoKeyHelpers'\r\n\r\nexport function generatePrivateKey (): string {\r\n return bytesToHex(schnorr.utils.randomPrivateKey())\r\n}\r\n\r\nexport function generatePublicKey (privateKey: string): string {\r\n return bytesToHex(schnorr.getPublicKey(privateKey))\r\n}\r\n\r\nexport async function getPublicKey (webId) {\r\n await store.fetcher.load(webId)\r\n const publicKeyDoc = pubKeyUrl(webId)\r\n try {\r\n await store.fetcher.load(publicKeyDoc) // url.href)\r\n const key = store.any(store.sym(webId), store.sym(CERT + 'PublicKey'))\r\n return key?.value // as NamedNode\r\n } catch (err) {\r\n return undefined\r\n }\r\n // this is called in display message and should not try to create a publicKeyDoc\r\n // const publicKey = await publicKeyExists(webId)\r\n // return publicKey\r\n}\r\n\r\nexport async function getPrivateKey (webId: string) {\r\n await store.fetcher.load(webId)\r\n // find keys url's\r\n const publicKeyDoc = pubKeyUrl(webId)\r\n const privateKeyDoc = privKeyUrl(webId)\r\n\r\n // find key pair\r\n const publicKey = await publicKeyExists(webId)\r\n let privateKey = await privateKeyExists(webId)\r\n\r\n // is publicKey valid ?\r\n let validPublicKey = true\r\n if (privateKey && (publicKey !== generatePublicKey(privateKey as string))) {\r\n if (confirm('This is strange the publicKey is not valid for\\n' + webId +\r\n '\\'shall we repair keeping the private key ?')) validPublicKey = false\r\n }\r\n\r\n // create key pair or repair publicKey\r\n if (!privateKey || !publicKey || !validPublicKey) {\r\n let del: any[] = []\r\n let add: any[] = []\r\n // if (privateKey) del.push($rdf.st($rdf.sym(webId), $rdf.sym(CERT + 'PrivateKey'), $rdf.lit(privateKey), $rdf.sym(privateKeyDoc)))\r\n\r\n if (!privateKey) {\r\n // add = []\r\n privateKey = generatePrivateKey()\r\n add = [$rdf.st($rdf.sym(webId), $rdf.sym(CERT + 'PrivateKey'), $rdf.literal(privateKey), $rdf.sym(privateKeyDoc))]\r\n await saveKey(privateKeyDoc, [], add, webId)\r\n }\r\n if (!publicKey || !validPublicKey) {\r\n del = []\r\n // delete invalid public key\r\n if (publicKey) {\r\n del = [$rdf.st($rdf.sym(webId), $rdf.sym(CERT + 'PublicKey'), $rdf.lit(publicKey), $rdf.sym(publicKeyDoc))]\r\n debug.log(del)\r\n }\r\n // update new valid key\r\n const newPublicKey = generatePublicKey(privateKey)\r\n add = [$rdf.st($rdf.sym(webId), $rdf.sym(CERT + 'PublicKey'), $rdf.literal(newPublicKey), $rdf.sym(publicKeyDoc))]\r\n await saveKey(publicKeyDoc, del, add)\r\n }\r\n const keyContainer = privateKeyDoc.substring(0, privateKeyDoc.lastIndexOf('/') + 1)\r\n await setAcl(keyContainer, keyContainerAclBody(webId)) // includes DELETE and PUT\r\n }\r\n return privateKey as string\r\n}\r\n\r\n/**\r\n * key container ACL\r\n * @param me\r\n * @returns aclBody\r\n */\r\nconst keyContainerAclBody = (me: string) => {\r\n const aclBody = `\r\n@prefix : <#>.\r\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\r\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\r\n@prefix key: <./>.\r\n\r\n:ReadWrite\r\n a acl:Authorization;\r\n acl:accessTo key:;\r\n acl:default key:;\r\n acl:agent <${me}>;\r\n acl:mode acl:Read, acl:Write.\r\n`\r\n return aclBody\r\n}\r\n\r\n/**\r\n * Read only ACL\r\n * @param keyDoc\r\n * @param me\r\n * @returns aclBody\r\n */\r\nconst keyAclBody = (keyDoc, me) => {\r\n let keyAgent = 'acl:agentClass foaf:Agent' // publicKey\r\n if (me?.length) keyAgent = `acl:agent <${me}>` // privateKey\r\n const aclBody = `\r\n@prefix foaf: <http://xmlns.com/foaf/0.1/>.\r\n@prefix acl: <http://www.w3.org/ns/auth/acl#>.\r\n<#Read>\r\n a acl:Authorization;\r\n ${keyAgent};\r\n acl:accessTo <${keyDoc.split('/').pop()}>;\r\n acl:mode acl:Read.\r\n`\r\n return aclBody\r\n}\r\n\r\n/**\r\n * set ACL\r\n * @param keyDoc\r\n * @param aclBody\r\n */\r\nasync function setAcl (keyDoc, aclBody) {\r\n // Some servers don't present a Link http response header\r\n // if the container doesn't exist yet, so refetch the resource\r\n await store.fetcher.load(keyDoc)\r\n\r\n // FIXME: check the Why value on this quad:\r\n debug.log(store.statementsMatching($rdf.sym(keyDoc), $rdf.sym('http://www.iana.org/assignments/link-relations/acl')))\r\n const keyAclDoc = store.any($rdf.sym(keyDoc), $rdf.sym('http://www.iana.org/assignments/link-relations/acl'))\r\n if (!keyAclDoc) {\r\n throw new Error('Key ACL doc not found!')\r\n }\r\n\r\n // delete READ only keyAclDoc. This is possible if the webId is an owner\r\n try {\r\n const response = await store.fetcher.webOperation('DELETE', keyAclDoc.value) // this may fail if webId is not an owner\r\n debug.log('delete ' + keyAclDoc.value + ' ' + response.status) // should test 404 and 2xx\r\n } catch (err) {\r\n if (err.response.status !== 404) { throw new Error(err) }\r\n debug.log('delete ' + keyAclDoc.value + ' ' + err.response.status) // should test 404 and 2xx\r\n }\r\n\r\n const aclResponse = await store.fetcher.webOperation('PUT', keyAclDoc.value, {\r\n data: aclBody,\r\n contentType: 'text/turtle'\r\n })\r\n}\r\n\r\n/**\r\n * delete acl if keydoc exists\r\n * create/edit keyDoc\r\n * set keyDoc acl\r\n */\r\nasync function saveKey (keyDoc, del, add, me = '') {\r\n await store.fetcher.load(keyDoc)\r\n // delete keyAclDoc\r\n try {\r\n // get keyAcldoc\r\n const keyAclDoc = store.any($rdf.sym(keyDoc), $rdf.sym('http://www.iana.org/assignments/link-relations/acl'))\r\n if (keyAclDoc) {\r\n // delete READ only keyAclDoc. This is possible if the webId is an owner\r\n try {\r\n const response = await store.fetcher.webOperation('DELETE', keyAclDoc.value) // this may fail if webId is not an owner\r\n debug.log('delete ' + keyAclDoc.value + ' ' + response.status) // should test 404 and 2xx\r\n } catch (err) {\r\n if (err.response.status !== 404) { throw new Error(err) }\r\n debug.log('delete ' + keyAclDoc.value + ' ' + err.response.status) // should test 404 and 2xx\r\n }\r\n }\r\n\r\n // save key\r\n await store.updater.updateMany(del, add) // or a promise store.updater.update ?\r\n\r\n // create READ only ACL\r\n const aclBody = keyAclBody(keyDoc, me)\r\n await setAcl(keyDoc, aclBody)\r\n } catch (err) { thro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,CAACO,MAAM,KAAK,GAAG;cAAAS,SAAA,CAAAtE,IAAA;cAAA;YAAA;YAAA,MAAU,IAAI2D,KAAK,CAAAW,SAAA,CAAA5D,EAAA,CAAK;UAAA;YACvD/D,KAAK,CAACwF,GAAG,CAAC,SAAS,GAAGkB,SAAS,CAAC5C,KAAK,GAAG,GAAG,GAAG6D,SAAA,CAAA5D,EAAA,CAAI4C,QAAQ,CAACO,MAAM,CAAC,EAAC;UAAA;YAAAS,SAAA,CAAAtE,IAAA;YAAA,OAKjEC,iBAAK,CAACsE,OAAO,CAACC,UAAU,CAACpD,GAAG,EAAEC,GAAG,CAAC;UAAA;YAAC;YAEzC;YACMoB,OAAO,GAAGE,UAAU,CAACC,MAAM,EAAEJ,EAAE,CAAC;YAAA8B,SAAA,CAAAtE,IAAA;YAAA,OAChCsC,MAAM,CAACM,MAAM,EAAEH,OAAO,CAAC;UAAA;YAAA6B,SAAA,CAAAtE,IAAA;YAAA;UAAA;YAAAsE,SAAA,CAAAvE,IAAA;YAAAuE,SAAA,CAAAG,EAAA,GAAAH,SAAA;YAAA,MACT,IAAIX,KAAK,CAAAW,SAAA,CAAAG,EAAA,CAAK;UAAA;UAAA;YAAA,OAAAH,SAAA,CAAA1D,IAAA;QAAA;MAAA,GAAAwD,QAAA;IAAA;EAAA,CACrC;EAAA,OAAAD,QAAA,CAAA/E,KAAA,OAAAC,SAAA;AAAA"}
|
package/lib/chat/message.js
CHANGED
|
@@ -12,7 +12,6 @@ exports.renderMessageEditor = renderMessageEditor;
|
|
|
12
12
|
exports.renderMessageRow = renderMessageRow;
|
|
13
13
|
exports.switchToEditor = switchToEditor;
|
|
14
14
|
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
15
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
15
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
17
16
|
var _infinite = require("./infinite");
|
|
18
17
|
var _messageTools = require("./messageTools");
|
|
@@ -28,11 +27,11 @@ var pad = _interopRequireWildcard(require("../pad"));
|
|
|
28
27
|
var style = _interopRequireWildcard(require("../style"));
|
|
29
28
|
var utils = _interopRequireWildcard(require("../utils"));
|
|
30
29
|
var widgets = _interopRequireWildcard(require("../widgets"));
|
|
30
|
+
var _signature = require("./signature");
|
|
31
|
+
var _keys = require("./keys");
|
|
31
32
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
32
33
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
33
|
-
function
|
|
34
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2["default"])(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
35
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e2) { throw _e2; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e3) { didErr = true; err = _e3; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
34
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
36
35
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
37
36
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
38
37
|
var dom = window.document;
|
|
@@ -111,232 +110,154 @@ function creatorAndDateHorizontal(td1, creator, date, message) {
|
|
|
111
110
|
/**
|
|
112
111
|
* Renders a chat message, read-only mode
|
|
113
112
|
*/
|
|
114
|
-
function renderMessageRow(
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
return _regenerator["default"].wrap(function _callee9$(_context10) {
|
|
121
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
122
|
-
case 0:
|
|
123
|
-
getBgColor = function _getBgColor(fresh) {
|
|
124
|
-
return fresh ? '#e8ffe8' : 'white';
|
|
125
|
-
};
|
|
126
|
-
colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true;
|
|
127
|
-
creator = _solidLogic.store.any(message, ns.foaf('maker'));
|
|
128
|
-
date = _solidLogic.store.any(message, ns.dct('created'));
|
|
129
|
-
_context10.next = 6;
|
|
130
|
-
return (0, _chatLogic.mostRecentVersion)(message);
|
|
131
|
-
case 6:
|
|
132
|
-
latestVersion = _context10.sent;
|
|
133
|
-
content = _solidLogic.store.any(latestVersion, ns.sioc('content')); // const id = store.any(latestVersion, ns.sioc('id'))
|
|
134
|
-
// const replies = store.each(latestVersion, ns.sioc('has_reply'))
|
|
135
|
-
_context10.next = 10;
|
|
136
|
-
return (0, _chatLogic.allVersions)(message);
|
|
137
|
-
case 10:
|
|
138
|
-
versions = _context10.sent;
|
|
139
|
-
if (versions.length > 1) {
|
|
140
|
-
debug.log('renderMessageRow versions: ', versions.join(', '));
|
|
141
|
-
}
|
|
142
|
-
// be tolerant in accepting replies on any version of a message
|
|
143
|
-
replies = versions.map(function (version) {
|
|
144
|
-
return _solidLogic.store.each(version, ns.sioc('has_reply'));
|
|
145
|
-
}).flat();
|
|
146
|
-
thread = null;
|
|
147
|
-
straightReplies = [];
|
|
148
|
-
_iterator2 = _createForOfIteratorHelper(replies);
|
|
149
|
-
try {
|
|
150
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
151
|
-
reply = _step2.value;
|
|
152
|
-
if (_solidLogic.store.holds(reply, ns.rdf('type'), ns.sioc('Thread'))) {
|
|
153
|
-
thread = reply;
|
|
154
|
-
debug.log('renderMessageRow: found thread: ' + thread);
|
|
155
|
-
} else {
|
|
156
|
-
straightReplies.push(reply);
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
} catch (err) {
|
|
160
|
-
_iterator2.e(err);
|
|
161
|
-
} finally {
|
|
162
|
-
_iterator2.f();
|
|
163
|
-
}
|
|
164
|
-
if (straightReplies.length > 1) {
|
|
165
|
-
debug.log('renderMessageRow: found normal replies: ', straightReplies);
|
|
166
|
-
}
|
|
167
|
-
_context10.next = 20;
|
|
168
|
-
return (0, _chatLogic.originalVersion)(message);
|
|
169
|
-
case 20:
|
|
170
|
-
originalMessage = _context10.sent;
|
|
171
|
-
edited = !message.sameTerm(originalMessage); // @@ load it first @@ Or display the new data at the old date.
|
|
172
|
-
// @@@ kludge!
|
|
173
|
-
sortDate = _solidLogic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()) || _solidLogic.store.the(message, ns.dct('created'), null, message.doc()); // In message
|
|
174
|
-
messageRow = dom.createElement('tr');
|
|
175
|
-
messageRow.AJAR_date = sortDate.value;
|
|
176
|
-
messageRow.AJAR_subject = message;
|
|
177
|
-
td1 = dom.createElement('td');
|
|
178
|
-
messageRow.appendChild(td1);
|
|
179
|
-
if (!options.authorDateOnLeft) {
|
|
180
|
-
img = dom.createElement('img');
|
|
181
|
-
img.setAttribute('style', 'max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;');
|
|
182
|
-
widgets.setImage(img, creator);
|
|
183
|
-
td1.appendChild(img);
|
|
184
|
-
} else {
|
|
185
|
-
creatorAndDate(td1, creator, widgets.shortDate(sortDate.value), message);
|
|
186
|
-
}
|
|
187
|
-
bothDates = widgets.shortDate(sortDate.value);
|
|
188
|
-
if (edited) {
|
|
189
|
-
bothDates += ' ... ' + widgets.shortDate(date.value);
|
|
190
|
-
}
|
|
113
|
+
function renderMessageRow(channelObject, message, fresh, options, userContext) {
|
|
114
|
+
var colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true;
|
|
115
|
+
var creator = _solidLogic.store.any(message, ns.foaf('maker'));
|
|
116
|
+
var date = _solidLogic.store.any(message, ns.dct('created'));
|
|
117
|
+
var latestVersion = (0, _chatLogic.mostRecentVersion)(message);
|
|
118
|
+
var latestVersionCreator = _solidLogic.store.any(latestVersion, ns.foaf('maker'));
|
|
191
119
|
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
// widgets.shortDate(dateString)
|
|
197
|
-
message);
|
|
198
|
-
}
|
|
199
|
-
text = content ? content.value.trim() : '??? no content?';
|
|
200
|
-
isURI = /^https?:\/[^ <>]*$/i.test(text);
|
|
201
|
-
para = null;
|
|
202
|
-
if (isURI) {
|
|
203
|
-
isImage = /\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(text); // @@ Should use content-type not URI
|
|
204
|
-
if (isImage && options.expandImagesInline) {
|
|
205
|
-
_img = elementForImageURI(text, options);
|
|
206
|
-
td2.appendChild(_img);
|
|
207
|
-
} else {
|
|
208
|
-
// Link but not Image
|
|
209
|
-
anc = td2.appendChild(dom.createElement('a'));
|
|
210
|
-
para = anc.appendChild(dom.createElement('p'));
|
|
211
|
-
anc.href = text;
|
|
212
|
-
para.textContent = text;
|
|
213
|
-
td2.appendChild(anc);
|
|
214
|
-
}
|
|
215
|
-
} else {
|
|
216
|
-
// text
|
|
217
|
-
para = dom.createElement('p');
|
|
218
|
-
td2.appendChild(para);
|
|
219
|
-
para.textContent = text;
|
|
220
|
-
}
|
|
221
|
-
if (para) {
|
|
222
|
-
bgcolor = colorizeByAuthor ? pad.lightColorHash(creator) : getBgColor(fresh);
|
|
223
|
-
para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
|
|
224
|
-
}
|
|
225
|
-
_context10.next = 40;
|
|
226
|
-
return (0, _messageTools.sentimentStripLinked)(message, message.doc());
|
|
227
|
-
case 40:
|
|
228
|
-
strip = _context10.sent;
|
|
229
|
-
if (strip.children.length) {
|
|
230
|
-
td2.appendChild(dom.createElement('br'));
|
|
231
|
-
td2.appendChild(strip);
|
|
232
|
-
}
|
|
120
|
+
// use latest content if same owner, else use original
|
|
121
|
+
var msgId = creator.uri === latestVersionCreator.uri ? latestVersion : message;
|
|
122
|
+
var content = _solidLogic.store.any(msgId, ns.sioc('content'));
|
|
123
|
+
var signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "Proof")));
|
|
233
124
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
return _context9.abrupt("return");
|
|
253
|
-
case 4:
|
|
254
|
-
toolsTR = dom.createElement('tr');
|
|
255
|
-
_context9.next = 7;
|
|
256
|
-
return (0, _messageTools.messageToolbar)(message, messageRow, _objectSpread(_objectSpread({}, userContext), {}, {
|
|
257
|
-
chatOptions: options
|
|
258
|
-
}), channelObject);
|
|
259
|
-
case 7:
|
|
260
|
-
tools = _context9.sent;
|
|
261
|
-
tools.style = 'border: 0.05em solid #888; border-radius: 0 0 0.7em 0.7em; border-top: 0; height:3.5em; background-color: #fff;'; // @@ fix
|
|
262
|
-
if (messageRow.nextSibling) {
|
|
263
|
-
messageRow.parentElement.insertBefore(toolsTR, messageRow.nextSibling);
|
|
264
|
-
} else {
|
|
265
|
-
messageRow.parentElement.appendChild(toolsTR);
|
|
266
|
-
}
|
|
267
|
-
messageRow.toolTR = toolsTR;
|
|
268
|
-
toolsTR.appendChild(dom.createElement('td')); // left
|
|
269
|
-
toolsTD = toolsTR.appendChild(dom.createElement('td'));
|
|
270
|
-
toolsTR.appendChild(dom.createElement('td')); // right
|
|
271
|
-
toolsTD.appendChild(tools);
|
|
272
|
-
case 15:
|
|
273
|
-
case "end":
|
|
274
|
-
return _context9.stop();
|
|
275
|
-
}
|
|
276
|
-
}, _callee8);
|
|
277
|
-
}));
|
|
278
|
-
return function (_x20) {
|
|
279
|
-
return _ref4.apply(this, arguments);
|
|
280
|
-
};
|
|
281
|
-
}());
|
|
282
|
-
if (thread && options.showThread) {
|
|
283
|
-
debug.log(' message has thread ' + thread);
|
|
284
|
-
td3.appendChild(widgets.button(dom, _iconBase.icons.iconBase + 'noun_1180164.svg',
|
|
285
|
-
// right arrow .. @@ think of stg better
|
|
286
|
-
'see thread', function (_e) {
|
|
287
|
-
debug.log('@@@@ Calling showThread thread ' + thread);
|
|
288
|
-
options.showThread(thread, options);
|
|
289
|
-
}));
|
|
290
|
-
}
|
|
291
|
-
return _context10.abrupt("return", messageRow);
|
|
292
|
-
case 49:
|
|
293
|
-
case "end":
|
|
294
|
-
return _context10.stop();
|
|
125
|
+
// set message object
|
|
126
|
+
var msg = (0, _signature.getBlankMsg)();
|
|
127
|
+
msg.id = msgId.uri;
|
|
128
|
+
msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
|
|
129
|
+
msg.content = content.value;
|
|
130
|
+
msg.maker = creator.uri;
|
|
131
|
+
|
|
132
|
+
// unsigned message
|
|
133
|
+
if (!(signature !== null && signature !== void 0 && signature.value)) debug.warn(msgId.uri + ' is unsigned'); // TODO replace with UI (colored message ?)
|
|
134
|
+
|
|
135
|
+
// signed message, get public key and check signature
|
|
136
|
+
else {
|
|
137
|
+
(0, _keys.getPublicKey)(creator.uri).then(function (publicKey) {
|
|
138
|
+
debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
|
|
139
|
+
if (!publicKey) {
|
|
140
|
+
// TODO try to recreate the publicKey
|
|
141
|
+
// if(me.uri === creator.uri) await getPrivateKey(creator.uri)
|
|
142
|
+
debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
|
|
295
143
|
}
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
144
|
+
// check that publicKey is a valid hex string
|
|
145
|
+
var regex = /[0-9A-Fa-f]{6}/g;
|
|
146
|
+
if (!(publicKey !== null && publicKey !== void 0 && publicKey.match(regex))) debug.warn('invalid publicKey hex string\n' + creator.uri + '\n' + publicKey);
|
|
147
|
+
// verify signature
|
|
148
|
+
else if (signature !== null && signature !== void 0 && signature.value && !(0, _signature.verifySignature)(signature === null || signature === void 0 ? void 0 : signature.value, msg, publicKey)) debug.warn('invalid signature\n' + msg.id);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
var originalMessage = (0, _chatLogic.originalVersion)(message);
|
|
152
|
+
var edited = !message.sameTerm(originalMessage);
|
|
153
|
+
var sortDate = _solidLogic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()); // In message
|
|
154
|
+
|
|
155
|
+
var messageRow = dom.createElement('tr');
|
|
156
|
+
messageRow.AJAR_date = sortDate.value;
|
|
157
|
+
messageRow.AJAR_subject = message;
|
|
158
|
+
var td1 = dom.createElement('td');
|
|
159
|
+
messageRow.appendChild(td1);
|
|
160
|
+
if (!options.authorDateOnLeft) {
|
|
161
|
+
var img = dom.createElement('img');
|
|
162
|
+
img.setAttribute('style', 'max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;');
|
|
163
|
+
widgets.setImage(img, creator);
|
|
164
|
+
td1.appendChild(img);
|
|
165
|
+
} else {
|
|
166
|
+
creatorAndDate(td1, creator, widgets.shortDate(sortDate.value), message);
|
|
167
|
+
}
|
|
168
|
+
var bothDates = widgets.shortDate(sortDate.value);
|
|
169
|
+
if (edited) {
|
|
170
|
+
bothDates += ' ... ' + widgets.shortDate(date.value);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Render the content ot the message itself
|
|
174
|
+
var td2 = messageRow.appendChild(dom.createElement('td'));
|
|
175
|
+
if (!options.authorDateOnLeft) {
|
|
176
|
+
creatorAndDateHorizontal(td2, creator, bothDates,
|
|
177
|
+
// widgets.shortDate(dateString)
|
|
178
|
+
message);
|
|
179
|
+
}
|
|
180
|
+
var text = content.value.trim();
|
|
181
|
+
var isURI = /^https?:\/[^ <>]*$/i.test(text);
|
|
182
|
+
var para = null;
|
|
183
|
+
if (isURI) {
|
|
184
|
+
var isImage = /\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(text); // @@ Should use content-type not URI
|
|
185
|
+
if (isImage && options.expandImagesInline) {
|
|
186
|
+
var _img = elementForImageURI(text, options);
|
|
187
|
+
td2.appendChild(_img);
|
|
188
|
+
} else {
|
|
189
|
+
// Link but not Image
|
|
190
|
+
var anc = td2.appendChild(dom.createElement('a'));
|
|
191
|
+
para = anc.appendChild(dom.createElement('p'));
|
|
192
|
+
anc.href = text;
|
|
193
|
+
para.textContent = text;
|
|
194
|
+
td2.appendChild(anc);
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
// text
|
|
198
|
+
para = dom.createElement('p');
|
|
199
|
+
td2.appendChild(para);
|
|
200
|
+
para.textContent = text;
|
|
201
|
+
}
|
|
202
|
+
if (para) {
|
|
203
|
+
var bgcolor = colorizeByAuthor ? pad.lightColorHash(creator) : getBgColor(fresh);
|
|
204
|
+
para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
|
|
205
|
+
}
|
|
206
|
+
function getBgColor(fresh) {
|
|
207
|
+
return fresh ? '#e8ffe8' : 'white';
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Sentiment strip
|
|
211
|
+
var strip = (0, _messageTools.sentimentStripLinked)(message, message.doc());
|
|
212
|
+
if (strip.children.length) {
|
|
213
|
+
td2.appendChild(dom.createElement('br'));
|
|
214
|
+
td2.appendChild(strip);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Message tool bar button
|
|
218
|
+
var td3 = dom.createElement('td');
|
|
219
|
+
messageRow.appendChild(td3);
|
|
220
|
+
var toolsButton = widgets.button(dom, _iconBase.icons.iconBase + 'noun_243787.svg', '...');
|
|
221
|
+
td3.appendChild(toolsButton);
|
|
222
|
+
toolsButton.addEventListener('click', function (_event) {
|
|
223
|
+
if (messageRow.toolTR) {
|
|
224
|
+
// already got a toolbar? Toogle
|
|
225
|
+
messageRow.parentNode.removeChild(messageRow.toolTR);
|
|
226
|
+
delete messageRow.toolTR;
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
var toolsTR = dom.createElement('tr');
|
|
230
|
+
var tools = (0, _messageTools.messageToolbar)(message, messageRow, userContext, channelObject);
|
|
231
|
+
tools.style = 'border: 0.05em solid #888; border-radius: 0 0 0.7em 0.7em; border-top: 0; height:3.5em; background-color: #fff;'; // @@ fix
|
|
232
|
+
if (messageRow.nextSibling) {
|
|
233
|
+
messageRow.parentElement.insertBefore(toolsTR, messageRow.nextSibling);
|
|
234
|
+
} else {
|
|
235
|
+
messageRow.parentElement.appendChild(toolsTR);
|
|
236
|
+
}
|
|
237
|
+
messageRow.toolTR = toolsTR;
|
|
238
|
+
toolsTR.appendChild(dom.createElement('td')); // left
|
|
239
|
+
var toolsTD = toolsTR.appendChild(dom.createElement('td'));
|
|
240
|
+
toolsTR.appendChild(dom.createElement('td')); // right
|
|
241
|
+
toolsTD.appendChild(tools);
|
|
242
|
+
});
|
|
243
|
+
return messageRow;
|
|
299
244
|
}
|
|
300
|
-
function switchToEditor(
|
|
301
|
-
|
|
245
|
+
function switchToEditor(messageRow, message, channelObject, userContext) {
|
|
246
|
+
var messageTable = messageRow.parentNode;
|
|
247
|
+
var editRow = renderMessageEditor(channelObject, messageTable, userContext, channelObject.options, (0, _chatLogic.mostRecentVersion)(message));
|
|
248
|
+
messageTable.insertBefore(editRow, messageRow);
|
|
249
|
+
editRow.originalRow = messageRow;
|
|
250
|
+
messageRow.style.visibility = 'hidden'; // Hide the original message. unhide if user cancels edit
|
|
302
251
|
}
|
|
303
252
|
/* Control for a new message -- or editing an old message ***************
|
|
304
253
|
*
|
|
305
254
|
*/
|
|
306
|
-
function _switchToEditor() {
|
|
307
|
-
_switchToEditor = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(messageRow, message, channelObject, userContext) {
|
|
308
|
-
var messageTable, editRow;
|
|
309
|
-
return _regenerator["default"].wrap(function _callee10$(_context11) {
|
|
310
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
311
|
-
case 0:
|
|
312
|
-
messageTable = messageRow.parentNode;
|
|
313
|
-
_context11.t0 = renderMessageEditor;
|
|
314
|
-
_context11.t1 = channelObject;
|
|
315
|
-
_context11.t2 = messageTable;
|
|
316
|
-
_context11.t3 = userContext;
|
|
317
|
-
_context11.t4 = channelObject.options;
|
|
318
|
-
_context11.next = 8;
|
|
319
|
-
return (0, _chatLogic.mostRecentVersion)(message);
|
|
320
|
-
case 8:
|
|
321
|
-
_context11.t5 = _context11.sent;
|
|
322
|
-
editRow = (0, _context11.t0)(_context11.t1, _context11.t2, _context11.t3, _context11.t4, _context11.t5);
|
|
323
|
-
messageTable.insertBefore(editRow, messageRow);
|
|
324
|
-
editRow.originalRow = messageRow;
|
|
325
|
-
messageRow.style.visibility = 'hidden'; // Hide the original message. unhide if user cancels edit
|
|
326
|
-
case 13:
|
|
327
|
-
case "end":
|
|
328
|
-
return _context11.stop();
|
|
329
|
-
}
|
|
330
|
-
}, _callee10);
|
|
331
|
-
}));
|
|
332
|
-
return _switchToEditor.apply(this, arguments);
|
|
333
|
-
}
|
|
334
255
|
function renderMessageEditor(channelObject, messageTable, userContext, options, originalMessage) {
|
|
335
256
|
function revertEditing(messageEditor) {
|
|
336
257
|
messageEditor.originalRow.style.visibility = 'visible'; // restore read-only version
|
|
337
258
|
messageEditor.parentNode.removeChild(messageEditor);
|
|
338
259
|
}
|
|
339
|
-
function handleFieldInput(
|
|
260
|
+
function handleFieldInput(_x) {
|
|
340
261
|
return _handleFieldInput.apply(this, arguments);
|
|
341
262
|
}
|
|
342
263
|
function _handleFieldInput() {
|
|
@@ -354,87 +275,72 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
354
275
|
}));
|
|
355
276
|
return _handleFieldInput.apply(this, arguments);
|
|
356
277
|
}
|
|
357
|
-
function sendMessage(
|
|
278
|
+
function sendMessage(_x2, _x3) {
|
|
358
279
|
return _sendMessage.apply(this, arguments);
|
|
359
280
|
} // sendMessage
|
|
360
281
|
// DRAG AND DROP
|
|
361
282
|
function _sendMessage() {
|
|
362
|
-
_sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
363
|
-
var sendComplete,
|
|
364
|
-
return _regenerator["default"].wrap(function
|
|
365
|
-
while (1) switch (
|
|
283
|
+
_sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(text, fromMainField) {
|
|
284
|
+
var sendComplete, message, statusArea;
|
|
285
|
+
return _regenerator["default"].wrap(function _callee6$(_context7) {
|
|
286
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
366
287
|
case 0:
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
372
|
-
case 0:
|
|
373
|
-
_context7.next = 2;
|
|
374
|
-
return (0, _infinite.insertMessageIntoTable)(channelObject, messageTable, message, false, options, userContext);
|
|
375
|
-
case 2:
|
|
376
|
-
// not green
|
|
288
|
+
sendComplete = function _sendComplete(message, _text2) {
|
|
289
|
+
// const dateStamp = store.any(message, ns.dct('created'), null, message.doc())
|
|
290
|
+
// const content = $rdf.literal(text2)
|
|
291
|
+
(0, _infinite.insertMessageIntoTable)(channelObject, messageTable, message, false, options, userContext); // not green
|
|
377
292
|
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
293
|
+
if (originalMessage) {
|
|
294
|
+
// editing another message
|
|
295
|
+
var oldRow = messageEditor.originalRow;
|
|
296
|
+
// oldRow.style.display = '' // restore read-only version, re-attack
|
|
297
|
+
if (oldRow.parentNode) {
|
|
298
|
+
oldRow.parentNode.removeChild(oldRow); // No longer needed old version
|
|
299
|
+
} else {
|
|
300
|
+
debug.warn('No parentNode on old message ' + oldRow.textContent);
|
|
301
|
+
oldRow.style.backgroundColor = '#fee';
|
|
302
|
+
oldRow.style.visibility = 'hidden'; // @@ FIX THIS AND REMOVE FROM DOM INSTEAD
|
|
303
|
+
}
|
|
388
304
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
case 3:
|
|
402
|
-
case "end":
|
|
403
|
-
return _context7.stop();
|
|
404
|
-
}
|
|
405
|
-
}, _callee6);
|
|
406
|
-
}));
|
|
407
|
-
return _sendComplete.apply(this, arguments);
|
|
408
|
-
};
|
|
409
|
-
sendComplete = function _sendComplete2(_x18, _x19) {
|
|
410
|
-
return _sendComplete.apply(this, arguments);
|
|
305
|
+
messageEditor.parentNode.removeChild(messageEditor); // no longer need editor
|
|
306
|
+
} else {
|
|
307
|
+
if (fromMainField) {
|
|
308
|
+
field.value = ''; // clear from out for reuse
|
|
309
|
+
field.setAttribute('style', messageBodyStyle);
|
|
310
|
+
field.disabled = false;
|
|
311
|
+
field.scrollIntoView(options.newestFirst); // allign bottom (top)
|
|
312
|
+
field.focus(); // Start typing next line immediately
|
|
313
|
+
field.select();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
// await channelObject.div.refresh() // Add new day if nec @@ add back
|
|
411
317
|
};
|
|
318
|
+
|
|
412
319
|
// const me = authn.currentUser() // Must be logged on or wuld have got login button
|
|
413
320
|
if (fromMainField) {
|
|
414
321
|
field.setAttribute('style', messageBodyStyle + 'color: #bbb;'); // pendingedit
|
|
415
322
|
field.disabled = true;
|
|
416
323
|
}
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
return channelObject.updateMessage(text, originalMessage
|
|
420
|
-
case
|
|
421
|
-
message =
|
|
422
|
-
|
|
324
|
+
_context7.prev = 2;
|
|
325
|
+
_context7.next = 5;
|
|
326
|
+
return channelObject.updateMessage(text, originalMessage);
|
|
327
|
+
case 5:
|
|
328
|
+
message = _context7.sent;
|
|
329
|
+
_context7.next = 13;
|
|
423
330
|
break;
|
|
424
|
-
case
|
|
425
|
-
|
|
426
|
-
|
|
331
|
+
case 8:
|
|
332
|
+
_context7.prev = 8;
|
|
333
|
+
_context7.t0 = _context7["catch"](2);
|
|
427
334
|
statusArea = userContext.statusArea || messageEditor;
|
|
428
|
-
statusArea.appendChild(widgets.errorMessageBlock(dom, 'Error writing message: ' +
|
|
429
|
-
return
|
|
335
|
+
statusArea.appendChild(widgets.errorMessageBlock(dom, 'Error writing message: ' + _context7.t0));
|
|
336
|
+
return _context7.abrupt("return");
|
|
337
|
+
case 13:
|
|
338
|
+
sendComplete(message, text);
|
|
430
339
|
case 14:
|
|
431
|
-
_context8.next = 16;
|
|
432
|
-
return sendComplete(message, text);
|
|
433
|
-
case 16:
|
|
434
340
|
case "end":
|
|
435
|
-
return
|
|
341
|
+
return _context7.stop();
|
|
436
342
|
}
|
|
437
|
-
},
|
|
343
|
+
}, _callee6, null, [[2, 8]]);
|
|
438
344
|
}));
|
|
439
345
|
return _sendMessage.apply(this, arguments);
|
|
440
346
|
}
|
|
@@ -453,7 +359,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
453
359
|
}
|
|
454
360
|
}, _callee);
|
|
455
361
|
}));
|
|
456
|
-
return function (
|
|
362
|
+
return function (_x4, _x5) {
|
|
457
363
|
return _ref.apply(this, arguments);
|
|
458
364
|
};
|
|
459
365
|
}());
|
|
@@ -497,7 +403,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
497
403
|
}
|
|
498
404
|
}, _callee2, null, [[1, 11, 14, 17]]);
|
|
499
405
|
}));
|
|
500
|
-
return function droppedURIHandler(
|
|
406
|
+
return function droppedURIHandler(_x6) {
|
|
501
407
|
return _ref2.apply(this, arguments);
|
|
502
408
|
};
|
|
503
409
|
}();
|
|
@@ -508,7 +414,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
508
414
|
imageDoc = $rdf.sym(chatDocument.dir().uri + 'Image_' + Date.now() + '.png');
|
|
509
415
|
return imageDoc;
|
|
510
416
|
}
|
|
511
|
-
function tookPicture(
|
|
417
|
+
function tookPicture(_x7) {
|
|
512
418
|
return _tookPicture.apply(this, arguments);
|
|
513
419
|
} // Body of turnOnInput
|
|
514
420
|
function _tookPicture() {
|
|
@@ -585,7 +491,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
585
491
|
}
|
|
586
492
|
}, _callee3);
|
|
587
493
|
}));
|
|
588
|
-
return function (
|
|
494
|
+
return function (_x8) {
|
|
589
495
|
return _ref3.apply(this, arguments);
|
|
590
496
|
};
|
|
591
497
|
}(), false);
|
|
@@ -647,7 +553,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
647
553
|
turnOnInput();
|
|
648
554
|
Object.assign(context, userContext);
|
|
649
555
|
(0, _bookmarks.findBookmarkDocument)(context).then(function (_context) {
|
|
650
|
-
//
|
|
556
|
+
// console.log('Bookmark file: ' + context.bookmarkDocument)
|
|
651
557
|
});
|
|
652
558
|
});
|
|
653
559
|
return messageEditor;
|