@gmb/bitmark-parser-generator 1.4.17 → 1.4.18

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.
Files changed (209) hide show
  1. package/dist/browser/bitmark-parser-generator.min.js +1 -1
  2. package/dist/browser/bundle-report.html +2 -2
  3. package/dist/cjs/BitmarkParserGenerator.js +2 -13
  4. package/dist/cjs/BitmarkParserGenerator.js.map +1 -1
  5. package/dist/cjs/ast/Builder.js +8 -8
  6. package/dist/cjs/ast/Builder.js.map +1 -1
  7. package/dist/cjs/ast/rules/NodeValidator.js +6 -23
  8. package/dist/cjs/ast/rules/NodeValidator.js.map +1 -1
  9. package/dist/cjs/config/Config.js +57 -86
  10. package/dist/cjs/config/Config.js.map +1 -1
  11. package/dist/cjs/config/raw/bits.js +328 -467
  12. package/dist/cjs/config/raw/bits.js.map +1 -1
  13. package/dist/cjs/config/raw/properties.js +10 -0
  14. package/dist/cjs/config/raw/properties.js.map +1 -1
  15. package/dist/cjs/generated/build-info.js +1 -1
  16. package/dist/cjs/generator/bitmark/BitmarkGenerator.js +9 -11
  17. package/dist/cjs/generator/bitmark/BitmarkGenerator.js.map +1 -1
  18. package/dist/cjs/generator/json/JsonGenerator.js +224 -205
  19. package/dist/cjs/generator/json/JsonGenerator.js.map +1 -1
  20. package/dist/cjs/index.js +2 -3
  21. package/dist/cjs/index.js.map +1 -1
  22. package/dist/cjs/info/InfoBuilder.js +10 -33
  23. package/dist/cjs/info/InfoBuilder.js.map +1 -1
  24. package/dist/cjs/model/ast/NodeType.js +4 -0
  25. package/dist/cjs/model/ast/NodeType.js.map +1 -1
  26. package/dist/cjs/model/config/BitConfig.js +8 -7
  27. package/dist/cjs/model/config/BitConfig.js.map +1 -1
  28. package/dist/cjs/model/config/enum/PropertyConfigKey.js +2 -0
  29. package/dist/cjs/model/config/enum/PropertyConfigKey.js.map +1 -1
  30. package/dist/cjs/model/enum/BitType.js +86 -89
  31. package/dist/cjs/model/enum/BitType.js.map +1 -1
  32. package/dist/cjs/model/enum/PropertyTag.js +2 -0
  33. package/dist/cjs/model/enum/PropertyTag.js.map +1 -1
  34. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserProcessor.js +9 -9
  35. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserProcessor.js.map +1 -1
  36. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserValidator.js +6 -6
  37. package/dist/cjs/parser/bitmark/peg/BitmarkPegParserValidator.js.map +1 -1
  38. package/dist/cjs/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js.map +1 -1
  39. package/dist/cjs/parser/bitmark/peg/contentProcessors/CardContentProcessor.js +4 -4
  40. package/dist/cjs/parser/bitmark/peg/contentProcessors/CardContentProcessor.js.map +1 -1
  41. package/dist/cjs/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js.map +1 -1
  42. package/dist/cjs/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js.map +1 -1
  43. package/dist/cjs/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js +52 -47
  44. package/dist/cjs/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js.map +1 -1
  45. package/dist/cjs/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.js.map +1 -1
  46. package/dist/cjs/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js.map +1 -1
  47. package/dist/cjs/parser/bitmark/peg/contentProcessors/InternalCommentTagContentProcessor.js.map +1 -1
  48. package/dist/cjs/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.js.map +1 -1
  49. package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.js.map +1 -1
  50. package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js.map +1 -1
  51. package/dist/cjs/parser/bitmark/peg/contentProcessors/MarkTagContentProcessor.js.map +1 -1
  52. package/dist/cjs/parser/bitmark/peg/contentProcessors/PartnerChainContentProcessor.js.map +1 -1
  53. package/dist/cjs/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js.map +1 -1
  54. package/dist/cjs/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js.map +1 -1
  55. package/dist/cjs/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js.map +1 -1
  56. package/dist/cjs/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js +15 -17
  57. package/dist/cjs/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js.map +1 -1
  58. package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js +14 -11
  59. package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js.map +1 -1
  60. package/dist/cjs/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js.map +1 -1
  61. package/dist/cjs/parser/json/JsonParser.js +5 -5
  62. package/dist/cjs/parser/json/JsonParser.js.map +1 -1
  63. package/dist/cjs/utils/ObjectUtils.js +62 -0
  64. package/dist/cjs/utils/ObjectUtils.js.map +1 -1
  65. package/dist/esm/BitmarkParserGenerator.js +2 -13
  66. package/dist/esm/BitmarkParserGenerator.js.map +1 -1
  67. package/dist/esm/ast/Builder.js +9 -9
  68. package/dist/esm/ast/Builder.js.map +1 -1
  69. package/dist/esm/ast/rules/NodeValidator.js +6 -23
  70. package/dist/esm/ast/rules/NodeValidator.js.map +1 -1
  71. package/dist/esm/config/Config.js +57 -86
  72. package/dist/esm/config/Config.js.map +1 -1
  73. package/dist/esm/config/raw/bits.js +329 -468
  74. package/dist/esm/config/raw/bits.js.map +1 -1
  75. package/dist/esm/config/raw/properties.js +10 -0
  76. package/dist/esm/config/raw/properties.js.map +1 -1
  77. package/dist/esm/generated/build-info.js +1 -1
  78. package/dist/esm/generator/bitmark/BitmarkGenerator.js +10 -12
  79. package/dist/esm/generator/bitmark/BitmarkGenerator.js.map +1 -1
  80. package/dist/esm/generator/json/JsonGenerator.js +225 -206
  81. package/dist/esm/generator/json/JsonGenerator.js.map +1 -1
  82. package/dist/esm/index.js +1 -1
  83. package/dist/esm/index.js.map +1 -1
  84. package/dist/esm/info/InfoBuilder.js +11 -34
  85. package/dist/esm/info/InfoBuilder.js.map +1 -1
  86. package/dist/esm/model/ast/NodeType.js +4 -0
  87. package/dist/esm/model/ast/NodeType.js.map +1 -1
  88. package/dist/esm/model/config/BitConfig.js +8 -7
  89. package/dist/esm/model/config/BitConfig.js.map +1 -1
  90. package/dist/esm/model/config/enum/PropertyConfigKey.js +2 -0
  91. package/dist/esm/model/config/enum/PropertyConfigKey.js.map +1 -1
  92. package/dist/esm/model/enum/BitType.js +85 -87
  93. package/dist/esm/model/enum/BitType.js.map +1 -1
  94. package/dist/esm/model/enum/PropertyTag.js +2 -0
  95. package/dist/esm/model/enum/PropertyTag.js.map +1 -1
  96. package/dist/esm/parser/bitmark/peg/BitmarkPegParserProcessor.js +10 -10
  97. package/dist/esm/parser/bitmark/peg/BitmarkPegParserProcessor.js.map +1 -1
  98. package/dist/esm/parser/bitmark/peg/BitmarkPegParserValidator.js +6 -6
  99. package/dist/esm/parser/bitmark/peg/BitmarkPegParserValidator.js.map +1 -1
  100. package/dist/esm/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.js.map +1 -1
  101. package/dist/esm/parser/bitmark/peg/contentProcessors/CardContentProcessor.js +5 -5
  102. package/dist/esm/parser/bitmark/peg/contentProcessors/CardContentProcessor.js.map +1 -1
  103. package/dist/esm/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.js.map +1 -1
  104. package/dist/esm/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.js.map +1 -1
  105. package/dist/esm/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js +53 -48
  106. package/dist/esm/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.js.map +1 -1
  107. package/dist/esm/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.js.map +1 -1
  108. package/dist/esm/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.js.map +1 -1
  109. package/dist/esm/parser/bitmark/peg/contentProcessors/InternalCommentTagContentProcessor.js.map +1 -1
  110. package/dist/esm/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.js.map +1 -1
  111. package/dist/esm/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.js.map +1 -1
  112. package/dist/esm/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.js.map +1 -1
  113. package/dist/esm/parser/bitmark/peg/contentProcessors/MarkTagContentProcessor.js.map +1 -1
  114. package/dist/esm/parser/bitmark/peg/contentProcessors/PartnerChainContentProcessor.js.map +1 -1
  115. package/dist/esm/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.js.map +1 -1
  116. package/dist/esm/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.js.map +1 -1
  117. package/dist/esm/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.js.map +1 -1
  118. package/dist/esm/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js +16 -18
  119. package/dist/esm/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.js.map +1 -1
  120. package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js +15 -12
  121. package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.js.map +1 -1
  122. package/dist/esm/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.js.map +1 -1
  123. package/dist/esm/parser/json/JsonParser.js +6 -6
  124. package/dist/esm/parser/json/JsonParser.js.map +1 -1
  125. package/dist/esm/utils/ObjectUtils.js +59 -0
  126. package/dist/esm/utils/ObjectUtils.js.map +1 -1
  127. package/dist/types/BitmarkParserGenerator.d.ts.map +1 -1
  128. package/dist/types/ast/Builder.d.ts +4 -2
  129. package/dist/types/ast/Builder.d.ts.map +1 -1
  130. package/dist/types/ast/rules/NodeValidator.d.ts +0 -1
  131. package/dist/types/ast/rules/NodeValidator.d.ts.map +1 -1
  132. package/dist/types/config/Config.d.ts +16 -28
  133. package/dist/types/config/Config.d.ts.map +1 -1
  134. package/dist/types/config/raw/bits.d.ts.map +1 -1
  135. package/dist/types/config/raw/properties.d.ts.map +1 -1
  136. package/dist/types/generator/bitmark/BitmarkGenerator.d.ts +4 -4
  137. package/dist/types/generator/bitmark/BitmarkGenerator.d.ts.map +1 -1
  138. package/dist/types/generator/json/JsonGenerator.d.ts +22 -22
  139. package/dist/types/generator/json/JsonGenerator.d.ts.map +1 -1
  140. package/dist/types/generator/text/TextGenerator.d.ts +2 -2
  141. package/dist/types/generator/text/TextGenerator.d.ts.map +1 -1
  142. package/dist/types/index.d.ts +2 -2
  143. package/dist/types/index.d.ts.map +1 -1
  144. package/dist/types/info/InfoBuilder.d.ts +3 -4
  145. package/dist/types/info/InfoBuilder.d.ts.map +1 -1
  146. package/dist/types/model/ast/NodeType.d.ts +8 -0
  147. package/dist/types/model/ast/NodeType.d.ts.map +1 -1
  148. package/dist/types/model/ast/Nodes.d.ts +4 -2
  149. package/dist/types/model/ast/Nodes.d.ts.map +1 -1
  150. package/dist/types/model/config/BitConfig.d.ts +5 -4
  151. package/dist/types/model/config/BitConfig.d.ts.map +1 -1
  152. package/dist/types/model/config/_Config.d.ts +3 -5
  153. package/dist/types/model/config/_Config.d.ts.map +1 -1
  154. package/dist/types/model/config/enum/ConfigKey.d.ts +4 -0
  155. package/dist/types/model/config/enum/ConfigKey.d.ts.map +1 -1
  156. package/dist/types/model/config/enum/PropertyConfigKey.d.ts +6 -0
  157. package/dist/types/model/config/enum/PropertyConfigKey.d.ts.map +1 -1
  158. package/dist/types/model/enum/BitType.d.ts +171 -188
  159. package/dist/types/model/enum/BitType.d.ts.map +1 -1
  160. package/dist/types/model/enum/PropertyTag.d.ts +4 -0
  161. package/dist/types/model/enum/PropertyTag.d.ts.map +1 -1
  162. package/dist/types/model/json/BitJson.d.ts +2 -0
  163. package/dist/types/model/json/BitJson.d.ts.map +1 -1
  164. package/dist/types/parser/bitmark/peg/BitmarkPegParserTypes.d.ts +3 -3
  165. package/dist/types/parser/bitmark/peg/BitmarkPegParserTypes.d.ts.map +1 -1
  166. package/dist/types/parser/bitmark/peg/BitmarkPegParserValidator.d.ts +6 -6
  167. package/dist/types/parser/bitmark/peg/BitmarkPegParserValidator.d.ts.map +1 -1
  168. package/dist/types/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.d.ts +2 -2
  169. package/dist/types/parser/bitmark/peg/contentProcessors/BookChainContentProcessor.d.ts.map +1 -1
  170. package/dist/types/parser/bitmark/peg/contentProcessors/CardContentProcessor.d.ts +2 -2
  171. package/dist/types/parser/bitmark/peg/contentProcessors/CardContentProcessor.d.ts.map +1 -1
  172. package/dist/types/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.d.ts +2 -2
  173. package/dist/types/parser/bitmark/peg/contentProcessors/ClozeTagContentProcessor.d.ts.map +1 -1
  174. package/dist/types/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.d.ts +2 -2
  175. package/dist/types/parser/bitmark/peg/contentProcessors/DefaultTagContentProcessor.d.ts.map +1 -1
  176. package/dist/types/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.d.ts +2 -2
  177. package/dist/types/parser/bitmark/peg/contentProcessors/ExampleTagContentProcessor.d.ts.map +1 -1
  178. package/dist/types/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.d.ts +2 -2
  179. package/dist/types/parser/bitmark/peg/contentProcessors/GapChainContentProcessor.d.ts.map +1 -1
  180. package/dist/types/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.d.ts +2 -2
  181. package/dist/types/parser/bitmark/peg/contentProcessors/ImageSourceChainContentProcessor.d.ts.map +1 -1
  182. package/dist/types/parser/bitmark/peg/contentProcessors/InternalCommentTagContentProcessor.d.ts +2 -2
  183. package/dist/types/parser/bitmark/peg/contentProcessors/InternalCommentTagContentProcessor.d.ts.map +1 -1
  184. package/dist/types/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.d.ts +2 -2
  185. package/dist/types/parser/bitmark/peg/contentProcessors/ItemLeadTagContentProcessor.d.ts.map +1 -1
  186. package/dist/types/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.d.ts +2 -2
  187. package/dist/types/parser/bitmark/peg/contentProcessors/MarkChainContentProcessor.d.ts.map +1 -1
  188. package/dist/types/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.d.ts +2 -2
  189. package/dist/types/parser/bitmark/peg/contentProcessors/MarkConfigChainContentProcessor.d.ts.map +1 -1
  190. package/dist/types/parser/bitmark/peg/contentProcessors/MarkTagContentProcessor.d.ts +2 -2
  191. package/dist/types/parser/bitmark/peg/contentProcessors/MarkTagContentProcessor.d.ts.map +1 -1
  192. package/dist/types/parser/bitmark/peg/contentProcessors/PartnerChainContentProcessor.d.ts +2 -2
  193. package/dist/types/parser/bitmark/peg/contentProcessors/PartnerChainContentProcessor.d.ts.map +1 -1
  194. package/dist/types/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.d.ts +2 -2
  195. package/dist/types/parser/bitmark/peg/contentProcessors/PropertyContentProcessor.d.ts.map +1 -1
  196. package/dist/types/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.d.ts +2 -2
  197. package/dist/types/parser/bitmark/peg/contentProcessors/ReferenceTagContentProcessor.d.ts.map +1 -1
  198. package/dist/types/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.d.ts +3 -3
  199. package/dist/types/parser/bitmark/peg/contentProcessors/ResourceContentProcessor.d.ts.map +1 -1
  200. package/dist/types/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.d.ts +3 -3
  201. package/dist/types/parser/bitmark/peg/contentProcessors/TitleTagContentProcessor.d.ts.map +1 -1
  202. package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.d.ts +2 -2
  203. package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseChainContentProcessor.d.ts.map +1 -1
  204. package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.d.ts +2 -2
  205. package/dist/types/parser/bitmark/peg/contentProcessors/TrueFalseTagContentProcessor.d.ts.map +1 -1
  206. package/dist/types/parser/json/JsonParser.d.ts.map +1 -1
  207. package/dist/types/utils/ObjectUtils.d.ts +9 -0
  208. package/dist/types/utils/ObjectUtils.d.ts.map +1 -1
  209. package/package.json +3 -1
