@bendyline/squisq-editor-react 2.12.8 → 2.12.10

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.
@@ -5,7 +5,7 @@ import {
5
5
  import {
6
6
  markdownToTiptap,
7
7
  tiptapToMarkdown
8
- } from "./chunk-MHG4KPMA.js";
8
+ } from "./chunk-LTT6QQHJ.js";
9
9
 
10
10
  // src/InsertMenuItems.tsx
11
11
  import { createContext, useContext, useEffect, useMemo, useRef } from "react";
@@ -492,7 +492,11 @@ import {
492
492
  useRef as useRef3,
493
493
  useEffect as useEffect3
494
494
  } from "react";
495
- import { parseMarkdown as parseMarkdown3, stringifyMarkdown } from "@bendyline/squisq/markdown";
495
+ import {
496
+ parseMarkdown as parseMarkdown3,
497
+ stringifyMarkdown,
498
+ resolveWikiLinks
499
+ } from "@bendyline/squisq/markdown";
496
500
  import { markdownToDoc } from "@bendyline/squisq/doc";
497
501
 
498
502
  // src/speech/useDictationController.ts
@@ -1512,6 +1516,7 @@ function EditorProvider({
1512
1516
  proofingIgnoreStore = null,
1513
1517
  speechInput = null,
1514
1518
  documentLinkProvider = null,
1519
+ wikiLinks = null,
1515
1520
  fenceRenderers = null,
1516
1521
  onCopyCode,
1517
1522
  linkSchemes,
@@ -1827,6 +1832,33 @@ function EditorProvider({
1827
1832
  setIsParsing(false);
1828
1833
  }
1829
1834
  }, []);
1835
+ const [wikiProjection, setWikiProjection] = useState3(null);
1836
+ const presentationDoc = wikiProjection?.source === markdownDoc && wikiProjection?.support === wikiLinks ? wikiProjection.doc : doc;
1837
+ useEffect3(() => {
1838
+ if (!markdownDoc || !wikiLinks) return;
1839
+ let cancelled = false;
1840
+ void resolveWikiLinks(
1841
+ markdownDoc,
1842
+ (target) => wikiLinks.resolve ? wikiLinks.resolve(target) : wikiLinks.exists(target)
1843
+ ).then(
1844
+ (resolved) => {
1845
+ if (!cancelled && resolved !== markdownDoc)
1846
+ setWikiProjection({
1847
+ source: markdownDoc,
1848
+ support: wikiLinks,
1849
+ doc: markdownToDoc(resolved, {
1850
+ articleId: articleIdRef.current,
1851
+ fileName: fileNameRef.current
1852
+ })
1853
+ });
1854
+ },
1855
+ () => {
1856
+ }
1857
+ );
1858
+ return () => {
1859
+ cancelled = true;
1860
+ };
1861
+ }, [markdownDoc, wikiLinks]);
1830
1862
  useEffect3(() => {
1831
1863
  if (editorMode !== "markdown") return;
1832
1864
  if (skipInitialDebouncedParseRef.current) {
@@ -2181,7 +2213,7 @@ function EditorProvider({
2181
2213
  () => ({
2182
2214
  markdownSource,
2183
2215
  markdownDoc,
2184
- doc,
2216
+ doc: presentationDoc,
2185
2217
  activeView,
2186
2218
  parseError,
2187
2219
  isParsing,
@@ -2228,6 +2260,7 @@ function EditorProvider({
2228
2260
  dictation,
2229
2261
  articleId,
2230
2262
  documentLinkProvider,
2263
+ wikiLinks,
2231
2264
  fenceRenderers,
2232
2265
  onCopyCode,
2233
2266
  linkSchemes,
@@ -2270,7 +2303,7 @@ function EditorProvider({
2270
2303
  [
2271
2304
  markdownSource,
2272
2305
  markdownDoc,
2273
- doc,
2306
+ presentationDoc,
2274
2307
  activeView,
2275
2308
  parseError,
2276
2309
  isParsing,
@@ -2311,6 +2344,7 @@ function EditorProvider({
2311
2344
  dictation,
2312
2345
  articleId,
2313
2346
  documentLinkProvider,
2347
+ wikiLinks,
2314
2348
  fenceRenderers,
2315
2349
  onCopyCode,
2316
2350
  linkSchemes,