solid-ui 2.4.32-8d90d955 → 2.4.32-9d930db7
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/{320.solid-ui.min.js → 670.solid-ui.min.js} +1 -1
- package/dist/805.solid-ui.min.js +3 -0
- package/dist/805.solid-ui.min.js.map +1 -0
- package/dist/solid-ui.js +1509 -2226
- package/dist/solid-ui.js.map +1 -1
- package/dist/solid-ui.min.js +1 -1
- package/dist/solid-ui.min.js.map +1 -1
- package/dist/vendors-node_modules_jsonld_lib_jsonld_js.solid-ui.js +1 -1
- package/dist/vendors-node_modules_jsonld_lib_jsonld_js.solid-ui.js.map +1 -1
- package/lib/chat/bookmarks.js +42 -7
- package/lib/chat/bookmarks.js.map +1 -1
- package/lib/chat/chatLogic.js +101 -226
- package/lib/chat/chatLogic.js.map +1 -1
- package/lib/chat/dateFolder.js +136 -139
- package/lib/chat/dateFolder.js.map +1 -1
- package/lib/chat/infinite.js +432 -618
- package/lib/chat/infinite.js.map +1 -1
- package/lib/chat/keys.js +3 -3
- package/lib/chat/keys.js.map +1 -1
- package/lib/chat/message.js +191 -323
- package/lib/chat/message.js.map +1 -1
- package/lib/chat/messageTools.js +276 -459
- 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/pad.js +8 -6
- package/lib/pad.js.map +1 -1
- package/lib/participation.js +6 -5
- package/lib/participation.js.map +1 -1
- package/lib/preferences.js +0 -4
- package/lib/preferences.js.map +1 -1
- package/lib/tabs.js +10 -7
- 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/utils/keyHelpers/acl.js +14 -14
- package/lib/utils/keyHelpers/acl.js.map +1 -1
- package/lib/versionInfo.js +2 -2
- package/lib/versionInfo.js.map +1 -1
- package/package.json +2 -3
- package/dist/376.solid-ui.min.js +0 -3
- package/dist/376.solid-ui.min.js.map +0 -1
- 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/dist/{376.solid-ui.min.js.LICENSE.txt → 805.solid-ui.min.js.LICENSE.txt} +0 -0
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,270 +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
|
-
latestVersionCreator = _solidLogic.store.any(latestVersion, ns.foaf('maker')); // use latest content if same owner, else use original
|
|
163
|
-
// this is may be too strict. Should we find latest valid version if any ?
|
|
164
|
-
msgId = creator.uri === (latestVersionCreator === null || latestVersionCreator === void 0 ? void 0 : latestVersionCreator.uri) ? latestVersion : message;
|
|
165
|
-
content = _solidLogic.store.any(msgId, ns.sioc('content'));
|
|
166
|
-
_context10.next = 13;
|
|
167
|
-
return (0, _chatLogic.allVersions)(msgId);
|
|
168
|
-
case 13:
|
|
169
|
-
versions = _context10.sent;
|
|
170
|
-
if (versions.length > 1) {
|
|
171
|
-
debug.log('renderMessageRow versions: ', versions.join(', '));
|
|
172
|
-
}
|
|
173
|
-
// be tolerant in accepting replies on any version of a message
|
|
174
|
-
replies = versions.map(function (version) {
|
|
175
|
-
return _solidLogic.store.each(version, ns.sioc('has_reply'));
|
|
176
|
-
}).flat();
|
|
177
|
-
thread = null;
|
|
178
|
-
straightReplies = [];
|
|
179
|
-
_iterator2 = _createForOfIteratorHelper(replies);
|
|
180
|
-
try {
|
|
181
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
182
|
-
reply = _step2.value;
|
|
183
|
-
if (_solidLogic.store.holds(reply, ns.rdf('type'), ns.sioc('Thread'))) {
|
|
184
|
-
thread = reply;
|
|
185
|
-
debug.log('renderMessageRow: found thread: ' + thread);
|
|
186
|
-
} else {
|
|
187
|
-
straightReplies.push(reply);
|
|
188
|
-
}
|
|
189
|
-
}
|
|
190
|
-
} catch (err) {
|
|
191
|
-
_iterator2.e(err);
|
|
192
|
-
} finally {
|
|
193
|
-
_iterator2.f();
|
|
194
|
-
}
|
|
195
|
-
if (straightReplies.length > 1) {
|
|
196
|
-
debug.log('renderMessageRow: found normal replies: ', straightReplies);
|
|
197
|
-
}
|
|
198
|
-
if (!thread) {
|
|
199
|
-
// thread = store.any(message, ns.sioc('has_reply'))
|
|
200
|
-
thread = _solidLogic.store.any(null, ns.sioc('has_member'), message);
|
|
201
|
-
}
|
|
202
|
-
// debug.log('@@@@ is thread' + thread)
|
|
203
|
-
|
|
204
|
-
// get signature
|
|
205
|
-
signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "proofValue"))); // set proof message object
|
|
206
|
-
msg = (0, _signature.getBlankMsg)();
|
|
207
|
-
msg.id = msgId.uri;
|
|
208
|
-
msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
|
|
209
|
-
msg.content = content.value;
|
|
210
|
-
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'));
|
|
211
145
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
debug.warn(msgId.uri + ' is unsigned'); // TODO replace with UI (colored message ?)
|
|
217
|
-
} else {
|
|
218
|
-
// signed message, get public key and check signature
|
|
219
|
-
(0, _keys.getPublicKey)(creator).then(function (publicKey) {
|
|
220
|
-
// debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey)
|
|
221
|
-
if (!publicKey) {
|
|
222
|
-
debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
|
|
223
|
-
}
|
|
224
|
-
// check that publicKey is a valid hex string
|
|
225
|
-
var regex = /[0-9A-Fa-f]{6}/g;
|
|
226
|
-
if (!(publicKey !== null && publicKey !== void 0 && publicKey.match(regex))) debug.warn('invalid publicKey hex string\n' + creator.uri + '\n' + publicKey);
|
|
227
|
-
// verify signature
|
|
228
|
-
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);
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
_context10.next = 31;
|
|
232
|
-
return (0, _chatLogic.originalVersion)(message);
|
|
233
|
-
case 31:
|
|
234
|
-
originalMessage = _context10.sent;
|
|
235
|
-
edited = !message.sameTerm(originalMessage); // @@ load it first @@ Or display the new data at the old date.
|
|
236
|
-
// @@@ kludge!
|
|
237
|
-
sortDate = _solidLogic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()) || _solidLogic.store.the(message, ns.dct('created'), null, message.doc()); // In message
|
|
238
|
-
messageRow = dom.createElement('tr');
|
|
239
|
-
if (unsignedMessage) messageRow.setAttribute('style', 'background-color: red');
|
|
240
|
-
messageRow.AJAR_date = sortDate.value;
|
|
241
|
-
messageRow.AJAR_subject = message;
|
|
242
|
-
td1 = dom.createElement('td');
|
|
243
|
-
messageRow.appendChild(td1);
|
|
244
|
-
if (!options.authorDateOnLeft) {
|
|
245
|
-
img = dom.createElement('img');
|
|
246
|
-
img.setAttribute('style', 'max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;');
|
|
247
|
-
widgets.setImage(img, creator);
|
|
248
|
-
td1.appendChild(img);
|
|
249
|
-
} else {
|
|
250
|
-
creatorAndDate(td1, creator, widgets.shortDate(sortDate.value), message);
|
|
251
|
-
}
|
|
252
|
-
bothDates = widgets.shortDate(sortDate.value);
|
|
253
|
-
if (edited) {
|
|
254
|
-
bothDates += ' ... ' + widgets.shortDate(date.value);
|
|
255
|
-
}
|
|
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")));
|
|
256
150
|
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
}
|
|
264
|
-
text = content ? content.value.trim() : '??? no content?';
|
|
265
|
-
isURI = /^https?:\/[^ <>]*$/i.test(text);
|
|
266
|
-
para = null;
|
|
267
|
-
if (isURI) {
|
|
268
|
-
isImage = /\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(text); // @@ Should use content-type not URI
|
|
269
|
-
if (isImage && options.expandImagesInline) {
|
|
270
|
-
_img = elementForImageURI(text, options);
|
|
271
|
-
td2.appendChild(_img);
|
|
272
|
-
} else {
|
|
273
|
-
// Link but not Image
|
|
274
|
-
anc = td2.appendChild(dom.createElement('a'));
|
|
275
|
-
para = anc.appendChild(dom.createElement('p'));
|
|
276
|
-
anc.href = text;
|
|
277
|
-
para.textContent = text;
|
|
278
|
-
td2.appendChild(anc);
|
|
279
|
-
}
|
|
280
|
-
} else {
|
|
281
|
-
// text
|
|
282
|
-
para = dom.createElement('p');
|
|
283
|
-
td2.appendChild(para);
|
|
284
|
-
para.textContent = text;
|
|
285
|
-
}
|
|
286
|
-
if (para) {
|
|
287
|
-
bgcolor = colorizeByAuthor ? pad.lightColorHash(creator) : getBgColor(fresh);
|
|
288
|
-
para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
|
|
289
|
-
}
|
|
290
|
-
_context10.next = 52;
|
|
291
|
-
return (0, _messageTools.sentimentStripLinked)(message, message.doc());
|
|
292
|
-
case 52:
|
|
293
|
-
strip = _context10.sent;
|
|
294
|
-
if (strip.children.length) {
|
|
295
|
-
td2.appendChild(dom.createElement('br'));
|
|
296
|
-
td2.appendChild(strip);
|
|
297
|
-
}
|
|
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;
|
|
298
157
|
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
_context9.next = 4;
|
|
312
|
-
break;
|
|
313
|
-
}
|
|
314
|
-
// already got a toolbar? Toogle
|
|
315
|
-
messageRow.parentNode.removeChild(messageRow.toolTR);
|
|
316
|
-
delete messageRow.toolTR;
|
|
317
|
-
return _context9.abrupt("return");
|
|
318
|
-
case 4:
|
|
319
|
-
toolsTR = dom.createElement('tr');
|
|
320
|
-
_context9.next = 7;
|
|
321
|
-
return (0, _messageTools.messageToolbar)(message, messageRow, _objectSpread(_objectSpread({}, userContext), {}, {
|
|
322
|
-
chatOptions: options
|
|
323
|
-
}), channelObject);
|
|
324
|
-
case 7:
|
|
325
|
-
tools = _context9.sent;
|
|
326
|
-
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
|
|
327
|
-
if (messageRow.nextSibling) {
|
|
328
|
-
messageRow.parentElement.insertBefore(toolsTR, messageRow.nextSibling);
|
|
329
|
-
} else {
|
|
330
|
-
messageRow.parentElement.appendChild(toolsTR);
|
|
331
|
-
}
|
|
332
|
-
messageRow.toolTR = toolsTR;
|
|
333
|
-
toolsTR.appendChild(dom.createElement('td')); // left
|
|
334
|
-
toolsTD = toolsTR.appendChild(dom.createElement('td'));
|
|
335
|
-
toolsTR.appendChild(dom.createElement('td')); // right
|
|
336
|
-
toolsTD.appendChild(tools);
|
|
337
|
-
case 15:
|
|
338
|
-
case "end":
|
|
339
|
-
return _context9.stop();
|
|
340
|
-
}
|
|
341
|
-
}, _callee8);
|
|
342
|
-
}));
|
|
343
|
-
return function (_x20) {
|
|
344
|
-
return _ref4.apply(this, arguments);
|
|
345
|
-
};
|
|
346
|
-
}());
|
|
347
|
-
if (thread && options.showThread) {
|
|
348
|
-
// debug.log(' message has thread ' + thread)
|
|
349
|
-
td3.appendChild(widgets.button(dom, _iconBase.icons.iconBase + 'noun_1180164.svg',
|
|
350
|
-
// right arrow .. @@ think of stg better
|
|
351
|
-
'see thread', function (_e) {
|
|
352
|
-
// debug.log('@@@@ Calling showThread thread ' + thread)
|
|
353
|
-
options.showThread(thread, options);
|
|
354
|
-
}));
|
|
355
|
-
}
|
|
356
|
-
return _context10.abrupt("return", messageRow);
|
|
357
|
-
case 61:
|
|
358
|
-
case "end":
|
|
359
|
-
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');
|
|
360
170
|
}
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
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
|
|
367
280
|
}
|
|
368
281
|
/* Control for a new message -- or editing an old message ***************
|
|
369
282
|
*
|
|
370
283
|
*/
|
|
371
|
-
function _switchToEditor() {
|
|
372
|
-
_switchToEditor = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(messageRow, message, channelObject, userContext) {
|
|
373
|
-
var messageTable, editRow;
|
|
374
|
-
return _regenerator["default"].wrap(function _callee10$(_context11) {
|
|
375
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
376
|
-
case 0:
|
|
377
|
-
messageTable = messageRow.parentNode;
|
|
378
|
-
_context11.t0 = renderMessageEditor;
|
|
379
|
-
_context11.t1 = channelObject;
|
|
380
|
-
_context11.t2 = messageTable;
|
|
381
|
-
_context11.t3 = userContext;
|
|
382
|
-
_context11.t4 = channelObject.options;
|
|
383
|
-
_context11.next = 8;
|
|
384
|
-
return (0, _chatLogic.mostRecentVersion)(message);
|
|
385
|
-
case 8:
|
|
386
|
-
_context11.t5 = _context11.sent;
|
|
387
|
-
editRow = (0, _context11.t0)(_context11.t1, _context11.t2, _context11.t3, _context11.t4, _context11.t5);
|
|
388
|
-
messageTable.insertBefore(editRow, messageRow);
|
|
389
|
-
editRow.originalRow = messageRow;
|
|
390
|
-
messageRow.style.visibility = 'hidden'; // Hide the original message. unhide if user cancels edit
|
|
391
|
-
case 13:
|
|
392
|
-
case "end":
|
|
393
|
-
return _context11.stop();
|
|
394
|
-
}
|
|
395
|
-
}, _callee10);
|
|
396
|
-
}));
|
|
397
|
-
return _switchToEditor.apply(this, arguments);
|
|
398
|
-
}
|
|
399
284
|
function renderMessageEditor(channelObject, messageTable, userContext, options, originalMessage) {
|
|
400
285
|
function revertEditing(messageEditor) {
|
|
401
286
|
messageEditor.originalRow.style.visibility = 'visible'; // restore read-only version
|
|
402
287
|
messageEditor.parentNode.removeChild(messageEditor);
|
|
403
288
|
}
|
|
404
|
-
function handleFieldInput(
|
|
289
|
+
function handleFieldInput(_x) {
|
|
405
290
|
return _handleFieldInput.apply(this, arguments);
|
|
406
291
|
}
|
|
407
292
|
function _handleFieldInput() {
|
|
@@ -419,85 +304,68 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
419
304
|
}));
|
|
420
305
|
return _handleFieldInput.apply(this, arguments);
|
|
421
306
|
}
|
|
422
|
-
function sendMessage(
|
|
307
|
+
function sendMessage(_x2, _x3) {
|
|
423
308
|
return _sendMessage.apply(this, arguments);
|
|
424
309
|
} // sendMessage
|
|
425
310
|
// DRAG AND DROP
|
|
426
311
|
function _sendMessage() {
|
|
427
|
-
_sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
428
|
-
var sendComplete,
|
|
429
|
-
return _regenerator["default"].wrap(function
|
|
430
|
-
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) {
|
|
431
316
|
case 0:
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
var oldRow;
|
|
435
|
-
return _regenerator["default"].wrap(function _callee6$(_context7) {
|
|
436
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
437
|
-
case 0:
|
|
438
|
-
_context7.next = 2;
|
|
439
|
-
return (0, _infinite.insertMessageIntoTable)(channelObject, messageTable, message, false, options, userContext);
|
|
440
|
-
case 2:
|
|
441
|
-
// not green
|
|
317
|
+
sendComplete = function _sendComplete(message, _text2) {
|
|
318
|
+
(0, _infinite.insertMessageIntoTable)(channelObject, messageTable, message, false, options, userContext); // not green
|
|
442
319
|
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
case "end":
|
|
467
|
-
return _context7.stop();
|
|
468
|
-
}
|
|
469
|
-
}, _callee6);
|
|
470
|
-
}));
|
|
471
|
-
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
|
|
472
343
|
};
|
|
473
|
-
|
|
474
|
-
return _sendComplete.apply(this, arguments);
|
|
475
|
-
}; // 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
|
|
476
345
|
if (fromMainField) {
|
|
477
346
|
field.setAttribute('style', messageBodyStyle + 'color: #bbb;'); // pendingedit
|
|
478
347
|
field.disabled = true;
|
|
479
348
|
}
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
return channelObject.updateMessage(text, originalMessage
|
|
483
|
-
case
|
|
484
|
-
message =
|
|
485
|
-
|
|
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;
|
|
486
355
|
break;
|
|
487
|
-
case
|
|
488
|
-
|
|
489
|
-
|
|
356
|
+
case 8:
|
|
357
|
+
_context7.prev = 8;
|
|
358
|
+
_context7.t0 = _context7["catch"](2);
|
|
490
359
|
statusArea = userContext.statusArea || messageEditor;
|
|
491
|
-
statusArea.appendChild(widgets.errorMessageBlock(dom, 'Error writing message: ' +
|
|
492
|
-
return
|
|
360
|
+
statusArea.appendChild(widgets.errorMessageBlock(dom, 'Error writing message: ' + _context7.t0));
|
|
361
|
+
return _context7.abrupt("return");
|
|
362
|
+
case 13:
|
|
363
|
+
sendComplete(message, text);
|
|
493
364
|
case 14:
|
|
494
|
-
_context8.next = 16;
|
|
495
|
-
return sendComplete(message, text);
|
|
496
|
-
case 16:
|
|
497
365
|
case "end":
|
|
498
|
-
return
|
|
366
|
+
return _context7.stop();
|
|
499
367
|
}
|
|
500
|
-
},
|
|
368
|
+
}, _callee6, null, [[2, 8]]);
|
|
501
369
|
}));
|
|
502
370
|
return _sendMessage.apply(this, arguments);
|
|
503
371
|
}
|
|
@@ -516,7 +384,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
516
384
|
}
|
|
517
385
|
}, _callee);
|
|
518
386
|
}));
|
|
519
|
-
return function (
|
|
387
|
+
return function (_x4, _x5) {
|
|
520
388
|
return _ref.apply(this, arguments);
|
|
521
389
|
};
|
|
522
390
|
}());
|
|
@@ -560,7 +428,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
560
428
|
}
|
|
561
429
|
}, _callee2, null, [[1, 11, 14, 17]]);
|
|
562
430
|
}));
|
|
563
|
-
return function droppedURIHandler(
|
|
431
|
+
return function droppedURIHandler(_x6) {
|
|
564
432
|
return _ref2.apply(this, arguments);
|
|
565
433
|
};
|
|
566
434
|
}();
|
|
@@ -571,7 +439,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
571
439
|
imageDoc = $rdf.sym(chatDocument.dir().uri + 'Image_' + Date.now() + '.png');
|
|
572
440
|
return imageDoc;
|
|
573
441
|
}
|
|
574
|
-
function tookPicture(
|
|
442
|
+
function tookPicture(_x7) {
|
|
575
443
|
return _tookPicture.apply(this, arguments);
|
|
576
444
|
} // Body of turnOnInput
|
|
577
445
|
function _tookPicture() {
|
|
@@ -648,7 +516,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
648
516
|
}
|
|
649
517
|
}, _callee3);
|
|
650
518
|
}));
|
|
651
|
-
return function (
|
|
519
|
+
return function (_x8) {
|
|
652
520
|
return _ref3.apply(this, arguments);
|
|
653
521
|
};
|
|
654
522
|
}(), false);
|
|
@@ -709,7 +577,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
709
577
|
turnOnInput();
|
|
710
578
|
Object.assign(context, userContext);
|
|
711
579
|
(0, _bookmarks.findBookmarkDocument)(context).then(function (_context) {
|
|
712
|
-
//
|
|
580
|
+
// console.log('Bookmark file: ' + context.bookmarkDocument)
|
|
713
581
|
});
|
|
714
582
|
});
|
|
715
583
|
return messageEditor;
|