@social-mail/social-mail-client 1.2.13 → 1.2.15

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.
Files changed (65) hide show
  1. package/dist/admin/AdminAppIndex.pack.js +704 -120
  2. package/dist/admin/AdminAppIndex.pack.js.map +1 -1
  3. package/dist/admin/AdminAppIndex.pack.min.js +78 -8
  4. package/dist/admin/AdminAppIndex.pack.min.js.map +1 -1
  5. package/dist/common/controls/html/InlineHtmlEditorWithToolbar.d.ts.map +1 -1
  6. package/dist/common/controls/html/InlineHtmlEditorWithToolbar.js +11 -2
  7. package/dist/common/controls/html/InlineHtmlEditorWithToolbar.js.map +1 -1
  8. package/dist/common/events/CommonEvents.d.ts +2 -0
  9. package/dist/common/events/CommonEvents.d.ts.map +1 -1
  10. package/dist/common/events/CommonEvents.js +3 -1
  11. package/dist/common/events/CommonEvents.js.map +1 -1
  12. package/dist/common/pages/mailboxes/MailboxEditorPage.d.ts.map +1 -1
  13. package/dist/common/pages/mailboxes/MailboxEditorPage.js +1 -1
  14. package/dist/common/pages/mailboxes/MailboxEditorPage.js.map +1 -1
  15. package/dist/tsconfig.tsbuildinfo +1 -1
  16. package/dist/web/AppIndex.pack.js +704 -120
  17. package/dist/web/AppIndex.pack.js.map +1 -1
  18. package/dist/web/AppIndex.pack.min.js +79 -9
  19. package/dist/web/AppIndex.pack.min.js.map +1 -1
  20. package/dist/web/page/mails/ConversationPage.d.ts +4 -1
  21. package/dist/web/page/mails/ConversationPage.d.ts.map +1 -1
  22. package/dist/web/page/mails/ConversationPage.js +58 -7
  23. package/dist/web/page/mails/ConversationPage.js.map +1 -1
  24. package/dist/web/page/mails/mini-compose/Insert.d.ts +4 -0
  25. package/dist/web/page/mails/mini-compose/Insert.d.ts.map +1 -0
  26. package/dist/web/page/mails/mini-compose/Insert.js +71 -0
  27. package/dist/web/page/mails/mini-compose/Insert.js.map +1 -0
  28. package/dist/web/page/mails/mini-compose/MiniComposeBox.d.ts +8 -2
  29. package/dist/web/page/mails/mini-compose/MiniComposeBox.d.ts.map +1 -1
  30. package/dist/web/page/mails/mini-compose/MiniComposeBox.js +66 -29
  31. package/dist/web/page/mails/mini-compose/MiniComposeBox.js.map +1 -1
  32. package/dist/web/page/mails/service/ConversationService.d.ts +1 -0
  33. package/dist/web/page/mails/service/ConversationService.d.ts.map +1 -1
  34. package/dist/web/page/mails/service/ConversationService.js +30 -15
  35. package/dist/web/page/mails/service/ConversationService.js.map +1 -1
  36. package/dist/web/page/mails/service/MailService.d.ts.map +1 -1
  37. package/dist/web/page/mails/service/MailService.js +1 -0
  38. package/dist/web/page/mails/service/MailService.js.map +1 -1
  39. package/node_modules/@web-atoms/entity/dist/models/TaskManager.d.ts.map +1 -1
  40. package/node_modules/@web-atoms/entity/dist/models/TaskManager.js +1 -0
  41. package/node_modules/@web-atoms/entity/dist/models/TaskManager.js.map +1 -1
  42. package/node_modules/@web-atoms/entity/dist/services/BaseEntityService.d.ts +1 -1
  43. package/node_modules/@web-atoms/entity/dist/services/BaseEntityService.d.ts.map +1 -1
  44. package/node_modules/@web-atoms/entity/dist/services/BaseEntityService.js +8 -1
  45. package/node_modules/@web-atoms/entity/dist/services/BaseEntityService.js.map +1 -1
  46. package/node_modules/@web-atoms/entity/dist/tsconfig.tsbuildinfo +1 -1
  47. package/node_modules/@web-atoms/entity/package.json +1 -1
  48. package/node_modules/@web-atoms/entity/src/models/TaskManager.ts +4 -0
  49. package/node_modules/@web-atoms/entity/src/services/BaseEntityService.ts +9 -2
  50. package/node_modules/@web-atoms/web-controls/dist/html-editor/commands/Align.d.ts +3 -1
  51. package/node_modules/@web-atoms/web-controls/dist/html-editor/commands/Align.d.ts.map +1 -1
  52. package/node_modules/@web-atoms/web-controls/dist/html-editor/commands/Align.js +5 -2
  53. package/node_modules/@web-atoms/web-controls/dist/html-editor/commands/Align.js.map +1 -1
  54. package/node_modules/@web-atoms/web-controls/dist/tsconfig.tsbuildinfo +1 -1
  55. package/node_modules/@web-atoms/web-controls/package.json +1 -1
  56. package/node_modules/@web-atoms/web-controls/src/html-editor/commands/Align.tsx +4 -2
  57. package/package.json +3 -3
  58. package/src/common/controls/html/InlineHtmlEditorWithToolbar.tsx +9 -0
  59. package/src/common/events/CommonEvents.ts +6 -1
  60. package/src/common/pages/mailboxes/MailboxEditorPage.tsx +1 -1
  61. package/src/web/page/mails/ConversationPage.tsx +43 -1
  62. package/src/web/page/mails/mini-compose/Insert.tsx +66 -0
  63. package/src/web/page/mails/mini-compose/MiniComposeBox.tsx +56 -19
  64. package/src/web/page/mails/service/ConversationService.tsx +26 -14
  65. package/src/web/page/mails/service/MailService.ts +1 -0
