wysimark-lite 0.26.1 → 0.27.1

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 from 'react';
2
- import react__default from 'react';
1
+ import * as React$1 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';
@@ -9,6 +9,7 @@ import { EditableProps as EditableProps$1, RenderElementProps, RenderLeafProps,
9
9
 
10
10
  type OnImageChangeHandler = (file: File) => Promise<string>;
11
11
  type OnFileSelectHandler = () => Promise<string | null>;
12
+ type RenderInternalLinkPreview = (target: string) => ReactNode;
12
13
  type ImageDialogState = {
13
14
  url: string;
14
15
  alt: string;
@@ -53,6 +54,14 @@ type WysimarkEditor = {
53
54
  * Whether highlight mark is disabled
54
55
  */
55
56
  disableHighlight?: boolean;
57
+ /**
58
+ * Whether Obsidian-style internal links are enabled
59
+ */
60
+ enableInternalLinks?: boolean;
61
+ /**
62
+ * Render preview content for an internal link target.
63
+ */
64
+ renderInternalLinkPreview?: RenderInternalLinkPreview;
56
65
  };
57
66
  /**
58
67
  * Public methods for the wysimark editor.
@@ -88,8 +97,15 @@ type UseEditorOptions = {
88
97
  * Defaults to true (highlight is disabled by default).
89
98
  */
90
99
  disableHighlight?: boolean;
100
+ /**
101
+ * Enable Obsidian-style internal links and embeds.
102
+ * When true, [[Page]] and ![[file.png]] are parsed and serialized as
103
+ * internal links. Defaults to false.
104
+ */
105
+ enableInternalLinks?: boolean;
106
+ renderInternalLinkPreview?: RenderInternalLinkPreview;
91
107
  };
92
- declare function useEditor({ authToken, height, minHeight, maxHeight, disableRawMode, disableTaskList, disableCodeBlock, disableHighlight, }?: UseEditorOptions): Editor & ReactEditor & WysimarkEditor;
108
+ declare function useEditor({ authToken, height, minHeight, maxHeight, disableRawMode, disableTaskList, disableCodeBlock, disableHighlight, enableInternalLinks, renderInternalLinkPreview, }?: UseEditorOptions): Editor & ReactEditor & WysimarkEditor;
93
109
 
94
110
  /**
95
111
  * SinkEditor just adds a `sink` object where we drop all of our sink
@@ -201,9 +217,9 @@ type VoidActionReturn = boolean | (() => void);
201
217
 
202
218
  type RenderEditableProps = {
203
219
  attributes: EditableProps$1;
204
- Editable: react__default.ComponentType<EditableProps$1>;
220
+ Editable: React__default.ComponentType<EditableProps$1>;
205
221
  };
206
- type RenderEditable = (props: RenderEditableProps) => react__default.ReactElement;
222
+ type RenderEditable = (props: RenderEditableProps) => React__default.ReactElement;
207
223
  /**
208
224
  * The return type of the BasePluginFn which specifies how the Plugin is
209
225
  * supposed to behave.
@@ -228,9 +244,9 @@ type BasePluginPolicy = {
228
244
  renderEditable?: RenderEditable;
229
245
  editableProps?: {
230
246
  decorate?: ((entry: NodeEntry) => BaseRange[]) | undefined;
231
- renderElement?: (props: RenderElementProps) => react__default.ReactElement | undefined;
232
- renderLeaf?: (props: RenderLeafProps) => react__default.ReactElement | undefined;
233
- renderPlaceholder?: (props: RenderPlaceholderProps) => react__default.ReactElement;
247
+ renderElement?: (props: RenderElementProps) => React__default.ReactElement | undefined;
248
+ renderLeaf?: (props: RenderLeafProps) => React__default.ReactElement | undefined;
249
+ renderPlaceholder?: (props: RenderPlaceholderProps) => React__default.ReactElement;
234
250
  onKeyDown?: EditableVoidToBooleanHandlerType<"onKeyDown">;
235
251
  onKeyUp?: EditableVoidToBooleanHandlerType<"onKeyDown">;
236
252
  onPaste?: EditableVoidToBooleanHandlerType<"onPaste">;
@@ -577,7 +593,7 @@ declare function createListMethods(editor: Editor): {
577
593
  convertTaskList: (allowToggle: boolean) => void;
578
594
  insertBreak: () => boolean;
579
595
  toggleTaskListItem: (args_0?: {
580
- at?: BetterAt | undefined;
596
+ at?: BetterAt;
581
597
  } | undefined) => boolean;
582
598
  getListDepth: () => number;
583
599
  canIncreaseDepth: () => boolean;
@@ -725,85 +741,66 @@ type TableInfo = {
725
741
  cellCount: number;
726
742
  };
727
743
 
728
- declare function createAnchorMethods(editor: Editor): {
729
- insertLink: (args_0: string, args_1?: string | undefined, args_2?: {
730
- select?: boolean | undefined;
731
- title?: string | undefined;
732
- } | undefined) => void;
733
- removeLink: (args_0: {
734
- at?: BetterAt | undefined;
735
- }) => boolean;
736
- editLink: (args_0: {
737
- href: string;
738
- title?: string | undefined;
739
- text?: string | undefined;
740
- }, args_1: {
741
- at?: BetterAt | undefined;
744
+ declare function createTableMethods(editor: Editor): {
745
+ getTableInfo: (args_0?: {
746
+ at?: slate.Location | slate.Element | null;
747
+ } | undefined) => TableInfo | undefined;
748
+ insertTable: (columnCount: number, rowCount: number, args_2?: {
749
+ at?: slate.Location | null;
750
+ } | undefined) => boolean;
751
+ insertColumn: (args_0?: {
752
+ offset?: 0 | 1;
753
+ at?: BetterAt;
754
+ } | undefined) => boolean;
755
+ insertRow: (args_0?: {
756
+ at?: BetterAt;
757
+ offset?: 0 | 1;
758
+ } | undefined) => boolean;
759
+ removeTable: () => boolean;
760
+ removeColumn: (args_0?: {
761
+ at?: BetterAt;
762
+ } | undefined) => boolean | undefined;
763
+ removeRow: (args_0?: {
764
+ at?: BetterAt;
765
+ } | undefined) => boolean;
766
+ tabForward: () => boolean;
767
+ tabBackward: () => boolean | undefined;
768
+ shiftEnterForward: () => boolean;
769
+ selectCell: (args_0?: {
770
+ at?: BetterAt;
771
+ } | undefined) => boolean;
772
+ down: () => boolean;
773
+ up: () => boolean;
774
+ setTableColumnAlign: (options: {
775
+ align: "left" | "center" | "right";
742
776
  }) => boolean;
743
777
  };
744
778
 
745
- type AnchorMethods = ReturnType<typeof createAnchorMethods>;
746
- type AnchorEditor = {
747
- anchor: AnchorMethods;
748
- };
749
- type AnchorElement = {
750
- type: "anchor";
751
- href: string;
752
- target?: string;
753
- title?: string;
754
- children: Descendant[];
755
- };
756
- type AnchorPluginCustomTypes = {
757
- Name: "anchor";
758
- Editor: AnchorEditor;
759
- Element: AnchorElement;
779
+ type TableEditor = {
780
+ supportsTable: true;
781
+ tablePlugin: ReturnType<typeof createTableMethods>;
760
782
  };
761
-
762
- declare function createHeadingMethods(editor: Editor): {
763
- convertHeading: (level: 1 | 2 | 3 | 4 | 5 | 6, allowToggle: boolean) => void;
764
- isHeadingActive: (level: 1 | 2 | 3 | 4 | 5 | 6) => boolean;
783
+ type TablePluginCustomTypes = {
784
+ Name: "table";
785
+ Editor: TableEditor;
786
+ Element: TableElement | TableRowElement | TableCellElement | TableContentElement;
765
787
  };
766
788
 
767
- type HeadingEditor = {
768
- heading: ReturnType<typeof createHeadingMethods>;
769
- };
770
- type HeadingElement = {
771
- type: "heading";
789
+ /**
790
+ * HTML block element for preserving raw HTML content
791
+ */
792
+ type HtmlBlockElement = {
793
+ type: "html-block";
772
794
  /**
773
- * NOTE:
774
- *
775
- * Don't extract these into a new type. It's easier to just repeat this and
776
- * there's less indirection.
795
+ * The raw HTML content
777
796
  */
778
- level: 1 | 2 | 3 | 4 | 5 | 6;
779
- children: Descendant[];
780
- };
781
- type HeadingPluginCustomTypes = {
782
- Name: "heading";
783
- Editor: HeadingEditor;
784
- Element: HeadingElement;
785
- };
786
-
787
- type BlockQuoteEditor = {
788
- supportsBlockQuote: true;
789
- blockQuotePlugin: {
790
- indent: () => void;
791
- outdent: () => void;
792
- isActive: () => boolean;
793
- increaseDepth: () => void;
794
- decreaseDepth: () => void;
795
- canIncreaseDepth: () => boolean;
796
- canDecreaseDepth: () => boolean;
797
- };
798
- };
799
- type BlockQuoteElement = {
800
- type: "block-quote";
801
- children: Descendant[];
797
+ html: string;
798
+ children: Text[];
802
799
  };
803
- type BlockQuotePluginCustomTypes = {
804
- Name: "block-quote";
805
- Editor: BlockQuoteEditor;
806
- Element: BlockQuoteElement;
800
+ type HtmlBlockPluginCustomTypes = {
801
+ Name: "html-block";
802
+ Editor: Record<string, never>;
803
+ Element: HtmlBlockElement;
807
804
  };
808
805
 
809
806
  declare function createCodeBlockMethods(editor: Editor): {
@@ -811,7 +808,7 @@ declare function createCodeBlockMethods(editor: Editor): {
811
808
  language: BuiltInLanguage;
812
809
  }) => void;
813
810
  setCodeBlockLanguage: (language: BuiltInLanguage, options?: {
814
- at?: BetterAt | undefined;
811
+ at?: BetterAt;
815
812
  } | undefined) => boolean;
816
813
  };
817
814
 
@@ -847,66 +844,26 @@ type CodeBlockPluginCustomTypes = {
847
844
  };
848
845
  };
