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