solid-ui 2.4.15 → 2.4.16-9d83fb17
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/lib/chat/bookmarks.js +14 -13
- package/lib/chat/bookmarks.js.map +1 -1
- package/lib/chat/chatLogic.js +340 -0
- package/lib/chat/chatLogic.js.map +1 -0
- package/lib/chat/dateFolder.js +12 -12
- package/lib/chat/dateFolder.js.map +1 -1
- package/lib/chat/infinite.js +285 -665
- package/lib/chat/infinite.js.map +1 -1
- package/lib/chat/message.js +445 -71
- package/lib/chat/message.js.map +1 -1
- package/lib/chat/messageTools.js +165 -103
- package/lib/chat/messageTools.js.map +1 -1
- package/lib/chat/thread.js +162 -32
- package/lib/chat/thread.js.map +1 -1
- package/lib/versionInfo.js +3 -3
- package/lib/versionInfo.js.map +1 -1
- package/lib/webpack-bundle.js +1401 -986
- package/lib/webpack-bundle.js.map +1 -1
- package/lib/widgets/buttons.d.ts.map +1 -1
- package/lib/widgets/buttons.js +8 -1
- package/lib/widgets/buttons.js.map +1 -1
- package/package.json +1 -1
package/lib/chat/message.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
3
5
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
4
6
|
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
@@ -8,10 +10,24 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
8
10
|
exports.creatorAndDate = creatorAndDate;
|
|
9
11
|
exports.creatorAndDateHorizontal = creatorAndDateHorizontal;
|
|
10
12
|
exports.elementForImageURI = elementForImageURI;
|
|
11
|
-
exports.
|
|
13
|
+
exports.renderMessageEditor = renderMessageEditor;
|
|
14
|
+
exports.renderMessageRow = renderMessageRow;
|
|
15
|
+
exports.switchToEditor = switchToEditor;
|
|
16
|
+
|
|
17
|
+
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
18
|
+
|
|
19
|
+
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
20
|
+
|
|
21
|
+
var _infinite = require("./infinite");
|
|
12
22
|
|
|
13
23
|
var _messageTools = require("./messageTools");
|
|
14
24
|
|
|
25
|
+
var _bookmarks = require("./bookmarks");
|
|
26
|
+
|
|
27
|
+
var _chatLogic = require("./chatLogic");
|
|
28
|
+
|
|
29
|
+
var debug = _interopRequireWildcard(require("../debug"));
|
|
30
|
+
|
|
15
31
|
var _index = require("../authn/index");
|
|
16
32
|
|
|
17
33
|
var _iconBase = require("../iconBase");
|
|
@@ -24,8 +40,6 @@ var ns = _interopRequireWildcard(require("../ns"));
|
|
|
24
40
|
|
|
25
41
|
var pad = _interopRequireWildcard(require("../pad"));
|
|
26
42
|
|
|
27
|
-
var rdf = _interopRequireWildcard(require("rdflib"));
|
|
28
|
-
|
|
29
43
|
var style = _interopRequireWildcard(require("../style"));
|
|
30
44
|
|
|
31
45
|
var utils = _interopRequireWildcard(require("../utils"));
|
|
@@ -36,31 +50,17 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
|
36
50
|
|
|
37
51
|
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; }
|
|
38
52
|
|
|
39
|
-
|
|
40
|
-
* Contains the [[renderMessage]] function,
|
|
41
|
-
* along with [[elementForImageURI]],
|
|
42
|
-
* [[creatorAndDate]], and [[creatorAndDateHorizontal]]
|
|
43
|
-
* @packageDocumentation
|
|
44
|
-
*/
|
|
53
|
+
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; } } }; }
|
|
45
54
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
var
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
media: _index2.media,
|
|
53
|
-
pad: pad,
|
|
54
|
-
rdf: rdf,
|
|
55
|
-
store: _logic.store,
|
|
56
|
-
style: style,
|
|
57
|
-
utils: utils,
|
|
58
|
-
widgets: widgets
|
|
59
|
-
};
|
|
60
|
-
var dom = UI.dom || window.document; // const kb = UI.store
|
|
55
|
+
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); }
|
|
56
|
+
|
|
57
|
+
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; }
|
|
58
|
+
|
|
59
|
+
// const UI = { authn, icons, ns, media, pad, rdf, store, style, utils, widgets }
|
|
60
|
+
var dom = window.document; // const store = store
|
|
61
61
|
|
|
62
|
-
var messageBodyStyle =
|
|
63
|
-
var label =
|
|
62
|
+
var messageBodyStyle = style.messageBodyStyle;
|
|
63
|
+
var label = utils.label;
|
|
64
64
|
/**
|
|
65
65
|
* HTML component for an image
|
|
66
66
|
*/
|
|
@@ -73,14 +73,14 @@ function elementForImageURI(imageUri, options) {
|
|
|
73
73
|
height = ('' + options.inlineImageHeightEms).trim();
|
|
74
74
|
}
|
|
75
75
|
|
|
76
|
-
img.setAttribute('style', 'max-height: ' + height + 'em; border-radius: 1em; margin: 0.7em;'); //
|
|
76
|
+
img.setAttribute('style', 'max-height: ' + height + 'em; border-radius: 1em; margin: 0.7em;'); // widgets.makeDropTarget(img, handleURIsDroppedOnMugshot, droppedFileHandler)
|
|
77
77
|
|
|
78
78
|
if (imageUri) img.setAttribute('src', imageUri);
|
|
79
79
|
var anchor = dom.createElement('a');
|
|
80
80
|
anchor.setAttribute('href', imageUri);
|
|
81
81
|
anchor.setAttribute('target', 'images');
|
|
82
82
|
anchor.appendChild(img);
|
|
83
|
-
|
|
83
|
+
widgets.makeDraggable(img, $rdf.sym(imageUri));
|
|
84
84
|
return anchor;
|
|
85
85
|
}
|
|
86
86
|
|
|
@@ -90,7 +90,7 @@ var anchor = function anchor(text, term) {
|
|
|
90
90
|
|
|
91
91
|
if (term && term.uri) {
|
|
92
92
|
a.setAttribute('href', term.uri);
|
|
93
|
-
a.addEventListener('click',
|
|
93
|
+
a.addEventListener('click', widgets.openHrefInOutlineMode, true);
|
|
94
94
|
a.setAttribute('style', 'color: #3B5998; text-decoration: none; '); // font-weight: bold
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -99,7 +99,8 @@ var anchor = function anchor(text, term) {
|
|
|
99
99
|
};
|
|
100
100
|
|
|
101
101
|
function nick(person) {
|
|
102
|
-
var s =
|
|
102
|
+
var s = _logic.store.any(person, ns.foaf('nick'));
|
|
103
|
+
|
|
103
104
|
if (s) return '' + s.value;
|
|
104
105
|
return '' + label(person);
|
|
105
106
|
}
|
|
@@ -113,7 +114,7 @@ function creatorAndDate(td1, creator, date, message) {
|
|
|
113
114
|
var nickAnchor = td1.appendChild(anchor(nick(creator), creator));
|
|
114
115
|
|
|
115
116
|
if (creator.uri) {
|
|
116
|
-
|
|
117
|
+
_logic.store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (_ok, _body) {
|
|
117
118
|
nickAnchor.textContent = nick(creator);
|
|
118
119
|
});
|
|
119
120
|
}
|
|
@@ -131,7 +132,7 @@ function creatorAndDateHorizontal(td1, creator, date, message) {
|
|
|
131
132
|
var nickAnchor = td1.appendChild(anchor(label(creator), creator));
|
|
132
133
|
|
|
133
134
|
if (creator.uri) {
|
|
134
|
-
|
|
135
|
+
_logic.store.fetcher.nowOrWhenFetched(creator.doc(), undefined, function (_ok, _body) {
|
|
135
136
|
nickAnchor.textContent = nick(creator);
|
|
136
137
|
});
|
|
137
138
|
}
|
|
@@ -142,65 +143,54 @@ function creatorAndDateHorizontal(td1, creator, date, message) {
|
|
|
142
143
|
td1.appendChild(dom.createElement('br'));
|
|
143
144
|
}
|
|
144
145
|
/**
|
|
145
|
-
* Renders a chat message
|
|
146
|
+
* Renders a chat message, read-only mode
|
|
146
147
|
*/
|
|
147
148
|
|
|
148
149
|
|
|
149
|
-
function
|
|
150
|
+
function renderMessageRow(channelObject, message, fresh, options, userContext) {
|
|
150
151
|
var colorizeByAuthor = options.colorizeByAuthor === '1' || options.colorizeByAuthor === true;
|
|
151
|
-
var creator = bindings['?creator'];
|
|
152
|
-
var message = bindings['?msg'];
|
|
153
|
-
var date = bindings['?date'];
|
|
154
|
-
var content = bindings['?content'];
|
|
155
|
-
var dateString = date.value;
|
|
156
|
-
var messageRow = dom.createElement('tr');
|
|
157
|
-
messageRow.AJAR_date = dateString;
|
|
158
|
-
messageRow.AJAR_subject = message;
|
|
159
152
|
|
|
160
|
-
|
|
161
|
-
messageRow.style.backgroundColor = 'yellow';
|
|
162
|
-
options.selectedElement = messageRow;
|
|
163
|
-
messageTable.selectedElement = messageRow;
|
|
164
|
-
}
|
|
153
|
+
var creator = _logic.store.any(message, ns.foaf('maker'));
|
|
165
154
|
|
|
166
|
-
var
|
|
155
|
+
var date = _logic.store.any(message, ns.dct('created'));
|
|
167
156
|
|
|
168
|
-
|
|
169
|
-
if (!ele) {
|
|
170
|
-
// empty
|
|
171
|
-
break;
|
|
172
|
-
}
|
|
157
|
+
var latestVersion = (0, _chatLogic.mostRecentVersion)(message);
|
|
173
158
|
|
|
174
|
-
|
|
159
|
+
var content = _logic.store.any(latestVersion, ns.sioc('content'));
|
|
175
160
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
done = true;
|
|
179
|
-
break;
|
|
180
|
-
}
|
|
181
|
-
}
|
|
161
|
+
var originalMessage = (0, _chatLogic.originalVersion)(message);
|
|
162
|
+
var edited = !message.sameTerm(originalMessage);
|
|
182
163
|
|
|
183
|
-
|
|
184
|
-
messageTable.appendChild(messageRow);
|
|
185
|
-
}
|
|
164
|
+
var sortDate = _logic.store.the(originalMessage, ns.dct('created'), null, originalMessage.doc()); // In message
|
|
186
165
|
|
|
166
|
+
|
|
167
|
+
var messageRow = dom.createElement('tr');
|
|
168
|
+
messageRow.AJAR_date = sortDate.value;
|
|
169
|
+
messageRow.AJAR_subject = message;
|
|
187
170
|
var td1 = dom.createElement('td');
|
|
188
171
|
messageRow.appendChild(td1);
|
|
189
172
|
|
|
190
|
-
if (options.
|
|
173
|
+
if (!options.authorDateOnLeft) {
|
|
191
174
|
var img = dom.createElement('img');
|
|
192
175
|
img.setAttribute('style', 'max-height: 2.5em; max-width: 2.5em; border-radius: 0.5em; margin: auto;');
|
|
193
|
-
|
|
176
|
+
widgets.setImage(img, creator);
|
|
194
177
|
td1.appendChild(img);
|
|
195
178
|
} else {
|
|
196
|
-
creatorAndDate(td1, creator,
|
|
179
|
+
creatorAndDate(td1, creator, widgets.shortDate(sortDate.value), message);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
var bothDates = widgets.shortDate(sortDate.value);
|
|
183
|
+
|
|
184
|
+
if (edited) {
|
|
185
|
+
bothDates += ' ... ' + widgets.shortDate(date.value);
|
|
197
186
|
} // Render the content ot the message itself
|
|
198
187
|
|
|
199
188
|
|
|
200
189
|
var td2 = messageRow.appendChild(dom.createElement('td'));
|
|
201
190
|
|
|
202
|
-
if (options.
|
|
203
|
-
creatorAndDateHorizontal(td2, creator,
|
|
191
|
+
if (!options.authorDateOnLeft) {
|
|
192
|
+
creatorAndDateHorizontal(td2, creator, bothDates, // widgets.shortDate(dateString)
|
|
193
|
+
message);
|
|
204
194
|
}
|
|
205
195
|
|
|
206
196
|
var text = content.value.trim();
|
|
@@ -230,7 +220,7 @@ function renderMessage(messageTable, bindings, fresh, options, userContext) {
|
|
|
230
220
|
}
|
|
231
221
|
|
|
232
222
|
if (para) {
|
|
233
|
-
var bgcolor = colorizeByAuthor ?
|
|
223
|
+
var bgcolor = colorizeByAuthor ? pad.lightColorHash(creator) : getBgColor(fresh);
|
|
234
224
|
para.setAttribute('style', messageBodyStyle + 'background-color: ' + bgcolor + ';');
|
|
235
225
|
}
|
|
236
226
|
|
|
@@ -249,7 +239,7 @@ function renderMessage(messageTable, bindings, fresh, options, userContext) {
|
|
|
249
239
|
|
|
250
240
|
var td3 = dom.createElement('td');
|
|
251
241
|
messageRow.appendChild(td3);
|
|
252
|
-
var toolsButton =
|
|
242
|
+
var toolsButton = widgets.button(dom, _iconBase.icons.iconBase + 'noun_243787.svg', '...');
|
|
253
243
|
td3.appendChild(toolsButton);
|
|
254
244
|
toolsButton.addEventListener('click', function (_event) {
|
|
255
245
|
if (messageRow.toolTR) {
|
|
@@ -260,7 +250,7 @@ function renderMessage(messageTable, bindings, fresh, options, userContext) {
|
|
|
260
250
|
}
|
|
261
251
|
|
|
262
252
|
var toolsTR = dom.createElement('tr');
|
|
263
|
-
var tools = (0, _messageTools.messageToolbar)(message, messageRow, userContext);
|
|
253
|
+
var tools = (0, _messageTools.messageToolbar)(message, messageRow, userContext, channelObject);
|
|
264
254
|
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
255
|
|
|
266
256
|
if (messageRow.nextSibling) {
|
|
@@ -279,4 +269,388 @@ function renderMessage(messageTable, bindings, fresh, options, userContext) {
|
|
|
279
269
|
});
|
|
280
270
|
return messageRow;
|
|
281
271
|
}
|
|
272
|
+
|
|
273
|
+
function switchToEditor(messageRow, message, channelObject, userContext) {
|
|
274
|
+
var messageTable = messageRow.parentNode;
|
|
275
|
+
var editRow = renderMessageEditor(channelObject, messageTable, userContext, channelObject.options, (0, _chatLogic.mostRecentVersion)(message));
|
|
276
|
+
messageTable.insertBefore(editRow, messageRow);
|
|
277
|
+
editRow.originalRow = messageRow;
|
|
278
|
+
messageRow.style.visibility = 'hidden'; // Hide the original message. unhide if user cancels edit
|
|
279
|
+
}
|
|
280
|
+
/* Control for a new message -- or editing an old message ***************
|
|
281
|
+
*
|
|
282
|
+
*/
|
|
283
|
+
|
|
284
|
+
|
|
285
|
+
function renderMessageEditor(channelObject, messageTable, userContext, options, originalMessage) {
|
|
286
|
+
function revertEditing(messageEditor) {
|
|
287
|
+
messageEditor.originalRow.style.visibility = 'visible'; // restore read-only version
|
|
288
|
+
|
|
289
|
+
messageEditor.parentNode.removeChild(messageEditor);
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
function handleFieldInput(_x) {
|
|
293
|
+
return _handleFieldInput.apply(this, arguments);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
function _handleFieldInput() {
|
|
297
|
+
_handleFieldInput = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee5(_event) {
|
|
298
|
+
return _regenerator["default"].wrap(function _callee5$(_context6) {
|
|
299
|
+
while (1) {
|
|
300
|
+
switch (_context6.prev = _context6.next) {
|
|
301
|
+
case 0:
|
|
302
|
+
_context6.next = 2;
|
|
303
|
+
return sendMessage(field.value, true);
|
|
304
|
+
|
|
305
|
+
case 2:
|
|
306
|
+
case "end":
|
|
307
|
+
return _context6.stop();
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
}, _callee5);
|
|
311
|
+
}));
|
|
312
|
+
return _handleFieldInput.apply(this, arguments);
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
function sendMessage(_x2, _x3) {
|
|
316
|
+
return _sendMessage.apply(this, arguments);
|
|
317
|
+
} // sendMessage
|
|
318
|
+
// DRAG AND DROP
|
|
319
|
+
|
|
320
|
+
|
|
321
|
+
function _sendMessage() {
|
|
322
|
+
_sendMessage = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee6(text, fromMainField) {
|
|
323
|
+
var sendComplete, message, statusArea;
|
|
324
|
+
return _regenerator["default"].wrap(function _callee6$(_context7) {
|
|
325
|
+
while (1) {
|
|
326
|
+
switch (_context7.prev = _context7.next) {
|
|
327
|
+
case 0:
|
|
328
|
+
sendComplete = function _sendComplete(message, _text2) {
|
|
329
|
+
// const dateStamp = store.any(message, ns.dct('created'), null, message.doc())
|
|
330
|
+
// const content = $rdf.literal(text2)
|
|
331
|
+
(0, _infinite.insertMessageIntoTable)(channelObject, messageTable, message, false, options, userContext); // not green
|
|
332
|
+
|
|
333
|
+
if (originalMessage) {
|
|
334
|
+
// editing another message
|
|
335
|
+
var oldRow = messageEditor.originalRow; // oldRow.style.display = '' // restore read-only version, re-attack
|
|
336
|
+
|
|
337
|
+
if (oldRow.parentNode) {
|
|
338
|
+
oldRow.parentNode.removeChild(oldRow); // No longer needed old version
|
|
339
|
+
} else {
|
|
340
|
+
debug.warn('No parentNode on old message ' + oldRow.textContent);
|
|
341
|
+
oldRow.style.backgroundColor = '#fee';
|
|
342
|
+
oldRow.style.visibility = 'hidden'; // @@ FIX THIS AND REMOVE FROM DOM INSTEAD
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
messageEditor.parentNode.removeChild(messageEditor); // no longer need editor
|
|
346
|
+
} else {
|
|
347
|
+
if (fromMainField) {
|
|
348
|
+
field.value = ''; // clear from out for reuse
|
|
349
|
+
|
|
350
|
+
field.setAttribute('style', messageBodyStyle);
|
|
351
|
+
field.disabled = false;
|
|
352
|
+
field.scrollIntoView(options.newestFirst); // allign bottom (top)
|
|
353
|
+
|
|
354
|
+
field.focus(); // Start typing next line immediately
|
|
355
|
+
|
|
356
|
+
field.select();
|
|
357
|
+
}
|
|
358
|
+
} // await channelObject.div.refresh() // Add new day if nec @@ add back
|
|
359
|
+
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
// const me = authn.currentUser() // Must be logged on or wuld have got login button
|
|
363
|
+
if (fromMainField) {
|
|
364
|
+
field.setAttribute('style', messageBodyStyle + 'color: #bbb;'); // pendingedit
|
|
365
|
+
|
|
366
|
+
field.disabled = true;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
_context7.prev = 2;
|
|
370
|
+
_context7.next = 5;
|
|
371
|
+
return channelObject.updateMessage(text, originalMessage);
|
|
372
|
+
|
|
373
|
+
case 5:
|
|
374
|
+
message = _context7.sent;
|
|
375
|
+
_context7.next = 13;
|
|
376
|
+
break;
|
|
377
|
+
|
|
378
|
+
case 8:
|
|
379
|
+
_context7.prev = 8;
|
|
380
|
+
_context7.t0 = _context7["catch"](2);
|
|
381
|
+
statusArea = userContext.statusArea || messageEditor;
|
|
382
|
+
statusArea.appendChild(widgets.errorMessageBlock(dom, 'Error writing message: ' + _context7.t0));
|
|
383
|
+
return _context7.abrupt("return");
|
|
384
|
+
|
|
385
|
+
case 13:
|
|
386
|
+
sendComplete(message, text);
|
|
387
|
+
|
|
388
|
+
case 14:
|
|
389
|
+
case "end":
|
|
390
|
+
return _context7.stop();
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
}, _callee6, null, [[2, 8]]);
|
|
394
|
+
}));
|
|
395
|
+
return _sendMessage.apply(this, arguments);
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
function droppedFileHandler(files) {
|
|
399
|
+
var base = messageTable.chatDocument.dir().uri;
|
|
400
|
+
widgets.uploadFiles(_logic.store.fetcher, files, base + 'Files', base + 'Pictures', /*#__PURE__*/function () {
|
|
401
|
+
var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(theFile, destURI) {
|
|
402
|
+
return _regenerator["default"].wrap(function _callee$(_context2) {
|
|
403
|
+
while (1) {
|
|
404
|
+
switch (_context2.prev = _context2.next) {
|
|
405
|
+
case 0:
|
|
406
|
+
_context2.next = 2;
|
|
407
|
+
return sendMessage(destURI);
|
|
408
|
+
|
|
409
|
+
case 2:
|
|
410
|
+
case "end":
|
|
411
|
+
return _context2.stop();
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
}, _callee);
|
|
415
|
+
}));
|
|
416
|
+
|
|
417
|
+
return function (_x4, _x5) {
|
|
418
|
+
return _ref.apply(this, arguments);
|
|
419
|
+
};
|
|
420
|
+
}());
|
|
421
|
+
} // When a set of URIs are dropped on the field
|
|
422
|
+
|
|
423
|
+
|
|
424
|
+
var droppedURIHandler = /*#__PURE__*/function () {
|
|
425
|
+
var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(uris) {
|
|
426
|
+
var _iterator, _step, uri;
|
|
427
|
+
|
|
428
|
+
return _regenerator["default"].wrap(function _callee2$(_context3) {
|
|
429
|
+
while (1) {
|
|
430
|
+
switch (_context3.prev = _context3.next) {
|
|
431
|
+
case 0:
|
|
432
|
+
_iterator = _createForOfIteratorHelper(uris);
|
|
433
|
+
_context3.prev = 1;
|
|
434
|
+
|
|
435
|
+
_iterator.s();
|
|
436
|
+
|
|
437
|
+
case 3:
|
|
438
|
+
if ((_step = _iterator.n()).done) {
|
|
439
|
+
_context3.next = 9;
|
|
440
|
+
break;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
uri = _step.value;
|
|
444
|
+
_context3.next = 7;
|
|
445
|
+
return sendMessage(uri);
|
|
446
|
+
|
|
447
|
+
case 7:
|
|
448
|
+
_context3.next = 3;
|
|
449
|
+
break;
|
|
450
|
+
|
|
451
|
+
case 9:
|
|
452
|
+
_context3.next = 14;
|
|
453
|
+
break;
|
|
454
|
+
|
|
455
|
+
case 11:
|
|
456
|
+
_context3.prev = 11;
|
|
457
|
+
_context3.t0 = _context3["catch"](1);
|
|
458
|
+
|
|
459
|
+
_iterator.e(_context3.t0);
|
|
460
|
+
|
|
461
|
+
case 14:
|
|
462
|
+
_context3.prev = 14;
|
|
463
|
+
|
|
464
|
+
_iterator.f();
|
|
465
|
+
|
|
466
|
+
return _context3.finish(14);
|
|
467
|
+
|
|
468
|
+
case 17:
|
|
469
|
+
case "end":
|
|
470
|
+
return _context3.stop();
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
}, _callee2, null, [[1, 11, 14, 17]]);
|
|
474
|
+
}));
|
|
475
|
+
|
|
476
|
+
return function droppedURIHandler(_x6) {
|
|
477
|
+
return _ref2.apply(this, arguments);
|
|
478
|
+
};
|
|
479
|
+
}(); // When we are actually logged on
|
|
480
|
+
|
|
481
|
+
|
|
482
|
+
function turnOnInput() {
|
|
483
|
+
function getImageDoc() {
|
|
484
|
+
imageDoc = $rdf.sym(chatDocument.dir().uri + 'Image_' + Date.now() + '.png');
|
|
485
|
+
return imageDoc;
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
function tookPicture(_x7) {
|
|
489
|
+
return _tookPicture.apply(this, arguments);
|
|
490
|
+
} // Body of turnOnInput
|
|
491
|
+
|
|
492
|
+
|
|
493
|
+
function _tookPicture() {
|
|
494
|
+
_tookPicture = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(imageDoc) {
|
|
495
|
+
return _regenerator["default"].wrap(function _callee4$(_context5) {
|
|
496
|
+
while (1) {
|
|
497
|
+
switch (_context5.prev = _context5.next) {
|
|
498
|
+
case 0:
|
|
499
|
+
if (!imageDoc) {
|
|
500
|
+
_context5.next = 3;
|
|
501
|
+
break;
|
|
502
|
+
}
|
|
503
|
+
|
|
504
|
+
_context5.next = 3;
|
|
505
|
+
return sendMessage(imageDoc.uri);
|
|
506
|
+
|
|
507
|
+
case 3:
|
|
508
|
+
case "end":
|
|
509
|
+
return _context5.stop();
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
}, _callee4);
|
|
513
|
+
}));
|
|
514
|
+
return _tookPicture.apply(this, arguments);
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
var menuButton;
|
|
518
|
+
|
|
519
|
+
if (options.menuHandler) {
|
|
520
|
+
var _menuButton = widgets.button(dom, _iconBase.icons.iconBase + 'noun_243787.svg', 'More');
|
|
521
|
+
|
|
522
|
+
_menuButton.setAttribute('style', style.buttonStyle + 'float: right;'); // menuButton.addEventListener('click', _event => sendMessage(), false) (done in turnoninput)
|
|
523
|
+
|
|
524
|
+
|
|
525
|
+
rhs.appendChild(_menuButton);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
if (options.menuHandler && menuButton) {
|
|
529
|
+
var _me = _index.authn.currentUser();
|
|
530
|
+
|
|
531
|
+
var menuOptions = {
|
|
532
|
+
me: _me,
|
|
533
|
+
dom: dom,
|
|
534
|
+
div: null,
|
|
535
|
+
// @@ was: div
|
|
536
|
+
newBase: messageTable.chatDocument.dir().uri
|
|
537
|
+
};
|
|
538
|
+
menuButton.addEventListener('click', function (event) {
|
|
539
|
+
options.menuHandler(event, channelObject.chatChannel, menuOptions);
|
|
540
|
+
}, false);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
var me = _index.authn.currentUser(); // If already logged on
|
|
544
|
+
|
|
545
|
+
|
|
546
|
+
creatorAndDate(lhs, me, '', null);
|
|
547
|
+
field = dom.createElement('textarea');
|
|
548
|
+
middle.innerHTML = '';
|
|
549
|
+
middle.appendChild(field);
|
|
550
|
+
field.rows = 3;
|
|
551
|
+
|
|
552
|
+
if (originalMessage) {
|
|
553
|
+
field.value = _logic.store.anyValue(originalMessage, ns.sioc('content'), null, originalMessage.doc());
|
|
554
|
+
} // field.cols = 40
|
|
555
|
+
|
|
556
|
+
|
|
557
|
+
field.setAttribute('style', messageBodyStyle + 'background-color: #eef;'); // Trap the Enter BEFORE it is used ti make a newline
|
|
558
|
+
|
|
559
|
+
field.addEventListener('keydown', /*#__PURE__*/function () {
|
|
560
|
+
var _ref3 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3(e) {
|
|
561
|
+
return _regenerator["default"].wrap(function _callee3$(_context4) {
|
|
562
|
+
while (1) {
|
|
563
|
+
switch (_context4.prev = _context4.next) {
|
|
564
|
+
case 0:
|
|
565
|
+
if (!(e.code === 'Enter')) {
|
|
566
|
+
_context4.next = 4;
|
|
567
|
+
break;
|
|
568
|
+
}
|
|
569
|
+
|
|
570
|
+
if (!(!e.shiftKey && !options.shiftEnterSendsMessage || e.shiftKey && options.shiftEnterSendsMessage)) {
|
|
571
|
+
_context4.next = 4;
|
|
572
|
+
break;
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
_context4.next = 4;
|
|
576
|
+
return handleFieldInput(e);
|
|
577
|
+
|
|
578
|
+
case 4:
|
|
579
|
+
case "end":
|
|
580
|
+
return _context4.stop();
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}, _callee3);
|
|
584
|
+
}));
|
|
585
|
+
|
|
586
|
+
return function (_x8) {
|
|
587
|
+
return _ref3.apply(this, arguments);
|
|
588
|
+
};
|
|
589
|
+
}(), false);
|
|
590
|
+
widgets.makeDropTarget(field, droppedURIHandler, droppedFileHandler);
|
|
591
|
+
rhs.innerHTML = '';
|
|
592
|
+
sendButton = widgets.button(dom, sendIcon, 'Send');
|
|
593
|
+
sendButton.style["float"] = 'right';
|
|
594
|
+
sendButton.addEventListener('click', function (_event) {
|
|
595
|
+
return handleFieldInput();
|
|
596
|
+
}, false);
|
|
597
|
+
rhs.appendChild(sendButton);
|
|
598
|
+
|
|
599
|
+
if (originalMessage) {
|
|
600
|
+
// Are we editing another message?
|
|
601
|
+
var cancelButton = rhs.appendChild(widgets.cancelButton(dom));
|
|
602
|
+
cancelButton.style["float"] = 'left'; // cancelButton.firstChild.style.opacity = '0.3' // moved to buttons
|
|
603
|
+
|
|
604
|
+
cancelButton.addEventListener('click', function (_event) {
|
|
605
|
+
return revertEditing(messageEditor);
|
|
606
|
+
}, false);
|
|
607
|
+
rhs.appendChild(cancelButton);
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
var chatDocument = channelObject.dateFolder.leafDocumentFromDate(new Date());
|
|
611
|
+
var imageDoc;
|
|
612
|
+
middle.appendChild(_index2.media.cameraButton(dom, _logic.store, getImageDoc, tookPicture));
|
|
613
|
+
pad.recordParticipation(channelObject.channel, channelObject.channel.doc()); // participation =
|
|
614
|
+
} // turn on inpuut
|
|
615
|
+
// Body of renderMessageEditor
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
var sortDate, sendIcon;
|
|
619
|
+
|
|
620
|
+
if (originalMessage) {
|
|
621
|
+
sortDate = _logic.store.anyValue(originalMessage, ns.dct('created'), null, originalMessage.doc()); // text = store.anyValue(originalMessage, ns.sioc('content'), null, originalMessage.doc())
|
|
622
|
+
|
|
623
|
+
sendIcon = _iconBase.icons.iconBase + 'noun_1180158.svg'; // Green check
|
|
624
|
+
// cancelIcon = icons.iconBase + 'noun_1180156.svg' // Black cross
|
|
625
|
+
} else {
|
|
626
|
+
sendIcon = _iconBase.icons.iconBase + 'noun_383448.svg';
|
|
627
|
+
sortDate = '9999-01-01T00:00:00Z'; // ISO format for field sort
|
|
628
|
+
// text = ''
|
|
629
|
+
}
|
|
630
|
+
|
|
631
|
+
var messageEditor = dom.createElement('tr');
|
|
632
|
+
var lhs = dom.createElement('td');
|
|
633
|
+
var middle = dom.createElement('td');
|
|
634
|
+
var rhs = dom.createElement('td');
|
|
635
|
+
messageEditor.appendChild(lhs);
|
|
636
|
+
messageEditor.appendChild(middle);
|
|
637
|
+
messageEditor.appendChild(rhs);
|
|
638
|
+
messageEditor.AJAR_date = sortDate; // messageEditor.appendChild(dom.createElement('br'))
|
|
639
|
+
|
|
640
|
+
var field, sendButton;
|
|
641
|
+
var context = {
|
|
642
|
+
div: middle,
|
|
643
|
+
dom: dom
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
_index.authn.logIn(context).then(function (context) {
|
|
647
|
+
// me = context.me
|
|
648
|
+
turnOnInput();
|
|
649
|
+
Object.assign(context, userContext);
|
|
650
|
+
(0, _bookmarks.findBookmarkDocument)(context).then(function (_context) {// console.log('Bookmark file: ' + context.bookmarkDocument)
|
|
651
|
+
});
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
return messageEditor;
|
|
655
|
+
} // renderMessageEditor
|
|
282
656
|
//# sourceMappingURL=message.js.map
|