@@ -0,0 +1,66 @@
1
+ import Bind from "@web-atoms/core/dist/core/Bind";
2
+ import XNode from "@web-atoms/core/dist/core/XNode";
3
+ import { IPopupOptions } from "@web-atoms/core/dist/web/services/PopupService";
4
+ import PopupButton, { MenuItem } from "@web-atoms/web-controls/dist/basic/PopupButton";
5
+ import UploadEvent from "@web-atoms/web-controls/dist/basic/UploadEvent";
6
+ import AtomHtmlEditor from "@web-atoms/web-controls/dist/html-editor/AtomHtmlEditor";
7
+
8
+ export default function Insert({ alignment = "above" as IPopupOptions["alignment"]}) {
9
+ return <PopupButton
10
+ class="command"
11
+ data-layout="toolbar-button"
12
+ icon="fas fa-plus"
13
+ title="Change Alignment"
14
+ alignment={alignment}>
15
+ <MenuItem
16
+ icon="ri-list-unordered"
17
+ label="List"
18
+ event-click={Bind.event((editor: any) => editor.executeCommand("insertUnorderedList"))}
19
+ />
20
+ <MenuItem
21
+ icon="ri-list-ordered"
22
+ label="Numbered List"
23
+ event-click={Bind.event((editor: any) => editor.executeCommand("insertOrderedList"))}
24
+ />
25
+ <MenuItem
26
+ { ... UploadEvent.AttachUploadAction({
27
+ accept: "image/*",
28
+ multiple: true,
29
+ extra: {}
30
+ })}
31
+ data-click-event="send-photos"
32
+ icon="fas fa-image"
33
+ label="Add Photos"
34
+ />
35
+ <MenuItem
36
+ { ... UploadEvent.AttachUploadAction({
37
+ accept: "image/*",
38
+ capture: "user",
39
+ extra: {}
40
+ })}
41
+ data-click-event="take-photo"
42
+ icon="fa-duotone fa-camera-retro"
43
+ label="Take Photo"
44
+ />
45
+ <MenuItem
46
+ { ... UploadEvent.AttachUploadAction({
47
+ accept: "video/*",
48
+ multiple: false,
49
+ extra: {}
50
+ })}
51
+ data-click-event="send-video"
52
+ icon="fas fa-file-video"
53
+ label="Add Video"
54
+ />
55
+ <MenuItem
56
+ { ... UploadEvent.AttachUploadAction({
57
+ accept: "video/*",
58
+ capture: "user",
59
+ extra: {}
60
+ })}
61
+ data-click-event="record-video"
62
+ icon="fa-duotone fa-video-plus"
63
+ label="Record Video"
64
+ />
65
+ </PopupButton>;
66
+ }
@@ -1,7 +1,7 @@
1
1
  import XNode from "@web-atoms/core/dist/core/XNode";
2
2
  import styled from "@web-atoms/core/dist/style/styled";
3
3
  import { AtomControl } from "@web-atoms/core/dist/web/controls/AtomControl";
4
- import { AppFile, Email, EmailRecipient, IAppFile, IEmail, IMailbox, IMailboxContact, MailboxEmail } from "../../../../model/model";
4
+ import { AppFile, Email, EmailRecipient, IAppFile, IEmail, IMailbox, IMailboxContact, IMailboxContactEmail, MailboxEmail } from "../../../../model/model";
5
5
  import Bind from "@web-atoms/core/dist/core/Bind";
6
6
  import Action from "@web-atoms/core/dist/view-model/Action";
7
7
  import AudioRecorder from "../../../../common/controls/audio/AudioRecorder";
@@ -16,6 +16,19 @@ import MailService from "../service/MailService";
16
16
  import DateTime from "@web-atoms/date-time/dist/DateTime";
17
17
  import SendFiles from "./SendFiles";
