diff --git a/packages/survey-creator-core/src/creator-base.ts b/packages/survey-creator-core/src/creator-base.ts index 25193dfce8..2291f6e82b 100644 --- a/packages/survey-creator-core/src/creator-base.ts +++ b/packages/survey-creator-core/src/creator-base.ts @@ -2551,8 +2551,18 @@ export class SurveyCreatorModel extends Base delete json.pages; } } + if(this.storeSjsVersion) { + json["sjsVersion"] = SurveySettings.version; + } return json; } + private storeSjsVersionValue: boolean; + public get storeSjsVersion(): boolean { + return this.storeSjsVersionValue === true; + } + public set storeSjsVersion(val: boolean) { + this.storeSjsVersionValue = val; + } /** * A survey JSON schema. * diff --git a/packages/survey-creator-core/tests/string-editor.tests.ts b/packages/survey-creator-core/tests/string-editor.tests.ts index 694410e9b8..0a5e6ee09e 100644 --- a/packages/survey-creator-core/tests/string-editor.tests.ts +++ b/packages/survey-creator-core/tests/string-editor.tests.ts @@ -956,7 +956,18 @@ test("StringEditor multiline paste for matrix questions", (): any => { connectorItemRow.onTextChanging.fire(null, { value: "a\nb\r\nc" }); expect(question.rows.map(c => c.text)).toEqual(["a", "b", "c", "Row 2"]); }); - +test("Support for creator.storeSjsVersion", (): any => { + const creator = new CreatorTester(); + expect(creator.JSON["sjsVersion"]).toBeFalsy(); + expect(creator.text.indexOf("sjsVersion") > 0).toBeFalsy(); + creator.storeSjsVersion = true; + creator.JSON = { elements: [{ type: "text", name: "q1" }] }; + expect(creator.JSON["sjsVersion"]).toBeTruthy(); + expect(creator.text.indexOf("sjsVersion") > 0).toBeTruthy(); + creator.storeSjsVersion = false; + expect(creator.JSON["sjsVersion"]).toBeFalsy(); + expect(creator.text.indexOf("sjsVersion") > 0).toBeFalsy(); +}); test("StringEditor Navigator - supported types", (): any => { expect(StringItemsNavigatorBase.setQuestion({ element: new QuestionTextModel("q") })).toBeFalsy(); expect(StringItemsNavigatorBase.setQuestion({ element: new QuestionMultipleTextModel("q") })).toBeTruthy();