aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2024-03-23 15:03:29 -0400
committerbobzel <zzzman@gmail.com>2024-03-23 15:03:29 -0400
commit1606b9cfd1bf48890d2cc0b39595982cafeb990e (patch)
treef188f89651043a3ae43410ec5a82ad5c28e1015f
parent695ee551e3013be7b741d127a58a69ed797d2891 (diff)
from last
-rw-r--r--src/client/documents/Documents.ts19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/client/documents/Documents.ts b/src/client/documents/Documents.ts
index d68021062..17cb6fef8 100644
--- a/src/client/documents/Documents.ts
+++ b/src/client/documents/Documents.ts
@@ -1777,10 +1777,23 @@ export namespace DocUtils {
subitems: userDocList,
icon: 'file',
});
- } // applies a custom template to a document. the template is identified by it's short name (e.g, slideView not layout_slideView)
- export function makeCustomViewClicked(doc: Doc, creator: Opt<(documents: Array<Doc>, options: DocumentOptions, id?: string) => Doc>, templateSignature: string = 'custom', docLayoutTemplate?: Doc) {
+ }
+
+ // applies a custom template to a document. the template is identified by it's short name (e.g, slideView not layout_slideView)
+
+ /**
+ * Applies a template to a Doc and logs the action with the UndoManager
+ * If the template already exists and has been registered, it can be specified by it's signature name (e.g., 'icon' not 'layout_icon').
+ * Alternatively, the signature can be omitted and the template can be provided.
+ * @param doc the Doc to apply the template to.
+ * @param creator a function that will create the template if it doesn't exist
+ * @param templateSignature the signature name for a template that has already been created and registered on the userDoc. (can be "" if template is provide)
+ * @param template the template to use (optional if templateSignature is provided)
+ * @returns doc
+ */
+ export function makeCustomViewClicked(doc: Doc, creator: Opt<(documents: Array<Doc>, options: DocumentOptions, id?: string) => Doc>, templateSignature: string = 'custom', template?: Doc) {
const batch = UndoManager.StartBatch('makeCustomViewClicked');
- createCustomView(doc, creator, templateSignature, docLayoutTemplate);
+ createCustomView(doc, creator, templateSignature || StrCast(template?.title), template);
batch.end();
return doc;
}