@@ -22,7 +22,7 @@ import { Ast } from '../../ast/Ast';
22
22
  import { Breakscape } from '../../breakscaping/Breakscape';
23
23
  import { Config } from '../../config/Config';
24
24
  import { NodeType } from '../../model/ast/NodeType';
25
- import { AliasBitType, RootBitType } from '../../model/enum/BitType';
25
+ import { BitType } from '../../model/enum/BitType';
26
26
  import { BitmarkVersion, DEFAULT_BITMARK_VERSION } from '../../model/enum/BitmarkVersion';
27
27
  import { BodyBitType } from '../../model/enum/BodyBitType';
28
28
  import { ExampleType } from '../../model/enum/ExampleType';
@@ -218,7 +218,7 @@ class JsonGenerator {
218
218
  if (isBoolean) {
219
219
  // Boolean example
220
220
  defaultExample = true;
221
- if (bit.bitType.root === RootBitType.trueFalse1) {
221
+ if (Config.isOfBitType(bit.bitType, BitType.trueFalse1)) {
222
222
  if (((_b = (_a = bit.cardNode) === null || _a === void 0 ? void 0 : _a.statement) === null || _b === void 0 ? void 0 : _b.isCorrect) !== undefined) {
223
223
  defaultExample = bit.cardNode.statement.isCorrect;
224
224
  }
@@ -336,7 +336,7 @@ class JsonGenerator {
336
336
  return;
337
337
  // Create the listItems / sections if not already created
338
338
  let listItems;
339
- if (bitType.alias === AliasBitType.pageFooter) {
339
+ if (bitType === BitType.pageFooter) {
340
340
  if (!this.bitJson.sections)
341
341
  this.bitJson.sections = [];
342
342
  listItems = this.bitJson.sections;
@@ -1686,9 +1686,9 @@ class JsonGenerator {
1686
1686
  return zoomDisabled;
1687
1687
  // The default value in the JSON is hardcoded, because there is currently no good way to set a different
1688
1688
  // default per bit in the BitConfig.
1689
- switch (bitType.alias) {
1690
- case AliasBitType.imageSeparator:
1691
- case AliasBitType.pageBanner:
1689
+ switch (bitType) {
1690
+ case BitType.imageSeparator:
1691
+ case BitType.pageBanner:
1692
1692
  return true;
1693
1693
  }
1694
1694
  return false;
@@ -1851,7 +1851,7 @@ class JsonGenerator {
1851
1851
  */
1852
1852
  createBitJson(bit) {
1853
1853
  const bitJson = {
1854
- type: bit.bitType.alias,
1854
+ type: bit.bitType,
1855
1855
  format: bit.textFormat,
1856
1856
  // Properties
1857
1857
  id: undefined,
@@ -1889,6 +1889,8 @@ class JsonGenerator {
1889
1889
  thumbImage: undefined,
1890
1890
  focusX: undefined,
1891
1891
  focusY: undefined,
1892
+ pointerLeft: undefined,
1893
+ pointerTop: undefined,
1892
1894
  deeplink: undefined,
1893
1895
  externalLink: undefined,
1894
1896
  externalLinkText: undefined,
@@ -1988,207 +1990,224 @@ class JsonGenerator {
1988
1990
  // NOTE: Not all bits have the same default properties.
1989
1991
  // The properties used are a bit random sometimes?
1990
1992
  // It would be better if this functionality was generated from the bit config
1991
- switch (bitType.root) {
1992
- case RootBitType._error:
1993
- case RootBitType._comment:
1994
- delete bitJson.format;
1995
- break;
1996
- case RootBitType.article:
1997
- case RootBitType.sampleSolution:
1998
- case RootBitType.page:
1999
- if (bitJson.body == null)
2000
- bitJson.body = this.bodyDefault;
2001
- break;
2002
- default: // Most bits have these defaults, but there are special cases (not sure if that is by error or design)
2003
- if (bitJson.item == null)
2004
- bitJson.item = this.textDefault;
2005
- if (bitJson.hint == null)
2006
- bitJson.hint = this.textDefault;
2007
- if (bitJson.isExample == null)
2008
- bitJson.isExample = false;
2009
- if (bitJson.example == null)
2010
- bitJson.example = null;
2011
- if (bitJson.body == null)
2012
- bitJson.body = this.bodyDefault;
2013
- // Special case for 'ai' bits
2014
- if (bitType.alias === AliasBitType.articleAi ||
2015
- bitType.alias === AliasBitType.noteAi ||
2016
- bitType.alias === AliasBitType.summaryAi) {
2017
- if (bitJson.AIGenerated == null)
2018
- bitJson.AIGenerated = true;
2019
- }
2020
- // Special case for 'review-...' bits
2021
- if (bitType.root === RootBitType.reviewNote) {
2022
- if (bitJson.resolved == null)
2023
- bitJson.resolved = false;
2024
- if (bitJson.resolvedDate == null)
2025
- bitJson.resolvedDate = '';
2026
- if (bitJson.resolvedBy == null)
2027
- bitJson.resolvedBy = '';
2028
- }
2029
- break;
1993
+ if (Config.isOfBitType(bitType, [BitType._error, BitType._comment])) {
1994
+ //
1995
+ delete bitJson.format;
1996
+ //
1997
+ }
1998
+ else if (Config.isOfBitType(bitType, [BitType.article, BitType.sampleSolution, BitType.page])) {
1999
+ //
2000
+ if (bitJson.body == null)
2001
+ bitJson.body = this.bodyDefault;
2002
+ //
2003
+ }
2004
+ else if (Config.isOfBitType(bitType, [
2005
+ BitType.cloze,
2006
+ BitType.multipleChoice1,
2007
+ BitType.multipleResponse1,
2008
+ BitType.multipleChoiceText,
2009
+ BitType.highlightText,
2010
+ BitType.clozeAndMultipleChoiceText,
2011
+ BitType.sequence,
2012
+ BitType.mark,
2013
+ BitType.flashcard,
2014
+ ])) {
2030
2015
  // Default, but with no 'example' at the bit level.
2031
- case RootBitType.cloze:
2032
- case RootBitType.multipleChoice1:
2033
- case RootBitType.multipleResponse1:
2034
- case RootBitType.multipleChoiceText:
2035
- case RootBitType.highlightText:
2036
- case RootBitType.clozeAndMultipleChoiceText:
2037
- case RootBitType.sequence:
2038
- case RootBitType.mark:
2039
- case RootBitType.flashcard:
2040
- if (bitJson.item == null)
2041
- bitJson.item = this.textDefault;
2042
- if (bitJson.hint == null)
2043
- bitJson.hint = this.textDefault;
2044
- if (bitJson.instruction == null)
2045
- bitJson.instruction = this.textDefault;
2046
- if (bitJson.isExample == null)
2047
- bitJson.isExample = false;
2048
- if (bitJson.body == null)
2049
- bitJson.body = this.bodyDefault;
2050
- break;
2016
+ if (bitJson.item == null)
2017
+ bitJson.item = this.textDefault;
2018
+ if (bitJson.hint == null)
2019
+ bitJson.hint = this.textDefault;
2020
+ if (bitJson.instruction == null)
2021
+ bitJson.instruction = this.textDefault;
2022
+ if (bitJson.isExample == null)
2023
+ bitJson.isExample = false;
2024
+ if (bitJson.body == null)
2025
+ bitJson.body = this.bodyDefault;
2026
+ //
2027
+ }
2028
+ else if (Config.isOfBitType(bitType, [BitType.multipleChoice, BitType.multipleResponse])) {
2051
2029
  // Default with a card (and hence a footer possibility)
2052
- case RootBitType.multipleChoice:
2053
- case RootBitType.multipleResponse:
2054
- if (bitJson.item == null)
2055
- bitJson.item = this.textDefault;
2056
- if (bitJson.hint == null)
2057
- bitJson.hint = this.textDefault;
2058
- if (bitJson.instruction == null)
2059
- bitJson.instruction = this.textDefault;
2060
- if (bitJson.isExample == null)
2061
- bitJson.isExample = false;
2062
- if (bitJson.body == null)
2063
- bitJson.body = this.bodyDefault;
2064
- if (bitJson.footer == null)
2065
- bitJson.footer = this.textDefault;
2066
- break;
2067
- case RootBitType.essay:
2068
- if (bitJson.item == null)
2069
- bitJson.item = this.textDefault;
2070
- if (bitJson.hint == null)
2071
- bitJson.hint = this.textDefault;
2072
- if (bitJson.instruction == null)
2073
- bitJson.instruction = this.textDefault;
2074
- if (bitJson.isExample == null)
2075
- bitJson.isExample = false;
2076
- if (bitJson.example == null)
2077
- bitJson.example = null;
2078
- if (bitJson.body == null)
2079
- bitJson.body = this.bodyDefault;
2080
- if (bitJson.partialAnswer == null)
2081
- bitJson.partialAnswer = '';
2082
- // if (bitJson.sampleSolution == null) bitJson.sampleSolution = '';
2083
- break;
2084
- case RootBitType.trueFalse1:
2085
- if (bitJson.item == null)
2086
- bitJson.item = this.textDefault;
2087
- if (bitJson.lead == null)
2088
- bitJson.lead = this.textDefault;
2089
- if (bitJson.hint == null)
2090
- bitJson.hint = this.textDefault;
2091
- if (bitJson.instruction == null)
2092
- bitJson.instruction = this.textDefault;
2093
- if (bitJson.isExample == null)
2094
- bitJson.isExample = false;
2095
- if (bitJson.example == null)
2096
- bitJson.example = null;
2097
- if (bitJson.isCorrect == null)
2098
- bitJson.isCorrect = false;
2099
- if (bitJson.body == null)
2100
- bitJson.body = this.bodyDefault;
2101
- break;
2102
- case RootBitType.trueFalse:
2103
- if (bitJson.item == null)
2104
- bitJson.item = this.textDefault;
2105
- if (bitJson.lead == null)
2106
- bitJson.lead = this.textDefault;
2107
- if (bitJson.hint == null)
2108
- bitJson.hint = this.textDefault;
2109
- if (bitJson.instruction == null)
2110
- bitJson.instruction = this.textDefault;
2111
- if (bitJson.isExample == null)
2112
- bitJson.isExample = false;
2113
- if (bitJson.labelFalse == null)
2114
- bitJson.labelFalse = '';
2115
- if (bitJson.labelTrue == null)
2116
- bitJson.labelTrue = '';
2117
- if (bitJson.body == null)
2118
- bitJson.body = this.bodyDefault;
2119
- break;
2120
- case RootBitType.chapter:
2121
- if (bitJson.item == null)
2122
- bitJson.item = this.textDefault;
2123
- if (bitJson.hint == null)
2124
- bitJson.hint = this.textDefault;
2125
- if (bitJson.isExample == null)
2126
- bitJson.isExample = false;
2127
- if (bitJson.example == null)
2128
- bitJson.example = null;
2129
- if (bitJson.toc == null)
2130
- bitJson.toc = true; // Always set on chapter bits?
2131
- if (bitJson.progress == null)
2132
- bitJson.progress = true; // Always set on chapter bits
2133
- if (bitJson.level == null)
2134
- bitJson.level = 1; // Set level 1 if none set (makes no sense, but in ANTLR parser)
2135
- if (bitJson.body == null)
2136
- bitJson.body = this.bodyDefault;
2137
- break;
2138
- case RootBitType.interview:
2139
- if (bitJson.item == null)
2140
- bitJson.item = this.textDefault;
2141
- if (bitJson.hint == null)
2142
- bitJson.hint = this.textDefault;
2143
- if (bitJson.instruction == null)
2144
- bitJson.instruction = this.textDefault;
2145
- if (bitJson.isExample == null)
2146
- bitJson.isExample = false;
2147
- if (bitJson.body == null)
2148
- bitJson.body = this.bodyDefault;
2149
- if (bitJson.footer == null)
2150
- bitJson.footer = this.textDefault;
2151
- if (bitJson.questions == null)
2152
- bitJson.questions = [];
2153
- break;
2154
- case RootBitType.match:
2155
- if (bitJson.item == null)
2156
- bitJson.item = this.textDefault;
2157
- if (bitJson.heading == null)
2158
- bitJson.heading = {};
2159
- if (bitJson.body == null)
2160
- bitJson.body = this.bodyDefault;
2161
- break;
2162
- case RootBitType.matchMatrix:
2163
- if (bitJson.item == null)
2164
- bitJson.item = this.textDefault;
2165
- if (bitJson.body == null)
2166
- bitJson.body = this.bodyDefault;
2167
- break;
2168
- case RootBitType.learningPathBook:
2169
- case RootBitType.learningPathExternalLink:
2170
- case RootBitType.learningPathVideoCall:
2171
- if (bitJson.item == null)
2172
- bitJson.item = this.textDefault;
2173
- if (bitJson.hint == null)
2174
- bitJson.hint = this.textDefault;
2175
- if (bitJson.isExample == null)
2176
- bitJson.isExample = false;
2177
- if (bitJson.example == null)
2178
- bitJson.example = null;
2179
- if (bitJson.isTracked == null)
2180
- bitJson.isTracked = true;
2181
- if (bitJson.isInfoOnly == null)
2182
- bitJson.isInfoOnly = false;
2183
- if (bitJson.body == null)
2184
- bitJson.body = this.bodyDefault;
2185
- break;
2186
- case RootBitType.pageBuyButton:
2187
- if (bitJson.content2Buy == null)
2188
- bitJson.content2Buy = '';
2189
- if (bitJson.body == null)
2190
- bitJson.body = this.bodyDefault;
2191
- break;
2030
+ if (bitJson.item == null)
2031
+ bitJson.item = this.textDefault;
2032
+ if (bitJson.hint == null)
2033
+ bitJson.hint = this.textDefault;
2034
+ if (bitJson.instruction == null)
2035
+ bitJson.instruction = this.textDefault;
2036
+ if (bitJson.isExample == null)
2037
+ bitJson.isExample = false;
2038
+ if (bitJson.body == null)
2039
+ bitJson.body = this.bodyDefault;
2040
+ if (bitJson.footer == null)
2041
+ bitJson.footer = this.textDefault;
2042
+ //
2043
+ }
2044
+ else if (Config.isOfBitType(bitType, BitType.essay)) {
2045
+ //
2046
+ if (bitJson.item == null)
2047
+ bitJson.item = this.textDefault;
2048
+ if (bitJson.hint == null)
2049
+ bitJson.hint = this.textDefault;
2050
+ if (bitJson.instruction == null)
2051
+ bitJson.instruction = this.textDefault;
2052
+ if (bitJson.isExample == null)
2053
+ bitJson.isExample = false;
2054
+ if (bitJson.example == null)
2055
+ bitJson.example = null;
2056
+ if (bitJson.body == null)
2057
+ bitJson.body = this.bodyDefault;
2058
+ if (bitJson.partialAnswer == null)
2059
+ bitJson.partialAnswer = '';
2060
+ // if (bitJson.sampleSolution == null) bitJson.sampleSolution = '';
2061
+ //
2062
+ }
2063
+ else if (Config.isOfBitType(bitType, BitType.trueFalse1)) {
2064
+ //
2065
+ if (bitJson.item == null)
2066
+ bitJson.item = this.textDefault;
2067
+ if (bitJson.lead == null)
2068
+ bitJson.lead = this.textDefault;
2069
+ if (bitJson.hint == null)
2070
+ bitJson.hint = this.textDefault;
2071
+ if (bitJson.instruction == null)
2072
+ bitJson.instruction = this.textDefault;
2073
+ if (bitJson.isExample == null)
2074
+ bitJson.isExample = false;
2075
+ if (bitJson.example == null)
2076
+ bitJson.example = null;
2077
+ if (bitJson.isCorrect == null)
2078
+ bitJson.isCorrect = false;
2079
+ if (bitJson.body == null)
2080
+ bitJson.body = this.bodyDefault;
2081
+ //
2082
+ }
2083
+ else if (Config.isOfBitType(bitType, BitType.trueFalse)) {
2084
+ //
2085
+ if (bitJson.item == null)
2086
+ bitJson.item = this.textDefault;
2087
+ if (bitJson.lead == null)
2088
+ bitJson.lead = this.textDefault;
2089
+ if (bitJson.hint == null)
2090
+ bitJson.hint = this.textDefault;
2091
+ if (bitJson.instruction == null)
2092
+ bitJson.instruction = this.textDefault;
2093
+ if (bitJson.isExample == null)
2094
+ bitJson.isExample = false;
2095
+ if (bitJson.labelFalse == null)
2096
+ bitJson.labelFalse = '';
2097
+ if (bitJson.labelTrue == null)
2098
+ bitJson.labelTrue = '';
2099
+ if (bitJson.body == null)
2100
+ bitJson.body = this.bodyDefault;
2101
+ //
2102
+ }
2103
+ else if (Config.isOfBitType(bitType, BitType.chapter)) {
2104
+ //
2105
+ if (bitJson.item == null)
2106
+ bitJson.item = this.textDefault;
2107
+ if (bitJson.hint == null)
2108
+ bitJson.hint = this.textDefault;
2109
+ if (bitJson.isExample == null)
2110
+ bitJson.isExample = false;
2111
+ if (bitJson.example == null)
2112
+ bitJson.example = null;
2113
+ if (bitJson.toc == null)
2114
+ bitJson.toc = true; // Always set on chapter bits?
2115
+ if (bitJson.progress == null)
2116
+ bitJson.progress = true; // Always set on chapter bits
2117
+ if (bitJson.level == null)
2118
+ bitJson.level = 1; // Set level 1 if none set (makes no sense, but in ANTLR parser)
2119
+ if (bitJson.body == null)
2120
+ bitJson.body = this.bodyDefault;
2121
+ //
2122
+ }
2123
+ else if (Config.isOfBitType(bitType, BitType.interview)) {
2124
+ //
2125
+ if (bitJson.item == null)
2126
+ bitJson.item = this.textDefault;
2127
+ if (bitJson.hint == null)
2128
+ bitJson.hint = this.textDefault;
2129
+ if (bitJson.instruction == null)
2130
+ bitJson.instruction = this.textDefault;
2131
+ if (bitJson.isExample == null)
2132
+ bitJson.isExample = false;
2133
+ if (bitJson.body == null)
2134
+ bitJson.body = this.bodyDefault;
2135
+ if (bitJson.footer == null)
2136
+ bitJson.footer = this.textDefault;
2137
+ if (bitJson.questions == null)
2138
+ bitJson.questions = [];
2139
+ //
2140
+ }
2141
+ else if (bitType === BitType.matchMatrix) {
2142
+ //
2143
+ if (bitJson.item == null)
2144
+ bitJson.item = this.textDefault;
2145
+ if (bitJson.body == null)
2146
+ bitJson.body = this.bodyDefault;
2147
+ //
2148
+ }
2149
+ else if (Config.isOfBitType(bitType, BitType.match)) {
2150
+ //
2151
+ if (bitJson.item == null)
2152
+ bitJson.item = this.textDefault;
2153
+ if (bitJson.heading == null)
2154
+ bitJson.heading = {};
2155
+ if (bitJson.body == null)
2156
+ bitJson.body = this.bodyDefault;
2157
+ //
2158
+ }
2159
+ else if (Config.isOfBitType(bitType, BitType.learningPathBook)) {
2160
+ //
2161
+ if (bitJson.item == null)
2162
+ bitJson.item = this.textDefault;
2163
+ if (bitJson.hint == null)
2164
+ bitJson.hint = this.textDefault;
2165
+ if (bitJson.isExample == null)
2166
+ bitJson.isExample = false;
2167
+ if (bitJson.example == null)
2168
+ bitJson.example = null;
2169
+ if (bitJson.isTracked == null)
2170
+ bitJson.isTracked = true;
2171
+ if (bitJson.isInfoOnly == null)
2172
+ bitJson.isInfoOnly = false;
2173
+ if (bitJson.body == null)
2174
+ bitJson.body = this.bodyDefault;
2175
+ //
2176
+ }
2177
+ else if (Config.isOfBitType(bitType, BitType.pageBuyButton)) {
2178
+ //
2179
+ if (bitJson.content2Buy == null)
2180
+ bitJson.content2Buy = '';
2181
+ if (bitJson.body == null)
2182
+ bitJson.body = this.bodyDefault;
2183
+ //
2184
+ }
2185
+ else {
2186
+ // Most bits have these defaults, but there are special cases (not sure if that is by error or design)
2187
+ if (bitJson.item == null)
2188
+ bitJson.item = this.textDefault;
2189
+ if (bitJson.hint == null)
2190
+ bitJson.hint = this.textDefault;
2191
+ if (bitJson.isExample == null)
2192
+ bitJson.isExample = false;
2193
+ if (bitJson.example == null)
2194
+ bitJson.example = null;
2195
+ if (bitJson.body == null)
2196
+ bitJson.body = this.bodyDefault;
2197
+ // Special case for 'ai' bits
2198
+ if (bitType === BitType.articleAi || bitType === BitType.noteAi || bitType === BitType.summaryAi) {
2199
+ if (bitJson.AIGenerated == null)
2200
+ bitJson.AIGenerated = true;
2201
+ }
2202
+ // Special case for 'review-...' bits
2203
+ if (Config.isOfBitType(bitType, BitType.reviewNote)) {
2204
+ if (bitJson.resolved == null)
2205
+ bitJson.resolved = false;
2206
+ if (bitJson.resolvedDate == null)
2207
+ bitJson.resolvedDate = '';
2208
+ if (bitJson.resolvedBy == null)
2209
+ bitJson.resolvedBy = '';
2210
+ }
2192
2211
  }
2193
2212
  // Remove unwanted properties
2194
2213
  // Properties