18
18
  import sleep from "@web-atoms/core/dist/core/sleep";
19
+ import InlineHtmlEditorWithToolbar, { MailHtmlEditor } from "../../../../common/controls/html/InlineHtmlEditorWithToolbar";
20
+ import InlineHtmlEditor from "@web-atoms/web-controls/dist/html-editor/InlineHtmlEditor";
21
+ import { Toolbar } from "@web-atoms/web-controls/dist/html-editor/AtomHtmlEditor";
22
+ import Align from "@web-atoms/web-controls/dist/html-editor/commands/Align";
23
+ import Bold from "@web-atoms/web-controls/dist/html-editor/commands/Bold";
24
+ import Italic from "@web-atoms/web-controls/dist/html-editor/commands/Italic";
25
+ import StrikeThrough from "@web-atoms/web-controls/dist/html-editor/commands/StrikeThrough";
26
+ import Underline from "@web-atoms/web-controls/dist/html-editor/commands/Underline";
27
+ import AddLink from "@web-atoms/web-controls/dist/html-editor/commands/AddLink";
28
+ import Unlink from "@web-atoms/web-controls/dist/html-editor/commands/Unlink";
29
+ import Separator from "@web-atoms/web-controls/dist/html-editor/commands/Separator";
30
+ import Insert from "./Insert";
31
+ import TimeSpan from "@web-atoms/date-time/dist/TimeSpan";
19
32
 
20
33
  const css = styled.css `
21
34
  display: grid;
@@ -37,6 +50,7 @@ const css = styled.css `
37
50
  grid-row: 2;
38
51
  grid-column: 3;
39
52
  border-radius: 10px;
53
+ place-self: center;
40
54
  }
41
55
 
