solid-ui 2.4.27-c6bf02ea → 2.4.27-cb30461a
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/README.md +6 -1
- package/dist/805.solid-ui.min.js +1 -1
- package/dist/805.solid-ui.min.js.map +1 -1
- package/dist/solid-ui.js +5877 -2920
- package/dist/solid-ui.js.map +1 -1
- package/dist/solid-ui.min.js +1 -1
- package/dist/solid-ui.min.js.LICENSE.txt +4 -0
- 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 +103 -248
- 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 -633
- package/lib/chat/infinite.js.map +1 -1
- package/lib/chat/keys.d.ts +13 -0
- package/lib/chat/keys.d.ts.map +1 -0
- package/lib/chat/keys.js +233 -0
- package/lib/chat/keys.js.map +1 -0
- package/lib/chat/message.js +193 -289
- 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 +25 -0
- package/lib/chat/signature.d.ts.map +1 -0
- package/lib/chat/signature.js +113 -0
- package/lib/chat/signature.js.map +1 -0
- package/lib/chat/thread.js +144 -166
- 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.js +1 -24
- package/lib/login/login.js.map +1 -1
- package/lib/pad.js +1 -4
- package/lib/pad.js.map +1 -1
- package/lib/participation.js +1 -2
- package/lib/participation.js.map +1 -1
- package/lib/preferences.js +0 -4
- package/lib/preferences.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 +10 -0
- package/lib/utils/keyHelpers/accessData.d.ts.map +1 -0
- package/lib/utils/keyHelpers/accessData.js +235 -0
- package/lib/utils/keyHelpers/accessData.js.map +1 -0
- package/lib/utils/keyHelpers/acl.d.ts +20 -0
- package/lib/utils/keyHelpers/acl.d.ts.map +1 -0
- package/lib/utils/keyHelpers/acl.js +93 -0
- package/lib/utils/keyHelpers/acl.js.map +1 -0
- package/lib/versionInfo.js +2 -2
- 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/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 +5 -3
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");
|
|
@@ -28,16 +27,13 @@ var pad = _interopRequireWildcard(require("../pad"));
|
|
|
28
27
|
var style = _interopRequireWildcard(require("../style"));
|
|
29
28
|
var utils = _interopRequireWildcard(require("../utils"));
|
|
30
29
|
var widgets = _interopRequireWildcard(require("../widgets"));
|
|
30
|
+
var _signature = require("./signature");
|
|
31
|
+
var _keys = require("./keys");
|
|
31
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); }
|
|
32
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; }
|
|
33
|
-
function
|
|
34
|
-
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; }
|
|
35
|
-
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; } } }; }
|
|
36
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); }
|
|
37
|
-
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; }
|
|
38
|
-
*
|
|
39
|
-
* @packageDocumentation
|
|
40
|
-
*/ /* 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; }
|
|
41
37
|
var dom = window.document;
|
|
42
38
|
var messageBodyStyle = style.messageBodyStyle;
|
|
43
39
|
var label = utils.label;
|
|
@@ -114,232 +110,154 @@ function creatorAndDateHorizontal(td1, creator, date, message) {
|
|
|
114
110
|
/**
|
|
115
111
|
* Renders a chat message, read-only mode
|
|
116
112
|
*/
|
|
117
|
-
function renderMessageRow(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
return _regenerator["default"].wrap(function _callee9$(_context10) {
|
|
124
|
-
while (1) switch (_context10.prev = _context10.next) {
|
|
125
|
-
case 0:
|
|
126
|
-
getBgColor = function _getBgColor(fresh) {
|
|
127
|
-
return fresh ? '#e8ffe8' : 'white';
|
|
128
|
-
};
|
|
129
|
-
colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true;
|
|
130
|
-
creator = _solidLogic.store.any(message, ns.foaf('maker'));
|
|
131
|
-
date = _solidLogic.store.any(message, ns.dct('created'));
|
|
132
|
-
_context10.next = 6;
|
|
133
|
-
return (0, _chatLogic.mostRecentVersion)(message);
|
|
134
|
-
case 6:
|
|
135
|
-
latestVersion = _context10.sent;
|
|
136
|
-
content = _solidLogic.store.any(latestVersion, ns.sioc('content')); // const id = store.any(latestVersion, ns.sioc('id'))
|
|
137
|
-
// const replies = store.each(latestVersion, ns.sioc('has_reply'))
|
|
138
|
-
_context10.next = 10;
|
|
139
|
-
return (0, _chatLogic.allVersions)(message);
|
|
140
|
-
case 10:
|
|
141
|
-
versions = _context10.sent;
|
|
142
|
-
if (versions.length > 1) {
|
|
143
|
-
debug.log('renderMessageRow versions: ', versions.join(', '));
|
|
144
|
-
}
|
|
145
|
-
// be tolerant in accepting replies on any version of a message
|
|
146
|
-
replies = versions.map(function (version) {
|
|
147
|
-
return _solidLogic.store.each(version, ns.sioc('has_reply'));
|
|
148
|
-
}).flat();
|
|
149
|
-
thread = null;
|
|
150
|
-
straightReplies = [];
|
|
151
|
-
_iterator2 = _createForOfIteratorHelper(replies);
|
|
152
|
-
try {
|
|
153
|
-
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
154
|
-
reply = _step2.value;
|
|
155
|
-
if (_solidLogic.store.holds(reply, ns.rdf('type'), ns.sioc('Thread'))) {
|
|
156
|
-
thread = reply;
|
|
157
|
-
debug.log('renderMessageRow: found thread: ' + thread);
|
|
158
|
-
} else {
|
|
159
|
-
straightReplies.push(reply);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
} catch (err) {
|
|
163
|
-
_iterator2.e(err);
|
|
164
|
-
} finally {
|
|
165
|
-
_iterator2.f();
|
|
166
|
-
}
|
|
167
|
-
if (straightReplies.length > 1) {
|
|
168
|
-
debug.log('renderMessageRow: found normal replies: ', straightReplies);
|
|
169
|
-
}
|
|
170
|
-
_context10.next = 20;
|
|
171
|
-
return (0, _chatLogic.originalVersion)(message);
|
|
172
|
-
case 20:
|
|
173
|
-
originalMessage = _context10.sent;
|
|
174
|
-
edited = !message.sameTerm(originalMessage); // @@ load it first @@ Or display the new data at the old date.
|
|
175
|
-
// @@@ kludge!
|
|
176
|
-
sortDate = _solidLogic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()) || _solidLogic.store.the(message, ns.dct('created'), null, message.doc()); // In message
|
|
177
|
-
messageRow = dom.createElement('tr');
|
|
178
|
-
messageRow.AJAR_date = sortDate.value;
|
|
179
|
-
messageRow.AJAR_subject = message;
|
|
180
|
-
td1 = dom.createElement('td');
|
|
181
|
-
messageRow.appendChild(td1);
|
|
182
|
-
if (!options.authorDateOnLeft) {
|
|
183
|
-
img = dom.createElement('img');
|
|
184
|
-
img.setAttribute('style', 'max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;');
|
|
185
|
-
widgets.setImage(img, creator);
|
|
186
|
-
td1.appendChild(img);
|
|
187
|
-
} else {
|
|
188
|
-
creatorAndDate(td1, creator, widgets.shortDate(sortDate.value), message);
|
|
189
|
-
}
|
|
190
|
-
bothDates = widgets.shortDate(sortDate.value);
|
|
191
|
-
if (edited) {
|
|
192
|
-
bothDates += ' ... ' + widgets.shortDate(date.value);
|
|
193
|
-
}
|
|
113
|
+
function renderMessageRow(channelObject, message, fresh, options, userContext) {
|
|
114
|
+
var colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true;
|
|
115
|
+
var creator = _solidLogic.store.any(message, ns.foaf('maker'));
|
|
116
|
+
var date = _solidLogic.store.any(message, ns.dct('created'));
|
|
117
|
+
var latestVersion = (0, _chatLogic.mostRecentVersion)(message);
|
|
118
|
+
var latestVersionCreator = _solidLogic.store.any(latestVersion, ns.foaf('maker'));
|
|
194
119
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
// widgets.shortDate(dateString)
|
|
200
|
-
message);
|
|
201
|
-
}
|
|
202
|
-
text = content ? content.value.trim() : '??? no content?';
|
|
203
|
-
isURI = /^https?:\/[^ <>]*$/i.test(text);
|
|
204
|
-
para = null;
|
|
205
|
-
if (isURI) {
|
|
206
|
-
isImage = /\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(text); // @@ Should use content-type not URI
|
|
207
|
-
if (isImage && options.expandImagesInline) {
|
|
208
|
-
_img = elementForImageURI(text, options);
|
|
209
|
-
td2.appendChild(_img);
|
|
210
|
-
} else {
|
|
211
|
-
// Link but not Image
|
|
212
|
-
anc = td2.appendChild(dom.createElement('a'));
|
|
213
|
-
para = anc.appendChild(dom.createElement('p'));
|
|
214
|
-
anc.href = text;
|
|
215
|
-
para.textContent = text;
|
|
216
|
-
td2.appendChild(anc);
|
|
217
|
-
}
|
|
218
|
-
} else {
|
|
219
|
-
// text
|
|
220
|
-
para = dom.createElement('p');
|
|
221
|
-
td2.appendChild(para);
|
|
222
|
-
para.textContent = text;
|
|
223
|
-
}
|
|
224
|
-
if (para) {
|
|
225
|
-
bgcolor = colorizeByAuthor ? pad.lightColorHash(creator) : getBgColor(fresh);
|
|
226
|
-
para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
|
|
227
|
-
}
|
|
228
|
-
_context10.next = 40;
|
|
229
|
-
return (0, _messageTools.sentimentStripLinked)(message, message.doc());
|
|
230
|
-
case 40:
|
|
231
|
-
strip = _context10.sent;
|
|
232
|
-
if (strip.children.length) {
|
|
233
|
-
td2.appendChild(dom.createElement('br'));
|
|
234
|
-
td2.appendChild(strip);
|
|
235
|
-
}
|
|
120
|
+
// use latest content if same owner, else use original
|
|
121
|
+
var msgId = creator.uri === latestVersionCreator.uri ? latestVersion : message;
|
|
122
|
+
var content = _solidLogic.store.any(msgId, ns.sioc('content'));
|
|
123
|
+
var signature = _solidLogic.store.any(msgId, $rdf.sym("".concat(_signature.SEC, "Proof")));
|
|
236
124
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
return _context9.abrupt("return");
|
|
256
|
-
case 4:
|
|
257
|
-
toolsTR = dom.createElement('tr');
|
|
258
|
-
_context9.next = 7;
|
|
259
|
-
return (0, _messageTools.messageToolbar)(message, messageRow, _objectSpread(_objectSpread({}, userContext), {}, {
|
|
260
|
-
chatOptions: options
|
|
261
|
-
}), channelObject);
|
|
262
|
-
case 7:
|
|
263
|
-
tools = _context9.sent;
|
|
264
|
-
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
|
|
265
|
-
if (messageRow.nextSibling) {
|
|
266
|
-
messageRow.parentElement.insertBefore(toolsTR, messageRow.nextSibling);
|
|
267
|
-
} else {
|
|
268
|
-
messageRow.parentElement.appendChild(toolsTR);
|
|
269
|
-
}
|
|
270
|
-
messageRow.toolTR = toolsTR;
|
|
271
|
-
toolsTR.appendChild(dom.createElement('td')); // left
|
|
272
|
-
toolsTD = toolsTR.appendChild(dom.createElement('td'));
|
|
273
|
-
toolsTR.appendChild(dom.createElement('td')); // right
|
|
274
|
-
toolsTD.appendChild(tools);
|
|
275
|
-
case 15:
|
|
276
|
-
case "end":
|
|
277
|
-
return _context9.stop();
|
|
278
|
-
}
|
|
279
|
-
}, _callee8);
|
|
280
|
-
}));
|
|
281
|
-
return function (_x20) {
|
|
282
|
-
return _ref4.apply(this, arguments);
|
|
283
|
-
};
|
|
284
|
-
}());
|
|
285
|
-
if (thread && options.showThread) {
|
|
286
|
-
debug.log(' message has thread ' + thread);
|
|
287
|
-
td3.appendChild(widgets.button(dom, _iconBase.icons.iconBase + 'noun_1180164.svg',
|
|
288
|
-
// right arrow .. @@ think of stg better
|
|
289
|
-
'see thread', function (_e) {
|
|
290
|
-
debug.log('@@@@ Calling showThread thread ' + thread);
|
|
291
|
-
options.showThread(thread, options);
|
|
292
|
-
}));
|
|
293
|
-
}
|
|
294
|
-
return _context10.abrupt("return", messageRow);
|
|
295
|
-
case 49:
|
|
296
|
-
case "end":
|
|
297
|
-
return _context10.stop();
|
|
125
|
+
// set message object
|
|
126
|
+
var msg = (0, _signature.getBlankMsg)();
|
|
127
|
+
msg.id = msgId.uri;
|
|
128
|
+
msg.created = _solidLogic.store.any(msgId, ns.dct('created')).value;
|
|
129
|
+
msg.content = content.value;
|
|
130
|
+
msg.maker = creator.uri;
|
|
131
|
+
|
|
132
|
+
// unsigned message
|
|
133
|
+
if (!(signature !== null && signature !== void 0 && signature.value)) debug.warn(msgId.uri + ' is unsigned'); // TODO replace with UI (colored message ?)
|
|
134
|
+
|
|
135
|
+
// signed message, get public key and check signature
|
|
136
|
+
else {
|
|
137
|
+
(0, _keys.getPublicKey)(creator).then(function (publicKey) {
|
|
138
|
+
debug.log(creator.uri + '\n' + msg.created + '\n' + msg.id + '\n' + publicKey);
|
|
139
|
+
if (!publicKey) {
|
|
140
|
+
// TODO try to recreate the publicKey
|
|
141
|
+
// if(me.uri === creator.uri) await getPrivateKey(creator)
|
|
142
|
+
debug.warn('message is signed but ' + creator.uri + ' is missing publicKey');
|
|
298
143
|
}
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
144
|
+
// check that publicKey is a valid hex string
|
|
145
|
+
var regex = /[0-9A-Fa-f]{6}/g;
|
|
146
|
+
if (!(publicKey !== null && publicKey !== void 0 && publicKey.match(regex))) debug.warn('invalid publicKey hex string\n' + creator.uri + '\n' + publicKey);
|
|
147
|
+
// verify signature
|
|
148
|
+
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);
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
var originalMessage = (0, _chatLogic.originalVersion)(message);
|
|
152
|
+
var edited = !message.sameTerm(originalMessage);
|
|
153
|
+
var sortDate = _solidLogic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()); // In message
|
|
154
|
+
|
|
155
|
+
var messageRow = dom.createElement('tr');
|
|
156
|
+
messageRow.AJAR_date = sortDate.value;
|
|
157
|
+
messageRow.AJAR_subject = message;
|
|
158
|
+
var td1 = dom.createElement('td');
|
|
159
|
+
messageRow.appendChild(td1);
|
|
160
|
+
if (!options.authorDateOnLeft) {
|
|
161
|
+
var img = dom.createElement('img');
|
|
162
|
+
img.setAttribute('style', 'max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;');
|
|
163
|
+
widgets.setImage(img, creator);
|
|
164
|
+
td1.appendChild(img);
|
|
165
|
+
} else {
|
|
166
|
+
creatorAndDate(td1, creator, widgets.shortDate(sortDate.value), message);
|
|
167
|
+
}
|
|
168
|
+
var bothDates = widgets.shortDate(sortDate.value);
|
|
169
|
+
if (edited) {
|
|
170
|
+
bothDates += ' ... ' + widgets.shortDate(date.value);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
// Render the content ot the message itself
|
|
174
|
+
var td2 = messageRow.appendChild(dom.createElement('td'));
|
|
175
|
+
if (!options.authorDateOnLeft) {
|
|
176
|
+
creatorAndDateHorizontal(td2, creator, bothDates,
|
|
177
|
+
// widgets.shortDate(dateString)
|
|
178
|
+
message);
|
|
179
|
+
}
|
|
180
|
+
var text = content.value.trim();
|
|
181
|
+
var isURI = /^https?:\/[^ <>]*$/i.test(text);
|
|
182
|
+
var para = null;
|
|
183
|
+
if (isURI) {
|
|
184
|
+
var isImage = /\.(gif|jpg|jpeg|tiff|png|svg)$/i.test(text); // @@ Should use content-type not URI
|
|
185
|
+
if (isImage && options.expandImagesInline) {
|
|
186
|
+
var _img = elementForImageURI(text, options);
|
|
187
|
+
td2.appendChild(_img);
|
|
188
|
+
} else {
|
|
189
|
+
// Link but not Image
|
|
190
|
+
var anc = td2.appendChild(dom.createElement('a'));
|
|
191
|
+
para = anc.appendChild(dom.createElement('p'));
|
|
192
|
+
anc.href = text;
|
|
193
|
+
para.textContent = text;
|
|
194
|
+
td2.appendChild(anc);
|
|
195
|
+
}
|
|
196
|
+
} else {
|
|
197
|
+
// text
|
|
198
|
+
para = dom.createElement('p');
|
|
199
|
+
td2.appendChild(para);
|
|
200
|
+
para.textContent = text;
|
|
201
|
+
}
|
|
202
|
+
if (para) {
|
|
203
|
+
var bgcolor = colorizeByAuthor ? pad.lightColorHash(creator) : getBgColor(fresh);
|
|
204
|
+
para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
|
|
205
|
+
}
|
|
206
|
+
function getBgColor(fresh) {
|
|
207
|
+
return fresh ? '#e8ffe8' : 'white';
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// Sentiment strip
|
|
211
|
+
var strip = (0, _messageTools.sentimentStripLinked)(message, message.doc());
|
|
212
|
+
if (strip.children.length) {
|
|
213
|
+
td2.appendChild(dom.createElement('br'));
|
|
214
|
+
td2.appendChild(strip);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// Message tool bar button
|
|
218
|
+
var td3 = dom.createElement('td');
|
|
219
|
+
messageRow.appendChild(td3);
|
|
220
|
+
var toolsButton = widgets.button(dom, _iconBase.icons.iconBase + 'noun_243787.svg', '...');
|
|
221
|
+
td3.appendChild(toolsButton);
|
|
222
|
+
toolsButton.addEventListener('click', function (_event) {
|
|
223
|
+
if (messageRow.toolTR) {
|
|
224
|
+
// already got a toolbar? Toogle
|
|
225
|
+
messageRow.parentNode.removeChild(messageRow.toolTR);
|
|
226
|
+
delete messageRow.toolTR;
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
var toolsTR = dom.createElement('tr');
|
|
230
|
+
var tools = (0, _messageTools.messageToolbar)(message, messageRow, userContext, channelObject);
|
|
231
|
+
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
|
|
232
|
+
if (messageRow.nextSibling) {
|
|
233
|
+
messageRow.parentElement.insertBefore(toolsTR, messageRow.nextSibling);
|
|
234
|
+
} else {
|
|
235
|
+
messageRow.parentElement.appendChild(toolsTR);
|
|
236
|
+
}
|
|
237
|
+
messageRow.toolTR = toolsTR;
|
|
238
|
+
toolsTR.appendChild(dom.createElement('td')); // left
|
|
239
|
+
var toolsTD = toolsTR.appendChild(dom.createElement('td'));
|
|
240
|
+
toolsTR.appendChild(dom.createElement('td')); // right
|
|
241
|
+
toolsTD.appendChild(tools);
|
|
242
|
+
});
|
|
243
|
+
return messageRow;
|
|
302
244
|
}
|
|
303
|
-
function switchToEditor(
|
|
304
|
-
|
|
245
|
+
function switchToEditor(messageRow, message, channelObject, userContext) {
|
|
246
|
+
var messageTable = messageRow.parentNode;
|
|
247
|
+
var editRow = renderMessageEditor(channelObject, messageTable, userContext, channelObject.options, (0, _chatLogic.mostRecentVersion)(message));
|
|
248
|
+
messageTable.insertBefore(editRow, messageRow);
|
|
249
|
+
editRow.originalRow = messageRow;
|
|
250
|
+
messageRow.style.visibility = 'hidden'; // Hide the original message. unhide if user cancels edit
|
|
305
251
|
}
|
|
306
252
|
/* Control for a new message -- or editing an old message ***************
|
|
307
253
|
*
|
|
308
254
|
*/
|
|
309
|
-
function _switchToEditor() {
|
|
310
|
-
_switchToEditor = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee10(messageRow, message, channelObject, userContext) {
|
|
311
|
-
var messageTable, editRow;
|
|
312
|
-
return _regenerator["default"].wrap(function _callee10$(_context11) {
|
|
313
|
-
while (1) switch (_context11.prev = _context11.next) {
|
|
314
|
-
case 0:
|
|
315
|
-
messageTable = messageRow.parentNode;
|
|
316
|
-
_context11.t0 = renderMessageEditor;
|
|
317
|
-
_context11.t1 = channelObject;
|
|
318
|
-
_context11.t2 = messageTable;
|
|
319
|
-
_context11.t3 = userContext;
|
|
320
|
-
_context11.t4 = channelObject.options;
|
|
321
|
-
_context11.next = 8;
|
|
322
|
-
return (0, _chatLogic.mostRecentVersion)(message);
|
|
323
|
-
case 8:
|
|
324
|
-
_context11.t5 = _context11.sent;
|
|
325
|
-
editRow = (0, _context11.t0)(_context11.t1, _context11.t2, _context11.t3, _context11.t4, _context11.t5);
|
|
326
|
-
messageTable.insertBefore(editRow, messageRow);
|
|
327
|
-
editRow.originalRow = messageRow;
|
|
328
|
-
messageRow.style.visibility = 'hidden'; // Hide the original message. unhide if user cancels edit
|
|
329
|
-
case 13:
|
|
330
|
-
case "end":
|
|
331
|
-
return _context11.stop();
|
|
332
|
-
}
|
|
333
|
-
}, _callee10);
|
|
334
|
-
}));
|
|
335
|
-
return _switchToEditor.apply(this, arguments);
|
|
336
|
-
}
|
|
337
255
|
function renderMessageEditor(channelObject, messageTable, userContext, options, originalMessage) {
|
|
338
256
|
function revertEditing(messageEditor) {
|
|
339
257
|
messageEditor.originalRow.style.visibility = 'visible'; // restore read-only version
|
|
340
258
|
messageEditor.parentNode.removeChild(messageEditor);
|
|
341
259
|
}
|
|
342
|
-
function handleFieldInput(
|
|
260
|
+
function handleFieldInput(_x) {
|
|
343
261
|
return _handleFieldInput.apply(this, arguments);
|
|
344
262
|
}
|
|
345
263
|
function _handleFieldInput() {
|
|
@@ -357,86 +275,72 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
357
275
|
}));
|
|
358
276
|
return _handleFieldInput.apply(this, arguments);
|
|
359
277
|
}
|
|
360
|
-
function sendMessage(
|
|
278
|
+
function sendMessage(_x2, _x3) {
|
|
361
279
|
return _sendMessage.apply(this, arguments);
|
|
362
280
|
} // sendMessage
|
|
363
281
|
// DRAG AND DROP
|
|
364
282
|
function _sendMessage() {
|
|
365
|
-
_sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function
|
|
366
|
-
var sendComplete,
|
|
367
|
-
return _regenerator["default"].wrap(function
|
|
368
|
-
while (1) switch (
|
|
283
|
+
_sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(text, fromMainField) {
|
|
284
|
+
var sendComplete, message, statusArea;
|
|
285
|
+
return _regenerator["default"].wrap(function _callee6$(_context7) {
|
|
286
|
+
while (1) switch (_context7.prev = _context7.next) {
|
|
369
287
|
case 0:
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
while (1) switch (_context7.prev = _context7.next) {
|
|
375
|
-
case 0:
|
|
376
|
-
_context7.next = 2;
|
|
377
|
-
return (0, _infinite.insertMessageIntoTable)(channelObject, messageTable, message, false, options, userContext);
|
|
378
|
-
case 2:
|
|
379
|
-
// not green
|
|
288
|
+
sendComplete = function _sendComplete(message, _text2) {
|
|
289
|
+
// const dateStamp = store.any(message, ns.dct('created'), null, message.doc())
|
|
290
|
+
// const content = $rdf.literal(text2)
|
|
291
|
+
(0, _infinite.insertMessageIntoTable)(channelObject, messageTable, message, false, options, userContext); // not green
|
|
380
292
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
293
|
+
if (originalMessage) {
|
|
294
|
+
// editing another message
|
|
295
|
+
var oldRow = messageEditor.originalRow;
|
|
296
|
+
// oldRow.style.display = '' // restore read-only version, re-attack
|
|
297
|
+
if (oldRow.parentNode) {
|
|
298
|
+
oldRow.parentNode.removeChild(oldRow); // No longer needed old version
|
|
299
|
+
} else {
|
|
300
|
+
debug.warn('No parentNode on old message ' + oldRow.textContent);
|
|
301
|
+
oldRow.style.backgroundColor = '#fee';
|
|
302
|
+
oldRow.style.visibility = 'hidden'; // @@ FIX THIS AND REMOVE FROM DOM INSTEAD
|
|
303
|
+
}
|
|
391
304
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
case 3:
|
|
405
|
-
case "end":
|
|
406
|
-
return _context7.stop();
|
|
407
|
-
}
|
|
408
|
-
}, _callee6);
|
|
409
|
-
}));
|
|
410
|
-
return _sendComplete.apply(this, arguments);
|
|
305
|
+
messageEditor.parentNode.removeChild(messageEditor); // no longer need editor
|
|
306
|
+
} else {
|
|
307
|
+
if (fromMainField) {
|
|
308
|
+
field.value = ''; // clear from out for reuse
|
|
309
|
+
field.setAttribute('style', messageBodyStyle);
|
|
310
|
+
field.disabled = false;
|
|
311
|
+
field.scrollIntoView(options.newestFirst); // allign bottom (top)
|
|
312
|
+
field.focus(); // Start typing next line immediately
|
|
313
|
+
field.select();
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
// await channelObject.div.refresh() // Add new day if nec @@ add back
|
|
411
317
|
};
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}; // const me = authn.currentUser() // Must be logged on or wuld have got login button
|
|
318
|
+
|
|
319
|
+
// const me = authn.currentUser() // Must be logged on or wuld have got login button
|
|
415
320
|
if (fromMainField) {
|
|
416
321
|
field.setAttribute('style', messageBodyStyle + 'color: #bbb;'); // pendingedit
|
|
417
322
|
field.disabled = true;
|
|
418
323
|
}
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
return channelObject.updateMessage(text, originalMessage
|
|
422
|
-
case
|
|
423
|
-
message =
|
|
424
|
-
|
|
324
|
+
_context7.prev = 2;
|
|
325
|
+
_context7.next = 5;
|
|
326
|
+
return channelObject.updateMessage(text, originalMessage);
|
|
327
|
+
case 5:
|
|
328
|
+
message = _context7.sent;
|
|
329
|
+
_context7.next = 13;
|
|
425
330
|
break;
|
|
426
|
-
case
|
|
427
|
-
|
|
428
|
-
|
|
331
|
+
case 8:
|
|
332
|
+
_context7.prev = 8;
|
|
333
|
+
_context7.t0 = _context7["catch"](2);
|
|
429
334
|
statusArea = userContext.statusArea || messageEditor;
|
|
430
|
-
statusArea.appendChild(widgets.errorMessageBlock(dom, 'Error writing message: ' +
|
|
431
|
-
return
|
|
335
|
+
statusArea.appendChild(widgets.errorMessageBlock(dom, 'Error writing message: ' + _context7.t0));
|
|
336
|
+
return _context7.abrupt("return");
|
|
337
|
+
case 13:
|
|
338
|
+
sendComplete(message, text);
|
|
432
339
|
case 14:
|
|
433
|
-
_context8.next = 16;
|
|
434
|
-
return sendComplete(message, text);
|
|
435
|
-
case 16:
|
|
436
340
|
case "end":
|
|
437
|
-
return
|
|
341
|
+
return _context7.stop();
|
|
438
342
|
}
|
|
439
|
-
},
|
|
343
|
+
}, _callee6, null, [[2, 8]]);
|
|
440
344
|
}));
|
|
441
345
|
return _sendMessage.apply(this, arguments);
|
|
442
346
|
}
|
|
@@ -455,7 +359,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
455
359
|
}
|
|
456
360
|
}, _callee);
|
|
457
361
|
}));
|
|
458
|
-
return function (
|
|
362
|
+
return function (_x4, _x5) {
|
|
459
363
|
return _ref.apply(this, arguments);
|
|
460
364
|
};
|
|
461
365
|
}());
|
|
@@ -499,7 +403,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
499
403
|
}
|
|
500
404
|
}, _callee2, null, [[1, 11, 14, 17]]);
|
|
501
405
|
}));
|
|
502
|
-
return function droppedURIHandler(
|
|
406
|
+
return function droppedURIHandler(_x6) {
|
|
503
407
|
return _ref2.apply(this, arguments);
|
|
504
408
|
};
|
|
505
409
|
}();
|
|
@@ -510,7 +414,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
510
414
|
imageDoc = $rdf.sym(chatDocument.dir().uri + 'Image_' + Date.now() + '.png');
|
|
511
415
|
return imageDoc;
|
|
512
416
|
}
|
|
513
|
-
function tookPicture(
|
|
417
|
+
function tookPicture(_x7) {
|
|
514
418
|
return _tookPicture.apply(this, arguments);
|
|
515
419
|
} // Body of turnOnInput
|
|
516
420
|
function _tookPicture() {
|
|
@@ -587,7 +491,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
587
491
|
}
|
|
588
492
|
}, _callee3);
|
|
589
493
|
}));
|
|
590
|
-
return function (
|
|
494
|
+
return function (_x8) {
|
|
591
495
|
return _ref3.apply(this, arguments);
|
|
592
496
|
};
|
|
593
497
|
}(), false);
|
|
@@ -649,7 +553,7 @@ function renderMessageEditor(channelObject, messageTable, userContext, options,
|
|
|
649
553
|
turnOnInput();
|
|
650
554
|
Object.assign(context, userContext);
|
|
651
555
|
(0, _bookmarks.findBookmarkDocument)(context).then(function (_context) {
|
|
652
|
-
//
|
|
556
|
+
// console.log('Bookmark file: ' + context.bookmarkDocument)
|
|
653
557
|
});
|
|
654
558
|
});
|
|
655
559
|
return messageEditor;
|