wysimark-lite 0.16.2 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -0
- package/dist/index.d.ts +59 -6
- package/dist/index.js +220 -132
- package/dist/index.mjs +1173 -568
- package/dist/index.mjs.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +15 -4
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
2
|
import * as slate from 'slate';
|
|
3
|
-
import { Descendant, Editor, Element as Element$1, BaseEditor, NodeEntry, BaseRange, Location, Path, BaseText } from 'slate';
|
|
3
|
+
import { Descendant, Editor, Element as Element$1, BaseEditor, NodeEntry, BaseRange, Location, Path, Text, BaseText } from 'slate';
|
|
4
4
|
import { HistoryEditor } from 'slate-history';
|
|
5
5
|
import { ReactEditor, Editable as Editable$1 } from 'slate-react';
|
|
6
6
|
import { SetReturnType, SetOptional, UnionToIntersection, Simplify } from 'type-fest';
|
|
@@ -16,6 +16,14 @@ type WysimarkEditor = {
|
|
|
16
16
|
markdown: string;
|
|
17
17
|
children: Descendant[];
|
|
18
18
|
};
|
|
19
|
+
/**
|
|
20
|
+
* Whether the editor is in Raw mode
|
|
21
|
+
*/
|
|
22
|
+
isRawMode?: boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Function to toggle Raw mode
|
|
25
|
+
*/
|
|
26
|
+
toggleRawMode?: () => void;
|
|
19
27
|
};
|
|
20
28
|
/**
|
|
21
29
|
* Public methods for the wysimark editor.
|
|
@@ -725,6 +733,10 @@ type BlockQuoteEditor = {
|
|
|
725
733
|
indent: () => void;
|
|
726
734
|
outdent: () => void;
|
|
727
735
|
isActive: () => boolean;
|
|
736
|
+
increaseDepth: () => void;
|
|
737
|
+
decreaseDepth: () => void;
|
|
738
|
+
canIncreaseDepth: () => boolean;
|
|
739
|
+
canDecreaseDepth: () => boolean;
|
|
728
740
|
};
|
|
729
741
|
};
|
|
730
742
|
type BlockQuoteElement = {
|
|
@@ -737,9 +749,50 @@ type BlockQuotePluginCustomTypes = {
|
|
|
737
749
|
Element: BlockQuoteElement;
|
|
738
750
|
};
|
|
739
751
|
|
|
752
|
+
declare function createCodeBlockMethods(editor: Editor): {
|
|
753
|
+
createCodeBlock: (args_0: {
|
|
754
|
+
language: BuiltInLanguage;
|
|
755
|
+
}) => void;
|
|
756
|
+
setCodeBlockLanguage: (language: BuiltInLanguage, options?: {
|
|
757
|
+
at?: BetterAt | undefined;
|
|
758
|
+
} | undefined) => boolean;
|
|
759
|
+
};
|
|
760
|
+
|
|
761
|
+
type CodeBlockMethods = ReturnType<typeof createCodeBlockMethods>;
|
|
762
|
+
type BuiltInLanguage = "text" | "html" | "svg" | "markup" | "css" | "javascript" | "js" | "java" | "c" | "clike";
|
|
763
|
+
type CodeBlockEditor = {
|
|
764
|
+
codeBlock: CodeBlockMethods;
|
|
765
|
+
};
|
|
766
|
+
/**
|
|
767
|
+
* The code block element is the root element of a code block.
|
|
768
|
+
*/
|
|
769
|
+
type CodeBlockElement = {
|
|
770
|
+
type: "code-block";
|
|
771
|
+
/**
|
|
772
|
+
* The language of the code block. Can accept any string because Markdown can
|
|
773
|
+
* accept any string; however, the built-in Prism languages are defined in:
|
|
774
|
+
* `BuiltInLanguage`
|
|
775
|
+
*/
|
|
776
|
+
language: string;
|
|
777
|
+
children: CodeBlockLineElement[];
|
|
778
|
+
};
|
|
779
|
+
type CodeBlockLineElement = {
|
|
780
|
+
type: "code-block-line";
|
|
781
|
+
children: Text[];
|
|
782
|
+
};
|
|
783
|
+
type CodeBlockPluginCustomTypes = {
|
|
784
|
+
Name: "code-block";
|
|
785
|
+
Editor: CodeBlockEditor;
|
|
786
|
+
Element: CodeBlockElement | CodeBlockLineElement;
|
|
787
|
+
Text: {
|
|
788
|
+
text: string;
|
|
789
|
+
prismToken?: string;
|
|
790
|
+
};
|
|
791
|
+
};
|
|
792
|
+
|
|
740
793
|
declare function createTableMethods(editor: Editor): {
|
|
741
794
|
getTableInfo: (args_0?: {
|
|
742
|
-
at?: ImageBlockElement | ParagraphElement | OrderedListItemElement | UnorderedListItemElement | TaskListItemElement | HorizontalRuleElement | TableElement | TableRowElement | TableCellElement | TableContentElement | BlockQuoteElement | HeadingElement | AnchorElement | slate.Location | null | undefined;
|
|
795
|
+
at?: ImageBlockElement | ParagraphElement | OrderedListItemElement | UnorderedListItemElement | TaskListItemElement | HorizontalRuleElement | TableElement | TableRowElement | TableCellElement | TableContentElement | CodeBlockElement | CodeBlockLineElement | BlockQuoteElement | HeadingElement | AnchorElement | slate.Location | null | undefined;
|
|
743
796
|
} | undefined) => TableInfo | undefined;
|
|
744
797
|
insertTable: (args_0: number, args_1: number, args_2?: {
|
|
745
798
|
at?: slate.Location | null | undefined;
|
|
@@ -800,7 +853,7 @@ declare function createMarksMethods(editor: Editor): {
|
|
|
800
853
|
removeMarks: (args_0?: {
|
|
801
854
|
at?: slate.Location | null | undefined;
|
|
802
855
|
} | undefined) => void;
|
|
803
|
-
toggleMark: (args_0: "bold" | "strike" | "text" | "code" | "italic" | "underline", args_1?: "bold" | "strike" | "text" | "code" | "italic" | "underline" | undefined, args_2?: {
|
|
856
|
+
toggleMark: (args_0: "bold" | "strike" | "text" | "prismToken" | "code" | "italic" | "underline", args_1?: "bold" | "strike" | "text" | "prismToken" | "code" | "italic" | "underline" | undefined, args_2?: {
|
|
804
857
|
at?: slate.Location | null | undefined;
|
|
805
858
|
} | undefined) => void;
|
|
806
859
|
toggleBold: () => void;
|
|
@@ -846,8 +899,8 @@ type CurriedConvertElements = <T extends Element$1 = Element$1>(matchForToggle:
|
|
|
846
899
|
|
|
847
900
|
declare function createConvertElementMethods(editor: Editor): {
|
|
848
901
|
convertElementTypes: string[];
|
|
849
|
-
addConvertElementType: (type: "anchor" | "heading" | "block-quote" | "table" | "horizontal-rule" | "paragraph" | "image-block" | "ordered-list-item" | "unordered-list-item" | "task-list-item" | "table-row" | "table-cell" | "table-content" | ("anchor" | "heading" | "block-quote" | "table" | "horizontal-rule" | "paragraph" | "image-block" | "ordered-list-item" | "unordered-list-item" | "task-list-item" | "table-row" | "table-cell" | "table-content")[]) => void;
|
|
850
|
-
isConvertibleElement: (element: ImageBlockElement | ParagraphElement | OrderedListItemElement | UnorderedListItemElement | TaskListItemElement | HorizontalRuleElement | TableElement | TableRowElement | TableCellElement | TableContentElement | BlockQuoteElement | HeadingElement | AnchorElement) => boolean;
|
|
902
|
+
addConvertElementType: (type: "anchor" | "heading" | "block-quote" | "table" | "horizontal-rule" | "code-block" | "paragraph" | "image-block" | "ordered-list-item" | "unordered-list-item" | "task-list-item" | "table-row" | "table-cell" | "table-content" | "code-block-line" | ("anchor" | "heading" | "block-quote" | "table" | "horizontal-rule" | "code-block" | "paragraph" | "image-block" | "ordered-list-item" | "unordered-list-item" | "task-list-item" | "table-row" | "table-cell" | "table-content" | "code-block-line")[]) => void;
|
|
903
|
+
isConvertibleElement: (element: ImageBlockElement | ParagraphElement | OrderedListItemElement | UnorderedListItemElement | TaskListItemElement | HorizontalRuleElement | TableElement | TableRowElement | TableCellElement | TableContentElement | CodeBlockElement | CodeBlockLineElement | BlockQuoteElement | HeadingElement | AnchorElement) => boolean;
|
|
851
904
|
convertElements: CurriedConvertElements;
|
|
852
905
|
};
|
|
853
906
|
|
|
@@ -872,7 +925,7 @@ type PasteMarkdownPluginCustomTypes = {
|
|
|
872
925
|
Editor: PasteMarkdownEditor;
|
|
873
926
|
};
|
|
874
927
|
|
|
875
|
-
declare const plugins: (TypedPlugin<PasteMarkdownPluginCustomTypes> | TypedPlugin<ConvertElementPluginCustomTypes> | TypedPlugin<AnchorPluginCustomTypes> | TypedPlugin<HeadingPluginCustomTypes> | TypedPlugin<MarksPluginCustomTypes> | TypedPlugin<InlineCodePluginCustomTypes> | TypedPlugin<BlockQuotePluginCustomTypes> | TypedPlugin<TablePluginCustomTypes> | TypedPlugin<HorizontalRulePluginCustomTypes> | TypedPlugin<{
|
|
928
|
+
declare const plugins: (TypedPlugin<PasteMarkdownPluginCustomTypes> | TypedPlugin<ConvertElementPluginCustomTypes> | TypedPlugin<AnchorPluginCustomTypes> | TypedPlugin<HeadingPluginCustomTypes> | TypedPlugin<MarksPluginCustomTypes> | TypedPlugin<InlineCodePluginCustomTypes> | TypedPlugin<BlockQuotePluginCustomTypes> | TypedPlugin<CodeBlockPluginCustomTypes> | TypedPlugin<TablePluginCustomTypes> | TypedPlugin<HorizontalRulePluginCustomTypes> | TypedPlugin<{
|
|
876
929
|
Name: "trailing-block";
|
|
877
930
|
Editor: {
|
|
878
931
|
allowTrailingBlock: true;
|