solid-ui 2.4.30 → 2.4.31-13dc2247
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 +6264 -2826
- 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 +1965 -1965
- package/dist/vendors-node_modules_jsonld_lib_jsonld_js.solid-ui.js.map +1 -1
- package/lib/chat/bookmarks.js +6 -7
- package/lib/chat/bookmarks.js.map +1 -1
- package/lib/chat/chatLogic.js +251 -66
- package/lib/chat/chatLogic.js.map +1 -1
- package/lib/chat/dateFolder.js +131 -126
- package/lib/chat/dateFolder.js.map +1 -1
- package/lib/chat/infinite.js +611 -416
- package/lib/chat/infinite.js.map +1 -1
- package/lib/chat/message.js +328 -191
- package/lib/chat/message.js.map +1 -1
- package/lib/chat/messageTools.js +462 -276
- package/lib/chat/messageTools.js.map +1 -1
- package/lib/chat/thread.js +299 -208
- package/lib/chat/thread.js.map +1 -1
- package/lib/login/login.d.ts.map +1 -1
- package/lib/login/login.js +14 -18
- 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 -39
- package/lib/pad.js.map +1 -1
- package/lib/participation.d.ts +7 -7
- package/lib/participation.d.ts.map +1 -1
- package/lib/participation.js +26 -24
- package/lib/participation.js.map +1 -1
- package/lib/preferences.js +4 -0
- package/lib/preferences.js.map +1 -1
- package/lib/style.js +93 -85
- package/lib/style.js.map +1 -1
- package/lib/styleConstants.js +35 -0
- package/lib/styleConstants.js.map +1 -0
- package/lib/tabs.d.ts +0 -125
- package/lib/tabs.d.ts.map +1 -1
- package/lib/tabs.js +15 -8
- 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 +59 -115
- package/lib/utils/keyHelpers/accessData.js.map +1 -1
- package/lib/utils/keyHelpers/otherHelpers.d.ts +3 -0
- package/lib/utils/keyHelpers/otherHelpers.d.ts.map +1 -0
- package/lib/utils/keyHelpers/otherHelpers.js +22 -0
- package/lib/utils/keyHelpers/otherHelpers.js.map +1 -0
- package/lib/versionInfo.js +3 -3
- package/lib/versionInfo.js.map +1 -1
- package/lib/widgets/dragAndDrop.js +11 -19
- package/lib/widgets/dragAndDrop.js.map +1 -1
- package/lib/widgets/error.d.ts.map +1 -1
- package/lib/widgets/error.js +9 -2
- package/lib/widgets/error.js.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompletePicker.d.ts.map +1 -1
- package/lib/widgets/forms/autocomplete/autocompletePicker.js +2 -1
- package/lib/widgets/forms/autocomplete/autocompletePicker.js.map +1 -1
- package/lib/widgets/forms/basic.d.ts.map +1 -1
- package/lib/widgets/forms/basic.js +5 -4
- package/lib/widgets/forms/basic.js.map +1 -1
- package/lib/widgets/forms/fieldParams.js +2 -2
- package/lib/widgets/forms/fieldParams.js.map +1 -1
- package/lib/widgets/forms.js +9 -8
- package/lib/widgets/forms.js.map +1 -1
- package/package.json +5 -5
package/lib/chat/message.js
CHANGED
|
@@ -12,6 +12,7 @@ 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"));
|
|
15
16
|
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
16
17
|
var _infinite = require("./infinite");
|
|
17
18
|
var _messageTools = require("./messageTools");
|
|
@@ -31,7 +32,9 @@ var _signature = require("./signature");
|
|
|
31
32
|
var _keys = require("./keys");
|
|
32
33
|
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); }
|
|
33
34
|
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; }
|
|
34
|
-
function
|
|
35
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
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; } } }; }
|
|
35
38
|
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); }
|
|
36
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; } /** UI code for individual messages: display them, edit them
|
|
37
40
|
*
|
|
@@ -135,158 +138,275 @@ function creatorAndDateHorizontal(td1, creator, date, message) {
|
|
|
135
138
|
* @param userContext
|
|
136
139
|
* @returns Message Row HTML Table Element
|
|
137
140
|
*/
|
|
138
|
-
function renderMessageRow(
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
141
|
+
function renderMessageRow(_x, _x2, _x3, _x4, _x5) {
|
|
142
|
+
return _renderMessageRow.apply(this, arguments);
|
|
143
|
+
} // END OF RENDERMESSAGE
|
|
144
|
+
function _renderMessageRow() {
|
|
145
|
+
_renderMessageRow = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee9(channelObject, message, fresh, options, userContext) {
|
|
146
|
+
var unsignedMessage, colorizeByAuthor, creator, date, latestVersion, latestVersionCreator, msgId, content, versions, replies, thread, straightReplies, _iterator2, _step2, reply, signature, msg, originalMessage, edited, sortDate, messageRow, td1, img, bothDates, td2, text, isURI, para, isImage, _img, anc, bgcolor, getBgColor, strip, td3, toolsButton;
|
|
147
|
+
return _regenerator["default"].wrap(function _callee9$(_context10) {
|
|
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;
|
|
145
216
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
217
|
+
// verify signature
|
|
218
|
+
if (!(signature !== null && signature !== void 0 && signature.value)) {
|
|
219
|
+
// unsigned message
|
|
220
|
+
unsignedMessage = true;
|
|
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
|
+
}
|
|
150
261
|
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
262
|
+
// Render the content ot the message itself
|
|
263
|
+
td2 = messageRow.appendChild(dom.createElement('td'));
|
|
264
|
+
if (!options.authorDateOnLeft) {
|
|
265
|
+
creatorAndDateHorizontal(td2, creator, bothDates,
|
|
266
|
+
// widgets.shortDate(dateString)
|
|
267
|
+
message);
|
|
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
|
+
}
|
|
157
303
|
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
304
|
+
// Message tool bar button
|
|
305
|
+
td3 = dom.createElement('td');
|
|
306
|
+
messageRow.appendChild(td3);
|
|
307
|
+
toolsButton = widgets.button(dom, _iconBase.icons.iconBase + 'noun_243787.svg', '...');
|
|
308
|
+
td3.appendChild(toolsButton);
|
|
309
|
+
toolsButton.addEventListener('click', /*#__PURE__*/function () {
|
|
310
|
+
var _ref4 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee8(_event) {
|
|
311
|
+
var toolsTR, tools, toolsTD;
|
|
312
|
+
return _regenerator["default"].wrap(function _callee8$(_context9) {
|
|
313
|
+
while (1) switch (_context9.prev = _context9.next) {
|
|
314
|
+
case 0:
|
|
315
|
+
if (!messageRow.toolTR) {
|
|
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();
|
|
170
365
|
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
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
|
|
366
|
+
}, _callee9);
|
|
367
|
+
}));
|
|
368
|
+
return _renderMessageRow.apply(this, arguments);
|
|
369
|
+
}
|
|
370
|
+
function switchToEditor(_x6, _x7, _x8, _x9) {
|
|
371
|
+
return _switchToEditor.apply(this, arguments);
|
|
280
372
|
}
|
|
281
373
|
/* Control for a new message -- or editing an old message ***************
|
|
282
374
|
*
|
|
283
375
|
*/
|
|
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
|
+
}
|
|
284
404
|
function renderMessageEditor(channelObject, messageTable, userContext, options, originalMessage) {
|
|
285
405
|
function revertEditing(messageEditor) {
|
|
286
406
|
messageEditor.originalRow.style.visibility = 'visible'; // restore read-only version
|
|
287
407
|
messageEditor.parentNode.removeChild(messageEditor);
|
|
288
408
|
}
|
|
289
|
-
function handleFieldInput(
|
|
409
|
+
function handleFieldInput(_x10) {
|
|
290
410
|
return _handleFieldInput.apply(this, arguments);
|
|
291
411
|
}
|
|
292
412
|
function _handleFieldInput() {
|
|
@@ -304,68 +424,85 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
304
424
|
}));
|
|
305
425
|
return _handleFieldInput.apply(this, arguments);
|
|
306
426
|
}
|
|
307
|
-
function sendMessage(
|
|
427
|
+
function sendMessage(_x11, _x12) {
|
|
308
428
|
return _sendMessage.apply(this, arguments);
|
|
309
429
|
} // sendMessage
|
|
310
430
|
// DRAG AND DROP
|
|
311
431
|
function _sendMessage() {
|
|
312
|
-
_sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
313
|
-
var sendComplete, message, statusArea;
|
|
314
|
-
return _regenerator["default"].wrap(function
|
|
315
|
-
while (1) switch (
|
|
432
|
+
_sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee7(text, fromMainField) {
|
|
433
|
+
var sendComplete, _sendComplete, message, statusArea;
|
|
434
|
+
return _regenerator["default"].wrap(function _callee7$(_context8) {
|
|
435
|
+
while (1) switch (_context8.prev = _context8.next) {
|
|
316
436
|
case 0:
|
|
317
|
-
|
|
318
|
-
(0,
|
|
437
|
+
_sendComplete = function _sendComplete3() {
|
|
438
|
+
_sendComplete = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(message, _text2) {
|
|
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
|
|
319
447
|
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
448
|
+
if (originalMessage) {
|
|
449
|
+
// editing another message
|
|
450
|
+
oldRow = messageEditor.originalRow; // oldRow.style.display = '' // restore read-only version, re-attack
|
|
451
|
+
if (oldRow.parentNode) {
|
|
452
|
+
oldRow.parentNode.removeChild(oldRow); // No longer needed old version
|
|
453
|
+
} else {
|
|
454
|
+
debug.warn('No parentNode on old message ' + oldRow.textContent);
|
|
455
|
+
oldRow.style.backgroundColor = '#fee';
|
|
456
|
+
oldRow.style.visibility = 'hidden'; // @@ FIX THIS AND REMOVE FROM DOM INSTEAD
|
|
457
|
+
}
|
|
458
|
+
messageEditor.parentNode.removeChild(messageEditor); // no longer need editor
|
|
459
|
+
} else {
|
|
460
|
+
if (fromMainField) {
|
|
461
|
+
field.value = ''; // clear from out for reuse
|
|
462
|
+
field.setAttribute('style', messageBodyStyle);
|
|
463
|
+
field.disabled = false;
|
|
464
|
+
field.scrollIntoView(options.newestFirst); // allign bottom (top)
|
|
465
|
+
field.focus(); // Start typing next line immediately
|
|
466
|
+
field.select();
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
// await channelObject.div.refresh() // Add new day if nec @@ add back
|
|
470
|
+
case 3:
|
|
471
|
+
case "end":
|
|
472
|
+
return _context7.stop();
|
|
473
|
+
}
|
|
474
|
+
}, _callee6);
|
|
475
|
+
}));
|
|
476
|
+
return _sendComplete.apply(this, arguments);
|
|
343
477
|
};
|
|
344
|
-
|
|
478
|
+
sendComplete = function _sendComplete2(_x18, _x19) {
|
|
479
|
+
return _sendComplete.apply(this, arguments);
|
|
480
|
+
}; // const me = authn.currentUser() // Must be logged on or wuld have got login button
|
|
345
481
|
if (fromMainField) {
|
|
346
482
|
field.setAttribute('style', messageBodyStyle + 'color: #bbb;'); // pendingedit
|
|
347
483
|
field.disabled = true;
|
|
348
484
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
return channelObject.updateMessage(text, originalMessage);
|
|
352
|
-
case
|
|
353
|
-
message =
|
|
354
|
-
|
|
485
|
+
_context8.prev = 3;
|
|
486
|
+
_context8.next = 6;
|
|
487
|
+
return channelObject.updateMessage(text, originalMessage, null, options.thread);
|
|
488
|
+
case 6:
|
|
489
|
+
message = _context8.sent;
|
|
490
|
+
_context8.next = 14;
|
|
355
491
|
break;
|
|
356
|
-
case
|
|
357
|
-
|
|
358
|
-
|
|
492
|
+
case 9:
|
|
493
|
+
_context8.prev = 9;
|
|
494
|
+
_context8.t0 = _context8["catch"](3);
|
|
359
495
|
statusArea = userContext.statusArea || messageEditor;
|
|
360
|
-
statusArea.appendChild(widgets.errorMessageBlock(dom, 'Error writing message: ' +
|
|
361
|
-
return
|
|
362
|
-
case 13:
|
|
363
|
-
sendComplete(message, text);
|
|
496
|
+
statusArea.appendChild(widgets.errorMessageBlock(dom, 'Error writing message: ' + _context8.t0));
|
|
497
|
+
return _context8.abrupt("return");
|
|
364
498
|
case 14:
|
|
499
|
+
_context8.next = 16;
|
|
500
|
+
return sendComplete(message, text);
|
|
501
|
+
case 16:
|
|
365
502
|
case "end":
|
|
366
|
-
return
|
|
503
|
+
return _context8.stop();
|
|
367
504
|
}
|
|
368
|
-
},
|
|
505
|
+
}, _callee7, null, [[3, 9]]);
|
|
369
506
|
}));
|
|
370
507
|
return _sendMessage.apply(this, arguments);
|
|
371
508
|
}
|
|
@@ -384,7 +521,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
384
521
|
}
|
|
385
522
|
}, _callee);
|
|
386
523
|
}));
|
|
387
|
-
return function (
|
|
524
|
+
return function (_x13, _x14) {
|
|
388
525
|
return _ref.apply(this, arguments);
|
|
389
526
|
};
|
|
390
527
|
}());
|
|
@@ -428,7 +565,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
428
565
|
}
|
|
429
566
|
}, _callee2, null, [[1, 11, 14, 17]]);
|
|
430
567
|
}));
|
|
431
|
-
return function droppedURIHandler(
|
|
568
|
+
return function droppedURIHandler(_x15) {
|
|
432
569
|
return _ref2.apply(this, arguments);
|
|
433
570
|
};
|
|
434
571
|
}();
|
|
@@ -439,7 +576,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
439
576
|
imageDoc = $rdf.sym(chatDocument.dir().uri + 'Image_' + Date.now() + '.png');
|
|
440
577
|
return imageDoc;
|
|
441
578
|
}
|
|
442
|
-
function tookPicture(
|
|
579
|
+
function tookPicture(_x16) {
|
|
443
580
|
return _tookPicture.apply(this, arguments);
|
|
444
581
|
} // Body of turnOnInput
|
|
445
582
|
function _tookPicture() {
|
|
@@ -516,7 +653,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
516
653
|
}
|
|
517
654
|
}, _callee3);
|
|
518
655
|
}));
|
|
519
|
-
return function (
|
|
656
|
+
return function (_x17) {
|
|
520
657
|
return _ref3.apply(this, arguments);
|
|
521
658
|
};
|
|
522
659
|
}(), false);
|
|
@@ -577,7 +714,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
577
714
|
turnOnInput();
|
|
578
715
|
Object.assign(context, userContext);
|
|
579
716
|
(0, _bookmarks.findBookmarkDocument)(context).then(function (_context) {
|
|
580
|
-
//
|
|
717
|
+
// debug.log('Bookmark file: ' + context.bookmarkDocument)
|
|
581
718
|
});
|
|
582
719
|
});
|
|
583
720
|
return messageEditor;
|