@speakableio/core 0.1.99 → 0.1.100

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.
@@ -151,6 +151,7 @@ interface PageActivity {
151
151
  correct_answer?: string | null;
152
152
  limit_attempts?: boolean;
153
153
  max_attempts?: number;
154
+ rich_text?: string;
154
155
  }
155
156
  declare enum ActivityPageType {
156
157
  READ_REPEAT = "READ_REPEAT",
@@ -271,6 +272,7 @@ declare function useCreateCards(): {
271
272
  correct_answer?: string | null;
272
273
  limit_attempts?: boolean;
273
274
  max_attempts?: number;
275
+ rich_text?: string;
274
276
  }[], Error, {
275
277
  cards: PageActivity[];
276
278
  }, unknown>;
@@ -362,6 +364,7 @@ declare const createCardRepo: () => {
362
364
  correct_answer?: string | null;
363
365
  limit_attempts?: boolean;
364
366
  max_attempts?: number;
367
+ rich_text?: string;
365
368
  }[]>;
366
369
  getCard: (params: {
367
370
  cardId: string;
@@ -387,7 +390,9 @@ declare const checkTypePageActivity: (cardType: ActivityPageType | undefined) =>
387
390
 
388
391
  declare function getPagePrompt(card: PageActivityWithId | undefined): {
389
392
  has: boolean;
390
- text: string | undefined;
393
+ text: string;
394
+ rich_text: string;
395
+ isTextEqualToRichText: boolean;
391
396
  };
392
397
 
393
398
  declare const getTotalCompletedCards: (pageScores: Score["cards"] | undefined) => number;
@@ -1142,6 +1147,7 @@ declare function createFsClientBase({ db, helpers, httpsCallable, logEvent, }: {
1142
1147
  correct_answer?: string | null;
1143
1148
  limit_attempts?: boolean;
1144
1149
  max_attempts?: number;
1150
+ rich_text?: string;
1145
1151
  }[]>;
1146
1152
  getCard: (params: {
1147
1153
  cardId: string;
@@ -2817,6 +2823,7 @@ declare const createFsClientNative: ({ db, httpsCallable, logEvent }: FsClientPa
2817
2823
  correct_answer?: string | null;
2818
2824
  limit_attempts?: boolean;
2819
2825
  max_attempts?: number;
2826
+ rich_text?: string;
2820
2827
  }[]>;
2821
2828
  getCard: (params: {
2822
2829
  cardId: string;
@@ -151,6 +151,7 @@ interface PageActivity {
151
151
  correct_answer?: string | null;
152
152
  limit_attempts?: boolean;
153
153
  max_attempts?: number;
154
+ rich_text?: string;
154
155
  }
155
156
  declare enum ActivityPageType {
156
157
  READ_REPEAT = "READ_REPEAT",
@@ -271,6 +272,7 @@ declare function useCreateCards(): {
271
272
  correct_answer?: string | null;
272
273
  limit_attempts?: boolean;
273
274
  max_attempts?: number;
275
+ rich_text?: string;
274
276
  }[], Error, {
275
277
  cards: PageActivity[];
276
278
  }, unknown>;
@@ -362,6 +364,7 @@ declare const createCardRepo: () => {
362
364
  correct_answer?: string | null;
363
365
  limit_attempts?: boolean;
364
366
  max_attempts?: number;
367
+ rich_text?: string;
365
368
  }[]>;
366
369
  getCard: (params: {
367
370
  cardId: string;
@@ -387,7 +390,9 @@ declare const checkTypePageActivity: (cardType: ActivityPageType | undefined) =>
387
390
 
388
391
  declare function getPagePrompt(card: PageActivityWithId | undefined): {
389
392
  has: boolean;
390
- text: string | undefined;
393
+ text: string;
394
+ rich_text: string;
395
+ isTextEqualToRichText: boolean;
391
396
  };
392
397
 
393
398
  declare const getTotalCompletedCards: (pageScores: Score["cards"] | undefined) => number;
@@ -1142,6 +1147,7 @@ declare function createFsClientBase({ db, helpers, httpsCallable, logEvent, }: {
1142
1147
  correct_answer?: string | null;
1143
1148
  limit_attempts?: boolean;
1144
1149
  max_attempts?: number;
1150
+ rich_text?: string;
1145
1151
  }[]>;
1146
1152
  getCard: (params: {
1147
1153
  cardId: string;
@@ -2817,6 +2823,7 @@ declare const createFsClientNative: ({ db, httpsCallable, logEvent }: FsClientPa
2817
2823
  correct_answer?: string | null;
2818
2824
  limit_attempts?: boolean;
2819
2825
  max_attempts?: number;
2826
+ rich_text?: string;
2820
2827
  }[]>;
2821
2828
  getCard: (params: {
2822
2829
  cardId: string;
@@ -1990,37 +1990,41 @@ var checkTypePageActivity = (cardType) => {
1990
1990
  };
1991
1991
 
1992
1992
  // src/domains/cards/utils/get-page-prompt.ts
1993
+ function extractTextFromRichText(richText) {
1994
+ if (!richText) return "";
1995
+ return richText.replace(/<[^>]*>/g, "").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").trim();
1996
+ }
1993
1997
  function getPagePrompt(card) {
1994
- if (!card) return { has: false, text: "" };
1998
+ if (!card) return { has: false, text: "", rich_text: "", isTextEqualToRichText: false };
1995
1999
  const { isMC, isRepeat, isRespond, isShortAnswer } = checkTypePageActivity(card == null ? void 0 : card.type);
1996
2000
  const hidePrompt = (card == null ? void 0 : card.hidePrompt) === true;
1997
- if (isRepeat) {
2001
+ const createReturnObject = (text, richText) => {
2002
+ const plainText = text || "";
2003
+ const richTextPlain = extractTextFromRichText(richText);
1998
2004
  return {
1999
2005
  has: true,
2000
- text: card == null ? void 0 : card.target_text
2006
+ text: plainText,
2007
+ rich_text: richText || "",
2008
+ isTextEqualToRichText: plainText.trim() === richTextPlain.trim()
2001
2009
  };
2010
+ };
2011
+ if (isRepeat) {
2012
+ return createReturnObject(card == null ? void 0 : card.target_text, card == null ? void 0 : card.rich_text);
2002
2013
  }
2003
2014
  if (isRespond && !hidePrompt) {
2004
- return {
2005
- has: true,
2006
- text: card == null ? void 0 : card.prompt
2007
- };
2015
+ return createReturnObject(card == null ? void 0 : card.prompt, card == null ? void 0 : card.rich_text);
2008
2016
  }
2009
2017
  if (isMC) {
2010
- return {
2011
- has: true,
2012
- text: card == null ? void 0 : card.question
2013
- };
2018
+ return createReturnObject(card == null ? void 0 : card.question, card == null ? void 0 : card.rich_text);
2014
2019
  }
2015
2020
  if (isShortAnswer && !hidePrompt) {
2016
- return {
2017
- has: true,
2018
- text: card == null ? void 0 : card.prompt
2019
- };
2021
+ return createReturnObject(card == null ? void 0 : card.prompt, card == null ? void 0 : card.rich_text);
2020
2022
  }
2021
2023
  return {
2022
2024
  has: false,
2023
- text: ""
2025
+ text: "",
2026
+ rich_text: "",
2027
+ isTextEqualToRichText: false
2024
2028
  };
2025
2029
  }
2026
2030