pro-editor-schema 1.2.1 → 1.2.3

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) => {
@@ -3115,8 +3128,10 @@ var validateOlink = (element) => {
3115
3128
  if (isDeletedElement(element)) {
3116
3129
  return errors;
3117
3130
  }
3118
- const text = retrieveTextIgnoringNodesWithSelector(element).trim();
3119
- if (ORCID_PATTERN.test(text)) {
3131
+ const text = retrieveTextIgnoringNodesWithSelector(element);
3132
+ const isEmpty = text.length === 0;
3133
+ const isValidOrcid = ORCID_PATTERN.test(text);
3134
+ if (isEmpty || isValidOrcid) {
3120
3135
  return errors;
3121
3136
  }
3122
3137
  addValidationIssue(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) => {
@@ -3035,8 +3048,10 @@ var validateOlink = (element) => {
3035
3048
  if (isDeletedElement(element)) {
3036
3049
  return errors;
3037
3050
  }
3038
- const text = retrieveTextIgnoringNodesWithSelector(element).trim();
3039
- if (ORCID_PATTERN.test(text)) {
3051
+ const text = retrieveTextIgnoringNodesWithSelector(element);
3052
+ const isEmpty = text.length === 0;
3053
+ const isValidOrcid = ORCID_PATTERN.test(text);
3054
+ if (isEmpty || isValidOrcid) {
3040
3055
  return errors;
3041
3056
  }
3042
3057
  addValidationIssue(errors, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pro-editor-schema",
3
- "version": "1.2.1",
3
+ "version": "1.2.3",
4
4
  "description": "Pro Editor XML schemas",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",