wysimark-lite 0.21.2 → 0.23.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 +41 -2
- package/dist/index.d.ts +80 -3
- package/dist/index.js +131 -127
- package/dist/index.mjs +722 -463
- package/dist/index.mjs.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -6,9 +6,11 @@ wysimark ( https://github.com/portive/wysimark ) is a modern and clean rich text
|
|
|
6
6
|
|
|
7
7
|
Thanks to the original author of wysimark, portive m(_ _)m
|
|
8
8
|
|
|
9
|
+
[日本語版 README はこちら](README_ja.md)
|
|
10
|
+
|
|
9
11
|
## Demo
|
|
10
12
|
|
|
11
|
-
You can try out
|
|
13
|
+
You can try out the editor using storybook in the following link:
|
|
12
14
|
https://takeshy.github.io/wysimark-lite
|
|
13
15
|
|
|
14
16
|
## Usage
|
|
@@ -35,6 +37,33 @@ const Editor: React.FC = () => {
|
|
|
35
37
|
};
|
|
36
38
|
```
|
|
37
39
|
|
|
40
|
+
### Editor Options
|
|
41
|
+
|
|
42
|
+
The `useEditor` hook accepts the following options:
|
|
43
|
+
|
|
44
|
+
```tsx
|
|
45
|
+
const editor = useEditor({
|
|
46
|
+
// Enable raw markdown editing mode (default: true = disabled)
|
|
47
|
+
disableRawMode: false,
|
|
48
|
+
|
|
49
|
+
// Enable highlight mark feature (default: true = disabled)
|
|
50
|
+
disableHighlight: false,
|
|
51
|
+
|
|
52
|
+
// Disable task list / checklist (default: false)
|
|
53
|
+
disableTaskList: true,
|
|
54
|
+
|
|
55
|
+
// Disable code block (default: false)
|
|
56
|
+
disableCodeBlock: true,
|
|
57
|
+
});
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
| Option | Default | Description |
|
|
61
|
+
|--------|---------|-------------|
|
|
62
|
+
| `disableRawMode` | `true` | When `false`, shows a toggle button to switch between WYSIWYG and raw Markdown editing |
|
|
63
|
+
| `disableHighlight` | `true` | When `false`, shows a highlight button in the toolbar. Highlight is saved as `<mark>text</mark>` in Markdown |
|
|
64
|
+
| `disableTaskList` | `false` | When `true`, hides the task list (checklist) button from the toolbar |
|
|
65
|
+
| `disableCodeBlock` | `false` | When `true`, hides the code block button from the toolbar |
|
|
66
|
+
|
|
38
67
|
### With Image Upload
|
|
39
68
|
|
|
40
69
|
You can enable image file upload by providing the `onImageChange` callback:
|
|
@@ -100,17 +129,27 @@ pin "wysimark-lite", to: "https://cdn.jsdelivr.net/npm/wysimark-lite@latest/dist
|
|
|
100
129
|
## Features
|
|
101
130
|
|
|
102
131
|
- **Modern Design**: Clean and contemporary interface that integrates seamlessly with React applications
|
|
103
|
-
- **Raw Markdown Mode**: Switch between WYSIWYG and raw Markdown editing modes
|
|
132
|
+
- **Raw Markdown Mode**: Switch between WYSIWYG and raw Markdown editing modes (enable with `disableRawMode: false`)
|
|
133
|
+
- **Highlight Support**: Highlight text with `<mark>` tags (enable with `disableHighlight: false`)
|
|
104
134
|
- **Image Upload Support**: Upload images via file picker or drag and drop when `onImageChange` callback is provided
|
|
135
|
+
- **Code Block with Custom Language**: Click on the language label to enter any language name
|
|
105
136
|
- **User-Friendly Interface**:
|
|
106
137
|
- Simplified toolbar with toggle buttons (click to activate/deactivate formatting)
|
|
107
138
|
- Markdown shortcuts (e.g., `**` for **bold**, `#` for heading)
|
|
108
139
|
- Keyboard shortcuts (e.g., `Ctrl/Cmd + B` for bold)
|
|
109
140
|
- Japanese localized UI (toolbar and menu items in Japanese)
|
|
141
|
+
- **Enhanced Link Editing**:
|
|
142
|
+
- Edit link text and tooltip directly in the link dialog
|
|
143
|
+
- Both insert and edit dialogs support text and tooltip fields
|
|
110
144
|
- **Enhanced List Support**:
|
|
111
145
|
- Nested lists support (create hierarchical lists with multiple levels)
|
|
112
146
|
- Mix different list types in the hierarchy
|
|
147
|
+
- **Enhanced Table Editing**:
|
|
148
|
+
- Press `Enter` in a table cell to insert a line break (soft break)
|
|
149
|
+
- Press `Shift+Enter` to move to the next cell
|
|
150
|
+
- Press `Tab` in the last cell to exit the table and create a new paragraph
|
|
113
151
|
- **Smart Block Splitting**: When applying heading/paragraph styles to multi-line blocks, only the selected lines are converted
|
|
152
|
+
- **Cursor Position Preservation**: Cursor position is maintained after element type conversion (e.g., paragraph to heading)
|
|
114
153
|
|
|
115
154
|
## Browser Support
|
|
116
155
|
|
package/dist/index.d.ts
CHANGED
|
@@ -40,6 +40,22 @@ type WysimarkEditor = {
|
|
|
40
40
|
* Persisted state for the image dialog
|
|
41
41
|
*/
|
|
42
42
|
imageDialogState?: ImageDialogState;
|
|
43
|
+
/**
|
|
44
|
+
* Whether raw mode is disabled
|
|
45
|
+
*/
|
|
46
|
+
disableRawMode?: boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Whether task list is disabled
|
|
49
|
+
*/
|
|
50
|
+
disableTaskList?: boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Whether code block is disabled
|
|
53
|
+
*/
|
|
54
|
+
disableCodeBlock?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Whether highlight mark is disabled
|
|
57
|
+
*/
|
|
58
|
+
disableHighlight?: boolean;
|
|
43
59
|
};
|
|
44
60
|
/**
|
|
45
61
|
* Public methods for the wysimark editor.
|
|
@@ -48,12 +64,65 @@ type WysimarkEditor = {
|
|
|
48
64
|
setMarkdown: (markdown: string) => void;
|
|
49
65
|
};
|
|
50
66
|
|
|
51
|
-
|
|
67
|
+
type UseEditorOptions = {
|
|
52
68
|
authToken?: string;
|
|
53
69
|
height?: string | number;
|
|
54
70
|
minHeight?: string | number;
|
|
55
71
|
maxHeight?: string | number;
|
|
56
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Disable raw Markdown editing mode.
|
|
74
|
+
* When true, the raw mode toggle button will be hidden from the toolbar.
|
|
75
|
+
* Defaults to true (raw mode is disabled by default).
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```tsx
|
|
79
|
+
* const editor = useEditor({
|
|
80
|
+
* disableRawMode: false // Enable raw mode
|
|
81
|
+
* })
|
|
82
|
+
* ```
|
|
83
|
+
*/
|
|
84
|
+
disableRawMode?: boolean;
|
|
85
|
+
/**
|
|
86
|
+
* Disable task list (checklist) functionality.
|
|
87
|
+
* When true, the task list button will be hidden from the toolbar
|
|
88
|
+
* and task list creation will be disabled.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* ```tsx
|
|
92
|
+
* const editor = useEditor({
|
|
93
|
+
* disableTaskList: true
|
|
94
|
+
* })
|
|
95
|
+
* ```
|
|
96
|
+
*/
|
|
97
|
+
disableTaskList?: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* Disable code block functionality.
|
|
100
|
+
* When true, the code block button will be hidden from the toolbar.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* ```tsx
|
|
104
|
+
* const editor = useEditor({
|
|
105
|
+
* disableCodeBlock: true
|
|
106
|
+
* })
|
|
107
|
+
* ```
|
|
108
|
+
*/
|
|
109
|
+
disableCodeBlock?: boolean;
|
|
110
|
+
/**
|
|
111
|
+
* Disable highlight mark functionality.
|
|
112
|
+
* When true, the highlight button will be hidden from the toolbar.
|
|
113
|
+
* Highlight is serialized as <mark>text</mark> in markdown.
|
|
114
|
+
* Defaults to true (highlight is disabled by default).
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* ```tsx
|
|
118
|
+
* const editor = useEditor({
|
|
119
|
+
* disableHighlight: false // Enable highlight
|
|
120
|
+
* })
|
|
121
|
+
* ```
|
|
122
|
+
*/
|
|
123
|
+
disableHighlight?: boolean;
|
|
124
|
+
};
|
|
125
|
+
declare function useEditor({ authToken, height, minHeight, maxHeight, disableRawMode, disableTaskList, disableCodeBlock, disableHighlight, }?: UseEditorOptions): Editor & ReactEditor & WysimarkEditor;
|
|
57
126
|
|
|
58
127
|
/**
|
|
59
128
|
* SinkEditor just adds a `sink` object where we drop all of our sink
|
|
@@ -689,6 +758,7 @@ type TableInfo = {
|
|
|
689
758
|
declare function createAnchorMethods(editor: Editor): {
|
|
690
759
|
insertLink: (args_0: string, args_1?: string | undefined, args_2?: {
|
|
691
760
|
select?: boolean | undefined;
|
|
761
|
+
title?: string | undefined;
|
|
692
762
|
} | undefined) => void;
|
|
693
763
|
removeLink: (args_0: {
|
|
694
764
|
at?: BetterAt | undefined;
|
|
@@ -696,6 +766,7 @@ declare function createAnchorMethods(editor: Editor): {
|
|
|
696
766
|
editLink: (args_0: {
|
|
697
767
|
href: string;
|
|
698
768
|
title?: string | undefined;
|
|
769
|
+
text?: string | undefined;
|
|
699
770
|
}, args_1: {
|
|
700
771
|
at?: BetterAt | undefined;
|
|
701
772
|
}) => boolean;
|
|
@@ -830,6 +901,7 @@ declare function createTableMethods(editor: Editor): {
|
|
|
830
901
|
} | undefined) => boolean;
|
|
831
902
|
tabForward: () => boolean;
|
|
832
903
|
tabBackward: () => boolean | undefined;
|
|
904
|
+
shiftEnterForward: () => boolean;
|
|
833
905
|
selectCell: (args_0?: {
|
|
834
906
|
at?: BetterAt | undefined;
|
|
835
907
|
} | undefined) => boolean;
|
|
@@ -869,13 +941,14 @@ declare function createMarksMethods(editor: Editor): {
|
|
|
869
941
|
removeMarks: (args_0?: {
|
|
870
942
|
at?: slate.Location | null | undefined;
|
|
871
943
|
} | undefined) => void;
|
|
872
|
-
toggleMark: (args_0: "bold" | "strike" | "text" | "prismToken" | "code" | "italic" | "underline", args_1?: "bold" | "strike" | "text" | "prismToken" | "code" | "italic" | "underline" | undefined, args_2?: {
|
|
944
|
+
toggleMark: (args_0: "bold" | "strike" | "text" | "prismToken" | "code" | "italic" | "underline" | "highlight", args_1?: "bold" | "strike" | "text" | "prismToken" | "code" | "italic" | "underline" | "highlight" | undefined, args_2?: {
|
|
873
945
|
at?: slate.Location | null | undefined;
|
|
874
946
|
} | undefined) => void;
|
|
875
947
|
toggleBold: () => void;
|
|
876
948
|
toggleItalic: () => void;
|
|
877
949
|
toggleUnderline: () => void;
|
|
878
950
|
toggleStrike: () => void;
|
|
951
|
+
toggleHighlight: () => void;
|
|
879
952
|
};
|
|
880
953
|
|
|
881
954
|
type MarksEditor = {
|
|
@@ -899,6 +972,7 @@ type MarksText = {
|
|
|
899
972
|
italic?: true;
|
|
900
973
|
underline?: true;
|
|
901
974
|
strike?: true;
|
|
975
|
+
highlight?: true;
|
|
902
976
|
};
|
|
903
977
|
type MarksPluginCustomTypes = {
|
|
904
978
|
Name: "marks";
|
|
@@ -941,6 +1015,9 @@ type PasteMarkdownPluginCustomTypes = {
|
|
|
941
1015
|
Editor: PasteMarkdownEditor;
|
|
942
1016
|
};
|
|
943
1017
|
|
|
1018
|
+
/**
|
|
1019
|
+
* @deprecated Use defaultPlugins instead
|
|
1020
|
+
*/
|
|
944
1021
|
declare const plugins: (TypedPlugin<PasteMarkdownPluginCustomTypes> | TypedPlugin<ConvertElementPluginCustomTypes> | TypedPlugin<AnchorPluginCustomTypes> | TypedPlugin<HeadingPluginCustomTypes> | TypedPlugin<MarksPluginCustomTypes> | TypedPlugin<InlineCodePluginCustomTypes> | TypedPlugin<BlockQuotePluginCustomTypes> | TypedPlugin<CodeBlockPluginCustomTypes> | TypedPlugin<TablePluginCustomTypes> | TypedPlugin<HorizontalRulePluginCustomTypes> | TypedPlugin<{
|
|
945
1022
|
Name: "trailing-block";
|
|
946
1023
|
Editor: {
|