pro-editor-schema 1.2.2 → 1.2.4

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/index.js CHANGED
@@ -2902,13 +2902,20 @@ var validateRequiredChildren = (element, schema, childElements) => {
2902
2902
  return childSchema?.code === allowedChild.code;
2903
2903
  });
2904
2904
  if (!hasChild) {
2905
- const requiredChildrenTag = findSchemaByCode(allowedChild.code).tag;
2905
+ const requiredChild = findSchemaByCode(allowedChild.code);
2906
+ const elementLabel = ElementLabel[requiredChild.code];
2907
+ const parentLabel = ElementLabel[schema.code];
2908
+ const extraInstruction = getExtraInstruction(schema, requiredChild);
2909
+ const description = [
2910
+ `Please provide at least one ${elementLabel} in this ${parentLabel}.`,
2911
+ extraInstruction
2912
+ ].filter(Boolean).join(" ");
2906
2913
  addValidationIssue(errors, {
2907
2914
  store: getStore(element),
2908
- title: `Missing required child element ${requiredChildrenTag}`,
2915
+ title: `${elementLabel} missing`,
2909
2916
  level: "warning",
2910
2917
  kind: "missing",
2911
- description: `The child element ${requiredChildrenTag} is required but not present.`
2918
+ description
2912
2919
  });
2913
2920
  }
2914
2921
  }
@@ -2965,6 +2972,12 @@ var validateChildren = (element, schema) => {
2965
2972
  errors.push(...validateRequiredChildren(element, schema, childElements));
2966
2973
  return errors;
2967
2974
  };
2975
+ var getExtraInstruction = (schema, childSchema) => {
2976
+ if (schema.code === "dialogue" && childSchema.code === "speaker") {
2977
+ return "Select the speaker and tag using right click.";
2978
+ }
2979
+ return "";
2980
+ };
2968
2981
 
2969
2982
  // src/validation/validateReferences.ts
2970
2983
  var findElementLinkedTo2 = (xmlid, linkElements) => {
@@ -3102,7 +3115,7 @@ var validateHeadingHierarchy = (element) => {
3102
3115
  store: getStore(element),
3103
3116
  title: "Invalid heading hierarchy",
3104
3117
  kind: "forbidden",
3105
- description: `H${level} cannot follow H${parentLevel} directly. Please check the heading hierarchy.`,
3118
+ description: "The nesting of the heading tags is incorrect. Please contact Support.",
3106
3119
  level: "warning"
3107
3120
  });
3108
3121
  return errors;
package/dist/index.mjs CHANGED
@@ -2822,13 +2822,20 @@ var validateRequiredChildren = (element, schema, childElements) => {
2822
2822
  return childSchema?.code === allowedChild.code;
2823
2823
  });
2824
2824
  if (!hasChild) {
2825
- const requiredChildrenTag = findSchemaByCode(allowedChild.code).tag;
2825
+ const requiredChild = findSchemaByCode(allowedChild.code);
2826
+ const elementLabel = ElementLabel[requiredChild.code];
2827
+ const parentLabel = ElementLabel[schema.code];
2828
+ const extraInstruction = getExtraInstruction(schema, requiredChild);
2829
+ const description = [
2830
+ `Please provide at least one ${elementLabel} in this ${parentLabel}.`,
2831
+ extraInstruction
2832
+ ].filter(Boolean).join(" ");
2826
2833
  addValidationIssue(errors, {
2827
2834
  store: getStore(element),
2828
- title: `Missing required child element ${requiredChildrenTag}`,
2835
+ title: `${elementLabel} missing`,
2829
2836
  level: "warning",
2830
2837
  kind: "missing",
2831
- description: `The child element ${requiredChildrenTag} is required but not present.`
2838
+ description
2832
2839
  });
2833
2840
  }
2834
2841
  }
@@ -2885,6 +2892,12 @@ var validateChildren = (element, schema) => {
2885
2892
  errors.push(...validateRequiredChildren(element, schema, childElements));
2886
2893
  return errors;
2887
2894
  };
2895
+ var getExtraInstruction = (schema, childSchema) => {
2896
+ if (schema.code === "dialogue" && childSchema.code === "speaker") {
2897
+ return "Select the speaker and tag using right click.";
2898
+ }
2899
+ return "";
2900
+ };
2888
2901
 
2889
2902
  // src/validation/validateReferences.ts
2890
2903
  var findElementLinkedTo2 = (xmlid, linkElements) => {
@@ -3022,7 +3035,7 @@ var validateHeadingHierarchy = (element) => {
3022
3035
  store: getStore(element),
3023
3036
  title: "Invalid heading hierarchy",
3024
3037
  kind: "forbidden",
3025
- description: `H${level} cannot follow H${parentLevel} directly. Please check the heading hierarchy.`,
3038
+ description: "The nesting of the heading tags is incorrect. Please contact Support.",
3026
3039
  level: "warning"
3027
3040
  });
3028
3041
  return errors;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pro-editor-schema",
3
- "version": "1.2.2",
3
+ "version": "1.2.4",
4
4
  "description": "Pro Editor XML schemas",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",