lucid-extension-sdk 0.0.197 → 0.0.199

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
@@ -19,6 +19,8 @@ import { PanelLocation } from './ui/panel';
19
19
  * exposed through appropriate classes and methods elsewhere in this SDK.
20
20
  *
21
21
  * To use these directly, use [EditorClient.sendCommand](#classes_editorclient-EditorClient_sendcommand).
22
+ *
23
+ * IMPORTANT - Before you add a new command bring it up in #api-committee to get feedback
22
24
  */
23
25
  export declare const enum CommandName {
24
26
  AddCardIntegration = "aci",
@@ -101,6 +103,7 @@ export declare const enum CommandName {
101
103
  ListTextAreas = "lta",
102
104
  LoadBlockClasses = "lbc",
103
105
  LogForTestCase = "log",
106
+ MeasureText = "mt",
104
107
  OffsetItems = "oi",
105
108
  PatchDataItems = "pdi",
106
109
  Prompt = "p",
@@ -142,6 +145,8 @@ export declare const commandTitles: Map<CommandName, string>;
142
145
  * This is a type declaration whose purpose is to allow TypeScript to enforce the correct parameter and
143
146
  * return types from [EditorClient.sendCommand](#classes_editorclient-EditorClient_sendcommand) based on
144
147
  * which command name you pass in as the first parameter.
148
+ *
149
+ * IMPORTANT - Before you add a new command bring it up in #api-committee to get feedback
145
150
  */
146
151
  export type CommandArgs = {
147
152
  [CommandName.AddCardIntegration]: {
@@ -464,6 +469,10 @@ export type CommandArgs = {
464
469
  query: JsonSerializable;
465
470
  result: JsonSerializable;
466
471
  };
472
+ [CommandName.MeasureText]: {
473
+ query: MeasureTextQuery;
474
+ result: MeasureTextResult;
475
+ };
467
476
  [CommandName.OffsetItems]: {
468
477
  query: OffsetItemsQuery;
469
478
  result: OffsetItemsResult;
@@ -1163,6 +1172,20 @@ export type ListTextAreasQuery = string;
1163
1172
  export type ListTextAreasResult = string[];
1164
1173
  export type LoadBlockClassesQuery = string[];
1165
1174
  export type LoadBlockClassesResult = Promise<undefined>;
1175
+ export type MeasureTextQuery = {
1176
+ /** ID of the element to measure text area */
1177
+ 'id': string;
1178
+ /** Name of the text area to measure */
1179
+ 'n': string;
1180
+ /** Max width for giving text area*/
1181
+ 'w': number;
1182
+ };
1183
+ export type MeasureTextResult = {
1184
+ /** Text area width */
1185
+ 'w': number;
1186
+ /** Text area height */
1187
+ 'h': number;
1188
+ };
1166
1189
  export type OffsetItemsQuery = {
1167
1190
  /** IDs of the items (blocks, lines, groups) to move */
1168
1191
  'ids': string[];
package/commandtypes.js CHANGED
@@ -81,6 +81,7 @@ exports.commandTitles = new Map([
81
81
  ["lta" /* CommandName.ListTextAreas */, 'ListTextAreas'],
82
82
  ["lbc" /* CommandName.LoadBlockClasses */, 'LoadBlockClasses'],
83
83
  ["log" /* CommandName.LogForTestCase */, 'LogForTestCase'],
84
+ ["mt" /* CommandName.MeasureText */, 'MeasureText'],
84
85
  ["oi" /* CommandName.OffsetItems */, 'OffsetItems'],
85
86
  ["pdi" /* CommandName.PatchDataItems */, 'PatchDataItems'],
86
87
  ["p" /* CommandName.Prompt */, 'Prompt'],
@@ -65,6 +65,14 @@ export declare class ItemProxy extends ElementProxy {
65
65
  * @param offset The amount to offset
66
66
  */
67
67
  offset(type: LinearOffsetType, offset: Point): void;
68
+ /**
69
+ * Measure the amount of space necessary to render the text in the given text area, given a
70
+ * width to measure that text within.
71
+ * @param name Name of the text area whose content we should measure
72
+ * @param maxWidth Width of the area in which to measure this text. The result will usually be no wider than this, but if a single word is long enough to go beyond this maxWidth, the width of that word will be returned.
73
+ * @returns The size of rectangle necessary to render this text area's content.
74
+ */
75
+ measureText(name: string, maxWidth: number): import("../commandtypes").MeasureTextResult;
68
76
  /**
69
77
  * Delete this item from the document
70
78
  */
@@ -102,6 +102,16 @@ class ItemProxy extends elementproxy_1.ElementProxy {
102
102
  offset(type, offset) {
103
103
  this.client.sendCommand("oi" /* CommandName.OffsetItems */, { 'ids': [this.id], 't': type, 'o': offset });
104
104
  }
105
+ /**
106
+ * Measure the amount of space necessary to render the text in the given text area, given a
107
+ * width to measure that text within.
108
+ * @param name Name of the text area whose content we should measure
109
+ * @param maxWidth Width of the area in which to measure this text. The result will usually be no wider than this, but if a single word is long enough to go beyond this maxWidth, the width of that word will be returned.
110
+ * @returns The size of rectangle necessary to render this text area's content.
111
+ */
112
+ measureText(name, maxWidth) {
113
+ return this.client.sendCommand("mt" /* CommandName.MeasureText */, { 'id': this.id, 'n': name, 'w': maxWidth });
114
+ }
105
115
  /**
106
116
  * Delete this item from the document
107
117
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lucid-extension-sdk",
3
- "version": "0.0.197",
3
+ "version": "0.0.199",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",