wysimark-lite 0.27.7 → 0.27.9
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 +149 -147
- package/dist/index.js +4 -4
- package/dist/index.mjs +39 -20
- package/dist/index.mjs.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as
|
|
2
|
-
import
|
|
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:
|
|
232
|
+
Editable: react__default.ComponentType<EditableProps$1>;
|
|
233
233
|
};
|
|
234
|
-
type RenderEditable = (props: RenderEditableProps) =>
|
|
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) =>
|
|
260
|
-
renderLeaf?: (props: RenderLeafProps) =>
|
|
261
|
-
renderPlaceholder?: (props: RenderPlaceholderProps) =>
|
|
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
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
}
|
|
771
|
-
|
|
772
|
-
|
|
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
|
|
792
|
-
|
|
793
|
-
|
|
779
|
+
type AnchorMethods = ReturnType<typeof createAnchorMethods>;
|
|
780
|
+
type AnchorEditor = {
|
|
781
|
+
anchor: AnchorMethods;
|
|
794
782
|
};
|
|
795
|
-
type
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
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
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
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
|
-
*
|
|
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
|
-
|
|
810
|
-
children:
|
|
812
|
+
level: 1 | 2 | 3 | 4 | 5 | 6;
|
|
813
|
+
children: Descendant[];
|
|
811
814
|
};
|
|
812
|
-
type
|
|
813
|
-
Name: "
|
|
814
|
-
Editor:
|
|
815
|
-
Element:
|
|
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
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
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
|
|
872
|
-
|
|
873
|
-
|
|
895
|
+
type HtmlBlockPluginCustomTypes = {
|
|
896
|
+
Name: "html-block";
|
|
897
|
+
Editor: Record<string, never>;
|
|
898
|
+
Element: HtmlBlockElement;
|
|
874
899
|
};
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
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: (
|
|
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):
|
|
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
|
@@ -1193,7 +1193,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1193
1193
|
opacity: 0;
|
|
1194
1194
|
pointer-events: none;
|
|
1195
1195
|
`;import{useCallback as am}from"react";import{Transforms as Jg}from"slate";import{ReactEditor as lm,useSlateStatic as Zg}from"slate-react";import{jsx as mm,jsxs as eb}from"react/jsx-runtime";async function sm(e){if(navigator.clipboard?.writeText){await navigator.clipboard.writeText(e);return}throw new Error("Clipboard API is unavailable")}function Fo({element:e}){let t=Zg(),o=am(async n=>{n.preventDefault(),n.stopPropagation();try{await sm(fe([e]).trimEnd())}catch{}},[e]),r=am(async n=>{n.preventDefault(),n.stopPropagation();try{await sm(fe([e]).trimEnd())}catch{return}let i=lm.findPath(t,e);Jg.removeNodes(t,{at:i}),lm.focus(t)},[t,e]);return eb(Zs,{contentEditable:!1,children:[mm(qr,{"aria-label":"Copy code block",title:"Copy",type:"button",onMouseDown:n=>{n.preventDefault(),n.stopPropagation()},onClick:o,children:"\u29C9"}),mm(qr,{"aria-label":"Cut code block",title:"Cut",type:"button",onMouseDown:n=>{n.preventDefault(),n.stopPropagation()},onClick:r,children:"\u2702"})]})}import{useEffect as tb,useMemo as ob,useState as cm}from"react";import dm from"mermaid";import{Editor as rb,Node as nb,Transforms as ib}from"slate";import{ReactEditor as pm,useFocused as ab,useSelected as lb,useSlateStatic as sb}from"slate-react";import{jsx as bt,jsxs as cb}from"react/jsx-runtime";dm.initialize({startOnLoad:!1,securityLevel:"strict",theme:"default"});var mb=0;function um({element:e,attributes:t,children:o}){let r=sb(),n=lb(),i=ab(),a=ob(()=>e.children.map(p=>nb.string(p)).join(`
|
|
1196
|
-
`),[e.children]),[l,s]=cm(""),[m,c]=cm("");tb(()=>{let p=!1,u=`wysimark-mermaid-${++mb}`;c(""),s("");async function h(){try{let k=await dm.render(u,a);p||s(k.svg)}catch(k){p||c(k instanceof Error?k.message:"Invalid Mermaid diagram")}}return h(),()=>{p=!0}},[a]);function d(p){p.preventDefault(),p.stopPropagation();let u=pm.findPath(r,e);ib.select(r,rb.start(r,u)),pm.focus(r)}return cb(om,{...t,onMouseDown:d,children:[n&&i?bt(Fo,{element:e}):null,bt(rm,{contentEditable:!1,onMouseDown:d,children:m?bt(nm,{children:m}):l?bt("div",{dangerouslySetInnerHTML:{__html:l}}):bt("span",{children:"Rendering diagram..."})}),bt(im,{"aria-hidden":"true",children:o})]})}import{Fragment as hb,jsx as He,jsxs as Qr}from"react/jsx-runtime";function fm({element:e,attributes:t,children:o}){let r=db(null),n=fb(),i=ub(),a=Ca(e),l=i&&a,s=W("code-block-dropdown"),m=pb(()=>{s.layer&&s.close();let c=r.current;if(c===null)return;let d=Qs.map(p=>({icon:()=>He("span",{}),title:p,action:u=>{u.codeBlock.setCodeBlockLanguage(p,{at:e})}}));s.open(()=>He(ct,{dest:c,items:d,close:s.close}))},[s,e]);return e.language.toLowerCase()==="mermaid"&&!l?He(um,{element:e,attributes:t,children:o}):Qr(Kr,{className:n?"--selected":"",...t,children:[n&&i?He(Fo,{element:e}):null,l?He(Js,{children:o}):Qr(hb,{children:[Qr(em,{contentEditable:!1,onClick:m,ref:r,children:[He("span",{children:e.language}),He(Ys,{})]}),He(Gr,{children:o})]})]})}import{useSelected as gb}from"slate-react";import{jsx as bb}from"react/jsx-runtime";function hm({attributes:e,children:t}){let o=gb();return bb(tm,{className:o?"--selected":"",...e,spellCheck:"false",children:t})}import{jsx as gm}from"react/jsx-runtime";function bm({element:e,attributes:t,children:o}){if(e.type==="code-block")return gm(fm,{element:e,attributes:t,children:o});if(e.type==="code-block-line")return gm(hm,{element:e,attributes:t,children:o})}import{Fragment as xb,jsx as km}from"react/jsx-runtime";var xm=y((e,t,{createPolicy:o})=>{e.codeBlock=Ws(e);function r(){let{selection:
|
|
1196
|
+
`),[e.children]),[l,s]=cm(""),[m,c]=cm("");tb(()=>{let p=!1,u=`wysimark-mermaid-${++mb}`;c(""),s("");async function h(){try{let k=await dm.render(u,a);p||s(k.svg)}catch(k){p||c(k instanceof Error?k.message:"Invalid Mermaid diagram")}}return h(),()=>{p=!0}},[a]);function d(p){p.preventDefault(),p.stopPropagation();let u=pm.findPath(r,e);ib.select(r,rb.start(r,u)),pm.focus(r)}return cb(om,{...t,onMouseDown:d,children:[n&&i?bt(Fo,{element:e}):null,bt(rm,{contentEditable:!1,onMouseDown:d,children:m?bt(nm,{children:m}):l?bt("div",{dangerouslySetInnerHTML:{__html:l}}):bt("span",{children:"Rendering diagram..."})}),bt(im,{"aria-hidden":"true",children:o})]})}import{Fragment as hb,jsx as He,jsxs as Qr}from"react/jsx-runtime";function fm({element:e,attributes:t,children:o}){let r=db(null),n=fb(),i=ub(),a=Ca(e),l=i&&a,s=W("code-block-dropdown"),m=pb(()=>{s.layer&&s.close();let c=r.current;if(c===null)return;let d=Qs.map(p=>({icon:()=>He("span",{}),title:p,action:u=>{u.codeBlock.setCodeBlockLanguage(p,{at:e})}}));s.open(()=>He(ct,{dest:c,items:d,close:s.close}))},[s,e]);return e.language.toLowerCase()==="mermaid"&&!l?He(um,{element:e,attributes:t,children:o}):Qr(Kr,{className:n?"--selected":"",...t,children:[n&&i?He(Fo,{element:e}):null,l?He(Js,{children:o}):Qr(hb,{children:[Qr(em,{contentEditable:!1,onClick:m,ref:r,children:[He("span",{children:e.language}),He(Ys,{})]}),He(Gr,{children:o})]})]})}import{useSelected as gb}from"slate-react";import{jsx as bb}from"react/jsx-runtime";function hm({attributes:e,children:t}){let o=gb();return bb(tm,{className:o?"--selected":"",...e,spellCheck:"false",children:t})}import{jsx as gm}from"react/jsx-runtime";function bm({element:e,attributes:t,children:o}){if(e.type==="code-block")return gm(fm,{element:e,attributes:t,children:o});if(e.type==="code-block-line")return gm(hm,{element:e,attributes:t,children:o})}import{Fragment as xb,jsx as km}from"react/jsx-runtime";var xm=y((e,t,{createPolicy:o})=>{e.codeBlock=Ws(e);function r(){let{selection:i}=e;if(!ye(i))return!1;let a=b(e,"code-block");return a==null?!1:Eb.string(e,a[1])===""?(Em.removeNodes(e,{at:a[1]}),!0):!1}let n={...!e.wysimark.disableCodeBlock&&{"super+`":()=>e.codeBlock.createCodeBlock({language:"text"})},"mod+a":()=>{let i=b(e,a=>kb.isElement(a)&&a.type==="code-block");return i?(Em.select(e,i[1]),!0):!1}};return o({name:"code-block",editor:{deleteBackward:r,deleteForward:r,isInline(i){if(i.type==="code-block"||i.type==="code-block-line")return!1},isVoid(i){if(i.type==="code-block"||i.type==="code-block-line")return!1},isMaster(i){if(i.type==="code-block")return!0},normalizeNode:g(js,e)},editableProps:{decorate:Os,onKeyDown:_(n),renderElement:bm,renderLeaf:({leaf:i,children:a})=>{let l=i.prismToken&&qs[i.prismToken]||null;return l===null?km(xb,{children:a}):km("span",{style:l,children:a})}}})});import{Transforms as vb}from"slate";import ym from"@emotion/styled";var vm=ym("div")`
|
|
1197
1197
|
position: relative;
|
|
1198
1198
|
background-color: var(--shade-100);
|
|
1199
1199
|
border: 1px solid var(--shade-300);
|
|
@@ -1396,7 +1396,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1396
1396
|
stroke-width: 3px;
|
|
1397
1397
|
}
|
|
1398
1398
|
}
|
|
1399
|
-
`;import{jsx as mE}from"react/jsx-runtime";function Tc({element:e,attributes:t,children:o}){let r=sE();aE(()=>{let a=lE.findPath(r,e);Ko(r,[e,a])},[]);let n={marginLeft:`${2+e.depth*2}em`,"--list-item-var":`list-item-depth-${e.depth}`},i=iE({"--first-at-depth":e.__firstAtDepth});return mE(yc,{...t,className:i,style:n,children:o})}import{useCallback as cE}from"react";import{useSlateStatic as pE}from"slate-react";import{jsx as qe,jsxs as Cc}from"react/jsx-runtime";var wc=e=>Cc("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",strokeWidth:2,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...e,children:[qe("path",{d:"M0 0h24v24H0z",stroke:"none"}),qe("rect",{x:4,y:4,width:16,height:16,rx:2})]}),Ic=e=>Cc("svg",{xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-checkbox",width:"1em",height:"1em",strokeWidth:2,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...e,children:[qe("path",{d:"M0 0h24v24H0z",stroke:"none"}),qe("path",{d:"m9 11 3 3 8-8",className:"--checkmark"}),qe("path",{d:"M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9"})]}),Mc=e=>qe("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em",...e,children:qe("path",{d:"M12 8.25a3.75 3.75 0 1 0 0 7.5 3.75 3.75 0 0 0 0-7.5z"})});import{jsx as rn,jsxs as dE}from"react/jsx-runtime";function Pc({element:e,attributes:t,children:o}){let r=pE(),n=cE(()=>{r.list.toggleTaskListItem({at:e})},[r,e]),i=`${2+e.depth*2}em`;return dE(vc,{...t,style:{marginLeft:i},children:[rn("div",{className:"--list-item-icon",contentEditable:!1,children:e.checked?rn(Ic,{onClick:n,style:{cursor:"pointer"}}):rn(wc,{onClick:n,style:{cursor:"pointer"}})}),o]})}import{jsx as Sc,jsxs as uE}from"react/jsx-runtime";function Lc({element:e,attributes:t,children:o}){let r=`${2+e.depth*2}em`;return uE(xc,{...t,style:{marginLeft:r},children:[Sc("div",{className:"--list-item-icon",contentEditable:!1,children:Sc(Mc,{})}),o]})}import{jsx as nn}from"react/jsx-runtime";function Rc({element:e,attributes:t,children:o}){switch(e.type){case"ordered-list-item":return nn(Tc,{element:e,attributes:t,children:o});case"unordered-list-item":return nn(Lc,{element:e,attributes:t,children:o});case"task-list-item":return nn(Pc,{element:e,attributes:t,children:o})}}var $c=["unordered-list-item","ordered-list-item","task-list-item"],V=bo($c);function gE(e,t){if(t!==" "||!e.selection||!hE.isCollapsed(e.selection))return!1;let[o]=Array.from(jt.nodes(e,{match:s=>fE.isElement(s)&&s.type==="paragraph",mode:"lowest"}));if(!o)return!1;let[,r]=o,i={anchor:jt.start(e,r),focus:e.selection.anchor},a=jt.string(e,i),l=/^-\s+\[([ xX])\]$/.exec(a);return l?(jt.withoutNormalizing(e,()=>{Bc.delete(e,{at:i}),e.convertElement.convertElements(s=>s.type==="task-list-item",s=>({type:"task-list-item",checked:l[1].toLowerCase()==="x",depth:"depth"in s&&typeof s.depth=="number"?s.depth:0}),!1)}),!0):!1}var Dc=y((e,t,{createPolicy:o})=>{e.convertElement.addConvertElementType($c);let r=e.list=bc(e),n=
|
|
1399
|
+
`;import{jsx as mE}from"react/jsx-runtime";function Tc({element:e,attributes:t,children:o}){let r=sE();aE(()=>{let a=lE.findPath(r,e);Ko(r,[e,a])},[]);let n={marginLeft:`${2+e.depth*2}em`,"--list-item-var":`list-item-depth-${e.depth}`},i=iE({"--first-at-depth":e.__firstAtDepth});return mE(yc,{...t,className:i,style:n,children:o})}import{useCallback as cE}from"react";import{useSlateStatic as pE}from"slate-react";import{jsx as qe,jsxs as Cc}from"react/jsx-runtime";var wc=e=>Cc("svg",{xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",strokeWidth:2,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...e,children:[qe("path",{d:"M0 0h24v24H0z",stroke:"none"}),qe("rect",{x:4,y:4,width:16,height:16,rx:2})]}),Ic=e=>Cc("svg",{xmlns:"http://www.w3.org/2000/svg",className:"icon icon-tabler icon-tabler-checkbox",width:"1em",height:"1em",strokeWidth:2,stroke:"currentColor",fill:"none",strokeLinecap:"round",strokeLinejoin:"round",viewBox:"0 0 24 24",...e,children:[qe("path",{d:"M0 0h24v24H0z",stroke:"none"}),qe("path",{d:"m9 11 3 3 8-8",className:"--checkmark"}),qe("path",{d:"M20 12v6a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h9"})]}),Mc=e=>qe("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 24 24",fill:"currentColor",width:"1em",height:"1em",...e,children:qe("path",{d:"M12 8.25a3.75 3.75 0 1 0 0 7.5 3.75 3.75 0 0 0 0-7.5z"})});import{jsx as rn,jsxs as dE}from"react/jsx-runtime";function Pc({element:e,attributes:t,children:o}){let r=pE(),n=cE(()=>{r.list.toggleTaskListItem({at:e})},[r,e]),i=`${2+e.depth*2}em`;return dE(vc,{...t,style:{marginLeft:i},children:[rn("div",{className:"--list-item-icon",contentEditable:!1,children:e.checked?rn(Ic,{onClick:n,style:{cursor:"pointer"}}):rn(wc,{onClick:n,style:{cursor:"pointer"}})}),o]})}import{jsx as Sc,jsxs as uE}from"react/jsx-runtime";function Lc({element:e,attributes:t,children:o}){let r=`${2+e.depth*2}em`;return uE(xc,{...t,style:{marginLeft:r},children:[Sc("div",{className:"--list-item-icon",contentEditable:!1,children:Sc(Mc,{})}),o]})}import{jsx as nn}from"react/jsx-runtime";function Rc({element:e,attributes:t,children:o}){switch(e.type){case"ordered-list-item":return nn(Tc,{element:e,attributes:t,children:o});case"unordered-list-item":return nn(Lc,{element:e,attributes:t,children:o});case"task-list-item":return nn(Pc,{element:e,attributes:t,children:o})}}var $c=["unordered-list-item","ordered-list-item","task-list-item"],V=bo($c);function gE(e,t){if(e.wysimark.disableTaskList||t!==" "||!e.selection||!hE.isCollapsed(e.selection))return!1;let[o]=Array.from(jt.nodes(e,{match:s=>fE.isElement(s)&&s.type==="paragraph",mode:"lowest"}));if(!o)return!1;let[,r]=o,i={anchor:jt.start(e,r),focus:e.selection.anchor},a=jt.string(e,i),l=/^-\s+\[([ xX])\]$/.exec(a);return l?(jt.withoutNormalizing(e,()=>{Bc.delete(e,{at:i}),e.convertElement.convertElements(s=>s.type==="task-list-item",s=>({type:"task-list-item",checked:l[1].toLowerCase()==="x",depth:"depth"in s&&typeof s.depth=="number"?s.depth:0}),!1)}),!0):!1}var Dc=y((e,t,{createPolicy:o})=>{e.convertElement.addConvertElementType($c);let r=e.list=bc(e),n={tab:r.indent,"shift+tab":r.outdent,"super+7":g(r.convertOrderedList,!0),"super+8":g(r.convertUnorderedList,!0),...!e.wysimark.disableTaskList&&{"super+9":g(r.convertTaskList,!0)}},i=_(n);return o({name:"list",editor:{normalizeNode:a=>kc(e,a),insertText:a=>gE(e,a),insertBreak:r.insertBreak,deleteBackward:a=>{if(a!=="character"||!Fe(e,V))return!1;let l=b(e,V);if(!l)return!1;let[s,m]=l;return s.depth>0?(Bc.setNodes(e,{depth:s.depth-1},{at:m}),!0):(e.collapsibleParagraph.convertParagraph(),!0)}},editableProps:{renderElement:Rc,onKeyDown(a){return jt.nodes(e,{match:V})?i(a):!1}}})});import{clsx as vE}from"clsx";import{Editor as an,Range as TE}from"slate";import{Editor as bE,Text as zc,Transforms as EE}from"slate";function Nc(e,{at:t=e.selection}={}){if(t==null)return;let o=[...bE.nodes(e,{match:n=>zc.isText(n),at:t})],r={};for(let[n]of o)for(let i of Object.keys(n))i!=="text"&&(r[i]=null);EE.setNodes(e,r,{match:n=>zc.isText(n),split:!0,at:t})}import{Editor as Qe,Point as kE,Range as xE}from"slate";function je(e,t,o,{at:r=e.selection}={}){if(r==null)return;let n=xE.isRange(r)?r.focus:r,i=kE.isPoint(n)&&(Qe.after(e,n)===null||Qe.isEnd(e,n,Qe.end(e,[]))),a=t,s=(Qe.marks(e)||{})[a]===!0;if(i)if(!s)e.activeMarks={...e.activeMarks,[a]:!0};else{let{[a]:m,...c}=e.activeMarks||{};e.activeMarks=c}s?Qe.removeMark(e,a):Qe.addMark(e,a,!0),typeof o=="string"&&Qe.removeMark(e,o)}function Hc(e){return{removeMarks:g(Nc,e),toggleMark:g(je,e),toggleBold:()=>je(e,"bold"),toggleItalic:()=>je(e,"italic"),toggleUnderline:()=>je(e,"underline"),toggleStrike:()=>je(e,"strike"),toggleHighlight:()=>je(e,"highlight")}}import yE from"@emotion/styled";var Ac=yE("span")`
|
|
1400
1400
|
&.--bold {
|
|
1401
1401
|
font-weight: bold;
|
|
1402
1402
|
}
|
|
@@ -1419,7 +1419,7 @@ ${At(r.slice(1),o).trimStart()}`:At(r,o)).split(`
|
|
|
1419
1419
|
&.--highlight {
|
|
1420
1420
|
background-color: #ffff00;
|
|
1421
1421
|
}
|
|
1422
|
-
`;import{jsx as wE}from"react/jsx-runtime";var Oc=y(e=>{e.marksPlugin=Hc(e),e.activeMarks={};let t=
|
|
1422
|
+
`;import{jsx as wE}from"react/jsx-runtime";var Oc=y(e=>{e.marksPlugin=Hc(e),e.activeMarks={};let t={"mod+b":e.marksPlugin.toggleBold,"mod+i":e.marksPlugin.toggleItalic,"mod+u":e.marksPlugin.toggleUnderline,"super+0":e.marksPlugin.removeMarks,"super+k":e.marksPlugin.toggleStrike,...!e.wysimark.disableHighlight&&{"mod+h":e.marksPlugin.toggleHighlight}},o=_(t),{insertText:r}=e;e.insertText=i=>{if(e.activeMarks&&Object.keys(e.activeMarks).length>0){let{activeMarks:a}=e;Object.entries(a).forEach(([l,s])=>{s&&e.addMark(l,!0)})}r(i)};let{removeMarks:n}=e.marksPlugin;return e.marksPlugin.removeMarks=()=>{if(n(),e.selection&&TE.isRange(e.selection)){let i=e.selection.focus;(an.after(e,i)===null||an.isEnd(e,i,an.end(e,[])))&&(e.activeMarks={})}},{name:"marks",editableProps:{renderLeaf:({leaf:i,children:a})=>wE(Ac,{className:vE({"--bold":i.bold,"--italic":i.italic,"--underline":i.underline,"--strike":i.strike,"--highlight":i.highlight}),children:a}),onKeyDown:i=>!!o(i)}}});import{Editor as Xt,Point as Uc}from"slate";function Fc(e){if(!e.selection)return;let t=Xt.parent(e,e.selection);fa(e,t[1])}var Wc=y(e=>(e.normalizeAfterDelete=!0,{name:"normalize-after-delete",editor:{deleteBackward(){if(!e.selection)return!1;let t=Xt.parent(e,e.selection);return Uc.equals(Xt.start(e,t[1]),e.selection.anchor)?function(){Fc(e)}:!1},deleteForward(){if(!e.selection)return!1;let t=Xt.parent(e,e.selection);return Uc.equals(Xt.end(e,t[1]),e.selection.anchor)?function(){Fc(e)}:!1}},editableProps:{}}));import{Element as pk}from"slate";import{Editor as _c,Path as CE,Transforms as Kc}from"slate";import{Editor as IE,Path as ME}from"slate";function Vc(e,t,o){let r=[...IE.positions(e,{at:t})],n=[],i,a,l;i=a=r[0],l=at(e,o,{at:i});for(let m of r){let c=at(e,o,{at:m});if(l&&c&&ME.equals(l,c)||l==null&&c==null)a=m;else{let d={anchor:i,focus:a};n.push(d),i=a=m,l=c}}let s={anchor:i,focus:a};return n.push(s),n.reverse(),n}function Gc(e,t){if(e.selection==null)return!1;let[o,r]=_c.edges(e,e.selection),n=at(e,t,{at:o}),i=at(e,t,{at:r});if(!n&&!i||n&&i&&CE.equals(n,i))return!1;let a=Vc(e,e.selection,t);return _c.withoutNormalizing(e,()=>{for(let l of a)Kc.delete(e,{at:l});Kc.collapse(e,{edge:"start"})}),!0}import{Transforms as _E}from"slate";function O(e,{at:t=e.selection}={}){if(t==null)return;let o=b(e,"table-cell",{at:t});if(!o)return;let r=b(e,"table-row",{at:t});if(!r)return;let n=b(e,"table",{at:t});if(!n)return;let[i,a]=n,[l,s]=r,[m,c]=o;return{tableElement:i,tablePath:a,tableColumns:i.columns,rowElement:l,rowPath:s,rowIndex:s.slice(-1)[0],rowCount:i.children.length,cellElement:m,cellPath:c,cellIndex:c.slice(-1)[0],cellCount:l.children.length}}import{Editor as PE,Transforms as qc}from"slate";function vt(e,t=[{type:"table-content",children:[{text:""}]}]){return{type:"table-cell",children:t}}function Qc(e,{offset:t=0,at:o=e.selection}={}){let r=O(e,{at:o});if(r===void 0)return!1;let{tableElement:n,tablePath:i,cellIndex:a}=r,l=a+t;return PE.withoutNormalizing(e,()=>{let{columns:s}=n,m=[...s],c=Math.min(l,s.length-1);m.splice(l,0,s[c]),qc.setNodes(e,{columns:m},{at:i}),n.children.forEach((d,p)=>{qc.insertNodes(e,vt(l),{at:[...i,p,l]})})}),!0}import{Transforms as SE}from"slate";function LE(e){return{type:"table-row",children:[...Array(e).keys()].map(t=>vt(t))}}function ln(e,{at:t=e.selection,offset:o=0}={}){let r=O(e,{at:t});if(!r)return!1;let n=LE(r.tableElement.columns.length);return SE.insertNodes(e,n,{at:[...r.tablePath,r.rowIndex+o]}),!0}function jc(e,{at:t}={}){return ln(e,{at:t,offset:1})}import{Editor as sn,Element as RE,Path as BE,Transforms as Yt}from"slate";function Xc(e){return[...Array(e).keys()]}function $E(e){return Xc(e).map(()=>({align:"left"}))}function DE(e,t){return{type:"table",columns:$E(e),children:Xc(t).map(()=>zE(e))}}function zE(e){return{type:"table-row",children:[...Array(e).keys()].map(t=>vt(t))}}function Yc(e,t,o,{at:r=e.selection}={}){let n=DE(t,o);return NE(e,n,{at:r})}function NE(e,t,{at:o=e.selection}={}){if(o==null)return!1;let r=b(e,n=>RE.isElement(n)&&e.isMaster(n));if(r==null){let n=e.selection;sn.withoutNormalizing(e,()=>{Yt.insertNodes(e,t,{at:o}),n&&(Yt.select(e,n),Yt.move(e))})}else{let n=BE.next(r[1]);sn.withoutNormalizing(e,()=>{Yt.insertNodes(e,t,{at:n}),Yt.select(e,sn.start(e,n))})}return!0}import{Path as Jc}from"slate";function Zc(e,t){let{cellIndex:o,rowIndex:r,rowCount:n,tablePath:i}=t;if(r<n-1)return te(e,[...i,r+1,o]),!0;try{return te(e,Jc.next(i)),!0}catch{return!1}}function ep(e,t){let{cellIndex:o,rowIndex:r,tablePath:n}=t;if(r>0)return te(e,[...n,r-1,o]),!0;try{return Ea(e,Jc.previous(n)),!0}catch{return!1}}import{ReactEditor as HE}from"slate-react";function AE(){let e=window.getSelection();if(!e||e.rangeCount===0)return null;try{return e.getRangeAt(0).getBoundingClientRect()}catch{return null}}function OE(e,t){return HE.toDOMNode(e,t).getBoundingClientRect()}function mn(e,t){let o=AE();if(!o)return!1;let r=OE(e,t);return o.right<r.right&&o.left>r.left&&o.bottom<r.bottom&&o.top>r.top}function tp(e){let t=O(e);return t&&setTimeout(()=>{mn(e,t.cellElement)||Zc(e,t)}),!1}function op(e){let t=O(e);return t&&setTimeout(()=>{mn(e,t.cellElement)||ep(e,t)}),!1}import{Editor as rp,Transforms as cn}from"slate";import{Transforms as UE}from"slate";function Tt(e){let t=e.tablePlugin.getTableInfo();return t===void 0?!1:(UE.removeNodes(e,{at:t.tablePath}),!0)}function np(e,{at:t=e.selection}={}){let o=O(e,{at:t});if(!o)return!1;let{tableElement:r,tablePath:n,rowIndex:i,cellIndex:a,cellCount:l}=o;if(l===1)return Tt(e);rp.withoutNormalizing(e,()=>{let s=[...r.columns];s.splice(a,1),cn.setNodes(e,{columns:s},{at:n}),r.children.forEach((c,d)=>{cn.removeNodes(e,{at:[...n,d,a]})});let m=rp.start(e,[...n,i,Math.min(a,l-2)]);cn.select(e,m)})}import{Editor as ip,Transforms as ap}from"slate";function lp(e,{at:t=e.selection}={}){let o=O(e,{at:t});return o===void 0?!1:o.rowCount===1?(Tt(e),!0):(ip.withoutNormalizing(e,()=>{ap.removeNodes(e,{at:o.rowPath}),ap.select(e,ip.start(e,[...o.tablePath,Math.min(o.rowIndex,o.rowCount-2),o.cellIndex]))}),!0)}import{Transforms as FE}from"slate";function sp(e,t){let o=O(e);if(o===void 0)return!1;let{tableElement:r,tablePath:n,cellIndex:i}=o,a=r.columns.slice();return a.splice(i,1,{align:t.align}),FE.setNodes(e,{columns:a},{at:n}),!0}import{Path as WE,Transforms as VE}from"slate";function mp(e){let t=O(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,rowCount:i,tablePath:a}=t;if(o<r-1)return te(e,[...a,n,o+1]),!0;if(n<i-1)return te(e,[...a,n+1,0]),!0;let l=WE.next(a);return VE.insertNodes(e,{type:"paragraph",children:[{text:""}]},{at:l}),te(e,l),!0}function cp(e){let t=O(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,tablePath:i}=t;if(o>0)return te(e,[...i,n,o-1]),!0;if(n>0)return te(e,[...i,n-1,r-1]),!0}function pp(e){let t=O(e);if(!t)return!1;let{cellIndex:o,cellCount:r,rowIndex:n,rowCount:i,tablePath:a}=t;return o<r-1?(te(e,[...a,n,o+1]),!0):n<i-1?(te(e,[...a,n+1,0]),!0):(jc(e),te(e,[...a,n+1,0]),!0)}function dp(e){return{getTableInfo:g(O,e),insertTable:g(Yc,e),insertColumn:g(Qc,e),insertRow:g(ln,e),removeTable:g(Tt,e),removeColumn:g(np,e),removeRow:g(lp,e),tabForward:g(mp,e),tabBackward:g(cp,e),shiftEnterForward:g(pp,e),selectCell:g(KE,e),down:g(tp,e),up:g(op,e),setTableColumnAlign:g(sp,e)}}function KE(e,{at:t=e.selection}={}){let o=O(e,{at:t});if(o===void 0)return!1;let{cellPath:r}=o;return _E.select(e,r),!0}import{Transforms as GE}from"slate";function qo(e,t){let o=!1;return t[0].children.forEach((n,i)=>{n.children.forEach((l,s)=>{(l.x!==s||l.y!==i)&&(GE.setNodes(e,{x:s,y:i},{at:[...t[1],i,s]}),o=!0)})}),o}import{Editor as qE,Transforms as pn}from"slate";function up(e,t){let[o,r]=t;return o.children.length===1&&o.children[0].type==="table-content"?!1:(qE.withoutNormalizing(e,()=>{pn.insertNodes(e,{type:"table-content",children:[{text:"X"}]},{at:[...t[1],0]});for(let n=o.children.length;n>=0;n--)pn.mergeNodes(e,{at:[...r,n]});pn.delete(e,{at:{path:[...r,0,0],offset:0},unit:"character"})}),!0)}import{useEffect as jE}from"react";import{ReactEditor as XE,useSelected as YE,useSlateStatic as JE}from"slate-react";import jo from"@emotion/styled";import we from"@emotion/styled";var fp=we("div")`
|
|
1423
1423
|
position: absolute;
|
|
1424
1424
|
/**
|
|
1425
1425
|
* very slightly shaded
|
|
@@ -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};
|