@bendyline/squisq-editor-react 2.13.12 → 2.13.13

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.
@@ -40949,6 +40949,10 @@ import {
40949
40949
  parseMarkdown as parseMarkdown9,
40950
40950
  resolveWikiLinks
40951
40951
  } from "@bendyline/squisq/markdown";
40952
+ import {
40953
+ isMediaAnnotationName,
40954
+ parseStandaloneAnnotation
40955
+ } from "@bendyline/squisq/doc";
40952
40956
  import { sanitizedSvgImageUrl } from "@bendyline/squisq-react";
40953
40957
 
40954
40958
  // src/utils/collectInlineFontAwesomeCss.ts
@@ -40996,6 +41000,20 @@ function loadRenderFn() {
40996
41000
  }
40997
41001
  return cachedRenderPromise;
40998
41002
  }
41003
+ var preparationPromise = null;
41004
+ function loadPreparation() {
41005
+ preparationPromise ?? (preparationPromise = Promise.all([
41006
+ import("@bendyline/squisq-formats/html"),
41007
+ import("@bendyline/squisq-formats/diagrams"),
41008
+ import("@bendyline/squisq-react/diagram-pictures")
41009
+ ]).then(([html, diagrams, pictures]) => ({
41010
+ needs: html.needsPlainHtmlPreparation,
41011
+ prepare: html.prepareMarkdownDocForPlainHtml,
41012
+ renderDiagram: diagrams.cachingDiagramRasterizer(pictures.createDiagramPictureRenderer())
41013
+ })));
41014
+ return preparationPromise;
41015
+ }
41016
+ var PREPARE_DELAY_MS = 300;
40999
41017
  var IFRAME_STYLE = {
41000
41018
  width: "100%",
41001
41019
  height: "100%",
@@ -41010,6 +41028,7 @@ function PlainHtmlPreview({
41010
41028
  images,
41011
41029
  mediaProvider,
41012
41030
  mediaRevision,
41031
+ container,
41013
41032
  theme,
41014
41033
  className,
41015
41034
  style,
@@ -41087,6 +41106,56 @@ function PlainHtmlPreview({
41087
41106
  return merged;
41088
41107
  }, [resolvedImages, images]);
41089
41108
  const iconsCss = useMemo52(() => collectInlineFontAwesomeCss(), []);
41109
+ const [preparation, setPreparation] = useState76(null);
41110
+ useEffect64(() => {
41111
+ let cancelled = false;
41112
+ loadPreparation().then(
41113
+ (loaded) => {
41114
+ if (!cancelled) setPreparation(loaded);
41115
+ },
41116
+ () => {
41117
+ }
41118
+ );
41119
+ return () => {
41120
+ cancelled = true;
41121
+ };
41122
+ }, []);
41123
+ const dataTableCache = useMemo52(
41124
+ () => container ? dataTableCacheFor(container, mediaRevision ?? 0) : void 0,
41125
+ [container, mediaRevision]
41126
+ );
41127
+ const needsPreparation = useMemo52(
41128
+ () => preparation?.needs(mdDoc, { renderDiagram: preparation.renderDiagram, container }) ?? false,
41129
+ [preparation, mdDoc, container]
41130
+ );
41131
+ const [prepared, setPrepared] = useState76(null);
41132
+ const preparedOnceRef = useRef59(false);
41133
+ useEffect64(() => {
41134
+ if (!preparation || !needsPreparation) return;
41135
+ let cancelled = false;
41136
+ const prepare = () => {
41137
+ preparation.prepare(mdDoc, {
41138
+ renderDiagram: preparation.renderDiagram,
41139
+ container,
41140
+ dataTableCache
41141
+ }).then(
41142
+ (result) => {
41143
+ if (!cancelled) setPrepared(result);
41144
+ },
41145
+ () => {
41146
+ if (!cancelled)
41147
+ setPrepared({ markdownDoc: mdDoc, images: /* @__PURE__ */ new Map(), icons: /* @__PURE__ */ new Map() });
41148
+ }
41149
+ );
41150
+ };
41151
+ const timer = setTimeout(prepare, preparedOnceRef.current ? PREPARE_DELAY_MS : 0);
41152
+ preparedOnceRef.current = true;
41153
+ return () => {
41154
+ cancelled = true;
41155
+ clearTimeout(timer);
41156
+ };
41157
+ }, [preparation, needsPreparation, mdDoc, container, dataTableCache]);
41158
+ const view = needsPreparation ? prepared : null;
41090
41159
  const [renderFn, setRenderFn] = useState76(() => cachedRender);
41091
41160
  useEffect64(() => {
41092
41161
  if (renderFn) return;
@@ -41098,14 +41167,18 @@ function PlainHtmlPreview({
41098
41167
  cancelled = true;
41099
41168
  };
41100
41169
  }, [renderFn]);
41101
- const html = useMemo52(
41102
- () => renderFn ? (
41103
- // The frame is sandboxed without scripts, and a nested player
41104
- // iframe inherits that sandbox — so videos show as linked posters.
41105
- renderFn(mdDoc, { title, images: mergedImages, theme, iconsCss, videoEmbeds: "poster" })
41106
- ) : "",
41107
- [renderFn, mdDoc, title, mergedImages, theme, iconsCss]
41108
- );
41170
+ const html = useMemo52(() => {
41171
+ if (!renderFn) return "";
41172
+ const images2 = view && view.images.size > 0 ? new Map([...mergedImages ?? [], ...view.images]) : mergedImages;
41173
+ return renderFn(view?.markdownDoc ?? mdDoc, {
41174
+ title,
41175
+ images: images2,
41176
+ theme,
41177
+ iconsCss,
41178
+ icons: view?.icons,
41179
+ videoEmbeds: "poster"
41180
+ });
41181
+ }, [renderFn, view, mdDoc, title, mergedImages, theme, iconsCss]);
41109
41182
  const installFrameLinkHandler = useCallback50(() => {
41110
41183
  removeFrameLinkHandlerRef.current();
41111
41184
  removeFrameLinkHandlerRef.current = () => void 0;
@@ -41292,6 +41365,12 @@ function collectImageRefs(doc) {
41292
41365
  if (n.type === "image" && typeof n.url === "string" && n.url) {
41293
41366
  refs.add(n.url);
41294
41367
  }
41368
+ if (n.type === "paragraph") {
41369
+ const tag = parseStandaloneAnnotation(node2);
41370
+ if (tag?.template && isMediaAnnotationName(tag.template) && tag.params.src) {
41371
+ refs.add(tag.params.src);
41372
+ }
41373
+ }
41295
41374
  if ((n.type === "htmlBlock" || n.type === "htmlInline") && Array.isArray(n.htmlChildren)) {
41296
41375
  visitHtml(n.htmlChildren);
41297
41376
  }
@@ -42278,7 +42357,8 @@ function PrintPreview({
42278
42357
  theme,
42279
42358
  showCover,
42280
42359
  transformStyle,
42281
- mediaRevision
42360
+ mediaRevision,
42361
+ container
42282
42362
  }) {
42283
42363
  const { slidesPerPage, registerPrintHandler } = usePrintMode();
42284
42364
  const mediaProvider = useMediaProvider();
@@ -42320,6 +42400,7 @@ function PrintPreview({
42320
42400
  title,
42321
42401
  mediaProvider,
42322
42402
  mediaRevision,
42403
+ container,
42323
42404
  theme,
42324
42405
  onFrameChange: setDocumentFrame
42325
42406
  }
@@ -42845,7 +42926,8 @@ function PreviewPanel({
42845
42926
  theme: activeTheme,
42846
42927
  showCover: activeCoverSlide,
42847
42928
  transformStyle: activeTransformStyle,
42848
- mediaRevision
42929
+ mediaRevision,
42930
+ container: workspaceContainer ?? null
42849
42931
  }
42850
42932
  );
42851
42933
  }
@@ -42858,6 +42940,7 @@ function PreviewPanel({
42858
42940
  title: contentDoc?.frontmatter?.title ?? void 0,
42859
42941
  mediaProvider,
42860
42942
  mediaRevision,
42943
+ container: workspaceContainer ?? null,
42861
42944
  theme: activeTheme,
42862
42945
  globalKeyboardShortcuts: !audience,
42863
42946
  onLinkClick,
package/dist/index.d.ts CHANGED
@@ -434,6 +434,11 @@ interface PlainHtmlPreviewProps {
434
434
  * Mirrors the `mediaRevision` bump the editor uses after an image
435
435
  * edit so saves show up in the preview without remount. */
436
436
  mediaRevision?: number;
437
+ /**
438
+ * The workspace holding the document's data files, so a
439
+ * `{[dataTable src=…]}` reference shows its first rows as the export does.
440
+ */
441
+ container?: ContentContainer | null;
437
442
  /**
438
443
  * Squisq theme to apply. When set, the iframe loads any Google-
439
444
  * hosted fonts the theme uses and the rendered HTML adopts the
@@ -456,7 +461,7 @@ interface PlainHtmlPreviewProps {
456
461
  /** Optional host clipboard adapter; otherwise the browser Clipboard API is used. */
457
462
  onCopyCode?: CodeBlockCopyHandler;
458
463
  }
459
- declare function PlainHtmlPreview({ markdown, wikiLinks, title, images, mediaProvider, mediaRevision, theme, className, style, globalKeyboardShortcuts, onFrameChange, onLinkClick, showCodeCopyButton, onCopyCode, }: PlainHtmlPreviewProps): react.JSX.Element;
464
+ declare function PlainHtmlPreview({ markdown, wikiLinks, title, images, mediaProvider, mediaRevision, container, theme, className, style, globalKeyboardShortcuts, onFrameChange, onLinkClick, showCodeCopyButton, onCopyCode, }: PlainHtmlPreviewProps): react.JSX.Element;
460
465
 
461
466
  /**
462
467
  * Emoji Dataset
package/dist/index.js CHANGED
@@ -243,7 +243,7 @@ import {
243
243
  videoEmbedParagraphJson,
244
244
  viewStateFromBinding,
245
245
  writeHeadingViewState
246
- } from "./chunk-J5IUF3BC.js";
246
+ } from "./chunk-FLCBGVPN.js";
247
247
  import {
248
248
  EditorProvider,
249
249
  applySourceEditsToText,
@@ -5,7 +5,7 @@ import {
5
5
  RawEditor,
6
6
  WysiwygEditor,
7
7
  useEditorContextMenuItems
8
- } from "../chunk-J5IUF3BC.js";
8
+ } from "../chunk-FLCBGVPN.js";
9
9
  import {
10
10
  EditorProvider,
11
11
  useEditorContext,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/squisq-editor-react",
3
- "version": "2.13.12",
3
+ "version": "2.13.13",
4
4
  "description": "React editor shell with raw/WYSIWYG/preview modes for Squisq documents",
5
5
  "license": "MIT",
6
6
  "author": "Bendyline",
@@ -102,12 +102,12 @@
102
102
  }
103
103
  },
104
104
  "dependencies": {
105
- "@bendyline/squisq": "2.13.7",
105
+ "@bendyline/squisq": "2.13.8",
106
106
  "@bendyline/squisq-calc": "2.11.2",
107
- "@bendyline/squisq-formats": "2.8.8",
108
- "@bendyline/squisq-grid-react": "2.11.36",
109
- "@bendyline/squisq-react": "2.12.19",
110
- "@bendyline/squisq-video-react": "2.5.20",
107
+ "@bendyline/squisq-formats": "2.8.9",
108
+ "@bendyline/squisq-grid-react": "2.11.37",
109
+ "@bendyline/squisq-react": "2.12.20",
110
+ "@bendyline/squisq-video-react": "2.5.21",
111
111
  "@fortawesome/fontawesome-free": "7.3.1",
112
112
  "@tiptap/core": "2.27.3",
113
113
  "@tiptap/extension-heading": "2.27.3",