squiffy-runtime 6.0.0-alpha.13 → 6.0.0-alpha.14
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/dist/squiffy.runtime.js
CHANGED
|
@@ -463,7 +463,7 @@ export const init = (options) => {
|
|
|
463
463
|
else if (newSection.text && newSection.text != story.sections[existingSection].text) {
|
|
464
464
|
// section has been updated
|
|
465
465
|
for (const element of elements) {
|
|
466
|
-
updateElementTextPreservingDisabledPassageLinks(element, newSection.text);
|
|
466
|
+
updateElementTextPreservingDisabledPassageLinks(element, ui.processText(newSection.text));
|
|
467
467
|
}
|
|
468
468
|
}
|
|
469
469
|
}
|
|
@@ -484,7 +484,7 @@ export const init = (options) => {
|
|
|
484
484
|
else if (newPassage.text && newPassage.text != story.sections[existingSection].passages[existingPassage].text) {
|
|
485
485
|
// passage has been updated
|
|
486
486
|
for (const element of elements) {
|
|
487
|
-
updateElementTextPreservingDisabledPassageLinks(element, newPassage.text);
|
|
487
|
+
updateElementTextPreservingDisabledPassageLinks(element, ui.processText(newPassage.text));
|
|
488
488
|
}
|
|
489
489
|
}
|
|
490
490
|
}
|
|
@@ -342,3 +342,53 @@ Text from a passage.
|
|
|
342
342
|
let output = getSectionContent(element, 'section1');
|
|
343
343
|
expect(output).toBe('Here is some text from a passage: Text from a passage.');
|
|
344
344
|
});
|
|
345
|
+
test('Update section with embedded text', async () => {
|
|
346
|
+
const script = `
|
|
347
|
+
[[section1]]:
|
|
348
|
+
Here is some text from the next section: {section2}
|
|
349
|
+
|
|
350
|
+
[[section2]]:
|
|
351
|
+
Text from next section.
|
|
352
|
+
`;
|
|
353
|
+
const { squiffyApi, element } = await initScript(script);
|
|
354
|
+
let output = getSectionContent(element, 'section1');
|
|
355
|
+
expect(output).toBe('Here is some text from the next section: Text from next section.');
|
|
356
|
+
const script2 = `
|
|
357
|
+
[[section1]]:
|
|
358
|
+
Here is an updated script with text from the next section: {section2}
|
|
359
|
+
|
|
360
|
+
[[section2]]:
|
|
361
|
+
Updated text from next section.
|
|
362
|
+
`;
|
|
363
|
+
const updated = await compile(script2);
|
|
364
|
+
squiffyApi.update(updated.story);
|
|
365
|
+
output = getSectionContent(element, 'section1');
|
|
366
|
+
// NOTE: The embedded text does not currently get updated. We would need to track where the embedded
|
|
367
|
+
// text has been written.
|
|
368
|
+
expect(output).toBe('Here is an updated script with text from the next section: Text from next section.');
|
|
369
|
+
});
|
|
370
|
+
test('Update passage with embedded text', async () => {
|
|
371
|
+
const script = `
|
|
372
|
+
[[section1]]:
|
|
373
|
+
Here is some text from a passage: {passage}
|
|
374
|
+
|
|
375
|
+
[passage]:
|
|
376
|
+
Text from a passage.
|
|
377
|
+
`;
|
|
378
|
+
const { squiffyApi, element } = await initScript(script);
|
|
379
|
+
let output = getSectionContent(element, 'section1');
|
|
380
|
+
expect(output).toBe('Here is some text from a passage: Text from a passage.');
|
|
381
|
+
const script2 = `
|
|
382
|
+
[[section1]]:
|
|
383
|
+
Here is an updated script with text from a passage: {passage}
|
|
384
|
+
|
|
385
|
+
[passage]:
|
|
386
|
+
Updated text from a passage.
|
|
387
|
+
`;
|
|
388
|
+
const updated = await compile(script2);
|
|
389
|
+
squiffyApi.update(updated.story);
|
|
390
|
+
output = getSectionContent(element, 'section1');
|
|
391
|
+
// NOTE: The embedded text does not currently get updated. We would need to track where the embedded
|
|
392
|
+
// text has been written.
|
|
393
|
+
expect(output).toBe('Here is an updated script with text from a passage: Text from a passage.');
|
|
394
|
+
});
|
package/package.json
CHANGED
|
@@ -440,4 +440,66 @@ Text from a passage.
|
|
|
440
440
|
|
|
441
441
|
let output = getSectionContent(element, 'section1');
|
|
442
442
|
expect(output).toBe('Here is some text from a passage: Text from a passage.');
|
|
443
|
+
});
|
|
444
|
+
|
|
445
|
+
test('Update section with embedded text', async () => {
|
|
446
|
+
const script = `
|
|
447
|
+
[[section1]]:
|
|
448
|
+
Here is some text from the next section: {section2}
|
|
449
|
+
|
|
450
|
+
[[section2]]:
|
|
451
|
+
Text from next section.
|
|
452
|
+
`;
|
|
453
|
+
|
|
454
|
+
const { squiffyApi, element } = await initScript(script);
|
|
455
|
+
|
|
456
|
+
let output = getSectionContent(element, 'section1');
|
|
457
|
+
expect(output).toBe('Here is some text from the next section: Text from next section.');
|
|
458
|
+
|
|
459
|
+
const script2 = `
|
|
460
|
+
[[section1]]:
|
|
461
|
+
Here is an updated script with text from the next section: {section2}
|
|
462
|
+
|
|
463
|
+
[[section2]]:
|
|
464
|
+
Updated text from next section.
|
|
465
|
+
`;
|
|
466
|
+
|
|
467
|
+
const updated = await compile(script2);
|
|
468
|
+
squiffyApi.update(updated.story);
|
|
469
|
+
output = getSectionContent(element, 'section1');
|
|
470
|
+
|
|
471
|
+
// NOTE: The embedded text does not currently get updated. We would need to track where the embedded
|
|
472
|
+
// text has been written.
|
|
473
|
+
expect(output).toBe('Here is an updated script with text from the next section: Text from next section.');
|
|
474
|
+
});
|
|
475
|
+
|
|
476
|
+
test('Update passage with embedded text', async () => {
|
|
477
|
+
const script = `
|
|
478
|
+
[[section1]]:
|
|
479
|
+
Here is some text from a passage: {passage}
|
|
480
|
+
|
|
481
|
+
[passage]:
|
|
482
|
+
Text from a passage.
|
|
483
|
+
`;
|
|
484
|
+
|
|
485
|
+
const { squiffyApi, element } = await initScript(script);
|
|
486
|
+
|
|
487
|
+
let output = getSectionContent(element, 'section1');
|
|
488
|
+
expect(output).toBe('Here is some text from a passage: Text from a passage.');
|
|
489
|
+
|
|
490
|
+
const script2 = `
|
|
491
|
+
[[section1]]:
|
|
492
|
+
Here is an updated script with text from a passage: {passage}
|
|
493
|
+
|
|
494
|
+
[passage]:
|
|
495
|
+
Updated text from a passage.
|
|
496
|
+
`;
|
|
497
|
+
|
|
498
|
+
const updated = await compile(script2);
|
|
499
|
+
squiffyApi.update(updated.story);
|
|
500
|
+
output = getSectionContent(element, 'section1');
|
|
501
|
+
|
|
502
|
+
// NOTE: The embedded text does not currently get updated. We would need to track where the embedded
|
|
503
|
+
// text has been written.
|
|
504
|
+
expect(output).toBe('Here is an updated script with text from a passage: Text from a passage.');
|
|
443
505
|
});
|
package/src/squiffy.runtime.ts
CHANGED
|
@@ -496,7 +496,7 @@ export const init = (options: SquiffyInitOptions): SquiffyApi => {
|
|
|
496
496
|
else if (newSection.text && newSection.text != story.sections[existingSection].text) {
|
|
497
497
|
// section has been updated
|
|
498
498
|
for (const element of elements) {
|
|
499
|
-
updateElementTextPreservingDisabledPassageLinks(element, newSection.text);
|
|
499
|
+
updateElementTextPreservingDisabledPassageLinks(element, ui.processText(newSection.text));
|
|
500
500
|
}
|
|
501
501
|
}
|
|
502
502
|
}
|
|
@@ -518,7 +518,7 @@ export const init = (options: SquiffyInitOptions): SquiffyApi => {
|
|
|
518
518
|
else if (newPassage.text && newPassage.text != story.sections[existingSection].passages[existingPassage].text) {
|
|
519
519
|
// passage has been updated
|
|
520
520
|
for (const element of elements) {
|
|
521
|
-
updateElementTextPreservingDisabledPassageLinks(element, newPassage.text);
|
|
521
|
+
updateElementTextPreservingDisabledPassageLinks(element, ui.processText(newPassage.text));
|
|
522
522
|
}
|
|
523
523
|
}
|
|
524
524
|
}
|