849
846
 
850
- /**
851
- * HTML block element for preserving raw HTML content
852
- */
853
- type HtmlBlockElement = {
854
- type: "html-block";
855
- /**
856
- * The raw HTML content
857
- */
858
- html: string;
859
- children: Text[];
860
- };
861
- type HtmlBlockPluginCustomTypes = {
862
- Name: "html-block";
863
- Editor: Record<string, never>;
864
- Element: HtmlBlockElement;
865
- };
866
-
867
- declare function createTableMethods(editor: Editor): {
868
- getTableInfo: (args_0?: {
869
- at?: ImageBlockElement | ImageInlineElement | ParagraphElement | OrderedListItemElement | UnorderedListItemElement | TaskListItemElement | HorizontalRuleElement | TableElement | TableRowElement | TableCellElement | TableContentElement | HtmlBlockElement | CodeBlockElement | CodeBlockLineElement | BlockQuoteElement | HeadingElement | AnchorElement | slate.Location | null | undefined;
870
- } | undefined) => TableInfo | undefined;
871
- insertTable: (args_0: number, args_1: number, args_2?: {
872
- at?: slate.Location | null | undefined;
873
- } | undefined) => boolean;
874
- insertColumn: (args_0?: {
875
- offset?: 0 | 1 | undefined;
876
- at?: BetterAt | undefined;
877
- } | undefined) => boolean;
878
- insertRow: (args_0?: {
879
- at?: BetterAt | undefined;
880
- offset?: 0 | 1 | undefined;
881
- } | undefined) => boolean;
882
- removeTable: () => boolean;
883
- removeColumn: (args_0?: {
884
- at?: BetterAt | undefined;
885
- } | undefined) => boolean | undefined;
886
- removeRow: (args_0?: {
887
- at?: BetterAt | undefined;
888
- } | undefined) => boolean;
889
- tabForward: () => boolean;
890
- tabBackward: () => boolean | undefined;
891
- shiftEnterForward: () => boolean;
892
- selectCell: (args_0?: {
893
- at?: BetterAt | undefined;
894
- } | undefined) => boolean;
895
- down: () => boolean;
896
- up: () => boolean;
897
- setTableColumnAlign: (options: {
898
- align: "center" | "left" | "right";
899
- }) => boolean;
847
+ type BlockQuoteEditor = {
848
+ supportsBlockQuote: true;
849
+ blockQuotePlugin: {
850
+ indent: () => void;
851
+ outdent: () => void;
852
+ isActive: () => boolean;
853
+ increaseDepth: () => void;
854
+ decreaseDepth: () => void;
855
+ canIncreaseDepth: () => boolean;
856
+ canDecreaseDepth: () => boolean;
857
+ };
900
858
  };
901
-
902
- type TableEditor = {
903
- supportsTable: true;
904
- tablePlugin: ReturnType<typeof createTableMethods>;
859
+ type BlockQuoteElement = {
860
+ type: "block-quote";
861
+ children: Descendant[];
905
862
  };
906
- type TablePluginCustomTypes = {
907
- Name: "table";
908
- Editor: TableEditor;
909
- Element: TableElement | TableRowElement | TableCellElement | TableContentElement;
863
+ type BlockQuotePluginCustomTypes = {
864
+ Name: "block-quote";
865
+ Editor: BlockQuoteEditor;
866
+ Element: BlockQuoteElement;
910
867
  };
911
868
 
912
869
  type InlineCodeEditor = {
@@ -926,10 +883,10 @@ type InlineCodePluginCustomTypes = {
926
883
 
927
884
  declare function createMarksMethods(editor: Editor): {
928
885
  removeMarks: (args_0?: {
929
- at?: slate.Location | null | undefined;
886
+ at?: slate.Location | null;
930
887
  } | undefined) => void;
931
- toggleMark: (args_0: "bold" | "strike" | "text" | "prismToken" | "code" | "italic" | "underline" | "highlight", args_1?: "bold" | "strike" | "text" | "prismToken" | "code" | "italic" | "underline" | "highlight" | undefined, args_2?: {
932
- at?: slate.Location | null | undefined;
888
+ toggleMark: (markKey: "bold" | "strike" | "text" | "prismToken" | "code" | "italic" | "underline" | "highlight", unsetKey?: "bold" | "strike" | "text" | "prismToken" | "code" | "italic" | "underline" | "highlight" | undefined, args_2?: {
889
+ at?: slate.Location | null;
933
890
  } | undefined) => void;
934
891
  toggleBold: () => void;
935
892
  toggleItalic: () => void;
@@ -968,6 +925,65 @@ type MarksPluginCustomTypes = {
968
925
  Text: MarksText;
969
926
  };
970
927
 
928
+ declare function createHeadingMethods(editor: Editor): {
929
+ convertHeading: (level: 1 | 2 | 3 | 4 | 5 | 6, allowToggle: boolean) => void;
930
+ isHeadingActive: (level: 1 | 2 | 3 | 4 | 5 | 6) => boolean;
931
+ };
932
+
933
+ type HeadingEditor = {
934
+ heading: ReturnType<typeof createHeadingMethods>;
935
+ };
936
+ type HeadingElement = {
937
+ type: "heading";
938
+ /**
939
+ * NOTE:
940
+ *
941
+ * Don't extract these into a new type. It's easier to just repeat this and
942
+ * there's less indirection.
943
+ */
944
+ level: 1 | 2 | 3 | 4 | 5 | 6;
945
+ children: Descendant[];
946
+ };
947
+ type HeadingPluginCustomTypes = {
948
+ Name: "heading";
949
+ Editor: HeadingEditor;
950
+ Element: HeadingElement;
951
+ };
952
+
953
+ declare function createAnchorMethods(editor: Editor): {
954
+ insertLink: (href: string, text?: string | undefined, args_2?: {
955
+ select?: boolean;
956
+ title?: string;
957
+ } | undefined) => void;
958
+ removeLink: (args_0: {
959
+ at?: BetterAt;
960
+ }) => boolean;
961
+ editLink: (args_0: {
962
+ href: string;
963
+ title?: string;
964
+ text?: string;
965
+ }, args_1: {
966
+ at?: BetterAt;
967
+ }) => boolean;
968
+ };
969
+
970
+ type AnchorMethods = ReturnType<typeof createAnchorMethods>;
971
+ type AnchorEditor = {
972
+ anchor: AnchorMethods;
973
+ };
974
+ type AnchorElement = {
975
+ type: "anchor";
976
+ href: string;
977
+ target?: string;
978
+ title?: string;
979
+ children: Descendant[];
980
+ };
981
+ type AnchorPluginCustomTypes = {
982
+ Name: "anchor";
983
+ Editor: AnchorEditor;
984
+ Element: AnchorElement;
985
+ };
986
+
971
987
  /**
972
988
  * A type with generic for `convertElements` (below) to be used with the curry
973
989
  * method. TypeScript, unfortunately, cannot automatically curry generics for
@@ -1032,7 +1048,7 @@ type EditableProps = {
1032
1048
  onImageChange?: OnImageChangeHandler;
1033
1049
  onFileSelect?: OnFileSelectHandler;
1034
1050
  };
1035
- declare function Editable({ editor, value, onChange, throttleInMs, placeholder, className, style, onImageChange, onFileSelect, }: EditableProps): react.JSX.Element;
1051
+ declare function Editable({ editor, value, onChange, throttleInMs, placeholder, className, style, onImageChange, onFileSelect, }: EditableProps): React$1.JSX.Element;
1036
1052
 
1037
1053
  /**
1038
1054
  * Remove inline escape backslashes added by the serializer's escapeText.