lucid-extension-sdk 0.0.197 → 0.0.198

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
@@ -101,6 +101,7 @@ export declare const enum CommandName {
101
101
  ListTextAreas = "lta",
102
102
  LoadBlockClasses = "lbc",
103
103
  LogForTestCase = "log",
104
+ MeasureText = "mt",
104
105
  OffsetItems = "oi",
105
106
  PatchDataItems = "pdi",
106
107
  Prompt = "p",
@@ -464,6 +465,10 @@ export type CommandArgs = {
464
465
  query: JsonSerializable;
465
466
  result: JsonSerializable;
466
467
  };
468
+ [CommandName.MeasureText]: {
469
+ query: MeasureTextQuery;
470
+ result: MeasureTextResult;
471
+ };
467
472
  [CommandName.OffsetItems]: {
468
473
  query: OffsetItemsQuery;
469
474
  result: OffsetItemsResult;
@@ -1163,6 +1168,20 @@ export type ListTextAreasQuery = string;
1163
1168
  export type ListTextAreasResult = string[];
1164
1169
  export type LoadBlockClassesQuery = string[];
1165
1170
  export type LoadBlockClassesResult = Promise<undefined>;
1171
+ export type MeasureTextQuery = {
1172
+ /** ID of the element to measure text area */
1173
+ 'id': string;
1174
+ /** Name of the text area to measure */
1175
+ 'n': string;
1176
+ /** Max width for giving text area*/
1177
+ 'w': number;
1178
+ };
1179
+ export type MeasureTextResult = {
1180
+ /** Text area width */
1181
+ 'w': number;
1182
+ /** Text area height */
1183
+ 'h': number;
1184
+ };
1166
1185
  export type OffsetItemsQuery = {
1167
1186
  /** IDs of the items (blocks, lines, groups) to move */
1168
1187
  '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.198",
4
4
  "description": "Utility classes for writing Lucid Software editor extensions",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",