wysimark-lite 0.27.7 → 0.27.8

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.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import * as React$1 from 'react';
2
- import React__default, { ReactNode } from 'react';
1
+ import * as react from 'react';
2
+ import react__default, { ReactNode } from 'react';
3
3
  import * as slate from 'slate';
4
4
  import { Descendant, Editor, Element as Element$1, BaseEditor, NodeEntry, BaseRange, Location, Path, Text, BaseText } from 'slate';
5
5
  import { HistoryEditor } from 'slate-history';
@@ -229,9 +229,9 @@ type VoidActionReturn = boolean | (() => void);
229
229
 
230
230
  type RenderEditableProps = {
231
231
  attributes: EditableProps$1;
232
- Editable: React__default.ComponentType<EditableProps$1>;
232
+ Editable: react__default.ComponentType<EditableProps$1>;
233
233
  };
234
- type RenderEditable = (props: RenderEditableProps) => React__default.ReactElement;
234
+ type RenderEditable = (props: RenderEditableProps) => react__default.ReactElement;
235
235
  /**
236
236
  * The return type of the BasePluginFn which specifies how the Plugin is
237
237
  * supposed to behave.
@@ -256,9 +256,9 @@ type BasePluginPolicy = {
256
256
  renderEditable?: RenderEditable;
257
257
  editableProps?: {
258
258
  decorate?: ((entry: NodeEntry) => BaseRange[]) | undefined;
259
- renderElement?: (props: RenderElementProps) => React__default.ReactElement | undefined;
260
- renderLeaf?: (props: RenderLeafProps) => React__default.ReactElement | undefined;
261
- renderPlaceholder?: (props: RenderPlaceholderProps) => React__default.ReactElement;
259
+ renderElement?: (props: RenderElementProps) => react__default.ReactElement | undefined;
260
+ renderLeaf?: (props: RenderLeafProps) => react__default.ReactElement | undefined;
261
+ renderPlaceholder?: (props: RenderPlaceholderProps) => react__default.ReactElement;
262
262
  onKeyDown?: EditableVoidToBooleanHandlerType<"onKeyDown">;
263
263
  onKeyUp?: EditableVoidToBooleanHandlerType<"onKeyDown">;
264
264
  onPaste?: EditableVoidToBooleanHandlerType<"onPaste">;
@@ -605,7 +605,7 @@ declare function createListMethods(editor: Editor): {
605
605
  convertTaskList: (allowToggle: boolean) => void;
606
606
  insertBreak: () => boolean;
607
607
  toggleTaskListItem: (args_0?: {
608
- at?: BetterAt;
608
+ at?: BetterAt | undefined;
609
609
  } | undefined) => boolean;
610
610
  getListDepth: () => number;
611
611
  canIncreaseDepth: () => boolean;
@@ -753,66 +753,91 @@ type TableInfo = {
753
753
  cellCount: number;
754
754
  };
755
755
 
756
- declare function createTableMethods(editor: Editor): {
757
- getTableInfo: (args_0?: {
758
- at?: slate.Location | slate.Element | null;
759
- } | undefined) => TableInfo | undefined;
760
- insertTable: (columnCount: number, rowCount: number, args_2?: {
761
- at?: slate.Location | null;
762
- } | undefined) => boolean;
763
- insertColumn: (args_0?: {
764
- offset?: 0 | 1;
765
- at?: BetterAt;
766
- } | undefined) => boolean;
767
- insertRow: (args_0?: {
768
- at?: BetterAt;
769
- offset?: 0 | 1;
770
- } | undefined) => boolean;
771
- removeTable: () => boolean;
772
- removeColumn: (args_0?: {
773
- at?: BetterAt;
774
- } | undefined) => boolean | undefined;
775
- removeRow: (args_0?: {
776
- at?: BetterAt;
777
- } | undefined) => boolean;
778
- tabForward: () => boolean;
779
- tabBackward: () => boolean | undefined;
780
- shiftEnterForward: () => boolean;
781
- selectCell: (args_0?: {
782
- at?: BetterAt;
783
- } | undefined) => boolean;
784
- down: () => boolean;
785
- up: () => boolean;
786
- setTableColumnAlign: (options: {
787
- align: "left" | "center" | "right";
756
+ declare function createAnchorMethods(editor: Editor): {
757
+ insertLink: (args_0: string, args_1?: string | undefined, args_2?: {
758
+ select?: boolean | undefined;
759
+ title?: string | undefined;
760
+ } | undefined) => void;
761
+ removeLink: (args_0: {
762
+ at?: BetterAt | undefined;
763
+ }) => boolean;
764
+ editLink: (args_0: {
765
+ href: string;
766
+ title?: string | undefined;
767
+ text?: string | undefined;
768
+ }, args_1: {
769
+ at?: BetterAt | undefined;
770
+ }) => boolean;
771
+ convertToEmbed: (args_0: string, args_1: {
772
+ at?: BetterAt | undefined;
788
773
  }) => boolean;
774
+ convertToLink: (args_0: string, args_1: {
775
+ at?: BetterAt | undefined;
776
+ }) => false | readonly [AnchorElement, number[]];
789
777
  };
790
778
 
791
- type TableEditor = {
792
- supportsTable: true;
793
- tablePlugin: ReturnType<typeof createTableMethods>;
779
+ type AnchorMethods = ReturnType<typeof createAnchorMethods>;
780
+ type AnchorEditor = {
781
+ anchor: AnchorMethods;
794
782
  };
795
- type TablePluginCustomTypes = {
796
- Name: "table";
797
- Editor: TableEditor;
798
- Element: TableElement | TableRowElement | TableCellElement | TableContentElement;
783
+ type AnchorElement = {
784
+ type: "anchor";
785
+ href: string;
786
+ target?: string;
787
+ title?: string;
788
+ children: Descendant[];
789
+ };
790
+ type AnchorPluginCustomTypes = {
791
+ Name: "anchor";
792
+ Editor: AnchorEditor;
793
+ Element: AnchorElement;
799
794
  };
800
795
 
801
- /**
802
- * HTML block element for preserving raw HTML content
803
- */
804
- type HtmlBlockElement = {
805
- type: "html-block";
796
+ declare function createHeadingMethods(editor: Editor): {
797
+ convertHeading: (level: 1 | 2 | 3 | 4 | 5 | 6, allowToggle: boolean) => void;
798
+ isHeadingActive: (level: 1 | 2 | 3 | 4 | 5 | 6) => boolean;
799
+ };
800
+
801
+ type HeadingEditor = {
802
+ heading: ReturnType<typeof createHeadingMethods>;
803
+ };
804
+ type HeadingElement = {
805
+ type: "heading";
806
806
  /**
807
- * The raw HTML content
807
+ * NOTE:
808
+ *
809
+ * Don't extract these into a new type. It's easier to just repeat this and
810
+ * there's less indirection.
808
811
  */
809
- html: string;
810
- children: Text[];
812
+ level: 1 | 2 | 3 | 4 | 5 | 6;
813
+ children: Descendant[];
811
814
  };
812
- type HtmlBlockPluginCustomTypes = {
813
- Name: "html-block";
814
- Editor: Record<string, never>;
815
- Element: HtmlBlockElement;
815
+ type HeadingPluginCustomTypes = {
816
+ Name: "heading";
817
+ Editor: HeadingEditor;
818
+ Element: HeadingElement;
819
+ };
820
+
821
+ type BlockQuoteEditor = {
822
+ supportsBlockQuote: true;
823
+ blockQuotePlugin: {
824
+ indent: () => void;
825
+ outdent: () => void;
826
+ isActive: () => boolean;
827
+ increaseDepth: () => void;
828
+ decreaseDepth: () => void;
829
+ canIncreaseDepth: () => boolean;
830
+ canDecreaseDepth: () => boolean;
831
+ };
832
+ };
833
+ type BlockQuoteElement = {
834
+ type: "block-quote";
835
+ children: Descendant[];
836
+ };
837
+ type BlockQuotePluginCustomTypes = {
838
+ Name: "block-quote";
839
+ Editor: BlockQuoteEditor;
840
+ Element: BlockQuoteElement;
816
841
  };
817
842
 
818
843
  declare function createCodeBlockMethods(editor: Editor): {
@@ -820,7 +845,7 @@ declare function createCodeBlockMethods(editor: Editor): {
820
845
  language: BuiltInLanguage;
821
846
  }) => void;
822
847
  setCodeBlockLanguage: (language: BuiltInLanguage, options?: {
823
- at?: BetterAt;
848
+ at?: BetterAt | undefined;
824
849
  } | undefined) => boolean;
825
850
  };
826
851
 
@@ -856,26 +881,66 @@ type CodeBlockPluginCustomTypes = {
856
881
  };
857
882
  };
