solid-ui 2.4.31-13dc2247 → 2.4.31-26d24f44
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/805.solid-ui.min.js +1 -1
- package/dist/805.solid-ui.min.js.map +1 -1
- package/dist/solid-ui.js +1641 -4633
- package/dist/solid-ui.js.map +1 -1
- package/dist/solid-ui.min.js +1 -1
- package/dist/solid-ui.min.js.LICENSE.txt +1 -1
- package/dist/solid-ui.min.js.map +1 -1
- package/dist/vendors-node_modules_jsonld_lib_jsonld_js.solid-ui.js +1957 -1957
- package/dist/vendors-node_modules_jsonld_lib_jsonld_js.solid-ui.js.map +1 -1
- package/lib/chat/bookmarks.js +7 -6
- package/lib/chat/bookmarks.js.map +1 -1
- package/lib/chat/chatLogic.js +66 -251
- package/lib/chat/chatLogic.js.map +1 -1
- package/lib/chat/dateFolder.js +126 -131
- package/lib/chat/dateFolder.js.map +1 -1
- package/lib/chat/infinite.js +416 -611
- package/lib/chat/infinite.js.map +1 -1
- package/lib/chat/message.js +191 -328
- package/lib/chat/message.js.map +1 -1
- package/lib/chat/messageTools.js +276 -462
- package/lib/chat/messageTools.js.map +1 -1
- package/lib/chat/thread.js +208 -299
- package/lib/chat/thread.js.map +1 -1
- package/lib/preferences.js +0 -4
- package/lib/preferences.js.map +1 -1
- package/lib/tabs.js +1 -1
- package/lib/tabs.js.map +1 -1
- package/lib/utils/keyHelpers/accessData.d.ts +2 -2
- package/lib/utils/keyHelpers/accessData.d.ts.map +1 -1
- package/lib/utils/keyHelpers/accessData.js +115 -59
- package/lib/utils/keyHelpers/accessData.js.map +1 -1
- package/lib/versionInfo.js +2 -2
- package/lib/versionInfo.js.map +1 -1
- package/package.json +2 -2
- package/lib/utils/keyHelpers/otherHelpers.d.ts +0 -3
- package/lib/utils/keyHelpers/otherHelpers.d.ts.map +0 -1
- package/lib/utils/keyHelpers/otherHelpers.js +0 -22
- package/lib/utils/keyHelpers/otherHelpers.js.map +0 -1
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");
|
|
@@ -32,9 +31,7 @@ var _signature = require("./signature");
|
|
|
32
31
|
var _keys = require("./keys");
|
|
33
32
|
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
34
33
|
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
35
|
-
function
|
|
36
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
37
|
-
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; } } }; }
|
|
38
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); }
|
|
39
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; } /** UI code for individual messages: display them, edit them
|
|
40
37
|
*
|
|
@@ -138,275 +135,158 @@ function creatorAndDateHorizontal(td1, creator, date, message) {
|
|
|
138
135
|
* @param userContext
|
|
139
136
|
* @returns Message Row HTML Table Element
|
|
140
137
|
*/
|
|
141
|
-
function renderMessageRow(
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
149
|
-
case 0:
|
|
150
|
-
getBgColor = function _getBgColor(fresh) {
|
|
151
|
-
return fresh ? '#e8ffe8' : 'white';
|
|
152
|
-
};
|
|
153
|
-
unsignedMessage = false;
|
|
154
|
-
colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true; // const id = store.any(latestVersion, ns.sioc('id'))
|
|
155
|
-
// const replies = store.each(latestVersion, ns.sioc('has_reply'))
|
|
156
|
-
creator = _solidLogic.store.any(message, ns.foaf('maker'));
|
|
157
|
-
date = _solidLogic.store.any(message, ns.dct('created'));
|
|
158
|
-
_context10.next = 7;
|
|
159
|
-
return (0, _chatLogic.mostRecentVersion)(message);
|
|
160
|
-
case 7:
|
|
161
|
-
latestVersion = _context10.sent;
|
|
162
|
-
debug.log('@@@@ alain mostRecentVersion');
|
|
163
|
-
debug.log(message);
|
|
164
|
-
debug.log(latestVersion);
|
|
165
|
-
latestVersionCreator = _solidLogic.store.any(latestVersion, ns.foaf('maker')); // use latest content if same owner, else use original
|
|
166
|
-
// this is may be too strict. Should we find latest valid version if any ?
|
|
167
|
-
debug.log('@@@@ alain creator');
|
|
168
|
-
debug.log(creator);
|
|
169
|
-
debug.log(latestVersionCreator);
|
|
170
|
-
msgId = creator.uri === (latestVersionCreator === null || latestVersionCreator === void 0 ? void 0 : latestVersionCreator.uri) ? latestVersion : message;
|
|
171
|
-
content = _solidLogic.store.any(msgId, ns.sioc('content'));
|
|
172
|
-
_context10.next = 19;
|
|
173
|
-
return (0, _chatLogic.allVersions)(msgId);
|
|
174
|
-
case 19:
|
|
175
|
-
versions = _context10.sent;
|
|
176
|
-
if (versions.length > 1) {
|
|
177
|
-
debug.log('renderMessageRow versions: ', versions.join(', '));
|
|
178
|
-
}
|
|
179
|
-
// be tolerant in accepting replies on any version of a message
|
|
180
|
-
replies = versions.map(function (version) {
|
|
181
|
-
return _solidLogic.store.each(version, ns.sioc('has_reply'));
|
|
182
|
-
}).flat();
|
|
183
|
-
thread = null;
|
|
184
|
-
straightReplies = [];
|
|
185
|
-
_iterator2 = _createForOfIteratorHelper(replies);
|
|
186
|
-
try {
|
|
187
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
188
|
-
reply = _step2.value;
|
|
189
|
-
if (_solidLogic.store.holds(reply, ns.rdf('type'), ns.sioc('Thread'))) {
|
|
190
|
-
thread = reply;
|
|
191
|
-
debug.log('renderMessageRow: found thread: ' + thread);
|
|
192
|
-
} else {
|
|
193
|
-
straightReplies.push(reply);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
} catch (err) {
|
|
197
|
-
_iterator2.e(err);
|
|
198
|
-
} finally {
|
|
199
|
-
_iterator2.f();
|
|
200
|
-
}
|
|
201
|
-
if (straightReplies.length > 1) {
|
|
202
|
-
debug.log('renderMessageRow: found normal replies: ', straightReplies);
|
|
203
|
-
}
|
|
204
|
-
debug.log('@@@@ is thread');
|
|
205
|
-
if (!thread) {
|
|
206
|
-
// thread = store.any(message, ns.sioc('has_reply'))
|
|
207
|
-
thread = _solidLogic.store.any(null, ns.sioc('has_member'), message);
|
|
208
|
-
}
|
|
209
|
-
// get signature
|
|
210
|
-
signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "proofValue"))); // set proof message object
|
|
211
|
-
msg = (0, _signature.getBlankMsg)();
|
|
212
|
-
msg.id = msgId.uri;
|
|
213
|
-
msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
|
|
214
|
-
msg.content = content.value;
|
|
215
|
-
msg.maker = creator.uri;
|
|
138
|
+
function renderMessageRow(channelObject, message, fresh, options, userContext) {
|
|
139
|
+
var unsignedMessage = false;
|
|
140
|
+
var colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true;
|
|
141
|
+
var creator = _solidLogic.store.any(message, ns.foaf('maker'));
|
|
142
|
+
var date = _solidLogic.store.any(message, ns.dct('created'));
|
|
143
|
+
var latestVersion = (0, _chatLogic.mostRecentVersion)(message);
|
|
144
|
+
var latestVersionCreator = _solidLogic.store.any(latestVersion, ns.foaf('maker'));
|
|
216
145
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
debug.warn(msgId.uri + ' is unsigned'); // TODO replace with UI (colored message ?)
|
|
222
|
-
} else {
|
|
223
|
-
// signed message, get public key and check signature
|
|
224
|
-
(0, _keys.getPublicKey)(creator).then(function (publicKey) {
|
|
225
|
-
debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
|
|
226
|
-
if (!publicKey) {
|
|
227
|
-
debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
|
|
228
|
-
}
|
|
229
|
-
// check that publicKey is a valid hex string
|
|
230
|
-
var regex = /[0-9A-Fa-f]{6}/g;
|
|
231
|
-
if (!(publicKey !== null && publicKey !== void 0 && publicKey.match(regex))) debug.warn('invalid publicKey hex string\n' + creator.uri + '\n' + publicKey);
|
|
232
|
-
// verify signature
|
|
233
|
-
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);
|
|
234
|
-
});
|
|
235
|
-
}
|
|
236
|
-
_context10.next = 38;
|
|
237
|
-
return (0, _chatLogic.originalVersion)(message);
|
|
238
|
-
case 38:
|
|
239
|
-
originalMessage = _context10.sent;
|
|
240
|
-
edited = !message.sameTerm(originalMessage); // @@ load it first @@ Or display the new data at the old date.
|
|
241
|
-
// @@@ kludge!
|
|
242
|
-
sortDate = _solidLogic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()) || _solidLogic.store.the(message, ns.dct('created'), null, message.doc()); // In message
|
|
243
|
-
messageRow = dom.createElement('tr');
|
|
244
|
-
if (unsignedMessage) messageRow.setAttribute('style', 'background-color: red');
|
|
245
|
-
messageRow.AJAR_date = sortDate.value;
|
|
246
|
-
messageRow.AJAR_subject = message;
|
|
247
|
-
td1 = dom.createElement('td');
|
|
248
|
-
messageRow.appendChild(td1);
|
|
249
|
-
if (!options.authorDateOnLeft) {
|
|
250
|
-
img = dom.createElement('img');
|
|
251
|
-
img.setAttribute('style', 'max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;');
|
|
252
|
-
widgets.setImage(img, creator);
|
|
253
|
-
td1.appendChild(img);
|
|
254
|
-
} else {
|
|
255
|
-
creatorAndDate(td1, creator, widgets.shortDate(sortDate.value), message);
|
|
256
|
-
}
|
|
257
|
-
bothDates = widgets.shortDate(sortDate.value);
|
|
258
|
-
if (edited) {
|
|
259
|
-
bothDates += ' ... ' + widgets.shortDate(date.value);
|
|
260
|
-
}
|
|
146
|
+
// use latest content if same owner, else use original
|
|
147
|
+
var msgId = creator.uri === latestVersionCreator.uri ? latestVersion : message;
|
|
148
|
+
var content = _solidLogic.store.any(msgId, ns.sioc('content'));
|
|
149
|
+
var signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "proofValue")));
|
|
261
150
|
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
}
|
|
269
|
-
text = content ? content.value.trim() : '??? no content?';
|
|
270
|
-
isURI = /^https?:\/[^ <>]*$/i.test(text);
|
|
271
|
-
para = null;
|
|
272
|
-
if (isURI) {
|
|
273
|
-
isImage = /\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(text); // @@ Should use content-type not URI
|
|
274
|
-
if (isImage && options.expandImagesInline) {
|
|
275
|
-
_img = elementForImageURI(text, options);
|
|
276
|
-
td2.appendChild(_img);
|
|
277
|
-
} else {
|
|
278
|
-
// Link but not Image
|
|
279
|
-
anc = td2.appendChild(dom.createElement('a'));
|
|
280
|
-
para = anc.appendChild(dom.createElement('p'));
|
|
281
|
-
anc.href = text;
|
|
282
|
-
para.textContent = text;
|
|
283
|
-
td2.appendChild(anc);
|
|
284
|
-
}
|
|
285
|
-
} else {
|
|
286
|
-
// text
|
|
287
|
-
para = dom.createElement('p');
|
|
288
|
-
td2.appendChild(para);
|
|
289
|
-
para.textContent = text;
|
|
290
|
-
}
|
|
291
|
-
if (para) {
|
|
292
|
-
bgcolor = colorizeByAuthor ? pad.lightColorHash(creator) : getBgColor(fresh);
|
|
293
|
-
para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
|
|
294
|
-
}
|
|
295
|
-
_context10.next = 59;
|
|
296
|
-
return (0, _messageTools.sentimentStripLinked)(message, message.doc());
|
|
297
|
-
case 59:
|
|
298
|
-
strip = _context10.sent;
|
|
299
|
-
if (strip.children.length) {
|
|
300
|
-
td2.appendChild(dom.createElement('br'));
|
|
301
|
-
td2.appendChild(strip);
|
|
302
|
-
}
|
|
151
|
+
// set message object
|
|
152
|
+
var msg = (0, _signature.getBlankMsg)();
|
|
153
|
+
msg.id = msgId.uri;
|
|
154
|
+
msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
|
|
155
|
+
msg.content = content.value;
|
|
156
|
+
msg.maker = creator.uri;
|
|
303
157
|
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
_context9.next = 4;
|
|
317
|
-
break;
|
|
318
|
-
}
|
|
319
|
-
// already got a toolbar? Toogle
|
|
320
|
-
messageRow.parentNode.removeChild(messageRow.toolTR);
|
|
321
|
-
delete messageRow.toolTR;
|
|
322
|
-
return _context9.abrupt("return");
|
|
323
|
-
case 4:
|
|
324
|
-
toolsTR = dom.createElement('tr');
|
|
325
|
-
_context9.next = 7;
|
|
326
|
-
return (0, _messageTools.messageToolbar)(message, messageRow, _objectSpread(_objectSpread({}, userContext), {}, {
|
|
327
|
-
chatOptions: options
|
|
328
|
-
}), channelObject);
|
|
329
|
-
case 7:
|
|
330
|
-
tools = _context9.sent;
|
|
331
|
-
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
|
|
332
|
-
if (messageRow.nextSibling) {
|
|
333
|
-
messageRow.parentElement.insertBefore(toolsTR, messageRow.nextSibling);
|
|
334
|
-
} else {
|
|
335
|
-
messageRow.parentElement.appendChild(toolsTR);
|
|
336
|
-
}
|
|
337
|
-
messageRow.toolTR = toolsTR;
|
|
338
|
-
toolsTR.appendChild(dom.createElement('td')); // left
|
|
339
|
-
toolsTD = toolsTR.appendChild(dom.createElement('td'));
|
|
340
|
-
toolsTR.appendChild(dom.createElement('td')); // right
|
|
341
|
-
toolsTD.appendChild(tools);
|
|
342
|
-
case 15:
|
|
343
|
-
case "end":
|
|
344
|
-
return _context9.stop();
|
|
345
|
-
}
|
|
346
|
-
}, _callee8);
|
|
347
|
-
}));
|
|
348
|
-
return function (_x20) {
|
|
349
|
-
return _ref4.apply(this, arguments);
|
|
350
|
-
};
|
|
351
|
-
}());
|
|
352
|
-
if (thread && options.showThread) {
|
|
353
|
-
debug.log(' message has thread ' + thread);
|
|
354
|
-
td3.appendChild(widgets.button(dom, _iconBase.icons.iconBase + 'noun_1180164.svg',
|
|
355
|
-
// right arrow .. @@ think of stg better
|
|
356
|
-
'see thread', function (_e) {
|
|
357
|
-
debug.log('@@@@ Calling showThread thread ' + thread);
|
|
358
|
-
options.showThread(thread, options);
|
|
359
|
-
}));
|
|
360
|
-
}
|
|
361
|
-
return _context10.abrupt("return", messageRow);
|
|
362
|
-
case 68:
|
|
363
|
-
case "end":
|
|
364
|
-
return _context10.stop();
|
|
158
|
+
// unsigned message
|
|
159
|
+
if (!(signature !== null && signature !== void 0 && signature.value)) {
|
|
160
|
+
unsignedMessage = true;
|
|
161
|
+
debug.warn(msgId.uri + ' is unsigned'); // TODO replace with UI (colored message ?)
|
|
162
|
+
} else {
|
|
163
|
+
// signed message, get public key and check signature
|
|
164
|
+
(0, _keys.getPublicKey)(creator).then(function (publicKey) {
|
|
165
|
+
debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
|
|
166
|
+
if (!publicKey) {
|
|
167
|
+
// TODO try to recreate the publicKey
|
|
168
|
+
// if(me.uri === creator.uri) await getPrivateKey(creator)
|
|
169
|
+
debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
|
|
365
170
|
}
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
171
|
+
// check that publicKey is a valid hex string
|
|
172
|
+
var regex = /[0-9A-Fa-f]{6}/g;
|
|
173
|
+
if (!(publicKey !== null && publicKey !== void 0 && publicKey.match(regex))) debug.warn('invalid publicKey hex string\n' + creator.uri + '\n' + publicKey);
|
|
174
|
+
// verify signature
|
|
175
|
+
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);
|
|
176
|
+
});
|
|
177
|
+
}
|
|
178
|
+
var originalMessage = (0, _chatLogic.originalVersion)(message);
|
|
179
|
+
var edited = !message.sameTerm(originalMessage);
|
|
180
|
+
var sortDate = _solidLogic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()); // In message
|
|
181
|
+
|
|
182
|
+
var messageRow = dom.createElement('tr');
|
|
183
|
+
if (unsignedMessage) messageRow.setAttribute('style', 'background-color: red');
|
|
184
|
+
messageRow.AJAR_date = sortDate.value;
|
|
185
|
+
messageRow.AJAR_subject = message;
|
|
186
|
+
var td1 = dom.createElement('td');
|
|
187
|
+
messageRow.appendChild(td1);
|
|
188
|
+
if (!options.authorDateOnLeft) {
|
|
189
|
+
var img = dom.createElement('img');
|
|
190
|
+
img.setAttribute('style', 'max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;');
|
|
191
|
+
widgets.setImage(img, creator);
|
|
192
|
+
td1.appendChild(img);
|
|
193
|
+
} else {
|
|
194
|
+
creatorAndDate(td1, creator, widgets.shortDate(sortDate.value), message);
|
|
195
|
+
}
|
|
196
|
+
var bothDates = widgets.shortDate(sortDate.value);
|
|
197
|
+
if (edited) {
|
|
198
|
+
bothDates += ' ... ' + widgets.shortDate(date.value);
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Render the content ot the message itself
|
|
202
|
+
var td2 = messageRow.appendChild(dom.createElement('td'));
|
|
203
|
+
if (!options.authorDateOnLeft) {
|
|
204
|
+
creatorAndDateHorizontal(td2, creator, bothDates,
|
|
205
|
+
// widgets.shortDate(dateString)
|
|
206
|
+
message);
|
|
207
|
+
}
|
|
208
|
+
var text = content.value.trim();
|
|
209
|
+
var isURI = /^https?:\/[^ <>]*$/i.test(text);
|
|
210
|
+
var para = null;
|
|
211
|
+
if (isURI) {
|
|
212
|
+
var isImage = /\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(text); // @@ Should use content-type not URI
|
|
213
|
+
if (isImage && options.expandImagesInline) {
|
|
214
|
+
var _img = elementForImageURI(text, options);
|
|
215
|
+
td2.appendChild(_img);
|
|
216
|
+
} else {
|
|
217
|
+
// Link but not Image
|
|
218
|
+
var anc = td2.appendChild(dom.createElement('a'));
|
|
219
|
+
para = anc.appendChild(dom.createElement('p'));
|
|
220
|
+
anc.href = text;
|
|
221
|
+
para.textContent = text;
|
|
222
|
+
td2.appendChild(anc);
|
|
223
|
+
}
|
|
224
|
+
} else {
|
|
225
|
+
// text
|
|
226
|
+
para = dom.createElement('p');
|
|
227
|
+
td2.appendChild(para);
|
|
228
|
+
para.textContent = text;
|
|
229
|
+
}
|
|
230
|
+
if (para) {
|
|
231
|
+
var bgcolor = colorizeByAuthor ? pad.lightColorHash(creator) : getBgColor(fresh);
|
|
232
|
+
para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
|
|
233
|
+
}
|
|
234
|
+
function getBgColor(fresh) {
|
|
235
|
+
return fresh ? '#e8ffe8' : 'white';
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
// Sentiment strip
|
|
239
|
+
var strip = (0, _messageTools.sentimentStripLinked)(message, message.doc());
|
|
240
|
+
if (strip.children.length) {
|
|
241
|
+
td2.appendChild(dom.createElement('br'));
|
|
242
|
+
td2.appendChild(strip);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
// Message tool bar button
|
|
246
|
+
var td3 = dom.createElement('td');
|
|
247
|
+
messageRow.appendChild(td3);
|
|
248
|
+
var toolsButton = widgets.button(dom, _iconBase.icons.iconBase + 'noun_243787.svg', '...');
|
|
249
|
+
td3.appendChild(toolsButton);
|
|
250
|
+
toolsButton.addEventListener('click', function (_event) {
|
|
251
|
+
if (messageRow.toolTR) {
|
|
252
|
+
// already got a toolbar? Toogle
|
|
253
|
+
messageRow.parentNode.removeChild(messageRow.toolTR);
|
|
254
|
+
delete messageRow.toolTR;
|
|
255
|
+
return;
|
|
256
|
+
}
|
|
257
|
+
var toolsTR = dom.createElement('tr');
|
|
258
|
+
var tools = (0, _messageTools.messageToolbar)(message, messageRow, userContext, channelObject);
|
|
259
|
+
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
|
|
260
|
+
if (messageRow.nextSibling) {
|
|
261
|
+
messageRow.parentElement.insertBefore(toolsTR, messageRow.nextSibling);
|
|
262
|
+
} else {
|
|
263
|
+
messageRow.parentElement.appendChild(toolsTR);
|
|
264
|
+
}
|
|
265
|
+
messageRow.toolTR = toolsTR;
|
|
266
|
+
toolsTR.appendChild(dom.createElement('td')); // left
|
|
267
|
+
var toolsTD = toolsTR.appendChild(dom.createElement('td'));
|
|
268
|
+
toolsTR.appendChild(dom.createElement('td')); // right
|
|
269
|
+
toolsTD.appendChild(tools);
|
|
270
|
+
});
|
|
271
|
+
return messageRow;
|
|
272
|
+
} // END OF RENDERMESSAGE
|
|
273
|
+
|
|
274
|
+
function switchToEditor(messageRow, message, channelObject, userContext) {
|
|
275
|
+
var messageTable = messageRow.parentNode;
|
|
276
|
+
var editRow = renderMessageEditor(channelObject, messageTable, userContext, channelObject.options, (0, _chatLogic.mostRecentVersion)(message));
|
|
277
|
+
messageTable.insertBefore(editRow, messageRow);
|
|
278
|
+
editRow.originalRow = messageRow;
|
|
279
|
+
messageRow.style.visibility = 'hidden'; // Hide the original message. unhide if user cancels edit
|
|
372
280
|
}
|
|
373
281
|
/* Control for a new message -- or editing an old message ***************
|
|
374
282
|
*
|
|
375
283
|
*/
|
|
376
|
-
function _switchToEditor() {
|
|
377
|
-
_switchToEditor = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(messageRow, message, channelObject, userContext) {
|
|
378
|
-
var messageTable, editRow;
|
|
379
|
-
return _regenerator["default"].wrap(function _callee10$(_context11) {
|
|
380
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
381
|
-
case 0:
|
|
382
|
-
messageTable = messageRow.parentNode;
|
|
383
|
-
_context11.t0 = renderMessageEditor;
|
|
384
|
-
_context11.t1 = channelObject;
|
|
385
|
-
_context11.t2 = messageTable;
|
|
386
|
-
_context11.t3 = userContext;
|
|
387
|
-
_context11.t4 = channelObject.options;
|
|
388
|
-
_context11.next = 8;
|
|
389
|
-
return (0, _chatLogic.mostRecentVersion)(message);
|
|
390
|
-
case 8:
|
|
391
|
-
_context11.t5 = _context11.sent;
|
|
392
|
-
editRow = (0, _context11.t0)(_context11.t1, _context11.t2, _context11.t3, _context11.t4, _context11.t5);
|
|
393
|
-
messageTable.insertBefore(editRow, messageRow);
|
|
394
|
-
editRow.originalRow = messageRow;
|
|
395
|
-
messageRow.style.visibility = 'hidden'; // Hide the original message. unhide if user cancels edit
|
|
396
|
-
case 13:
|
|
397
|
-
case "end":
|
|
398
|
-
return _context11.stop();
|
|
399
|
-
}
|
|
400
|
-
}, _callee10);
|
|
401
|
-
}));
|
|
402
|
-
return _switchToEditor.apply(this, arguments);
|
|
403
|
-
}
|
|
404
284
|
function renderMessageEditor(channelObject, messageTable, userContext, options, originalMessage) {
|
|
405
285
|
function revertEditing(messageEditor) {
|
|
406
286
|
messageEditor.originalRow.style.visibility = 'visible'; // restore read-only version
|
|
407
287
|
messageEditor.parentNode.removeChild(messageEditor);
|
|
408
288
|
}
|
|
409
|
-
function handleFieldInput(
|
|
289
|
+
function handleFieldInput(_x) {
|
|
410
290
|
return _handleFieldInput.apply(this, arguments);
|
|
411
291
|
}
|
|
412
292
|
function _handleFieldInput() {
|
|
@@ -424,85 +304,68 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
424
304
|
}));
|
|
425
305
|
return _handleFieldInput.apply(this, arguments);
|
|
426
306
|
}
|
|
427
|
-
function sendMessage(
|
|
307
|
+
function sendMessage(_x2, _x3) {
|
|
428
308
|
return _sendMessage.apply(this, arguments);
|
|
429
309
|
} // sendMessage
|
|
430
310
|
// DRAG AND DROP
|
|
431
311
|
function _sendMessage() {
|
|
432
|
-
_sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
433
|
-
var sendComplete,
|
|
434
|
-
return _regenerator["default"].wrap(function
|
|
435
|
-
while (1) switch (
|
|
312
|
+
_sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(text, fromMainField) {
|
|
313
|
+
var sendComplete, message, statusArea;
|
|
314
|
+
return _regenerator["default"].wrap(function _callee6$(_context7) {
|
|
315
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
436
316
|
case 0:
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
var oldRow;
|
|
440
|
-
return _regenerator["default"].wrap(function _callee6$(_context7) {
|
|
441
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
442
|
-
case 0:
|
|
443
|
-
_context7.next = 2;
|
|
444
|
-
return (0, _infinite.insertMessageIntoTable)(channelObject, messageTable, message, false, options, userContext);
|
|
445
|
-
case 2:
|
|
446
|
-
// not green
|
|
317
|
+
sendComplete = function _sendComplete(message, _text2) {
|
|
318
|
+
(0, _infinite.insertMessageIntoTable)(channelObject, messageTable, message, false, options, userContext); // not green
|
|
447
319
|
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
case "end":
|
|
472
|
-
return _context7.stop();
|
|
473
|
-
}
|
|
474
|
-
}, _callee6);
|
|
475
|
-
}));
|
|
476
|
-
return _sendComplete.apply(this, arguments);
|
|
320
|
+
if (originalMessage) {
|
|
321
|
+
// editing another message
|
|
322
|
+
var oldRow = messageEditor.originalRow;
|
|
323
|
+
// oldRow.style.display = '' // restore read-only version, re-attack
|
|
324
|
+
if (oldRow.parentNode) {
|
|
325
|
+
oldRow.parentNode.removeChild(oldRow); // No longer needed old version
|
|
326
|
+
} else {
|
|
327
|
+
debug.warn('No parentNode on old message ' + oldRow.textContent);
|
|
328
|
+
oldRow.style.backgroundColor = '#fee';
|
|
329
|
+
oldRow.style.visibility = 'hidden'; // @@ FIX THIS AND REMOVE FROM DOM INSTEAD
|
|
330
|
+
}
|
|
331
|
+
messageEditor.parentNode.removeChild(messageEditor); // no longer need editor
|
|
332
|
+
} else {
|
|
333
|
+
if (fromMainField) {
|
|
334
|
+
field.value = ''; // clear from out for reuse
|
|
335
|
+
field.setAttribute('style', messageBodyStyle);
|
|
336
|
+
field.disabled = false;
|
|
337
|
+
field.scrollIntoView(options.newestFirst); // allign bottom (top)
|
|
338
|
+
field.focus(); // Start typing next line immediately
|
|
339
|
+
field.select();
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
// await channelObject.div.refresh() // Add new day if nec @@ add back
|
|
477
343
|
};
|
|
478
|
-
|
|
479
|
-
return _sendComplete.apply(this, arguments);
|
|
480
|
-
}; // const me = authn.currentUser() // Must be logged on or wuld have got login button
|
|
344
|
+
// const me = authn.currentUser() // Must be logged on or wuld have got login button
|
|
481
345
|
if (fromMainField) {
|
|
482
346
|
field.setAttribute('style', messageBodyStyle + 'color: #bbb;'); // pendingedit
|
|
483
347
|
field.disabled = true;
|
|
484
348
|
}
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
return channelObject.updateMessage(text, originalMessage
|
|
488
|
-
case
|
|
489
|
-
message =
|
|
490
|
-
|
|
349
|
+
_context7.prev = 2;
|
|
350
|
+
_context7.next = 5;
|
|
351
|
+
return channelObject.updateMessage(text, originalMessage);
|
|
352
|
+
case 5:
|
|
353
|
+
message = _context7.sent;
|
|
354
|
+
_context7.next = 13;
|
|
491
355
|
break;
|
|
492
|
-
case
|
|
493
|
-
|
|
494
|
-
|
|
356
|
+
case 8:
|
|
357
|
+
_context7.prev = 8;
|
|
358
|
+
_context7.t0 = _context7["catch"](2);
|
|
495
359
|
statusArea = userContext.statusArea || messageEditor;
|
|
496
|
-
statusArea.appendChild(widgets.errorMessageBlock(dom, 'Error writing message: ' +
|
|
497
|
-
return
|
|
360
|
+
statusArea.appendChild(widgets.errorMessageBlock(dom, 'Error writing message: ' + _context7.t0));
|
|
361
|
+
return _context7.abrupt("return");
|
|
362
|
+
case 13:
|
|
363
|
+
sendComplete(message, text);
|
|
498
364
|
case 14:
|
|
499
|
-
_context8.next = 16;
|
|
500
|
-
return sendComplete(message, text);
|
|
501
|
-
case 16:
|
|
502
365
|
case "end":
|
|
503
|
-
return
|
|
366
|
+
return _context7.stop();
|
|
504
367
|
}
|
|
505
|
-
},
|
|
368
|
+
}, _callee6, null, [[2, 8]]);
|
|
506
369
|
}));
|
|
507
370
|
return _sendMessage.apply(this, arguments);
|
|
508
371
|
}
|
|
@@ -521,7 +384,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
521
384
|
}
|
|
522
385
|
}, _callee);
|
|
523
386
|
}));
|
|
524
|
-
return function (
|
|
387
|
+
return function (_x4, _x5) {
|
|
525
388
|
return _ref.apply(this, arguments);
|
|
526
389
|
};
|
|
527
390
|
}());
|
|
@@ -565,7 +428,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
565
428
|
}
|
|
566
429
|
}, _callee2, null, [[1, 11, 14, 17]]);
|
|
567
430
|
}));
|
|
568
|
-
return function droppedURIHandler(
|
|
431
|
+
return function droppedURIHandler(_x6) {
|
|
569
432
|
return _ref2.apply(this, arguments);
|
|
570
433
|
};
|
|
571
434
|
}();
|
|
@@ -576,7 +439,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
576
439
|
imageDoc = $rdf.sym(chatDocument.dir().uri + 'Image_' + Date.now() + '.png');
|
|
577
440
|
return imageDoc;
|
|
578
441
|
}
|
|
579
|
-
function tookPicture(
|
|
442
|
+
function tookPicture(_x7) {
|
|
580
443
|
return _tookPicture.apply(this, arguments);
|
|
581
444
|
} // Body of turnOnInput
|
|
582
445
|
function _tookPicture() {
|
|
@@ -653,7 +516,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
653
516
|
}
|
|
654
517
|
}, _callee3);
|
|
655
518
|
}));
|
|
656
|
-
return function (
|
|
519
|
+
return function (_x8) {
|
|
657
520
|
return _ref3.apply(this, arguments);
|
|
658
521
|
};
|
|
659
522
|
}(), false);
|
|
@@ -714,7 +577,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
714
577
|
turnOnInput();
|
|
715
578
|
Object.assign(context, userContext);
|
|
716
579
|
(0, _bookmarks.findBookmarkDocument)(context).then(function (_context) {
|
|
717
|
-
//
|
|
580
|
+
// console.log('Bookmark file: ' + context.bookmarkDocument)
|
|
718
581
|
});
|
|
719
582
|
});
|
|
720
583
|
return messageEditor;
|