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