858
883
 
859
- type BlockQuoteEditor = {
860
- supportsBlockQuote: true;
861
- blockQuotePlugin: {
862
- indent: () => void;
863
- outdent: () => void;
864
- isActive: () => boolean;
865
- increaseDepth: () => void;
866
- decreaseDepth: () => void;
867
- canIncreaseDepth: () => boolean;
868
- canDecreaseDepth: () => boolean;
869
- };
884
+ /**
885
+ * HTML block element for preserving raw HTML content
886
+ */
887
+ type HtmlBlockElement = {
888
+ type: "html-block";
889
+ /**
890
+ * The raw HTML content
891
+ */
892
+ html: string;
893
+ children: Text[];
870
894
  };
871
- type BlockQuoteElement = {
872
- type: "block-quote";
873
- children: Descendant[];
895
+ type HtmlBlockPluginCustomTypes = {
896
+ Name: "html-block";
897
+ Editor: Record<string, never>;
898
+ Element: HtmlBlockElement;
874
899
  };
875
- type BlockQuotePluginCustomTypes = {
876
- Name: "block-quote";
877
- Editor: BlockQuoteEditor;
878
- Element: BlockQuoteElement;
900
+
901
+ declare function createTableMethods(editor: Editor): {
902
+ getTableInfo: (args_0?: {
903
+ at?: ImageBlockElement | ImageInlineElement | ParagraphElement | OrderedListItemElement | UnorderedListItemElement | TaskListItemElement | HorizontalRuleElement | TableElement | TableRowElement | TableCellElement | TableContentElement | HtmlBlockElement | CodeBlockElement | CodeBlockLineElement | BlockQuoteElement | HeadingElement | AnchorElement | slate.Location | null | undefined;
904
+ } | undefined) => TableInfo | undefined;
905
+ insertTable: (args_0: number, args_1: number, args_2?: {
906
+ at?: slate.Location | null | undefined;
907
+ } | undefined) => boolean;
908
+ insertColumn: (args_0?: {
909
+ offset?: 0 | 1 | undefined;
910
+ at?: BetterAt | undefined;
911
+ } | undefined) => boolean;
912
+ insertRow: (args_0?: {
913
+ at?: BetterAt | undefined;
914
+ offset?: 0 | 1 | undefined;
915
+ } | undefined) => boolean;
916
+ removeTable: () => boolean;
917
+ removeColumn: (args_0?: {
918
+ at?: BetterAt | undefined;
919
+ } | undefined) => boolean | undefined;
920
+ removeRow: (args_0?: {
921
+ at?: BetterAt | undefined;
922
+ } | undefined) => boolean;
923
+ tabForward: () => boolean;
924
+ tabBackward: () => boolean | undefined;
925
+ shiftEnterForward: () => boolean;
926
+ selectCell: (args_0?: {
927
+ at?: BetterAt | undefined;
928
+ } | undefined) => boolean;
929
+ down: () => boolean;
930
+ up: () => boolean;
931
+ setTableColumnAlign: (options: {
932
+ align: "center" | "left" | "right";
933
+ }) => boolean;
934
+ };
935
+
936
+ type TableEditor = {
937
+ supportsTable: true;
938
+ tablePlugin: ReturnType<typeof createTableMethods>;
939
+ };
940
+ type TablePluginCustomTypes = {
941
+ Name: "table";
942
+ Editor: TableEditor;
943
+ Element: TableElement | TableRowElement | TableCellElement | TableContentElement;
879
944
  };
880
945
 
881
946
  type InlineCodeEditor = {
@@ -895,10 +960,10 @@ type InlineCodePluginCustomTypes = {
895
960
 
896
961
  declare function createMarksMethods(editor: Editor): {
897
962
  removeMarks: (args_0?: {
898
- at?: slate.Location | null;
963
+ at?: slate.Location | null | undefined;
899
964
  } | undefined) => void;
900
- toggleMark: (markKey: "bold" | "strike" | "text" | "prismToken" | "code" | "italic" | "underline" | "highlight", unsetKey?: "bold" | "strike" | "text" | "prismToken" | "code" | "italic" | "underline" | "highlight" | undefined, args_2?: {
901
- at?: slate.Location | null;
965
+ toggleMark: (args_0: "bold" | "strike" | "text" | "prismToken" | "code" | "italic" | "underline" | "highlight", args_1?: "bold" | "strike" | "text" | "prismToken" | "code" | "italic" | "underline" | "highlight" | undefined, args_2?: {
966
+ at?: slate.Location | null | undefined;
902
967
  } | undefined) => void;
903
968
  toggleBold: () => void;
904
969
  toggleItalic: () => void;
@@ -937,71 +1002,6 @@ type MarksPluginCustomTypes = {
937
1002
  Text: MarksText;
938
1003
  };
939
1004
 
940
- declare function createHeadingMethods(editor: Editor): {
941
- convertHeading: (level: 1 | 2 | 3 | 4 | 5 | 6, allowToggle: boolean) => void;
942
- isHeadingActive: (level: 1 | 2 | 3 | 4 | 5 | 6) => boolean;
943
- };
944
-
945
- type HeadingEditor = {
946
- heading: ReturnType<typeof createHeadingMethods>;
947
- };
948
- type HeadingElement = {
949
- type: "heading";
950
- /**
951
- * NOTE:
952
- *
953
- * Don't extract these into a new type. It's easier to just repeat this and
954
- * there's less indirection.
955
- */
956
- level: 1 | 2 | 3 | 4 | 5 | 6;
957
- children: Descendant[];
958
- };
959
- type HeadingPluginCustomTypes = {
960
- Name: "heading";
961
- Editor: HeadingEditor;
962
- Element: HeadingElement;
963
- };
964
-
965
- declare function createAnchorMethods(editor: Editor): {
966
- insertLink: (href: string, text?: string | undefined, args_2?: {
967
- select?: boolean;
968
- title?: string;
969
- } | undefined) => void;
970
- removeLink: (args_0: {
971
- at?: BetterAt;
972
- }) => boolean;
973
- editLink: (args_0: {
974
- href: string;
975
- title?: string;
976
- text?: string;
977
- }, args_1: {
978
- at?: BetterAt;
979
- }) => boolean;
980
- convertToEmbed: (spec: string, args_1: {
981
- at?: BetterAt;
982
- }) => boolean;
983
- convertToLink: (spec: string, args_1: {
984
- at?: BetterAt;
985
- }) => false | readonly [AnchorElement, number[]];
986
- };
987
-
988
- type AnchorMethods = ReturnType<typeof createAnchorMethods>;
989
- type AnchorEditor = {
990
- anchor: AnchorMethods;
991
- };
992
- type AnchorElement = {
993
- type: "anchor";
994
- href: string;
995
- target?: string;
996
- title?: string;
997
- children: Descendant[];
998
- };
999
- type AnchorPluginCustomTypes = {
1000
- Name: "anchor";
1001
- Editor: AnchorEditor;
1002
- Element: AnchorElement;
1003
- };
1004
-
1005
1005
  /**
1006
1006
  * A type with generic for `convertElements` (below) to be used with the curry
1007
1007
  * method. TypeScript, unfortunately, cannot automatically curry generics for
@@ -1066,7 +1066,7 @@ type EditableProps = {
1066
1066
  onImageChange?: OnImageChangeHandler;
1067
1067
  onFileSelect?: OnFileSelectHandler;
1068
1068
  };
1069
- declare function Editable({ editor, value, onChange, throttleInMs, placeholder, className, style, onImageChange, onFileSelect, }: EditableProps): React$1.JSX.Element;
1069
+ declare function Editable({ editor, value, onChange, throttleInMs, placeholder, className, style, onImageChange, onFileSelect, }: EditableProps): react.JSX.Element;
1070
1070
 
1071
1071
  /**
1072
1072
  * Remove inline escape backslashes added by the serializer's escapeText.
@@ -1083,6 +1083,8 @@ type StandaloneOptions = Parameters<typeof useEditor>[0] & {
1083
1083
  placeholder?: string;
1084
1084
  initialMarkdown?: string;
1085
1085
  className?: string;
1086
+ onImageChange?: OnImageChangeHandler;
1087
+ onFileSelect?: OnFileSelectHandler;
1086
1088
  };
1087
1089
  /**
1088
1090
  * The object returned by `createWysimark`
package/dist/index.js CHANGED
@@ -1725,4 +1725,4 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
1725
1725
  margin-top: 0.5em;
1726
1726
  color: var(--shade-500);
1727
1727
  line-height: 1.375;
1728
- `;import{Fragment as Hk,jsx as G,jsxs as Ct}from"react/jsx-runtime";var Nk=Sk("enter");function Cd({dest:e,close:t}){let o=zk(),r=Rk(null),[n,i]=Ye({x:0,y:0}),a=Jt((v,$)=>{i(de=>({x:de.x+v,y:de.y+$}))},[]),l=oe({src:r,dest:e},({src:v,dest:$},de)=>!v||!$?{left:0,top:0}:Be(v,de,{left:$.left-12,top:$.top+$.height},{margin:16})),s={...l,left:l.left+n.x,top:l.top+n.y},m=Lk(()=>{let{selection:v}=o;return v&&!$k.isCollapsed(v)?Bk.string(o,v):""},[]),[c,d]=Ye(""),[p,u]=Ye(""),[h,k]=Ye(m),[L,M]=Ye(m),[T,D]=Ye("external"),[P,H]=Ye(!1),C=()=>{if(T==="internal"){let v=p.trim();if(v==="")return;let $=h.trim(),de=$&&$!==me(v)?`${v}|${$}`:v;o.anchor.insertLink(Ce(de),$||me(v),{select:!0})}else{let v=h.trim()||c,$=L.trim()||void 0;o.anchor.insertLink(c,v,{select:!0,title:$})}Dk.focus(o),t()},B=Jt(v=>{d(v.currentTarget.value)},[d]),S=Jt(v=>{let $=ao(v.currentTarget.value);u($.target),$.display!==void 0&&k($.display)},[u,k]),R=Jt(v=>{let $=v.currentTarget.value;k($),P||M($)},[k,M,P]),w=Jt(v=>{M(v.currentTarget.value),H(!0)},[M]),U=v=>{Nk(v)&&(v.preventDefault(),v.stopPropagation(),C())};return Ct(Hk,{children:[G(Re,{close:t}),Ct(Qa,{ref:r,style:s,children:[G(De,{onDrag:a}),Ct("div",{style:{padding:"0.75em"},children:[o.wysimark.enableInternalLinks?G(Vt,{children:Ct("div",{style:{display:"flex",gap:"0.25em",padding:"0.25em",borderRadius:"0.375em",background:"var(--shade-100)",width:"100%"},children:[G("button",{type:"button",onClick:()=>D("external"),style:{flex:"1 1 0",border:0,borderRadius:"0.25em",padding:"0.375em 0.5em",cursor:"pointer",background:T==="external"?"white":"transparent",color:T==="external"?"var(--shade-700)":"var(--shade-500)",boxShadow:T==="external"?"0 1px 2px rgb(0 0 0 / 12%)":"none"},children:f("linkTypeExternal")}),G("button",{type:"button",onClick:()=>D("internal"),style:{flex:"1 1 0",border:0,borderRadius:"0.25em",padding:"0.375em 0.5em",cursor:"pointer",background:T==="internal"?"white":"transparent",color:T==="internal"?"var(--shade-700)":"var(--shade-500)",boxShadow:T==="internal"?"0 1px 2px rgb(0 0 0 / 12%)":"none"},children:f("linkTypeInternal")})]})}):null,G(Vt,{style:{marginTop:o.wysimark.enableInternalLinks?"0.5em":0},children:T==="internal"?G(_t,{type:"text",value:p,autoFocus:!0,placeholder:f("internalLinkTarget"),onChange:S,onKeyDown:U}):G(_t,{type:"text",value:c,autoFocus:!0,placeholder:f("linkUrl"),onChange:B,onKeyDown:U})}),G(Vt,{style:{marginTop:"0.5em"},children:G(_t,{type:"text",value:h,placeholder:f("linkText"),onChange:R,onKeyDown:U})}),Ct(Vt,{style:{marginTop:"0.5em"},children:[T==="external"?G(_t,{type:"text",value:L,placeholder:f("tooltipText"),onChange:w,onKeyDown:U}):G("span",{style:{flex:"1 1 auto"}}),Ct(vn,{onClick:C,children:[G(tr,{}),G(ed,{})]}),G(vn,{onClick:t,style:{marginLeft:"0.25em",background:"var(--shade-400)"},children:G(Ed,{})})]}),T==="external"?G(Tn,{children:f("tooltipHint")}):G(Tn,{children:f("internalLinkTargetHint")})]})]})]})}var wn=[{icon:tr,title:f("insertLink"),more:!0,hotkey:"mod+k",Component:Cd},{icon:pd,title:f("insertImageFromUrl"),more:!0,Component:Id},{icon:sd,title:f("insertTable"),more:!0,Component:Yp},{icon:xd,title:f("horizontalRule"),hotkey:"super+-",action:e=>e.horizontalRule.insertHorizontalRule()}],Pd=wn,Sd=wn,Ld=[{icon:dd,title:f("insert"),more:!0,children:wn}];import{Editor as Ak}from"slate";function Pt(e){let t=Ak.marks(e);return{bold:t?.bold||!1,italic:t?.italic||!1,strike:t?.strike||!1,code:t?.code||!1,underline:t?.underline||!1,highlight:t?.highlight||!1}}var Rd=[{icon:gn,title:f("bold"),hotkey:"mod+b",action:e=>e.marksPlugin.toggleBold(),active:e=>Pt(e).bold},{icon:id,title:f("italic"),hotkey:"mod+i",action:e=>e.marksPlugin.toggleItalic(),active:e=>Pt(e).italic},{icon:ud,title:f("strike"),hotkey:"super+k",action:e=>e.marksPlugin.toggleStrike(),active:e=>Pt(e).strike},{icon:md,title:f("inlineCode"),hotkey:"mod+j",action:e=>e.inlineCode.toggleInlineCode(),active:e=>Pt(e).code},{icon:fd,title:f("underline"),hotkey:"mod+u",action:e=>e.marksPlugin.toggleUnderline(),active:e=>Pt(e).underline},{icon:kd,title:f("highlight"),hotkey:"mod+h",action:e=>e.marksPlugin.toggleHighlight(),active:e=>Pt(e).highlight,show:e=>!e.wysimark.disableHighlight}],In=Rd,Bd=[{icon:gn,title:f("format"),more:!0,children:Rd}];var Ok=["unordered-list-item","ordered-list-item","task-list-item"],$d=[{icon:ld,title:f("bulletList"),hotkey:"super+8",action:e=>e.list.convertUnorderedList(!0),active:e=>!!b(e,"unordered-list-item")},{icon:En,title:f("numberedList"),hotkey:"super+7",action:e=>e.list.convertOrderedList(!0),active:e=>!!b(e,"ordered-list-item")},{icon:hd,title:f("checkList"),hotkey:"super+9",action:e=>e.list.convertTaskList(!0),active:e=>!!b(e,"task-list-item"),show:e=>!e.wysimark.disableTaskList}],Mn=[...$d,"divider",...kn],Dd=[{icon:En,title:f("list"),more:!0,active:e=>!!b(e,Ok),children:[...$d,"divider",...kn]}];import{Editor as zd,Path as Uk,Transforms as or}from"slate";var Nd=[{icon:bn,title:f("quote"),hotkey:"super+.",action:e=>{e.blockQuotePlugin.isActive()?e.blockQuotePlugin.outdent():e.blockQuotePlugin.indent()},active:e=>e.blockQuotePlugin.isActive()},{icon:ad,title:f("increaseQuoteDepth"),action:e=>e.blockQuotePlugin.increaseDepth(),active:e=>e.blockQuotePlugin.canIncreaseDepth()},{icon:cd,title:f("codeBlock"),action:e=>{let{selection:t}=e,o=b(e,"code-block");if(o){let[,r]=o,n=zd.string(e,r);or.removeNodes(e,{at:r}),or.insertNodes(e,{type:"paragraph",children:[{text:n}]},{at:r});return}if(t&&!Uk.equals(t.anchor.path,t.focus.path)){e.codeBlock.createCodeBlock({language:"text"});return}if(t&&t.anchor.offset!==t.focus.offset){let r=zd.string(e,t);or.delete(e),or.insertNodes(e,{type:"code-block",language:"text",children:[{type:"code-block-line",children:[{text:r}]}]});return}e.codeBlock.createCodeBlock({language:"text"})},active:e=>!!b(e,"code-block"),show:e=>!e.wysimark.disableCodeBlock}],Cn=Nd,Hd=[{icon:bn,title:f("quote"),more:!0,children:Nd}];var Fk=[...vd,"divider",...Mn,"divider",...In,"divider",...Pd,"divider",...Cn],Wk=[...xn,"divider",...Mn,"divider",...In,"divider",...Sd,"divider",...Cn],Ad=[...xn,"divider",...Dd,"divider",...Bd,"divider",...Ld,"divider",...Hd],Od=Ad;var St=[Fk,Wk,Ad];import{clsx as Vk}from"clsx";import{useCallback as Pn,useRef as _k}from"react";import{ReactEditor as Kk,useSlate as Gk,useSlateStatic as qk}from"slate-react";import{jsx as rr,jsxs as Qk}from"react/jsx-runtime";function Ud({item:e}){let t=qk(),o=Gk(),r=e.active?e.active(o):!1,n=_k(null),i=ne({title:e.title,hotkey:()=>e.hotkey?wo(e.hotkey):void 0}),a=W("menu"),l=Pn(()=>{let c=n.current,d=e.children,p=e.Component;c&&(d?a.open(()=>rr(ct,{dest:c,items:d,close:a.close})):p&&a.open(()=>rr(p,{dest:c,close:a.close})))},[e]),s=Pn(()=>{if(e.action){e.action(t),Kk.focus(t);return}a.layer?a.close():l()},[a.layer,e]),m=Pn(c=>{i.onMouseEnter(c),a.layer&&l()},[a.layer,l,i.onMouseEnter]);return Qk(al,{"data-item-type":"button",ref:n,onMouseEnter:m,onMouseLeave:i.onMouseLeave,onClick:s,className:Vk({"--active":r&&!Er(e?.title)?.includes("Depth"),"--more":e.more,"--disabled":!r&&Er(e?.title)?.includes("Depth")}),children:[rr(e.icon,{}),e.more?rr(Zp,{}):null]})}import{jsx as Lt}from"react/jsx-runtime";function Zk({item:e}){let t=Jk();return e==="divider"?Lt(nl,{"data-item-type":"divider",children:Lt(il,{})}):(e.show===void 0?!0:e.show(t))?Lt(Ud,{item:e}):null}function ex(e){let t=e.querySelector("[data-item-type=button]"),o=e.querySelector("[data-item-type=divider]");return!t||!o?null:{toolbar:e.offsetWidth,button:t.offsetWidth,divider:o.offsetWidth}}function tx(e,t,o){let r=0;for(let n of e)r+=n==="divider"?o:t;return r}var ox=4;function Fd(){let e=Xk(null),[t,o]=Yk(Od);return jk(()=>{let r=e.current;if(!r)return;let n=()=>{let a=ex(r);if(a){for(let l=0;l<St.length-1;l++)if(tx(St[l],a.button,a.divider)<a.toolbar-ox){o(St[l]);return}o(St[St.length-1])}},i=new ResizeObserver(n);return i.observe(r),()=>{i.disconnect()}},[]),Lt(ol,{ref:e,children:Lt(rl,{children:t.map((r,n)=>Lt(Zk,{item:r},typeof r=="string"?n:r.title))})})}import{jsx as Sn,jsxs as px}from"react/jsx-runtime";function Wd({attributes:e,Editable:t}){let o=ix(null),r=cx(),n=mx(),i=nx(a=>{a.target===a.currentTarget&&(lx.select(r,ax.end(r,[])),sx.focus(r))},[r]);return Sn(Fa,{children:px(Ja,{ref:o,className:rx({"--focused":n}),style:{height:r.toolbar.height,minHeight:r.toolbar.minHeight,maxHeight:r.toolbar.maxHeight},onClick:i,children:[Sn(Fd,{}),Sn(t,{as:Ya,...e,style:{overflowY:"auto"}})]})})}var Vd=y((e,t)=>(e.toolbar={height:t.toolbar?.height,minHeight:t.toolbar?.minHeight,maxHeight:t.toolbar?.maxHeight,showUploadButtons:t.toolbar?.showUploadButtons??!0},{name:"toolbar",editor:{},renderEditable:Wd,editableProps:{}}));import{Editor as Ln,Node as dx,Path as ux,Transforms as fx}from"slate";var _d=y(e=>(e.allowTrailingBlock=!0,{name:"trailing-block",editor:{normalizeNode:t=>{if(!Ln.isEditor(t[0]))return!1;let o=[e.children.length-1],r=dx.child(e,e.children.length-1);return(Ln.hasBlocks(e,r)||Ln.isVoid(e,r))&&fx.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:ux.next(o)}),!0}}}));import{Transforms as hx}from"slate";function gx(e,t){let o=Pe(t),r=Le(o,{enableInternalLinks:e.wysimark.enableInternalLinks});hx.insertNodes(e,r)}function Kd(e){return{pasteMarkdown:g(gx,e)}}function bx(e){return e.length===1&&e[0]==="text/plain"}function Ex(e){return/^>\s*\[![A-Za-z0-9_-]+\][+-]?(?:\s|$)/m.test(e)}var Gd=y(e=>(e.pasteMarkdown=Kd(e),{name:"paste-markdown",editor:{},editableProps:{onPaste(t){let o=Array.from(t.clipboardData.types),r=t.clipboardData.getData("text/markdown"),n=t.clipboardData.getData("text/plain");return r||n&&(bx(o)||Ex(n))?(e.pasteMarkdown.pasteMarkdown(r||n),Ue(t),!0):!1}}}));import{jsx as xx}from"react/jsx-runtime";function kx(e){let t={...e.attributes,style:{...e.attributes.style,width:void 0,maxWidth:void 0}};return xx("span",{...t,children:e.children})}var qd=y((e,t,{createPolicy:o})=>(e.placeholder={},o({name:"placeholder",editableProps:{renderPlaceholder:kx}})));var Qd=[Gd,Fm,Ml,Ym,Oc,lc,As,xm,Mm,Wp,rc,_d,Dc,Ll,Wc,Dm,Kp,Vd,Is,qd];var yx=na(Qd),{withSink:jd,SinkEditable:Xd}=yx;import{useState as vx}from"react";import{createEditor as Tx,Editor as wx,Transforms as Ix}from"slate";import{withHistory as Mx}from"slate-history";import{withReact as Cx}from"slate-react";function Rn({authToken:e,height:t,minHeight:o,maxHeight:r,disableRawMode:n,disableTaskList:i,disableCodeBlock:a,disableHighlight:l,enableInternalLinks:s,renderInternalLinkPreview:m,renderInternalEmbed:c,onInternalLinkClick:d}={}){let[p]=vx(()=>{let u=Tx(),h=jd(Cx(Mx(u)),{toolbar:{height:t,minHeight:o,maxHeight:r,showUploadButtons:!!e},image:{}});return h.convertElement.addConvertElementType("paragraph"),u.wysimark={disableRawMode:n??!0,disableTaskList:i,disableCodeBlock:a,disableHighlight:l??!0,enableInternalLinks:s??!1,renderInternalLinkPreview:m,renderInternalEmbed:c,onInternalLinkClick:d},u.getMarkdown=()=>fe(u.children,{enableInternalLinks:u.wysimark.enableInternalLinks}),u.setMarkdown=k=>{let L=Pe(k),M=Le(L,{enableInternalLinks:u.wysimark.enableInternalLinks});u.children=M,u.selection=null,Ix.select(u,wx.start(u,[0]))},h});return p.wysimark.renderInternalLinkPreview=m,p.wysimark.renderInternalEmbed=c,p.wysimark.onInternalLinkClick=d,p}import{jsx as le,jsxs as Jd}from"react/jsx-runtime";function $x({children:e,attributes:t}){return le("span",{...t,children:e})}function Zd({editor:e,value:t,onChange:o,throttleInMs:r=1e3,placeholder:n,className:i,style:a,onImageChange:l,onFileSelect:s}){let[m,c]=Yd(!1),[d,p]=Yd(t),u=eo(!1),h=eo(void 0),k=eo(void 0),L=eo(null),M=eo(o);M.current=o;let T=Zt(Px(()=>{let w=fe(e.children,{enableInternalLinks:e.wysimark.enableInternalLinks});e.wysimark.prevValue={markdown:w,children:e.children},M.current(w)},r,{leading:!1,trailing:!0}),[e,r]),D=Zt(()=>{k.current!==e.children&&(k.current=e.children,T())},[T]);if(!m){let w=L.current??t;if(L.current!==null&&(L.current=null),e.wysimark.prevValue==null||h.current==null){u.current=!0;let U=Pe(w),v=Le(U,{enableInternalLinks:e.wysimark.enableInternalLinks});e.children=v,k.current=h.current=v,e.wysimark.prevValue={markdown:w,children:v}}else if(w!==e.wysimark.prevValue.markdown){u.current=!0;let U=Pe(w),v=Le(U,{enableInternalLinks:e.wysimark.enableInternalLinks});e.children=v,e.selection=null,Lx.select(e,Sx.start(e,[0]))}}let P=Zt(()=>{navigator.userAgent.toLowerCase().includes("firefox")&&Rx.focus(e)},[e]),H=Zt(()=>{T.flush()},[T]),C=w=>{let U=w.target.value;p(U),o(U)},B=Zt(()=>{let w=e.getMarkdown();p(w)},[e]),S=()=>{m?(L.current=d,e.wysimark.prevValue=void 0,h.current=void 0,k.current=void 0):B(),c(!m)};e.wysimark.onImageChange=l,e.wysimark.onFileSelect=s;let R=e.wysimark.disableRawMode;return Jd("div",{style:{position:"relative",display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[!R&&le("div",{style:{position:"absolute",top:"5px",right:"25px",zIndex:10},children:le("div",{onClick:S,style:{background:"none",border:m?"1px solid #4a90e2":"1px solid transparent",cursor:"pointer",padding:"6px",borderRadius:"4px",backgroundColor:m?"rgba(74, 144, 226, 0.1)":"transparent",boxShadow:m?"0 1px 3px rgba(0, 0, 0, 0.1)":"none",transition:"all 0.2s ease-in-out",display:"flex",alignItems:"center",justifyContent:"center"},title:m?f("switchToVisualEditor"):f("switchToRawMarkdown"),role:"button",tabIndex:0,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(S(),w.preventDefault())},children:Jd("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[le("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",fill:m?"rgba(74, 144, 226, 0.05)":"transparent"}),le("path",{d:"M7 15V9L10 12L13 9V15",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),le("path",{d:"M16 9H18V15",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),le("path",{d:"M16 12H18",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),le("div",{style:{display:m?"block":"none",textAlign:"center"},children:le("textarea",{value:Dt(d),onChange:C,placeholder:n,className:i,style:{width:"calc(100% - 60px)",margin:"0 auto",minHeight:"200px",padding:"20px",fontFamily:"monospace",fontSize:"1rem",color:"#333",lineHeight:"1.5",backgroundColor:"#fff",border:"1px solid #ddd",borderRadius:"4px",...a}})}),le("div",{style:{display:m?"none":"flex",flexDirection:"column",flex:1,minHeight:0},children:le(Bx,{editor:e,initialValue:h.current,onChange:D,children:le(Xd,{renderLeaf:$x,onMouseDown:P,onBlur:H,placeholder:n,className:i,style:a})})})]})}import{jsx as eu}from"react/jsx-runtime";function Ux({standaloneOptions:{onChange:e,placeholder:t,className:o,...r},standaloneMethodsRef:n}){let[i,a]=Ax(r.initialMarkdown||""),l=Hx(i),s=Rn(r);l.current=i,Nx(n,()=>({getMarkdown(){return l.current},setMarkdown(c){l.current=c,a(c)}}),[l,a]);let m=zx(c=>{l.current=c,a(c),e?.(c)},[s]);return eu(Zd,{editor:s,value:i,className:o||"",onChange:m,placeholder:t})}function n6(e,t){let o=Dx(),r=Ox(e);return r.render(eu(Ux,{standaloneMethodsRef:o,standaloneOptions:t})),{unmount(){try{r.unmount()}catch{}},getMarkdown(){return o.current?.getMarkdown()||""},setMarkdown(n){o.current?.setMarkdown(n)}}}export{Zd as Editable,n6 as createWysimark,lo as unescapeMarkdown,Rn as useEditor};
1728
+ `;import{Fragment as Hk,jsx as G,jsxs as Ct}from"react/jsx-runtime";var Nk=Sk("enter");function Cd({dest:e,close:t}){let o=zk(),r=Rk(null),[n,i]=Ye({x:0,y:0}),a=Jt((v,$)=>{i(de=>({x:de.x+v,y:de.y+$}))},[]),l=oe({src:r,dest:e},({src:v,dest:$},de)=>!v||!$?{left:0,top:0}:Be(v,de,{left:$.left-12,top:$.top+$.height},{margin:16})),s={...l,left:l.left+n.x,top:l.top+n.y},m=Lk(()=>{let{selection:v}=o;return v&&!$k.isCollapsed(v)?Bk.string(o,v):""},[]),[c,d]=Ye(""),[p,u]=Ye(""),[h,k]=Ye(m),[L,M]=Ye(m),[T,D]=Ye("external"),[P,H]=Ye(!1),C=()=>{if(T==="internal"){let v=p.trim();if(v==="")return;let $=h.trim(),de=$&&$!==me(v)?`${v}|${$}`:v;o.anchor.insertLink(Ce(de),$||me(v),{select:!0})}else{let v=h.trim()||c,$=L.trim()||void 0;o.anchor.insertLink(c,v,{select:!0,title:$})}Dk.focus(o),t()},B=Jt(v=>{d(v.currentTarget.value)},[d]),S=Jt(v=>{let $=ao(v.currentTarget.value);u($.target),$.display!==void 0&&k($.display)},[u,k]),R=Jt(v=>{let $=v.currentTarget.value;k($),P||M($)},[k,M,P]),w=Jt(v=>{M(v.currentTarget.value),H(!0)},[M]),U=v=>{Nk(v)&&(v.preventDefault(),v.stopPropagation(),C())};return Ct(Hk,{children:[G(Re,{close:t}),Ct(Qa,{ref:r,style:s,children:[G(De,{onDrag:a}),Ct("div",{style:{padding:"0.75em"},children:[o.wysimark.enableInternalLinks?G(Vt,{children:Ct("div",{style:{display:"flex",gap:"0.25em",padding:"0.25em",borderRadius:"0.375em",background:"var(--shade-100)",width:"100%"},children:[G("button",{type:"button",onClick:()=>D("external"),style:{flex:"1 1 0",border:0,borderRadius:"0.25em",padding:"0.375em 0.5em",cursor:"pointer",background:T==="external"?"white":"transparent",color:T==="external"?"var(--shade-700)":"var(--shade-500)",boxShadow:T==="external"?"0 1px 2px rgb(0 0 0 / 12%)":"none"},children:f("linkTypeExternal")}),G("button",{type:"button",onClick:()=>D("internal"),style:{flex:"1 1 0",border:0,borderRadius:"0.25em",padding:"0.375em 0.5em",cursor:"pointer",background:T==="internal"?"white":"transparent",color:T==="internal"?"var(--shade-700)":"var(--shade-500)",boxShadow:T==="internal"?"0 1px 2px rgb(0 0 0 / 12%)":"none"},children:f("linkTypeInternal")})]})}):null,G(Vt,{style:{marginTop:o.wysimark.enableInternalLinks?"0.5em":0},children:T==="internal"?G(_t,{type:"text",value:p,autoFocus:!0,placeholder:f("internalLinkTarget"),onChange:S,onKeyDown:U}):G(_t,{type:"text",value:c,autoFocus:!0,placeholder:f("linkUrl"),onChange:B,onKeyDown:U})}),G(Vt,{style:{marginTop:"0.5em"},children:G(_t,{type:"text",value:h,placeholder:f("linkText"),onChange:R,onKeyDown:U})}),Ct(Vt,{style:{marginTop:"0.5em"},children:[T==="external"?G(_t,{type:"text",value:L,placeholder:f("tooltipText"),onChange:w,onKeyDown:U}):G("span",{style:{flex:"1 1 auto"}}),Ct(vn,{onClick:C,children:[G(tr,{}),G(ed,{})]}),G(vn,{onClick:t,style:{marginLeft:"0.25em",background:"var(--shade-400)"},children:G(Ed,{})})]}),T==="external"?G(Tn,{children:f("tooltipHint")}):G(Tn,{children:f("internalLinkTargetHint")})]})]})]})}var wn=[{icon:tr,title:f("insertLink"),more:!0,hotkey:"mod+k",Component:Cd},{icon:pd,title:f("insertImageFromUrl"),more:!0,Component:Id},{icon:sd,title:f("insertTable"),more:!0,Component:Yp},{icon:xd,title:f("horizontalRule"),hotkey:"super+-",action:e=>e.horizontalRule.insertHorizontalRule()}],Pd=wn,Sd=wn,Ld=[{icon:dd,title:f("insert"),more:!0,children:wn}];import{Editor as Ak}from"slate";function Pt(e){let t=Ak.marks(e);return{bold:t?.bold||!1,italic:t?.italic||!1,strike:t?.strike||!1,code:t?.code||!1,underline:t?.underline||!1,highlight:t?.highlight||!1}}var Rd=[{icon:gn,title:f("bold"),hotkey:"mod+b",action:e=>e.marksPlugin.toggleBold(),active:e=>Pt(e).bold},{icon:id,title:f("italic"),hotkey:"mod+i",action:e=>e.marksPlugin.toggleItalic(),active:e=>Pt(e).italic},{icon:ud,title:f("strike"),hotkey:"super+k",action:e=>e.marksPlugin.toggleStrike(),active:e=>Pt(e).strike},{icon:md,title:f("inlineCode"),hotkey:"mod+j",action:e=>e.inlineCode.toggleInlineCode(),active:e=>Pt(e).code},{icon:fd,title:f("underline"),hotkey:"mod+u",action:e=>e.marksPlugin.toggleUnderline(),active:e=>Pt(e).underline},{icon:kd,title:f("highlight"),hotkey:"mod+h",action:e=>e.marksPlugin.toggleHighlight(),active:e=>Pt(e).highlight,show:e=>!e.wysimark.disableHighlight}],In=Rd,Bd=[{icon:gn,title:f("format"),more:!0,children:Rd}];var Ok=["unordered-list-item","ordered-list-item","task-list-item"],$d=[{icon:ld,title:f("bulletList"),hotkey:"super+8",action:e=>e.list.convertUnorderedList(!0),active:e=>!!b(e,"unordered-list-item")},{icon:En,title:f("numberedList"),hotkey:"super+7",action:e=>e.list.convertOrderedList(!0),active:e=>!!b(e,"ordered-list-item")},{icon:hd,title:f("checkList"),hotkey:"super+9",action:e=>e.list.convertTaskList(!0),active:e=>!!b(e,"task-list-item"),show:e=>!e.wysimark.disableTaskList}],Mn=[...$d,"divider",...kn],Dd=[{icon:En,title:f("list"),more:!0,active:e=>!!b(e,Ok),children:[...$d,"divider",...kn]}];import{Editor as zd,Path as Uk,Transforms as or}from"slate";var Nd=[{icon:bn,title:f("quote"),hotkey:"super+.",action:e=>{e.blockQuotePlugin.isActive()?e.blockQuotePlugin.outdent():e.blockQuotePlugin.indent()},active:e=>e.blockQuotePlugin.isActive()},{icon:ad,title:f("increaseQuoteDepth"),action:e=>e.blockQuotePlugin.increaseDepth(),active:e=>e.blockQuotePlugin.canIncreaseDepth()},{icon:cd,title:f("codeBlock"),action:e=>{let{selection:t}=e,o=b(e,"code-block");if(o){let[,r]=o,n=zd.string(e,r);or.removeNodes(e,{at:r}),or.insertNodes(e,{type:"paragraph",children:[{text:n}]},{at:r});return}if(t&&!Uk.equals(t.anchor.path,t.focus.path)){e.codeBlock.createCodeBlock({language:"text"});return}if(t&&t.anchor.offset!==t.focus.offset){let r=zd.string(e,t);or.delete(e),or.insertNodes(e,{type:"code-block",language:"text",children:[{type:"code-block-line",children:[{text:r}]}]});return}e.codeBlock.createCodeBlock({language:"text"})},active:e=>!!b(e,"code-block"),show:e=>!e.wysimark.disableCodeBlock}],Cn=Nd,Hd=[{icon:bn,title:f("quote"),more:!0,children:Nd}];var Fk=[...vd,"divider",...Mn,"divider",...In,"divider",...Pd,"divider",...Cn],Wk=[...xn,"divider",...Mn,"divider",...In,"divider",...Sd,"divider",...Cn],Ad=[...xn,"divider",...Dd,"divider",...Bd,"divider",...Ld,"divider",...Hd],Od=Ad;var St=[Fk,Wk,Ad];import{clsx as Vk}from"clsx";import{useCallback as Pn,useRef as _k}from"react";import{ReactEditor as Kk,useSlate as Gk,useSlateStatic as qk}from"slate-react";import{jsx as rr,jsxs as Qk}from"react/jsx-runtime";function Ud({item:e}){let t=qk(),o=Gk(),r=e.active?e.active(o):!1,n=_k(null),i=ne({title:e.title,hotkey:()=>e.hotkey?wo(e.hotkey):void 0}),a=W("menu"),l=Pn(()=>{let c=n.current,d=e.children,p=e.Component;c&&(d?a.open(()=>rr(ct,{dest:c,items:d,close:a.close})):p&&a.open(()=>rr(p,{dest:c,close:a.close})))},[e]),s=Pn(()=>{if(e.action){e.action(t),Kk.focus(t);return}a.layer?a.close():l()},[a.layer,e]),m=Pn(c=>{i.onMouseEnter(c),a.layer&&l()},[a.layer,l,i.onMouseEnter]);return Qk(al,{"data-item-type":"button",ref:n,onMouseEnter:m,onMouseLeave:i.onMouseLeave,onClick:s,className:Vk({"--active":r&&!Er(e?.title)?.includes("Depth"),"--more":e.more,"--disabled":!r&&Er(e?.title)?.includes("Depth")}),children:[rr(e.icon,{}),e.more?rr(Zp,{}):null]})}import{jsx as Lt}from"react/jsx-runtime";function Zk({item:e}){let t=Jk();return e==="divider"?Lt(nl,{"data-item-type":"divider",children:Lt(il,{})}):(e.show===void 0?!0:e.show(t))?Lt(Ud,{item:e}):null}function ex(e){let t=e.querySelector("[data-item-type=button]"),o=e.querySelector("[data-item-type=divider]");return!t||!o?null:{toolbar:e.offsetWidth,button:t.offsetWidth,divider:o.offsetWidth}}function tx(e,t,o){let r=0;for(let n of e)r+=n==="divider"?o:t;return r}var ox=4;function Fd(){let e=Xk(null),[t,o]=Yk(Od);return jk(()=>{let r=e.current;if(!r)return;let n=()=>{let a=ex(r);if(a){for(let l=0;l<St.length-1;l++)if(tx(St[l],a.button,a.divider)<a.toolbar-ox){o(St[l]);return}o(St[St.length-1])}},i=new ResizeObserver(n);return i.observe(r),()=>{i.disconnect()}},[]),Lt(ol,{ref:e,children:Lt(rl,{children:t.map((r,n)=>Lt(Zk,{item:r},typeof r=="string"?n:r.title))})})}import{jsx as Sn,jsxs as px}from"react/jsx-runtime";function Wd({attributes:e,Editable:t}){let o=ix(null),r=cx(),n=mx(),i=nx(a=>{a.target===a.currentTarget&&(lx.select(r,ax.end(r,[])),sx.focus(r))},[r]);return Sn(Fa,{children:px(Ja,{ref:o,className:rx({"--focused":n}),style:{height:r.toolbar.height,minHeight:r.toolbar.minHeight,maxHeight:r.toolbar.maxHeight},onClick:i,children:[Sn(Fd,{}),Sn(t,{as:Ya,...e,style:{overflowY:"auto"}})]})})}var Vd=y((e,t)=>(e.toolbar={height:t.toolbar?.height,minHeight:t.toolbar?.minHeight,maxHeight:t.toolbar?.maxHeight,showUploadButtons:t.toolbar?.showUploadButtons??!0},{name:"toolbar",editor:{},renderEditable:Wd,editableProps:{}}));import{Editor as Ln,Node as dx,Path as ux,Transforms as fx}from"slate";var _d=y(e=>(e.allowTrailingBlock=!0,{name:"trailing-block",editor:{normalizeNode:t=>{if(!Ln.isEditor(t[0]))return!1;let o=[e.children.length-1],r=dx.child(e,e.children.length-1);return(Ln.hasBlocks(e,r)||Ln.isVoid(e,r))&&fx.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:ux.next(o)}),!0}}}));import{Transforms as hx}from"slate";function gx(e,t){let o=Pe(t),r=Le(o,{enableInternalLinks:e.wysimark.enableInternalLinks});hx.insertNodes(e,r)}function Kd(e){return{pasteMarkdown:g(gx,e)}}function bx(e){return e.length===1&&e[0]==="text/plain"}function Ex(e){return/^>\s*\[![A-Za-z0-9_-]+\][+-]?(?:\s|$)/m.test(e)}var Gd=y(e=>(e.pasteMarkdown=Kd(e),{name:"paste-markdown",editor:{},editableProps:{onPaste(t){let o=Array.from(t.clipboardData.types),r=t.clipboardData.getData("text/markdown"),n=t.clipboardData.getData("text/plain");return r||n&&(bx(o)||Ex(n))?(e.pasteMarkdown.pasteMarkdown(r||n),Ue(t),!0):!1}}}));import{jsx as xx}from"react/jsx-runtime";function kx(e){let t={...e.attributes,style:{...e.attributes.style,width:void 0,maxWidth:void 0}};return xx("span",{...t,children:e.children})}var qd=y((e,t,{createPolicy:o})=>(e.placeholder={},o({name:"placeholder",editableProps:{renderPlaceholder:kx}})));var Qd=[Gd,Fm,Ml,Ym,Oc,lc,As,xm,Mm,Wp,rc,_d,Dc,Ll,Wc,Dm,Kp,Vd,Is,qd];var yx=na(Qd),{withSink:jd,SinkEditable:Xd}=yx;import{useState as vx}from"react";import{createEditor as Tx,Editor as wx,Transforms as Ix}from"slate";import{withHistory as Mx}from"slate-history";import{withReact as Cx}from"slate-react";function Rn({authToken:e,height:t,minHeight:o,maxHeight:r,disableRawMode:n,disableTaskList:i,disableCodeBlock:a,disableHighlight:l,enableInternalLinks:s,renderInternalLinkPreview:m,renderInternalEmbed:c,onInternalLinkClick:d}={}){let[p]=vx(()=>{let u=Tx(),h=jd(Cx(Mx(u)),{toolbar:{height:t,minHeight:o,maxHeight:r,showUploadButtons:!!e},image:{}});return h.convertElement.addConvertElementType("paragraph"),u.wysimark={disableRawMode:n??!0,disableTaskList:i,disableCodeBlock:a,disableHighlight:l??!0,enableInternalLinks:s??!1,renderInternalLinkPreview:m,renderInternalEmbed:c,onInternalLinkClick:d},u.getMarkdown=()=>fe(u.children,{enableInternalLinks:u.wysimark.enableInternalLinks}),u.setMarkdown=k=>{let L=Pe(k),M=Le(L,{enableInternalLinks:u.wysimark.enableInternalLinks});u.children=M,u.selection=null,Ix.select(u,wx.start(u,[0]))},h});return p.wysimark.renderInternalLinkPreview=m,p.wysimark.renderInternalEmbed=c,p.wysimark.onInternalLinkClick=d,p}import{jsx as le,jsxs as Jd}from"react/jsx-runtime";function $x({children:e,attributes:t}){return le("span",{...t,children:e})}function Zd({editor:e,value:t,onChange:o,throttleInMs:r=1e3,placeholder:n,className:i,style:a,onImageChange:l,onFileSelect:s}){let[m,c]=Yd(!1),[d,p]=Yd(t),u=eo(!1),h=eo(void 0),k=eo(void 0),L=eo(null),M=eo(o);M.current=o;let T=Zt(Px(()=>{let w=fe(e.children,{enableInternalLinks:e.wysimark.enableInternalLinks});e.wysimark.prevValue={markdown:w,children:e.children},M.current(w)},r,{leading:!1,trailing:!0}),[e,r]),D=Zt(()=>{k.current!==e.children&&(k.current=e.children,T())},[T]);if(!m){let w=L.current??t;if(L.current!==null&&(L.current=null),e.wysimark.prevValue==null||h.current==null){u.current=!0;let U=Pe(w),v=Le(U,{enableInternalLinks:e.wysimark.enableInternalLinks});e.children=v,k.current=h.current=v,e.wysimark.prevValue={markdown:w,children:v}}else if(w!==e.wysimark.prevValue.markdown){u.current=!0;let U=Pe(w),v=Le(U,{enableInternalLinks:e.wysimark.enableInternalLinks});e.children=v,e.selection=null,Lx.select(e,Sx.start(e,[0]))}}let P=Zt(()=>{navigator.userAgent.toLowerCase().includes("firefox")&&Rx.focus(e)},[e]),H=Zt(()=>{T.flush()},[T]),C=w=>{let U=w.target.value;p(U),o(U)},B=Zt(()=>{let w=e.getMarkdown();p(w)},[e]),S=()=>{m?(L.current=d,e.wysimark.prevValue=void 0,h.current=void 0,k.current=void 0):B(),c(!m)};e.wysimark.onImageChange=l,e.wysimark.onFileSelect=s;let R=e.wysimark.disableRawMode;return Jd("div",{style:{position:"relative",display:"flex",flexDirection:"column",flex:1,minHeight:0},children:[!R&&le("div",{style:{position:"absolute",top:"5px",right:"25px",zIndex:10},children:le("div",{onClick:S,style:{background:"none",border:m?"1px solid #4a90e2":"1px solid transparent",cursor:"pointer",padding:"6px",borderRadius:"4px",backgroundColor:m?"rgba(74, 144, 226, 0.1)":"transparent",boxShadow:m?"0 1px 3px rgba(0, 0, 0, 0.1)":"none",transition:"all 0.2s ease-in-out",display:"flex",alignItems:"center",justifyContent:"center"},title:m?f("switchToVisualEditor"):f("switchToRawMarkdown"),role:"button",tabIndex:0,onKeyDown:w=>{(w.key==="Enter"||w.key===" ")&&(S(),w.preventDefault())},children:Jd("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:[le("rect",{x:"3",y:"3",width:"18",height:"18",rx:"2",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",fill:m?"rgba(74, 144, 226, 0.05)":"transparent"}),le("path",{d:"M7 15V9L10 12L13 9V15",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),le("path",{d:"M16 9H18V15",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),le("path",{d:"M16 12H18",stroke:m?"#4a90e2":"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]})})}),le("div",{style:{display:m?"block":"none",textAlign:"center"},children:le("textarea",{value:Dt(d),onChange:C,placeholder:n,className:i,style:{width:"calc(100% - 60px)",margin:"0 auto",minHeight:"200px",padding:"20px",fontFamily:"monospace",fontSize:"1rem",color:"#333",lineHeight:"1.5",backgroundColor:"#fff",border:"1px solid #ddd",borderRadius:"4px",...a}})}),le("div",{style:{display:m?"none":"flex",flexDirection:"column",flex:1,minHeight:0},children:le(Bx,{editor:e,initialValue:h.current,onChange:D,children:le(Xd,{renderLeaf:$x,onMouseDown:P,onBlur:H,placeholder:n,className:i,style:a})})})]})}import{jsx as eu}from"react/jsx-runtime";function Ux({standaloneOptions:{onChange:e,placeholder:t,className:o,onImageChange:r,onFileSelect:n,...i},standaloneMethodsRef:a}){let[l,s]=Ax(i.initialMarkdown||""),m=Hx(l),c=Rn(i);m.current=l,Nx(a,()=>({getMarkdown(){return m.current},setMarkdown(p){m.current=p,s(p)}}),[m,s]);let d=zx(p=>{m.current=p,s(p),e?.(p)},[c]);return eu(Zd,{editor:c,value:l,className:o||"",onChange:d,placeholder:t,onImageChange:r,onFileSelect:n})}function i6(e,t){let o=Dx(),r=Ox(e);return r.render(eu(Ux,{standaloneMethodsRef:o,standaloneOptions:t})),{unmount(){try{r.unmount()}catch{}},getMarkdown(){return o.current?.getMarkdown()||""},setMarkdown(n){o.current?.setMarkdown(n)}}}export{Zd as Editable,i6 as createWysimark,lo as unescapeMarkdown,Rn as useEditor};
package/dist/index.mjs CHANGED
@@ -11153,7 +11153,14 @@ function Editable2({
11153
11153
  // src/index.tsx
11154
11154
  import { jsx as jsx71 } from "react/jsx-runtime";
11155
11155
  function StandaloneEditor({
11156
- standaloneOptions: { onChange, placeholder, className, ...options },
11156
+ standaloneOptions: {
11157
+ onChange,
11158
+ placeholder,
11159
+ className,
11160
+ onImageChange,
11161
+ onFileSelect,
11162
+ ...options
11163
+ },
11157
11164
  standaloneMethodsRef
11158
11165
  }) {
11159
11166
  const [markdown, setMarkdown] = useState15(options.initialMarkdown || "");
@@ -11190,7 +11197,9 @@ function StandaloneEditor({
11190
11197
  value: markdown,
11191
11198
  className: className || "",
11192
11199
  onChange: onChangeEditable,
11193
- placeholder
11200
+ placeholder,
11201
+ onImageChange,
11202
+ onFileSelect
11194
11203
  }
11195
11204
  );
11196
11205
  }