42
56
  & > [data-element=editor] {
@@ -65,6 +79,10 @@ export default class MiniComposeBox extends AtomControl {
65
79
  @InjectProperty
66
80
  private mailService: MailService;
67
81
 
82
+ private active = false;
83
+
84
+ private editor: InlineHtmlEditor;
85
+
68
86
  constructor(app, e) {
69
87
  super(app, e);
70
88
  this.element.className = css;
@@ -75,21 +93,37 @@ export default class MiniComposeBox extends AtomControl {
75
93
 
76
94
  await sleep(100);
77
95
 
78
- this.draft = await this.conversationService.getDraft(this.mailboxContact);
96
+ this.draft = (await this.conversationService.getDraft(this.mailboxContact))?.email;
79
97
 
80
98
  if (this.draft) {
81
99
  this.draft.attachments ??= [];
82
100
  }
83
101
 
102
+ this.typedMessage = this.draft?.htmlBody
103
+ ? this.draft.htmlBody
104
+ : `<div contentEditable="true" style="background-color: white; color: black;"><p>&nbsp;</br></p></div>`;
105
+
84
106
  this.render(<div>
85
- <i
86
- data-click-event="add-media"
87
- data-element="add"
88
- class="fa-solid fa-plus"
89
- title="Attach media"/>
90
- <textarea
107
+ <MailHtmlEditor
108
+ toolbar={() => <div><Toolbar>
109
+ <Insert/>
110
+ <Separator/>
111
+ <Bold/>
112
+ <Italic/>
113
+ <Underline/>
114
+ <StrikeThrough/>
115
+ <Align alignment="above"/>
116
+ <Separator/>
117
+ <AddLink/>
118
+ <Unlink/>
119
+ <Separator/>
120
+ </Toolbar></div>}
91
121
  data-element="editor"
92
- value={Bind.twoWaysImmediate(() => this.typedMessage)}/>
122
+ data-html-editor="email-editor"
123
+ presenter={Bind.presenter((c) => this.editor = c )}
124
+ content={`<div contentEditable="true" style="background-color: white; color: black;">${this.typedMessage}</div>`}
125
+ style-min-height="50px"
126
+ />
93
127
  <i
94
128
  data-element="send"
95
129
  class="fa-solid fa-microphone-lines mic"
@@ -104,7 +138,7 @@ export default class MiniComposeBox extends AtomControl {
104
138
  <AtomRepeater
105
139
  data-element="files"
106
140
  items={Bind.oneWay(() => this.draft?.attachments)}
107
- style-display={Bind.oneWay(() => this.draft && this.draft.attachments && this.draft.attachments.length > 0)}
141
+ style-display={Bind.oneWay(() => this.draft && this.draft.attachments && this.draft.attachments.length > 0, false)}
108
142
  data-layout="flex-wrap-padding"
109
143
  itemRenderer={(item: IAppFile) => <div
110
144
  data-layout="icon-button">
@@ -119,12 +153,8 @@ export default class MiniComposeBox extends AtomControl {
119
153
  </div>);
120
154
  }
121
155
 
122
- @Action({ onEvent: "add-media"})
123
- async addMedia() {
124
- const files = await SendFiles.showModal<IUploadedFile[]>({});
125
- this.draft ??= Email.create({
126
- attachments: []
127
- });
156
+ @Action({ onEvent: "filesAvailable"})
157
+ async filesAvailable({ files, extra }) {
128
158
  this.addFiles(... files);
129
159
  }
130
160
 
@@ -146,22 +176,29 @@ export default class MiniComposeBox extends AtomControl {
146
176
 
147
177
  @Action({ onEvent: "input", defer: 500, blockMultipleExecution: true })
148
178
  async onChanged() {
149
- if (!this.typedMessage) {
179
+ if (!this.editor?.htmlTextContent) {
150
180
  return;
151
181
  }
152
182
  this.draft ??= Email.create({
153
183
  attachments: []
154
184
  });
155
- this.draft.mdBody = this.typedMessage;
185
+ const { html , text } = this.editor.htmlTextContent;
186
+ this.draft.htmlBody = html;
187
+ this.draft.textBody = text;
156
188
  await this.save();
157
189
  }
158
190
 
191
+ @Action({ onEvent: CommonEvents.onEmailUnscheduled})
192
+ async onEmailUnscheduled(mce: IMailboxContactEmail) {
193
+ this.draft = mce.email;
194
+ }
195
+
159
196
  @Action({
160
197
  onEvent: "send-email"
161
198
  })
162
199
  async sendEmail() {
163
200
  this.draft.status = "scheduled";
164
- this.draft.dateSent = DateTime.now;
201
+ this.draft.dateSent = DateTime.now.add(TimeSpan.fromSeconds(30));
165
202
  await this.mailService.send(this.draft);
166
203
  this.draft ??= Email.create({
167
204
  attachments: []
@@ -135,25 +135,28 @@ export default class ConversationService {
135
135
  return email;
136
136
  }
137
137
  if (create && email) {
138
- email.recipients ??= [];
139
- email.mailboxes ??= [];
138
+ const recipients = email.recipients ??= [];
139
+ const mailboxes = email.mailboxes ??= [];
140
+ const threads = email.threadEmails ??= [];
140
141
  email.senderID = mailboxID;
141
- if (!email.mailboxes.some((m) => m.mailboxID === mailboxID)) {
142
- email.mailboxes.push(MailboxEmail.create({
142
+ email.status = "draft";
143
+ if (!mailboxes.some((m) => m.mailboxID === mailboxID)) {
144
+ mailboxes.push(MailboxEmail.create({
143
145
  mailboxID
144
146
  }));
145
147
  }
146
- if(!email.recipients.some((r) => r.emailAddressID === emailAddressID)) {
147
- email.recipients.push(EmailRecipient.create({
148
+ if(!recipients.some((r) => r.emailAddressID === emailAddressID)) {
149
+ recipients.push(EmailRecipient.create({
148
150
  emailAddressID
149
151
  }));
150
152
  }
151
- const mce = MailboxContactEmail.create({
152
- mailboxID,
153
- emailAddressID,
154
- email
155
- });
156
- await this.entityService.save(mce);
153
+ if (!threads.some((r) => r.mailboxID === mailboxID)) {
154
+ threads.push(MailboxContactEmail.create({
155
+ mailboxID,
156
+ emailAddressID
157
+ }));
158
+ }
159
+ await this.entityService.save(email);
157
160
  }
158
161
  return email;
159
162
  }
@@ -210,6 +213,14 @@ export default class ConversationService {
210
213
  return emails;
211
214
  }
212
215
 
216
+ async stopEmail(mce: IMailboxContactEmail) {
217
+ const { email } = mce;
218
+ email.status = "draft";
219
+ await this.entityService.save(email, (c) => c);
220
+ CommonEvents.onEmailUnscheduled.dispatchEvent(mce);
221
+ }
222
+
223
+
213
224
  public renderText(html: string) {
214
225
  const div = document.createElement("div");
215
226
  div.innerHTML = html;
@@ -238,9 +249,10 @@ export default class ConversationService {
238
249
  }
239
250
 
240
251
  async delete(email: IEmail) {
241
- const { emailID } = email;
252
+ const { emailID, status } = email;
242
253
  await this.entityService.delete(Email.create({
243
- emailID
254
+ emailID,
255
+ status
244
256
  }));
245
257
  CommonEvents.onDraftDeleted.dispatchEvent(email);
246
258
  }
@@ -59,6 +59,7 @@ export default class MailService {
59
59
  }
60
60
  const cloner = this.entityService.cloner(email).include((x) => x.recipients).include((x) => x.attachments).copy;
61
61
  await this.entityService.save(cloner);
62
+ CommonEvents.onEmailScheduled.dispatchEvent(email);
62
63
  }
63
64
 
64
65
  async deleteAttachment(file: IAppFile) {