@pie-element/select-text 8.5.1-next.14 → 8.5.1-next.48

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.
@@ -19899,11 +19899,14 @@ var defaults = {
19899
19899
  tokens: tokens(),
19900
19900
  };
19901
19901
 
19902
- const isAnswerSelected = (token, selectedToken) => token && selectedToken && token.correct === true &&
19903
- !(
19904
- (token.start === selectedToken.start && token.end === selectedToken.end) ||
19905
- (token.start === selectedToken.oldStart && token.end === selectedToken.oldEnd)
19906
- );
19902
+ const isAnswerSelected = (token, selectedToken) =>
19903
+ token &&
19904
+ selectedToken &&
19905
+ token.correct === true &&
19906
+ !(
19907
+ (token.start === selectedToken.start && token.end === selectedToken.end) ||
19908
+ (token.start === selectedToken.oldStart && token.end === selectedToken.oldEnd)
19909
+ );
19907
19910
 
19908
19911
  const buildTokens = (tokens, selectedTokens, evaluateMode) => {
19909
19912
  tokens = tokens || [];
@@ -20079,12 +20082,21 @@ const createCorrectResponseSession = (question, env) => {
20079
20082
  });
20080
20083
  };
20081
20084
 
20085
+ // remove all html tags except img and iframe
20086
+ const getContent = (html) => (html || '').replace(/(<(?!img|iframe)([^>]+)>)/gi, '');
20087
+
20082
20088
  const validate = (model = {}, config = {}) => {
20083
20089
  const { tokens } = model;
20084
20090
  const { minTokens = 2, maxTokens, maxSelections } = config;
20085
20091
  const errors = {};
20086
20092
  const nbOfTokens = (tokens || []).length;
20087
20093
 
20094
+ ['teacherInstructions', 'prompt', 'rationale'].forEach((field) => {
20095
+ if (config[field]?.required && !getContent(model[field])) {
20096
+ errors[field] = 'This field is required.';
20097
+ }
20098
+ });
20099
+
20088
20100
  const nbOfSelections = (tokens || []).reduce((acc, token) => (token.correct ? acc + 1 : acc), 0);
20089
20101
 
20090
20102
  if (nbOfTokens < minTokens) {