@drghaliasri/butex 4.2.0 → 4.3.0

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.
@@ -11528,6 +11528,7 @@ function ButexDocumentEditor2({
11528
11528
  documentDirection = "rtl",
11529
11529
  equationSide = "arabic",
11530
11530
  editableEquations = true,
11531
+ previewOnly = false,
11531
11532
  uiLocale = "ar",
11532
11533
  mathOutput = "svg",
11533
11534
  onDocumentChange,
@@ -11570,10 +11571,10 @@ function ButexDocumentEditor2({
11570
11571
  injectBuTeXDocument2Styles();
11571
11572
  }, []);
11572
11573
  useEffect5(() => {
11573
- if (!editableEquations) {
11574
+ if (!editableEquations || previewOnly) {
11574
11575
  setSelectedMath(null);
11575
11576
  }
11576
- }, [editableEquations]);
11577
+ }, [editableEquations, previewOnly]);
11577
11578
  useEffect5(() => {
11578
11579
  const next = resolveInitialDocument2(initialDocument, uiLocale);
11579
11580
  setDocumentNode(next.document);
@@ -11862,6 +11863,8 @@ function ButexDocumentEditor2({
11862
11863
  pendingFocusRef.current = focusAfterDeletedMath(current, next, tokenId);
11863
11864
  applyDocument(next, "immediate");
11864
11865
  }
11866
+ const showEditorPanel = !previewOnly && editorOpen;
11867
+ const showPreviewPanel = previewOnly || previewOpen;
11865
11868
  return /* @__PURE__ */ jsx10(
11866
11869
  "div",
11867
11870
  {
@@ -11870,7 +11873,7 @@ function ButexDocumentEditor2({
11870
11873
  dir: uiLocaleDirection(uiLocale),
11871
11874
  lang: uiLocale,
11872
11875
  children: /* @__PURE__ */ jsxs8("div", { className: "butex-document2-widget__shell", children: [
11873
- /* @__PURE__ */ jsxs8("div", { className: "butex-document2-widget__toolbar", children: [
11876
+ !previewOnly ? /* @__PURE__ */ jsxs8("div", { className: "butex-document2-widget__toolbar", children: [
11874
11877
  /* @__PURE__ */ jsx10(
11875
11878
  DocumentInsertToolbar,
11876
11879
  {
@@ -11900,19 +11903,19 @@ function ButexDocumentEditor2({
11900
11903
  /* @__PURE__ */ jsx10("button", { type: "button", onClick: collapseAllBlocks, children: messages.collapseAll }),
11901
11904
  /* @__PURE__ */ jsx10("button", { type: "button", onClick: openAllBlocks, children: messages.openAll })
11902
11905
  ] })
11903
- ] }),
11906
+ ] }) : null,
11904
11907
  error ? /* @__PURE__ */ jsx10("p", { className: "butex-document2-widget__error", children: error }) : null,
11905
11908
  /* @__PURE__ */ jsxs8(
11906
11909
  "div",
11907
11910
  {
11908
- className: `butex-document2-widget__layout butex-document2-widget__layout--editor-${editorOpen ? "open" : "closed"} butex-document2-widget__layout--preview-${previewOpen ? "open" : "closed"}`,
11911
+ className: `butex-document2-widget__layout butex-document2-widget__layout--editor-${showEditorPanel ? "open" : "closed"} butex-document2-widget__layout--preview-${showPreviewPanel ? "open" : "closed"}`,
11909
11912
  children: [
11910
- /* @__PURE__ */ jsx10(
11913
+ !previewOnly ? /* @__PURE__ */ jsx10(
11911
11914
  "section",
11912
11915
  {
11913
11916
  className: "butex-document2-widget__panel butex-document2-widget__editor-panel",
11914
11917
  "aria-label": messages.documentEditor,
11915
- "aria-hidden": !editorOpen,
11918
+ "aria-hidden": !showEditorPanel,
11916
11919
  children: /* @__PURE__ */ jsx10("div", { className: "butex-document2-widget__blocks", children: documentNode.blocks.map((block, blockIndex) => /* @__PURE__ */ jsx10(
11917
11920
  BlockEditor,
11918
11921
  {
@@ -11942,13 +11945,13 @@ function ButexDocumentEditor2({
11942
11945
  block.id
11943
11946
  )) })
11944
11947
  }
11945
- ),
11948
+ ) : null,
11946
11949
  /* @__PURE__ */ jsx10(
11947
11950
  "section",
11948
11951
  {
11949
11952
  className: "butex-document2-widget__panel butex-document2-widget__preview-panel",
11950
11953
  "aria-label": messages.documentPreview,
11951
- "aria-hidden": !previewOpen,
11954
+ "aria-hidden": !showPreviewPanel,
11952
11955
  children: /* @__PURE__ */ jsx10(DocumentPreview, { blocks: preview.blocks, output: mathOutput, documentDirection, uiLocale })
11953
11956
  }
11954
11957
  )
@@ -11965,7 +11968,7 @@ function ButexDocumentEditor2({
11965
11968
  /* @__PURE__ */ jsx10("strong", { children: "AST" }),
11966
11969
  /* @__PURE__ */ jsx10("pre", { children: JSON.stringify(documentNode, null, 2) })
11967
11970
  ] }) : null,
11968
- selectedMath ? /* @__PURE__ */ jsx10(
11971
+ !previewOnly && selectedMath ? /* @__PURE__ */ jsx10(
11969
11972
  EquationDrawer,
11970
11973
  {
11971
11974
  session: selectedMath.session,