@speakableio/core 0.1.98 → 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.
@@ -1885,37 +1885,41 @@ var checkTypePageActivity = (cardType) => {
1885
1885
  };
1886
1886
 
1887
1887
  // src/domains/cards/utils/get-page-prompt.ts
1888
+ function extractTextFromRichText(richText) {
1889
+ if (!richText) return "";
1890
+ return richText.replace(/<[^>]*>/g, "").replace(/&nbsp;/g, " ").replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">").replace(/&quot;/g, '"').replace(/&#39;/g, "'").trim();
1891
+ }
1888
1892
  function getPagePrompt(card) {
1889
- if (!card) return { has: false, text: "" };
1893
+ if (!card) return { has: false, text: "", rich_text: "", isTextEqualToRichText: false };
1890
1894
  const { isMC, isRepeat, isRespond, isShortAnswer } = checkTypePageActivity(card == null ? void 0 : card.type);
1891
1895
  const hidePrompt = (card == null ? void 0 : card.hidePrompt) === true;
1892
- if (isRepeat) {
1896
+ const createReturnObject = (text, richText) => {
1897
+ const plainText = text || "";
1898
+ const richTextPlain = extractTextFromRichText(richText);
1893
1899
  return {
1894
1900
  has: true,
1895
- text: card == null ? void 0 : card.target_text
1901
+ text: plainText,
1902
+ rich_text: richText || "",
1903
+ isTextEqualToRichText: plainText.trim() === richTextPlain.trim()
1896
1904
  };
1905
+ };
1906
+ if (isRepeat) {
1907
+ return createReturnObject(card == null ? void 0 : card.target_text, card == null ? void 0 : card.rich_text);
1897
1908
  }
1898
1909
  if (isRespond && !hidePrompt) {
1899
- return {
1900
- has: true,
1901
- text: card == null ? void 0 : card.prompt
1902
- };
1910
+ return createReturnObject(card == null ? void 0 : card.prompt, card == null ? void 0 : card.rich_text);
1903
1911
  }
1904
1912
  if (isMC) {
1905
- return {
1906
- has: true,
1907
- text: card == null ? void 0 : card.question
1908
- };
1913
+ return createReturnObject(card == null ? void 0 : card.question, card == null ? void 0 : card.rich_text);
1909
1914
  }
1910
1915
  if (isShortAnswer && !hidePrompt) {
1911
- return {
1912
- has: true,
1913
- text: card == null ? void 0 : card.prompt
1914
- };
1916
+ return createReturnObject(card == null ? void 0 : card.prompt, card == null ? void 0 : card.rich_text);
1915
1917
  }
1916
1918
  return {
1917
1919
  has: false,
1918
- text: ""
1920
+ text: "",
1921
+ rich_text: "",
1922
+ isTextEqualToRichText: false
1919
1923
  };
1920
1924
  }
1921
1925