@wg-npm/survey-core 0.5.136 → 0.5.138

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