@krainovsd/markdown-editor 0.0.1 → 0.0.3

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 ADDED
@@ -0,0 +1,100 @@
1
+ # @krainovsd/markdown-editor
2
+
3
+ ## Download
4
+
5
+ ```
6
+ pnpm i @krainovsd/markdown-editor
7
+ ```
8
+
9
+ ## Usage
10
+
11
+
12
+ ```ts
13
+ import { Editor } from "@krainovsd/markdown-editor";
14
+
15
+ const root = document.querySelector<HTMLElement>("#root");
16
+
17
+ const editor = new Editor({
18
+ root,
19
+ initialText: "",
20
+ });
21
+ ```
22
+
23
+ ## API
24
+
25
+ ### root
26
+
27
+ Type: `HTMLElement`<br>
28
+ Required: `true`
29
+
30
+ The node for mounting the editor.
31
+
32
+ ### initialText
33
+
34
+ Type: `string | undefined`
35
+
36
+ Initial text after mounting the editor.
37
+
38
+ ### multiCursor
39
+
40
+ Type: `object | undefined`<br>
41
+ Properties:
42
+ - url (`string`) - path to yjs ws provider.
43
+ - roomId (`string`) - id for yjs ws provider.
44
+ - userName (`string | undefined`) - username to display above cursor.
45
+ - userColor (`string | undefined`) - cursor's color.
46
+ - onStartProvider: (`(status?: string) => void`) - execute by change provider's status.
47
+
48
+ Options for multi cursor mode.
49
+
50
+ ### readonly
51
+
52
+ Type: `boolean`<br>
53
+ Default: `false`
54
+
55
+ ### vimMode
56
+
57
+ Type: `boolean`<br>
58
+ Default: `false`
59
+
60
+ ### theme
61
+
62
+ Type: `"dark" | "light"`<br>
63
+ Default: `"light"`
64
+
65
+ ### dark, light
66
+
67
+ Type: `ThemeOptions`
68
+
69
+ Color configs to change default dark or light theme.
70
+
71
+ ### languages
72
+
73
+ Type: `LanguageDescription[] | undefined`
74
+
75
+ List of languages for markdown code section. Provided by [@codemirror/language-data](https://github.com/codemirror/language-data)
76
+
77
+ ### onBlur
78
+
79
+ Type: `((state: EditorState) => void) | undefined`
80
+
81
+ Execute by blur root node of editor.
82
+
83
+ ### onFocus
84
+
85
+ Type: `((state: EditorState) => void) | undefined`
86
+
87
+ Execute by focus root node of editor.
88
+
89
+ ### onChange
90
+
91
+ Type: `((view: ViewUpdate) => void) | undefined`
92
+
93
+ Execute by change text in editor.
94
+
95
+ ### onEnter
96
+
97
+ Type: `((view: EditorView) => boolean) | undefined`
98
+
99
+ Execute by keydown event in root node of editor. <br>
100
+ **Warning!!!** Line break will be canceled If set `false` by return of function. Only `shift + Enter` will be worked.