lucid-extension-sdk 0.0.156 → 0.0.157

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/commandtypes.d.ts CHANGED
@@ -120,6 +120,7 @@ export declare const enum CommandName {
120
120
  UnhookSelection = "us",
121
121
  UnhookTextEdit = "ute",
122
122
  WithMutex = "wm",
123
+ WithSilentActions = "wsa",
123
124
  ZOrder = "z"
124
125
  }
125
126
  /** @ignore */
@@ -530,6 +531,10 @@ export declare type CommandArgs = {
530
531
  query: WithMutexQuery;
531
532
  result: WithMutexResult;
532
533
  };
534
+ [CommandName.WithSilentActions]: {
535
+ query: WithSilentActionsQuery;
536
+ result: WithSilentActionsResult;
537
+ };
533
538
  [CommandName.ZOrder]: {
534
539
  query: ZOrderQuery;
535
540
  result: ZOrderResult;
@@ -1294,6 +1299,11 @@ export declare type WithMutexQuery = {
1294
1299
  };
1295
1300
  /** Resolves true if operation succeeded, or false if the mutex was held by someone else */
1296
1301
  export declare type WithMutexResult = Promise<boolean>;
1302
+ export declare type WithSilentActionsQuery = {
1303
+ /** Name of the synchronous action to run with undo/redo history suppressed */
1304
+ 'a': string;
1305
+ };
1306
+ export declare type WithSilentActionsResult = void;
1297
1307
  export declare enum ZOrderOperation {
1298
1308
  UP = 1,
1299
1309
  TOP = 2,
package/commandtypes.js CHANGED
@@ -100,6 +100,7 @@ exports.commandTitles = new Map([
100
100
  ["us" /* CommandName.UnhookSelection */, 'UnhookSelection'],
101
101
  ["ute" /* CommandName.UnhookTextEdit */, 'UnhookTextEdit'],
102
102
  ["wm" /* CommandName.WithMutex */, 'WithMutex'],
103
+ ["wsa" /* CommandName.WithSilentActions */, 'WithSilentActions'],
103
104
  ["z" /* CommandName.ZOrder */, 'ZOrder'],
104
105
  ]);
105
106
  var GetItemsAtSearchType;
package/editorclient.d.ts CHANGED
@@ -325,5 +325,12 @@ export declare class EditorClient {
325
325
  * @returns A promise resolving to a boolean indicating whether the mutex was successfully locked
326
326
  */
327
327
  withIntraDocumentMutex(name: string, callback: () => void | Promise<void>): Promise<boolean>;
328
+ /**
329
+ * @param callback Callback that will be executed with the user's local undo/redo history suppressed. This is
330
+ * useful when you want to make changes to a document that will not be erased if the user uses undo or redo,
331
+ * for example adding shape data onto shapes as a result of a background process that collects data from a
332
+ * remote API.
333
+ */
334
+ withSilentActions(callback: () => void): void;
328
335
  constructor();
329
336
  }
package/editorclient.js CHANGED
@@ -545,7 +545,28 @@ class EditorClient {
545
545
  return await this.sendCommand("wm" /* CommandName.WithMutex */, { 'n': name, 'a': action });
546
546
  }
547
547
  finally {
548
- this.deleteAction(name);
548
+ this.deleteAction(action);
549
+ }
550
+ }
551
+ /**
552
+ * @param callback Callback that will be executed with the user's local undo/redo history suppressed. This is
553
+ * useful when you want to make changes to a document that will not be erased if the user uses undo or redo,
554
+ * for example adding shape data onto shapes as a result of a background process that collects data from a
555
+ * remote API.
556
+ */
557
+ withSilentActions(callback) {
558
+ const action = this.getUniqueActionName();
559
+ this.registerAction(action, () => {
560
+ const result = callback();
561
+ if ((0, checks_1.isPromise)(result)) {
562
+ throw new Error('withSilentActions cannot be used with an async callback');
563
+ }
564
+ });
565
+ try {
566
+ this.sendCommand("wsa" /* CommandName.WithSilentActions */, { 'a': action });
567
+ }
568
+ finally {
569
+ this.deleteAction(action);
549
570
  }
550
571
  }
551
572
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.156",
3
+ "version": "0.0.157",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",