@wg-npm/survey-core 0.5.159 → 0.5.161

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.
@@ -353,12 +353,20 @@ function translate(obj, locale, prettyMath = false) {
353
353
  obj["zh-TW"]);
354
354
  }
355
355
 
356
+ const CUSTOM_INPUT_REG = /(_{5,})/g;
356
357
  function formatTitle(question, locale) {
357
358
  const title = translate(question.header.text, locale, true);
358
359
  if (!_.get(question, "options.richTextEnabled", false)) {
359
360
  return [title];
360
361
  }
361
- return title.split(/_{5,}/g);
362
+ const trimmedTitles = title.split(CUSTOM_INPUT_REG);
363
+ if (trimmedTitles[0] === "") {
364
+ trimmedTitles.splice(0, 1);
365
+ }
366
+ if (trimmedTitles[trimmedTitles.length - 1] === "") {
367
+ trimmedTitles.splice(trimmedTitles.length - 1, 1);
368
+ }
369
+ return trimmedTitles;
362
370
  }
363
371
  function showInput(index, formatTitle) {
364
372
  if (index === formatTitle.length - 2 &&
@@ -374,4 +382,4 @@ function move(array, fromIndex, toIndex) {
374
382
  array[toIndex] = moveValue;
375
383
  }
376
384
 
377
- export { BaseQuestionModel, ChoiceModel, EvaluationItemModel, ExprConditionModel, ExprEvaluationItemModel, PlanModel, PlanStatisticsModel, QuestionCheckBoxModel, QuestionEvaluationModel, QuestionFactory, QuestionFillBlankModel, QuestionHeaderModel, QuestionMatrixModel, QuestionMulitSelectionModel, QuestionOptionsModel, QuestionScoringModel, QuestionShortAnswerModel, QuestionSingleSelectionModel, QuestionTextTitleModel, ResponseModel, ResponseStatisticsModel, StarEvaluationItemModel, SubQuestionModel, formatTitle, move, showInput, translate };
385
+ export { BaseQuestionModel, CUSTOM_INPUT_REG, ChoiceModel, EvaluationItemModel, ExprConditionModel, ExprEvaluationItemModel, PlanModel, PlanStatisticsModel, QuestionCheckBoxModel, QuestionEvaluationModel, QuestionFactory, QuestionFillBlankModel, QuestionHeaderModel, QuestionMatrixModel, QuestionMulitSelectionModel, QuestionOptionsModel, QuestionScoringModel, QuestionShortAnswerModel, QuestionSingleSelectionModel, QuestionTextTitleModel, ResponseModel, ResponseStatisticsModel, StarEvaluationItemModel, SubQuestionModel, formatTitle, move, showInput, translate };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wg-npm/survey-core",
3
- "version": "0.5.159",
3
+ "version": "0.5.161",
4
4
  "description": "",
5
5
  "license": "MIT",
6
6
  "scripts": {
package/src/index.ts CHANGED
@@ -31,5 +31,5 @@ export {
31
31
  } from "./models";
32
32
  export { QuestionFactory } from "./quetion-factory";
33
33
  export { translate } from "./locale-utils";
34
- export { formatTitle, showInput } from "./question-title-utils";
34
+ export { CUSTOM_INPUT_REG, formatTitle, showInput } from "./question-title-utils";
35
35
  export { move } from "./array-utils";
@@ -1,13 +1,20 @@
1
1
  import _ from "lodash";
2
2
  import { translate } from "./locale-utils";
3
3
 
4
+ export const CUSTOM_INPUT_REG = /(_{5,})/g;
5
+
4
6
  export function formatTitle(question, locale) {
5
7
  const title = translate(question.header.text, locale, true);
6
8
  // @ts-ignore
7
9
  if (!_.get(question, "options.richTextEnabled", false)) {
8
10
  return [title];
9
11
  }
10
- return title.split(/_{5,}/g);
12
+ const trimmedTitles = title.split(CUSTOM_INPUT_REG);
13
+
14
+ if(trimmedTitles[0] === "") { trimmedTitles.splice(0, 1); }
15
+ if(trimmedTitles[trimmedTitles.length - 1] === "") { trimmedTitles.splice(trimmedTitles.length - 1, 1); }
16
+
17
+ return trimmedTitles;
11
18
  }
12
19
 
13
20
  export function showInput(index, formatTitle) {