@flighthq/text 0.5.1-next.973.788d3d7 → 0.6.0
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/README.md +2 -2
- package/dist/.tsbuildinfo.contract +1 -0
- package/dist/.tsbuildinfo.runtime +1 -0
- package/dist/contract.d.ts +12 -10
- package/dist/contract.d.ts.map +1 -1
- package/dist/contract.js +13 -10
- package/dist/contract.js.map +1 -1
- package/dist/contract.text-types.d.ts +2 -0
- package/dist/contract.text-types.d.ts.map +1 -0
- package/dist/contract.text-types.js +2 -0
- package/dist/contract.text-types.js.map +1 -0
- package/dist/enableTextLabelGuards.d.ts +2 -1
- package/dist/enableTextLabelGuards.d.ts.map +1 -1
- package/dist/enableTextLabelGuards.js +6 -6
- package/dist/enableTextLabelGuards.js.map +1 -1
- package/dist/explainTextLabelContent.d.ts +1 -1
- package/dist/explainTextLabelContent.d.ts.map +1 -1
- package/dist/explainTextLabelContent.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/index.js.map +1 -1
- package/dist/nativeText.d.ts +10 -5
- package/dist/nativeText.d.ts.map +1 -1
- package/dist/nativeText.js +14 -14
- package/dist/nativeText.js.map +1 -1
- package/dist/richText.d.ts +11 -4
- package/dist/richText.d.ts.map +1 -1
- package/dist/richText.js +97 -30
- package/dist/richText.js.map +1 -1
- package/dist/richTextContent.d.ts +6 -0
- package/dist/richTextContent.d.ts.map +1 -0
- package/dist/richTextContent.js +311 -0
- package/dist/richTextContent.js.map +1 -0
- package/dist/richTextMetrics.d.ts +10 -0
- package/dist/richTextMetrics.d.ts.map +1 -0
- package/dist/richTextMetrics.js +53 -0
- package/dist/richTextMetrics.js.map +1 -0
- package/dist/textFormatFont.d.ts +2 -2
- package/dist/textFormatFont.d.ts.map +1 -1
- package/dist/textFormatFont.js +4 -2
- package/dist/textFormatFont.js.map +1 -1
- package/dist/textLabel.d.ts +11 -5
- package/dist/textLabel.d.ts.map +1 -1
- package/dist/textLabel.js +17 -16
- package/dist/textLabel.js.map +1 -1
- package/dist/textLabelLayout.d.ts +6 -4
- package/dist/textLabelLayout.d.ts.map +1 -1
- package/dist/textLabelLayout.js +16 -7
- package/dist/textLabelLayout.js.map +1 -1
- package/dist/textLayoutRuntime.d.ts +5 -0
- package/dist/textLayoutRuntime.d.ts.map +1 -0
- package/dist/textLayoutRuntime.js +11 -0
- package/dist/textLayoutRuntime.js.map +1 -0
- package/dist/types.d.ts +141 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/package.json +12 -10
- package/src/enableTextLabelGuards.test.ts +13 -10
- package/src/explainTextLabelContent.test.ts +7 -4
- package/src/nativeText.test.ts +49 -16
- package/src/richText.test.ts +276 -70
- package/src/richTextContent.test.ts +154 -0
- package/src/richTextMetrics.test.ts +153 -0
- package/src/textFormatFont.test.ts +74 -16
- package/src/textLabel.test.ts +62 -20
- package/src/textLabelLayout.test.ts +31 -5
- package/src/textLayoutRuntime.test.ts +20 -0
package/src/richText.test.ts
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
import { getEntityRuntime } from '@flighthq/entity/contract';
|
|
2
|
+
import { EntityRuntimeKey } from '@flighthq/entity/contract';
|
|
2
3
|
import { createRectangle } from '@flighthq/geometry/contract';
|
|
3
4
|
import {
|
|
4
5
|
getNodeLocalBoundsRevision,
|
|
5
6
|
getNodeLocalContentRevision,
|
|
6
7
|
getNodeLocalTransformRevision,
|
|
7
8
|
} from '@flighthq/node/contract';
|
|
9
|
+
import type { Node } from '@flighthq/node/contract';
|
|
8
10
|
import { connectSignal } from '@flighthq/signals/contract';
|
|
9
|
-
import { createTextFormatRange
|
|
10
|
-
import type {
|
|
11
|
-
import {
|
|
11
|
+
import { createTextFormatRange } from '@flighthq/textformat/contract';
|
|
12
|
+
import type { TextFormatRangeRaw as TextFormatRange } from '@flighthq/textformat/contract';
|
|
13
|
+
import { setTextLayoutMeasureProvider } from '@flighthq/textlayout/contract';
|
|
12
14
|
|
|
13
15
|
import {
|
|
14
16
|
appendRichTextString,
|
|
@@ -64,17 +66,25 @@ import {
|
|
|
64
66
|
setRichTextVerticalAlign,
|
|
65
67
|
setRichTextWidth,
|
|
66
68
|
setRichTextWordWrap,
|
|
67
|
-
} from './richText';
|
|
69
|
+
} from './richText.ts';
|
|
70
|
+
import type { RichText, RichTextRuntime } from './types.ts';
|
|
71
|
+
import { RichTextKind } from './types.ts';
|
|
68
72
|
|
|
69
73
|
describe('appendRichTextString', () => {
|
|
70
74
|
it('appends the value to the existing text', () => {
|
|
71
|
-
const richText =
|
|
75
|
+
const richText = ((created) => {
|
|
76
|
+
Object.assign(created.data, { text: 'hello' });
|
|
77
|
+
return created;
|
|
78
|
+
})(createRichText());
|
|
72
79
|
appendRichTextString(richText, ' world');
|
|
73
80
|
expect(richText.data.text).toBe('hello world');
|
|
74
81
|
});
|
|
75
82
|
|
|
76
83
|
it('invalidates local content after append', () => {
|
|
77
|
-
const richText =
|
|
84
|
+
const richText = ((created) => {
|
|
85
|
+
Object.assign(created.data, { text: 'hi' });
|
|
86
|
+
return created;
|
|
87
|
+
})(createRichText());
|
|
78
88
|
const runtime = getEntityRuntime(richText) as RichTextRuntime;
|
|
79
89
|
const idBefore = runtime.localContentId;
|
|
80
90
|
appendRichTextString(richText, '!');
|
|
@@ -82,7 +92,10 @@ describe('appendRichTextString', () => {
|
|
|
82
92
|
});
|
|
83
93
|
|
|
84
94
|
it('does not invalidate when value is empty', () => {
|
|
85
|
-
const richText =
|
|
95
|
+
const richText = ((created) => {
|
|
96
|
+
Object.assign(created.data, { text: 'hi' });
|
|
97
|
+
return created;
|
|
98
|
+
})(createRichText());
|
|
86
99
|
const runtime = getEntityRuntime(richText) as RichTextRuntime;
|
|
87
100
|
const idBefore = runtime.localContentId;
|
|
88
101
|
appendRichTextString(richText, '');
|
|
@@ -92,7 +105,10 @@ describe('appendRichTextString', () => {
|
|
|
92
105
|
|
|
93
106
|
describe('buildRichTextLayoutParams', () => {
|
|
94
107
|
it('assembles content and wrap/multiline constraints for the layout engine', () => {
|
|
95
|
-
const richText =
|
|
108
|
+
const richText = ((created) => {
|
|
109
|
+
Object.assign(created.data, { multiline: true, width: 120, wordWrap: true });
|
|
110
|
+
return created;
|
|
111
|
+
})(createRichText());
|
|
96
112
|
setRichTextString(richText, 'hello');
|
|
97
113
|
const measure = (text: string) => text.length * 7;
|
|
98
114
|
const params = buildRichTextLayoutParams(richText, measure);
|
|
@@ -119,29 +135,38 @@ describe('computeRichTextLocalBoundsRectangle', () => {
|
|
|
119
135
|
});
|
|
120
136
|
|
|
121
137
|
it('sets out.width and out.height from data dimensions when autoSize is none', () => {
|
|
122
|
-
const richText =
|
|
138
|
+
const richText = ((created) => {
|
|
139
|
+
Object.assign(created.data, { width: 200, height: 150 });
|
|
140
|
+
return created;
|
|
141
|
+
})(createRichText());
|
|
123
142
|
const out = createRectangle();
|
|
124
|
-
computeRichTextLocalBoundsRectangle(out, richText
|
|
143
|
+
computeRichTextLocalBoundsRectangle(out, richText);
|
|
125
144
|
expect(out.x).toBe(0);
|
|
126
145
|
expect(out.width).toBe(200);
|
|
127
146
|
expect(out.height).toBe(150);
|
|
128
147
|
});
|
|
129
148
|
|
|
130
149
|
it('falls back to the fixed field box when autoSize is set but no measure provider exists', () => {
|
|
131
|
-
const richText =
|
|
150
|
+
const richText = ((created) => {
|
|
151
|
+
Object.assign(created.data, { autoSize: 'left', width: 200, height: 150 });
|
|
152
|
+
return created;
|
|
153
|
+
})(createRichText());
|
|
132
154
|
setRichTextString(richText, 'hello');
|
|
133
155
|
const out = createRectangle();
|
|
134
|
-
computeRichTextLocalBoundsRectangle(out, richText
|
|
156
|
+
computeRichTextLocalBoundsRectangle(out, richText);
|
|
135
157
|
expect(out.width).toBe(200);
|
|
136
158
|
expect(out.height).toBe(150);
|
|
137
159
|
});
|
|
138
160
|
|
|
139
161
|
it('shrinks to the measured content under autoSize left, anchored at the origin', () => {
|
|
140
162
|
setTextLayoutMeasureProvider((text) => text.length * 7);
|
|
141
|
-
const richText =
|
|
163
|
+
const richText = ((created) => {
|
|
164
|
+
Object.assign(created.data, { autoSize: 'left', width: 200, height: 150 });
|
|
165
|
+
return created;
|
|
166
|
+
})(createRichText());
|
|
142
167
|
setRichTextString(richText, 'hi');
|
|
143
168
|
const out = createRectangle();
|
|
144
|
-
computeRichTextLocalBoundsRectangle(out, richText
|
|
169
|
+
computeRichTextLocalBoundsRectangle(out, richText);
|
|
145
170
|
expect(out.x).toBe(0);
|
|
146
171
|
expect(out.width).toBeGreaterThan(0);
|
|
147
172
|
expect(out.width).toBeLessThan(200);
|
|
@@ -149,10 +174,13 @@ describe('computeRichTextLocalBoundsRectangle', () => {
|
|
|
149
174
|
|
|
150
175
|
it('keeps the right edge fixed under autoSize right (x = width - fieldWidth)', () => {
|
|
151
176
|
setTextLayoutMeasureProvider((text) => text.length * 7);
|
|
152
|
-
const richText =
|
|
177
|
+
const richText = ((created) => {
|
|
178
|
+
Object.assign(created.data, { autoSize: 'right', width: 200, height: 150 });
|
|
179
|
+
return created;
|
|
180
|
+
})(createRichText());
|
|
153
181
|
setRichTextString(richText, 'hi');
|
|
154
182
|
const out = createRectangle();
|
|
155
|
-
computeRichTextLocalBoundsRectangle(out, richText
|
|
183
|
+
computeRichTextLocalBoundsRectangle(out, richText);
|
|
156
184
|
expect(out.x).toBe(200 - out.width);
|
|
157
185
|
});
|
|
158
186
|
});
|
|
@@ -166,9 +194,9 @@ describe('createRichText', () => {
|
|
|
166
194
|
|
|
167
195
|
it('initializes default values', () => {
|
|
168
196
|
expect(richText.data.background).toBe(false);
|
|
169
|
-
expect(richText.data.backgroundColor).toBe(
|
|
197
|
+
expect(richText.data.backgroundColor).toBe(0xffffffff);
|
|
170
198
|
expect(richText.data.border).toBe(false);
|
|
171
|
-
expect(richText.data.borderColor).toBe(
|
|
199
|
+
expect(richText.data.borderColor).toBe(0x000000ff);
|
|
172
200
|
expect(richText.data.condenseWhite).toBe(false);
|
|
173
201
|
expect(richText.data.defaultTextFormat).not.toBeNull();
|
|
174
202
|
expect(richText.data.maxChars).toBe(-1);
|
|
@@ -183,7 +211,7 @@ describe('createRichText', () => {
|
|
|
183
211
|
expect(richText.kind).toStrictEqual(RichTextKind);
|
|
184
212
|
});
|
|
185
213
|
|
|
186
|
-
it('allows
|
|
214
|
+
it('allows fields to be assigned after creation', () => {
|
|
187
215
|
const base = {
|
|
188
216
|
data: {
|
|
189
217
|
background: true,
|
|
@@ -201,7 +229,15 @@ describe('createRichText', () => {
|
|
|
201
229
|
wordWrap: true,
|
|
202
230
|
},
|
|
203
231
|
};
|
|
204
|
-
const obj =
|
|
232
|
+
const obj = ((created, fields) => {
|
|
233
|
+
const entityData = created.data;
|
|
234
|
+
Object.assign(created, fields);
|
|
235
|
+
if (fields.data !== undefined) {
|
|
236
|
+
Object.assign(entityData, fields.data);
|
|
237
|
+
Object.assign(created, { data: entityData });
|
|
238
|
+
}
|
|
239
|
+
return created;
|
|
240
|
+
})(createRichText(), base);
|
|
205
241
|
expect(obj.data.background).toStrictEqual(base.data.background);
|
|
206
242
|
expect(obj.data.backgroundColor).toStrictEqual(base.data.backgroundColor);
|
|
207
243
|
expect(obj.data.border).toStrictEqual(base.data.border);
|
|
@@ -214,13 +250,13 @@ describe('createRichText', () => {
|
|
|
214
250
|
expect(obj.data.selectable).toStrictEqual(base.data.selectable);
|
|
215
251
|
expect(obj.data.textColor).toStrictEqual(base.data.textColor);
|
|
216
252
|
expect(obj.data.textFormatRanges).toStrictEqual(base.data.textFormatRanges);
|
|
217
|
-
expect(obj.data.textFormatRanges).
|
|
253
|
+
expect(obj.data.textFormatRanges).toBe(base.data.textFormatRanges);
|
|
218
254
|
expect(obj.data.wordWrap).toStrictEqual(base.data.wordWrap);
|
|
219
255
|
});
|
|
220
256
|
|
|
221
257
|
it('returns a new object for better hidden-class performance', () => {
|
|
222
258
|
const base = {};
|
|
223
|
-
const obj = createRichText(
|
|
259
|
+
const obj = createRichText();
|
|
224
260
|
expect(obj).not.toStrictEqual(base);
|
|
225
261
|
});
|
|
226
262
|
});
|
|
@@ -235,7 +271,7 @@ describe('createRichTextData', () => {
|
|
|
235
271
|
});
|
|
236
272
|
|
|
237
273
|
it('allows pre-defined values', () => {
|
|
238
|
-
const data = createRichTextData({ width: 300, height: 200, maxChars: 12 });
|
|
274
|
+
const data = Object.assign(createRichTextData(), { width: 300, height: 200, maxChars: 12 });
|
|
239
275
|
expect(data.width).toBe(300);
|
|
240
276
|
expect(data.height).toBe(200);
|
|
241
277
|
expect(data.maxChars).toBe(12);
|
|
@@ -255,7 +291,7 @@ describe('createRichTextRuntime', () => {
|
|
|
255
291
|
|
|
256
292
|
it('starts without attached content runtime state', () => {
|
|
257
293
|
const runtime = createRichTextRuntime();
|
|
258
|
-
expect(runtime.richTextContent).
|
|
294
|
+
expect(runtime.richTextContent).toBeUndefined();
|
|
259
295
|
});
|
|
260
296
|
|
|
261
297
|
it('uses computeRichTextLocalBoundsRectangle', () => {
|
|
@@ -290,7 +326,10 @@ describe('dispatchRichTextLinkAtPoint', () => {
|
|
|
290
326
|
|
|
291
327
|
it('returns null and emits nothing when the point is not over a link', () => {
|
|
292
328
|
setTextLayoutMeasureProvider((text) => text.length * 7);
|
|
293
|
-
const richText =
|
|
329
|
+
const richText = ((created) => {
|
|
330
|
+
Object.assign(created.data, { width: 200, height: 50 });
|
|
331
|
+
return created;
|
|
332
|
+
})(createRichText());
|
|
294
333
|
setRichTextString(richText, 'no links here');
|
|
295
334
|
const signals = enableTextFieldSignals(richText);
|
|
296
335
|
let emitted = false;
|
|
@@ -303,7 +342,10 @@ describe('dispatchRichTextLinkAtPoint', () => {
|
|
|
303
342
|
|
|
304
343
|
it('emits onTextFieldLink with the url and point when a link is hit', () => {
|
|
305
344
|
setTextLayoutMeasureProvider((text) => text.length * 7);
|
|
306
|
-
const richText =
|
|
345
|
+
const richText = ((created) => {
|
|
346
|
+
Object.assign(created.data, { width: 400, height: 50 });
|
|
347
|
+
return created;
|
|
348
|
+
})(createRichText());
|
|
307
349
|
setRichTextString(richText, 'click');
|
|
308
350
|
setRichTextFormatRange(richText, { url: 'https://example.com' }, 0, 5);
|
|
309
351
|
const signals = enableTextFieldSignals(richText);
|
|
@@ -346,7 +388,10 @@ describe('enableTextFieldSignals', () => {
|
|
|
346
388
|
});
|
|
347
389
|
|
|
348
390
|
it('enables onTextFieldChange emission from setters', () => {
|
|
349
|
-
const richText =
|
|
391
|
+
const richText = ((created) => {
|
|
392
|
+
Object.assign(created.data, { text: 'a' });
|
|
393
|
+
return created;
|
|
394
|
+
})(createRichText());
|
|
350
395
|
const signals = enableTextFieldSignals(richText);
|
|
351
396
|
const changes: string[] = [];
|
|
352
397
|
connectSignal(signals.onTextFieldChange, (event) => {
|
|
@@ -370,7 +415,10 @@ describe('getRichTextBottomScrollV', () => {
|
|
|
370
415
|
|
|
371
416
|
it('returns a value >= 1 when layout is available', () => {
|
|
372
417
|
setTextLayoutMeasureProvider((text) => text.length * 7);
|
|
373
|
-
const richText =
|
|
418
|
+
const richText = ((created) => {
|
|
419
|
+
Object.assign(created.data, { height: 20 });
|
|
420
|
+
return created;
|
|
421
|
+
})(createRichText());
|
|
374
422
|
setRichTextString(richText, 'line1\nline2\nline3');
|
|
375
423
|
expect(getRichTextBottomScrollV(richText)).toBeGreaterThanOrEqual(1);
|
|
376
424
|
});
|
|
@@ -389,7 +437,10 @@ describe('getRichTextCharIndexAtPoint', () => {
|
|
|
389
437
|
|
|
390
438
|
it('returns a valid index when layout is available and point is past last line', () => {
|
|
391
439
|
setTextLayoutMeasureProvider((text) => text.length * 7);
|
|
392
|
-
const richText =
|
|
440
|
+
const richText = ((created) => {
|
|
441
|
+
Object.assign(created.data, { width: 200, height: 50 });
|
|
442
|
+
return created;
|
|
443
|
+
})(createRichText());
|
|
393
444
|
setRichTextString(richText, 'hello');
|
|
394
445
|
// Use a y well beyond the text height to hit the end-of-field code path (avoids a known
|
|
395
446
|
// textlayout bug in the mid-line hit-test branch that references `text` instead of `_text`).
|
|
@@ -401,7 +452,10 @@ describe('getRichTextCharIndexAtPoint', () => {
|
|
|
401
452
|
describe('getRichTextDefaultTextFormat', () => {
|
|
402
453
|
it('returns the default text format', () => {
|
|
403
454
|
const format = { size: 16, bold: true };
|
|
404
|
-
const richText =
|
|
455
|
+
const richText = ((created) => {
|
|
456
|
+
Object.assign(created.data, { defaultTextFormat: format });
|
|
457
|
+
return created;
|
|
458
|
+
})(createRichText());
|
|
405
459
|
expect(getRichTextDefaultTextFormat(richText)).toBe(richText.data.defaultTextFormat);
|
|
406
460
|
});
|
|
407
461
|
});
|
|
@@ -415,12 +469,13 @@ describe('getRichTextFormatRangeAt', () => {
|
|
|
415
469
|
});
|
|
416
470
|
|
|
417
471
|
it('merges defaultTextFormat with overlapping ranges', () => {
|
|
418
|
-
const richText =
|
|
419
|
-
data
|
|
472
|
+
const richText = ((created) => {
|
|
473
|
+
Object.assign(created.data, {
|
|
420
474
|
defaultTextFormat: { size: 12, color: 0xff0000ff },
|
|
421
475
|
text: 'hello world',
|
|
422
|
-
}
|
|
423
|
-
|
|
476
|
+
});
|
|
477
|
+
return created;
|
|
478
|
+
})(createRichText());
|
|
424
479
|
setRichTextFormatRange(richText, { bold: true }, 0, 5);
|
|
425
480
|
const out: Record<string, unknown> = {};
|
|
426
481
|
getRichTextFormatRangeAt(out, richText, 2);
|
|
@@ -430,7 +485,10 @@ describe('getRichTextFormatRangeAt', () => {
|
|
|
430
485
|
});
|
|
431
486
|
|
|
432
487
|
it('does not apply a range that does not cover the index', () => {
|
|
433
|
-
const richText =
|
|
488
|
+
const richText = ((created) => {
|
|
489
|
+
Object.assign(created.data, { text: 'hello world' });
|
|
490
|
+
return created;
|
|
491
|
+
})(createRichText());
|
|
434
492
|
setRichTextFormatRange(richText, { bold: true }, 0, 3);
|
|
435
493
|
const out: Record<string, unknown> = {};
|
|
436
494
|
getRichTextFormatRangeAt(out, richText, 5);
|
|
@@ -446,7 +504,10 @@ describe('getRichTextFormatRangeByIndex', () => {
|
|
|
446
504
|
});
|
|
447
505
|
|
|
448
506
|
it('returns true and fills out with range data for a valid index', () => {
|
|
449
|
-
const richText =
|
|
507
|
+
const richText = ((created) => {
|
|
508
|
+
Object.assign(created.data, { text: 'hello' });
|
|
509
|
+
return created;
|
|
510
|
+
})(createRichText());
|
|
450
511
|
setRichTextFormatRange(richText, { italic: true }, 1, 4);
|
|
451
512
|
const out = createTextFormatRange({}, 0, 0);
|
|
452
513
|
expect(getRichTextFormatRangeByIndex(out, richText, 0)).toBe(true);
|
|
@@ -463,7 +524,10 @@ describe('getRichTextFormatRangeCount', () => {
|
|
|
463
524
|
});
|
|
464
525
|
|
|
465
526
|
it('returns the number of pushed ranges', () => {
|
|
466
|
-
const richText =
|
|
527
|
+
const richText = ((created) => {
|
|
528
|
+
Object.assign(created.data, { text: 'hello' });
|
|
529
|
+
return created;
|
|
530
|
+
})(createRichText());
|
|
467
531
|
setRichTextFormatRange(richText, { bold: true }, 0, 2);
|
|
468
532
|
setRichTextFormatRange(richText, { italic: true }, 2, 5);
|
|
469
533
|
expect(getRichTextFormatRangeCount(richText)).toBe(2);
|
|
@@ -472,7 +536,10 @@ describe('getRichTextFormatRangeCount', () => {
|
|
|
472
536
|
|
|
473
537
|
describe('getRichTextFormatRangesIn', () => {
|
|
474
538
|
it('clears out and leaves it empty when no ranges overlap the span', () => {
|
|
475
|
-
const richText =
|
|
539
|
+
const richText = ((created) => {
|
|
540
|
+
Object.assign(created.data, { text: 'hello world' });
|
|
541
|
+
return created;
|
|
542
|
+
})(createRichText());
|
|
476
543
|
setRichTextFormatRange(richText, { bold: true }, 6, 11);
|
|
477
544
|
const out: TextFormatRange[] = [createTextFormatRange({}, 99, 99)];
|
|
478
545
|
getRichTextFormatRangesIn(out, richText, 0, 5);
|
|
@@ -480,7 +547,10 @@ describe('getRichTextFormatRangesIn', () => {
|
|
|
480
547
|
});
|
|
481
548
|
|
|
482
549
|
it('collects every range overlapping the half-open span in stored order', () => {
|
|
483
|
-
const richText =
|
|
550
|
+
const richText = ((created) => {
|
|
551
|
+
Object.assign(created.data, { text: 'hello world' });
|
|
552
|
+
return created;
|
|
553
|
+
})(createRichText());
|
|
484
554
|
setRichTextFormatRange(richText, { bold: true }, 0, 5);
|
|
485
555
|
setRichTextFormatRange(richText, { italic: true }, 4, 8);
|
|
486
556
|
setRichTextFormatRange(richText, { underline: true }, 8, 11);
|
|
@@ -492,7 +562,10 @@ describe('getRichTextFormatRangesIn', () => {
|
|
|
492
562
|
});
|
|
493
563
|
|
|
494
564
|
it('excludes a range that only touches the span boundaries (half-open)', () => {
|
|
495
|
-
const richText =
|
|
565
|
+
const richText = ((created) => {
|
|
566
|
+
Object.assign(created.data, { text: 'hello world' });
|
|
567
|
+
return created;
|
|
568
|
+
})(createRichText());
|
|
496
569
|
setRichTextFormatRange(richText, { bold: true }, 5, 8);
|
|
497
570
|
const out: TextFormatRange[] = [];
|
|
498
571
|
// span [0, 5): range starting at 5 does not overlap.
|
|
@@ -501,7 +574,10 @@ describe('getRichTextFormatRangesIn', () => {
|
|
|
501
574
|
});
|
|
502
575
|
|
|
503
576
|
it('pushes ranges by reference', () => {
|
|
504
|
-
const richText =
|
|
577
|
+
const richText = ((created) => {
|
|
578
|
+
Object.assign(created.data, { text: 'hello' });
|
|
579
|
+
return created;
|
|
580
|
+
})(createRichText());
|
|
505
581
|
setRichTextFormatRange(richText, { bold: true }, 0, 5);
|
|
506
582
|
const out: TextFormatRange[] = [];
|
|
507
583
|
getRichTextFormatRangesIn(out, richText, 0, 5);
|
|
@@ -515,7 +591,10 @@ describe('getRichTextLength', () => {
|
|
|
515
591
|
});
|
|
516
592
|
|
|
517
593
|
it('returns the character count of the text', () => {
|
|
518
|
-
const richText =
|
|
594
|
+
const richText = ((created) => {
|
|
595
|
+
Object.assign(created.data, { text: 'hello' });
|
|
596
|
+
return created;
|
|
597
|
+
})(createRichText());
|
|
519
598
|
expect(getRichTextLength(richText)).toBe(5);
|
|
520
599
|
});
|
|
521
600
|
});
|
|
@@ -533,7 +612,10 @@ describe('getRichTextLineCount', () => {
|
|
|
533
612
|
|
|
534
613
|
it('returns >= 1 when layout is available', () => {
|
|
535
614
|
setTextLayoutMeasureProvider((text) => text.length * 7);
|
|
536
|
-
const richText =
|
|
615
|
+
const richText = ((created) => {
|
|
616
|
+
Object.assign(created.data, { width: 200 });
|
|
617
|
+
return created;
|
|
618
|
+
})(createRichText());
|
|
537
619
|
setRichTextString(richText, 'hello');
|
|
538
620
|
expect(getRichTextLineCount(richText)).toBeGreaterThanOrEqual(1);
|
|
539
621
|
});
|
|
@@ -552,7 +634,10 @@ describe('getRichTextLineMetrics', () => {
|
|
|
552
634
|
|
|
553
635
|
it('returns metrics for line 0 when layout is available', () => {
|
|
554
636
|
setTextLayoutMeasureProvider((text) => text.length * 7);
|
|
555
|
-
const richText =
|
|
637
|
+
const richText = ((created) => {
|
|
638
|
+
Object.assign(created.data, { width: 200 });
|
|
639
|
+
return created;
|
|
640
|
+
})(createRichText());
|
|
556
641
|
setRichTextString(richText, 'hello');
|
|
557
642
|
const metrics = getRichTextLineMetrics(richText, 0);
|
|
558
643
|
expect(metrics).not.toBeNull();
|
|
@@ -644,7 +729,10 @@ describe('getRichTextRuntime', () => {
|
|
|
644
729
|
|
|
645
730
|
describe('getRichTextString', () => {
|
|
646
731
|
it('returns the text field', () => {
|
|
647
|
-
const richText =
|
|
732
|
+
const richText = ((created) => {
|
|
733
|
+
Object.assign(created.data, { text: 'hello' });
|
|
734
|
+
return created;
|
|
735
|
+
})(createRichText());
|
|
648
736
|
expect(getRichTextString(richText)).toBe('hello');
|
|
649
737
|
});
|
|
650
738
|
});
|
|
@@ -662,7 +750,10 @@ describe('getRichTextTextHeight', () => {
|
|
|
662
750
|
|
|
663
751
|
it('returns a positive value when layout is available', () => {
|
|
664
752
|
setTextLayoutMeasureProvider((text) => text.length * 7);
|
|
665
|
-
const richText =
|
|
753
|
+
const richText = ((created) => {
|
|
754
|
+
Object.assign(created.data, { width: 200 });
|
|
755
|
+
return created;
|
|
756
|
+
})(createRichText());
|
|
666
757
|
setRichTextString(richText, 'hello');
|
|
667
758
|
expect(getRichTextTextHeight(richText)).toBeGreaterThan(0);
|
|
668
759
|
});
|
|
@@ -681,7 +772,10 @@ describe('getRichTextTextWidth', () => {
|
|
|
681
772
|
|
|
682
773
|
it('returns a positive value when layout is available', () => {
|
|
683
774
|
setTextLayoutMeasureProvider((text) => text.length * 7);
|
|
684
|
-
const richText =
|
|
775
|
+
const richText = ((created) => {
|
|
776
|
+
Object.assign(created.data, { width: 200 });
|
|
777
|
+
return created;
|
|
778
|
+
})(createRichText());
|
|
685
779
|
setRichTextString(richText, 'hello');
|
|
686
780
|
expect(getRichTextTextWidth(richText)).toBeGreaterThan(0);
|
|
687
781
|
});
|
|
@@ -707,13 +801,19 @@ describe('initializeTextFieldSignals', () => {
|
|
|
707
801
|
|
|
708
802
|
describe('insertRichTextString', () => {
|
|
709
803
|
it('inserts the value at the clamped index', () => {
|
|
710
|
-
const richText =
|
|
804
|
+
const richText = ((created) => {
|
|
805
|
+
Object.assign(created.data, { text: 'held' });
|
|
806
|
+
return created;
|
|
807
|
+
})(createRichText());
|
|
711
808
|
insertRichTextString(richText, 2, 'LLO wor');
|
|
712
809
|
expect(richText.data.text).toBe('heLLO world');
|
|
713
810
|
});
|
|
714
811
|
|
|
715
812
|
it('clamps the index into [0, text.length]', () => {
|
|
716
|
-
const richText =
|
|
813
|
+
const richText = ((created) => {
|
|
814
|
+
Object.assign(created.data, { text: 'abc' });
|
|
815
|
+
return created;
|
|
816
|
+
})(createRichText());
|
|
717
817
|
insertRichTextString(richText, 999, 'XYZ');
|
|
718
818
|
expect(richText.data.text).toBe('abcXYZ');
|
|
719
819
|
insertRichTextString(richText, -5, 'Q');
|
|
@@ -721,7 +821,10 @@ describe('insertRichTextString', () => {
|
|
|
721
821
|
});
|
|
722
822
|
|
|
723
823
|
it('does nothing for an empty value', () => {
|
|
724
|
-
const richText =
|
|
824
|
+
const richText = ((created) => {
|
|
825
|
+
Object.assign(created.data, { text: 'abc' });
|
|
826
|
+
return created;
|
|
827
|
+
})(createRichText());
|
|
725
828
|
const runtime = getEntityRuntime(richText) as RichTextRuntime;
|
|
726
829
|
const idBefore = runtime.localContentId;
|
|
727
830
|
insertRichTextString(richText, 1, '');
|
|
@@ -730,7 +833,10 @@ describe('insertRichTextString', () => {
|
|
|
730
833
|
});
|
|
731
834
|
|
|
732
835
|
it('shifts ranges starting at or after the insertion point', () => {
|
|
733
|
-
const richText =
|
|
836
|
+
const richText = ((created) => {
|
|
837
|
+
Object.assign(created.data, { text: 'abcdef' });
|
|
838
|
+
return created;
|
|
839
|
+
})(createRichText());
|
|
734
840
|
setRichTextFormatRange(richText, { bold: true }, 3, 5);
|
|
735
841
|
insertRichTextString(richText, 0, 'XX');
|
|
736
842
|
const range = richText.data.textFormatRanges[0];
|
|
@@ -739,7 +845,10 @@ describe('insertRichTextString', () => {
|
|
|
739
845
|
});
|
|
740
846
|
|
|
741
847
|
it('extends a range that straddles the insertion point', () => {
|
|
742
|
-
const richText =
|
|
848
|
+
const richText = ((created) => {
|
|
849
|
+
Object.assign(created.data, { text: 'abcdef' });
|
|
850
|
+
return created;
|
|
851
|
+
})(createRichText());
|
|
743
852
|
setRichTextFormatRange(richText, { bold: true }, 1, 5);
|
|
744
853
|
insertRichTextString(richText, 3, 'XX');
|
|
745
854
|
const range = richText.data.textFormatRanges[0];
|
|
@@ -748,7 +857,10 @@ describe('insertRichTextString', () => {
|
|
|
748
857
|
});
|
|
749
858
|
|
|
750
859
|
it('emits onTextFieldChange with the previous text when signals are enabled', () => {
|
|
751
|
-
const richText =
|
|
860
|
+
const richText = ((created) => {
|
|
861
|
+
Object.assign(created.data, { text: 'abc' });
|
|
862
|
+
return created;
|
|
863
|
+
})(createRichText());
|
|
752
864
|
const signals = enableTextFieldSignals(richText);
|
|
753
865
|
let previous = '';
|
|
754
866
|
connectSignal(signals.onTextFieldChange, (event) => {
|
|
@@ -762,7 +874,10 @@ describe('insertRichTextString', () => {
|
|
|
762
874
|
|
|
763
875
|
describe('removeRichTextFormatRangesIn', () => {
|
|
764
876
|
it('removes ranges that overlap the given span', () => {
|
|
765
|
-
const richText =
|
|
877
|
+
const richText = ((created) => {
|
|
878
|
+
Object.assign(created.data, { text: 'hello world' });
|
|
879
|
+
return created;
|
|
880
|
+
})(createRichText());
|
|
766
881
|
setRichTextFormatRange(richText, { bold: true }, 0, 5);
|
|
767
882
|
setRichTextFormatRange(richText, { italic: true }, 6, 11);
|
|
768
883
|
removeRichTextFormatRangesIn(richText, 0, 5);
|
|
@@ -771,7 +886,10 @@ describe('removeRichTextFormatRangesIn', () => {
|
|
|
771
886
|
});
|
|
772
887
|
|
|
773
888
|
it('does not invalidate when no ranges overlap', () => {
|
|
774
|
-
const richText =
|
|
889
|
+
const richText = ((created) => {
|
|
890
|
+
Object.assign(created.data, { text: 'hello world' });
|
|
891
|
+
return created;
|
|
892
|
+
})(createRichText());
|
|
775
893
|
setRichTextFormatRange(richText, { bold: true }, 6, 11);
|
|
776
894
|
const runtime = getEntityRuntime(richText) as RichTextRuntime;
|
|
777
895
|
const idBefore = runtime.localContentId;
|
|
@@ -782,20 +900,29 @@ describe('removeRichTextFormatRangesIn', () => {
|
|
|
782
900
|
|
|
783
901
|
describe('replaceRichTextString', () => {
|
|
784
902
|
it('replaces the substring in [beginIndex, endIndex)', () => {
|
|
785
|
-
const richText =
|
|
903
|
+
const richText = ((created) => {
|
|
904
|
+
Object.assign(created.data, { text: 'hello world' });
|
|
905
|
+
return created;
|
|
906
|
+
})(createRichText());
|
|
786
907
|
replaceRichTextString(richText, 0, 5, 'goodbye');
|
|
787
908
|
expect(richText.data.text).toBe('goodbye world');
|
|
788
909
|
});
|
|
789
910
|
|
|
790
911
|
it('clamps indices and degenerates to an insert when begin >= end', () => {
|
|
791
|
-
const richText =
|
|
912
|
+
const richText = ((created) => {
|
|
913
|
+
Object.assign(created.data, { text: 'abc' });
|
|
914
|
+
return created;
|
|
915
|
+
})(createRichText());
|
|
792
916
|
replaceRichTextString(richText, 5, 1, 'XYZ');
|
|
793
917
|
// begin clamps to 3, end clamps to max(begin, 1) = 3 -> insert at 3.
|
|
794
918
|
expect(richText.data.text).toBe('abcXYZ');
|
|
795
919
|
});
|
|
796
920
|
|
|
797
921
|
it('shifts ranges entirely after the replaced span by the net delta', () => {
|
|
798
|
-
const richText =
|
|
922
|
+
const richText = ((created) => {
|
|
923
|
+
Object.assign(created.data, { text: 'abcdefgh' });
|
|
924
|
+
return created;
|
|
925
|
+
})(createRichText());
|
|
799
926
|
setRichTextFormatRange(richText, { bold: true }, 6, 8);
|
|
800
927
|
replaceRichTextString(richText, 0, 2, 'X');
|
|
801
928
|
const range = richText.data.textFormatRanges[0];
|
|
@@ -804,7 +931,10 @@ describe('replaceRichTextString', () => {
|
|
|
804
931
|
});
|
|
805
932
|
|
|
806
933
|
it('leaves ranges entirely before the span unchanged', () => {
|
|
807
|
-
const richText =
|
|
934
|
+
const richText = ((created) => {
|
|
935
|
+
Object.assign(created.data, { text: 'abcdefgh' });
|
|
936
|
+
return created;
|
|
937
|
+
})(createRichText());
|
|
808
938
|
setRichTextFormatRange(richText, { bold: true }, 0, 2);
|
|
809
939
|
replaceRichTextString(richText, 4, 6, 'XXXX');
|
|
810
940
|
const range = richText.data.textFormatRanges[0];
|
|
@@ -813,14 +943,20 @@ describe('replaceRichTextString', () => {
|
|
|
813
943
|
});
|
|
814
944
|
|
|
815
945
|
it('removes ranges fully inside the replaced span', () => {
|
|
816
|
-
const richText =
|
|
946
|
+
const richText = ((created) => {
|
|
947
|
+
Object.assign(created.data, { text: 'abcdefgh' });
|
|
948
|
+
return created;
|
|
949
|
+
})(createRichText());
|
|
817
950
|
setRichTextFormatRange(richText, { bold: true }, 2, 5);
|
|
818
951
|
replaceRichTextString(richText, 1, 6, 'X');
|
|
819
952
|
expect(richText.data.textFormatRanges).toHaveLength(0);
|
|
820
953
|
});
|
|
821
954
|
|
|
822
955
|
it('shrinks a range that spans both boundaries by the net delta', () => {
|
|
823
|
-
const richText =
|
|
956
|
+
const richText = ((created) => {
|
|
957
|
+
Object.assign(created.data, { text: 'abcdefgh' });
|
|
958
|
+
return created;
|
|
959
|
+
})(createRichText());
|
|
824
960
|
setRichTextFormatRange(richText, { bold: true }, 0, 8);
|
|
825
961
|
replaceRichTextString(richText, 2, 4, 'X');
|
|
826
962
|
const range = richText.data.textFormatRanges[0];
|
|
@@ -829,7 +965,10 @@ describe('replaceRichTextString', () => {
|
|
|
829
965
|
});
|
|
830
966
|
|
|
831
967
|
it('trims a left-overlapping range to the end of the inserted text', () => {
|
|
832
|
-
const richText =
|
|
968
|
+
const richText = ((created) => {
|
|
969
|
+
Object.assign(created.data, { text: 'abcdefgh' });
|
|
970
|
+
return created;
|
|
971
|
+
})(createRichText());
|
|
833
972
|
setRichTextFormatRange(richText, { bold: true }, 0, 4);
|
|
834
973
|
replaceRichTextString(richText, 2, 6, 'XYZ');
|
|
835
974
|
const range = richText.data.textFormatRanges[0];
|
|
@@ -838,7 +977,10 @@ describe('replaceRichTextString', () => {
|
|
|
838
977
|
});
|
|
839
978
|
|
|
840
979
|
it('trims a right-overlapping range to after the inserted text', () => {
|
|
841
|
-
const richText =
|
|
980
|
+
const richText = ((created) => {
|
|
981
|
+
Object.assign(created.data, { text: 'abcdefgh' });
|
|
982
|
+
return created;
|
|
983
|
+
})(createRichText());
|
|
842
984
|
setRichTextFormatRange(richText, { bold: true }, 4, 8);
|
|
843
985
|
replaceRichTextString(richText, 2, 6, 'XYZ');
|
|
844
986
|
const range = richText.data.textFormatRanges[0];
|
|
@@ -847,7 +989,10 @@ describe('replaceRichTextString', () => {
|
|
|
847
989
|
});
|
|
848
990
|
|
|
849
991
|
it('emits onTextFieldChange only when the text actually changed', () => {
|
|
850
|
-
const richText =
|
|
992
|
+
const richText = ((created) => {
|
|
993
|
+
Object.assign(created.data, { text: 'abc' });
|
|
994
|
+
return created;
|
|
995
|
+
})(createRichText());
|
|
851
996
|
const signals = enableTextFieldSignals(richText);
|
|
852
997
|
const changes: string[] = [];
|
|
853
998
|
connectSignal(signals.onTextFieldChange, (event) => {
|
|
@@ -915,8 +1060,8 @@ describe('setRichTextBorderColor', () => {
|
|
|
915
1060
|
it('sets borderColor and bumps content', () => {
|
|
916
1061
|
const richText = createRichText();
|
|
917
1062
|
const content = getNodeLocalContentRevision(richText);
|
|
918
|
-
setRichTextBorderColor(richText,
|
|
919
|
-
expect(richText.data.borderColor).toBe(
|
|
1063
|
+
setRichTextBorderColor(richText, 0xff0000ff);
|
|
1064
|
+
expect(richText.data.borderColor).toBe(0xff0000ff);
|
|
920
1065
|
expect(getNodeLocalContentRevision(richText)).toBe(content + 1);
|
|
921
1066
|
});
|
|
922
1067
|
|
|
@@ -968,7 +1113,10 @@ describe('setRichTextContent', () => {
|
|
|
968
1113
|
});
|
|
969
1114
|
|
|
970
1115
|
it('emits onTextFieldChange when the text changes', () => {
|
|
971
|
-
const richText =
|
|
1116
|
+
const richText = ((created) => {
|
|
1117
|
+
Object.assign(created.data, { text: 'old' });
|
|
1118
|
+
return created;
|
|
1119
|
+
})(createRichText());
|
|
972
1120
|
const signals = enableTextFieldSignals(richText);
|
|
973
1121
|
let seen = '';
|
|
974
1122
|
connectSignal(signals.onTextFieldChange, (event) => {
|
|
@@ -977,6 +1125,22 @@ describe('setRichTextContent', () => {
|
|
|
977
1125
|
setRichTextContent(richText, { [EntityRuntimeKey]: undefined, formatRanges: [], text: 'new' });
|
|
978
1126
|
expect(seen).toBe('old');
|
|
979
1127
|
});
|
|
1128
|
+
|
|
1129
|
+
it('does not copy or invalidate structurally unchanged content', () => {
|
|
1130
|
+
const richText = ((created) => {
|
|
1131
|
+
Object.assign(created.data, { text: 'same', textFormatRanges: [createTextFormatRange({ bold: true }, 0, 4)] });
|
|
1132
|
+
return created;
|
|
1133
|
+
})(createRichText());
|
|
1134
|
+
const ranges = richText.data.textFormatRanges;
|
|
1135
|
+
const revision = getNodeLocalContentRevision(richText);
|
|
1136
|
+
setRichTextContent(richText, {
|
|
1137
|
+
[EntityRuntimeKey]: undefined,
|
|
1138
|
+
formatRanges: [createTextFormatRange({ bold: true }, 0, 4)],
|
|
1139
|
+
text: 'same',
|
|
1140
|
+
});
|
|
1141
|
+
expect(richText.data.textFormatRanges).toBe(ranges);
|
|
1142
|
+
expect(getNodeLocalContentRevision(richText)).toBe(revision);
|
|
1143
|
+
});
|
|
980
1144
|
});
|
|
981
1145
|
|
|
982
1146
|
describe('setRichTextDefaultTextFormat', () => {
|
|
@@ -988,14 +1152,50 @@ describe('setRichTextDefaultTextFormat', () => {
|
|
|
988
1152
|
expect(richText.data.defaultTextFormat).toBe(format);
|
|
989
1153
|
expect(getNodeLocalContentRevision(richText)).toBe(content + 1);
|
|
990
1154
|
});
|
|
1155
|
+
|
|
1156
|
+
it('does not invalidate for a structurally equal format', () => {
|
|
1157
|
+
const richText = ((created) => {
|
|
1158
|
+
Object.assign(created.data, { defaultTextFormat: { size: 18, tabStops: [4, 8] } });
|
|
1159
|
+
return created;
|
|
1160
|
+
})(createRichText());
|
|
1161
|
+
const content = getNodeLocalContentRevision(richText);
|
|
1162
|
+
setRichTextDefaultTextFormat(richText, { size: 18, tabStops: [4, 8] });
|
|
1163
|
+
expect(getNodeLocalContentRevision(richText)).toBe(content);
|
|
1164
|
+
});
|
|
991
1165
|
});
|
|
992
1166
|
|
|
993
1167
|
describe('setRichTextFormatRange', () => {
|
|
994
1168
|
it('adds a serialized format range', () => {
|
|
995
|
-
const richText =
|
|
1169
|
+
const richText = ((created) => {
|
|
1170
|
+
Object.assign(created.data, { text: 'hello' });
|
|
1171
|
+
return created;
|
|
1172
|
+
})(createRichText());
|
|
996
1173
|
setRichTextFormatRange(richText, { italic: true }, 1, 4);
|
|
997
1174
|
expect(richText.data.textFormatRanges).toMatchObject([{ start: 1, end: 4, format: { italic: true } }]);
|
|
998
1175
|
});
|
|
1176
|
+
|
|
1177
|
+
it('does not append or invalidate an exact repeat of the most recent range', () => {
|
|
1178
|
+
const richText = ((created) => {
|
|
1179
|
+
Object.assign(created.data, { text: 'hello' });
|
|
1180
|
+
return created;
|
|
1181
|
+
})(createRichText());
|
|
1182
|
+
setRichTextFormatRange(richText, { italic: true }, 1, 4);
|
|
1183
|
+
const revision = getNodeLocalContentRevision(richText);
|
|
1184
|
+
setRichTextFormatRange(richText, { italic: true }, 1, 4);
|
|
1185
|
+
expect(richText.data.textFormatRanges).toHaveLength(1);
|
|
1186
|
+
expect(getNodeLocalContentRevision(richText)).toBe(revision);
|
|
1187
|
+
});
|
|
1188
|
+
|
|
1189
|
+
it('appends a new override when an equal older range was superseded', () => {
|
|
1190
|
+
const richText = ((created) => {
|
|
1191
|
+
Object.assign(created.data, { text: 'hello' });
|
|
1192
|
+
return created;
|
|
1193
|
+
})(createRichText());
|
|
1194
|
+
setRichTextFormatRange(richText, { italic: true }, 1, 4);
|
|
1195
|
+
setRichTextFormatRange(richText, { italic: false }, 1, 4);
|
|
1196
|
+
setRichTextFormatRange(richText, { italic: true }, 1, 4);
|
|
1197
|
+
expect(richText.data.textFormatRanges).toHaveLength(3);
|
|
1198
|
+
});
|
|
999
1199
|
});
|
|
1000
1200
|
|
|
1001
1201
|
describe('setRichTextHeight', () => {
|
|
@@ -1131,7 +1331,10 @@ describe('setRichTextString', () => {
|
|
|
1131
1331
|
});
|
|
1132
1332
|
|
|
1133
1333
|
it('does not invalidate bounds when the field is fixed (autoSize none)', () => {
|
|
1134
|
-
const richText =
|
|
1334
|
+
const richText = ((created) => {
|
|
1335
|
+
Object.assign(created.data, { autoSize: 'none' });
|
|
1336
|
+
return created;
|
|
1337
|
+
})(createRichText());
|
|
1135
1338
|
const runtime = getEntityRuntime(richText) as RichTextRuntime;
|
|
1136
1339
|
const boundsBefore = runtime.localBoundsId;
|
|
1137
1340
|
setRichTextString(richText, 'hello');
|
|
@@ -1139,7 +1342,10 @@ describe('setRichTextString', () => {
|
|
|
1139
1342
|
});
|
|
1140
1343
|
|
|
1141
1344
|
it('invalidates bounds when autoSize resizes the field', () => {
|
|
1142
|
-
const richText =
|
|
1345
|
+
const richText = ((created) => {
|
|
1346
|
+
Object.assign(created.data, { autoSize: 'left' });
|
|
1347
|
+
return created;
|
|
1348
|
+
})(createRichText());
|
|
1143
1349
|
const runtime = getEntityRuntime(richText) as RichTextRuntime;
|
|
1144
1350
|
const boundsBefore = runtime.localBoundsId;
|
|
1145
1351
|
setRichTextString(richText, 'hello');
|