@social-mail/social-mail-client 1.2.41 → 1.2.42

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@social-mail/social-mail-client",
3
- "version": "1.2.41",
3
+ "version": "1.2.42",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -118,6 +118,9 @@ export class FolderTreeView extends TreeView<IAppFile> {
118
118
  }
119
119
  file.name = newName;
120
120
  await this.cloudFileService.save(file);
121
+ const e = this.map.get(file);
122
+ const { parentItem: { children } } = e;
123
+ children.set( children.indexOf(file), file);
121
124
  }
122
125
 
123
126
  protected async loadFolder(folder: number, accept: string, cancelToken) {
@@ -130,18 +133,22 @@ export class FolderTreeView extends TreeView<IAppFile> {
130
133
  }
131
134
 
132
135
  export class FileTreeView extends FolderTreeView {
136
+
137
+ public menuActions: (item: IAppFile) => XNode[];
138
+
133
139
  constructor(app, e) {
134
140
  super(app, e);
141
+ this.menuActions = null;
135
142
  this.canSelect = (item) => !item.isFolder;
136
143
  this.labelRenderer= (x) => <span
137
144
  text={x.name}
138
145
  title={x.name}
139
146
  data-click-event={ x.isFolder ? "none": "select-item" } />;
140
147
 
141
- this.actionRenderer = (item) => <InlinePopupButton
148
+ this.actionRenderer = (item) => <InlinePopupButton
142
149
  data-layout="icon-button"
143
- icon="fa-solid fa-ellipsis-vertical">
144
- <div data-layout="vertical-flex" style-width="200px">
150
+ icon="fa-solid fa-ellipsis-vertical"
151
+ popup={() => <div data-layout="vertical-flex" style-width="200px">
145
152
  { item.isFolder && <MenuItem
146
153
  data-click-event="new-folder"
147
154
  icon="fas fa-plus"
@@ -156,6 +163,7 @@ export class FileTreeView extends FolderTreeView {
156
163
  folder: true,
157
164
  accept: "*/*"
158
165
  })}/> }
166
+ { ... (this.menuActions?.(item) ?? [] )}
159
167
  { this.root !== item && <MenuItem
160
168
  data-click-event="rename-file"
161
169
  icon="fa-duotone fa-i-cursor"
@@ -166,8 +174,8 @@ export class FileTreeView extends FolderTreeView {
166
174
  icon="fas fa-trash-can"
167
175
  label="Delete"
168
176
  />}
169
- </div>
170
- </InlinePopupButton>;
177
+ </div>}
178
+ />;
171
179
  }
172
180
 
173
181
  protected async loadFolder(folder: number, accept: string, cancelToken) {
@@ -323,11 +323,17 @@ export default class TreeView<T extends object = any> extends AtomControl {
323
323
  }
324
324
 
325
325
  const watcher = children.watch((target, event, index, child) => {
326
- if (event === "add" || event === "set") {
326
+ if (event === "add") {
327
327
  // set parent in the
328
328
  this.createElement(child, item, index);
329
329
  return;
330
330
  }
331
+ if (event === "set") {
332
+ const childElement = this.map.get(child);
333
+ childElement?.dispose();
334
+ this.createElement(child, item, index);
335
+ return;
336
+ }
331
337
  if (event === "remove") {
332
338
  const childElement = this.map.get(child);
333
339
  childElement?.dispose();
@@ -147,6 +147,17 @@ export default class WebSiteStudioPage extends ContentPage {
147
147
  accept="text/html"
148
148
  presenter={Bind.presenter((c) => this.folderTree = c)}
149
149
  selectedItem={Bind.twoWaysImmediate(() => this.selectedFile)}
150
+ menuActions={(x: IAppFile) => !x.isFolder
151
+ ? ( /\.(htm|html)$/i.test(x.name)
152
+ ? [
153
+ <MenuItem
154
+ icon="fas fa-copy"
155
+ data-click-event="duplicate-html"
156
+ label="Duplicate Page"
157
+ />
158
+ ]
159
+ : [])
160
+ : void 0}
150
161
  event-selected-item-changing={(ce) => {
151
162
  if (this.pageContent) {
152
163
  if(confirm("Page is modified but not saved, your changes will be lost")) {
@@ -237,6 +248,20 @@ export default class WebSiteStudioPage extends ContentPage {
237
248
  this.pageContent = "";
238
249
  }
239
250
 
251
+ @Action({ onEvent: "duplicate-html"})
252
+ async duplicateHtml(file: IAppFile) {
253
+ let { name } = file;
254
+ name = name.replace(/(\.[^\.]+)$/, (ext) => " Copy" + ext);
255
+ file = await this.cloudFileService.save({ ... file,
256
+ appFileID: void 0,
257
+ children: void 0,
258
+ parent: void 0,
259
+ name
260
+ });
261
+ this.root.children.add(file);
262
+ this.selectedFile = file;
263
+ }
264
+
240
265
  protected hide(): void {
241
266
  this.pageContent = this.htmlEditor.htmlPage;
242
267
  super.hide();