rme 0.0.2
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/.gitattributes +3 -0
- package/.prettierrc.json +10 -0
- package/.stylelintrc.json +19 -0
- package/CODE_OF_CONDUCT.md +53 -0
- package/LICENSE +21 -0
- package/README.md +0 -0
- package/dist/index.cjs +22902 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.css +87 -0
- package/dist/index.d.ts +234 -0
- package/dist/index.min.cjs +180 -0
- package/dist/index.min.cjs.map +1 -0
- package/dist/index.min.css +1 -0
- package/dist/index.min.mjs +180 -0
- package/dist/index.min.mjs.map +1 -0
- package/dist/index.mjs +22854 -0
- package/dist/index.mjs.map +1 -0
- package/dist/index.umd.js +22862 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/index.umd.min.js +180 -0
- package/dist/index.umd.min.js.map +1 -0
- package/package.json +218 -0
- package/tsconfig.json +111 -0
package/dist/index.css
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/* src/style.css */
|
|
2
|
+
.prosemirror-flat-list {
|
|
3
|
+
padding: 0;
|
|
4
|
+
margin-top: 0;
|
|
5
|
+
margin-bottom: 0;
|
|
6
|
+
margin-left: 32px;
|
|
7
|
+
margin-bottom: 0;
|
|
8
|
+
position: relative;
|
|
9
|
+
display: list-item;
|
|
10
|
+
list-style: none;
|
|
11
|
+
}
|
|
12
|
+
.prosemirror-flat-list.ProseMirror-selectednode {
|
|
13
|
+
outline: none;
|
|
14
|
+
}
|
|
15
|
+
.prosemirror-flat-list.ProseMirror-selectednode:after {
|
|
16
|
+
content: "";
|
|
17
|
+
position: absolute;
|
|
18
|
+
left: -32px;
|
|
19
|
+
right: -2px;
|
|
20
|
+
top: -2px;
|
|
21
|
+
bottom: -2px;
|
|
22
|
+
border: 2px solid #8cf;
|
|
23
|
+
pointer-events: none;
|
|
24
|
+
}
|
|
25
|
+
.prosemirror-flat-list[data-list-kind=bullet] {
|
|
26
|
+
list-style: disc;
|
|
27
|
+
}
|
|
28
|
+
.prosemirror-flat-list[data-list-kind=ordered] {
|
|
29
|
+
counter-increment: prosemirror-flat-list-counter;
|
|
30
|
+
}
|
|
31
|
+
.prosemirror-flat-list[data-list-kind=ordered] > * {
|
|
32
|
+
contain: style;
|
|
33
|
+
}
|
|
34
|
+
.prosemirror-flat-list[data-list-kind=ordered]::before {
|
|
35
|
+
position: absolute;
|
|
36
|
+
right: 100%;
|
|
37
|
+
font-variant-numeric: tabular-nums;
|
|
38
|
+
content: counter(prosemirror-flat-list-counter, decimal) ". ";
|
|
39
|
+
}
|
|
40
|
+
.prosemirror-flat-list[data-list-kind=ordered]:first-child,
|
|
41
|
+
:not(.prosemirror-flat-list[data-list-kind=ordered]) + .prosemirror-flat-list[data-list-kind=ordered] {
|
|
42
|
+
counter-reset: prosemirror-flat-list-counter;
|
|
43
|
+
}
|
|
44
|
+
@supports (counter-set: prosemirror-flat-list-counter 1) {
|
|
45
|
+
[data-list-order]:is(.prosemirror-flat-list[data-list-kind=ordered]:first-child, :not(.prosemirror-flat-list[data-list-kind=ordered]) + .prosemirror-flat-list[data-list-kind=ordered]) {
|
|
46
|
+
counter-set: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
@supports not (counter-set: prosemirror-flat-list-counter 1) {
|
|
50
|
+
[data-list-order]:is(.prosemirror-flat-list[data-list-kind=ordered]:first-child, :not(.prosemirror-flat-list[data-list-kind=ordered]) + .prosemirror-flat-list[data-list-kind=ordered]) {
|
|
51
|
+
counter-increment: prosemirror-flat-list-counter var(--prosemirror-flat-list-order);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
.prosemirror-flat-list[data-list-kind=task] > .list-marker {
|
|
55
|
+
position: absolute;
|
|
56
|
+
right: 100%;
|
|
57
|
+
text-align: center;
|
|
58
|
+
width: 1.5em;
|
|
59
|
+
width: 1lh;
|
|
60
|
+
}
|
|
61
|
+
.prosemirror-flat-list[data-list-kind=task] > .list-marker,
|
|
62
|
+
.prosemirror-flat-list[data-list-kind=task] > .list-marker * {
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
}
|
|
65
|
+
.prosemirror-flat-list[data-list-kind=toggle] > .list-marker {
|
|
66
|
+
position: absolute;
|
|
67
|
+
right: 100%;
|
|
68
|
+
text-align: center;
|
|
69
|
+
width: 1.5em;
|
|
70
|
+
width: 1lh;
|
|
71
|
+
}
|
|
72
|
+
.prosemirror-flat-list[data-list-kind=toggle] > .list-marker::before {
|
|
73
|
+
content: "\23f7";
|
|
74
|
+
}
|
|
75
|
+
.prosemirror-flat-list[data-list-kind=toggle][data-list-collapsable][data-list-collapsed] > .list-marker::before {
|
|
76
|
+
content: "\23f5";
|
|
77
|
+
}
|
|
78
|
+
.prosemirror-flat-list[data-list-kind=toggle][data-list-collapsable] > .list-marker {
|
|
79
|
+
cursor: pointer;
|
|
80
|
+
}
|
|
81
|
+
.prosemirror-flat-list[data-list-kind=toggle]:not([data-list-collapsable]) > .list-marker {
|
|
82
|
+
opacity: 40%;
|
|
83
|
+
pointer-events: none;
|
|
84
|
+
}
|
|
85
|
+
.prosemirror-flat-list[data-list-kind=toggle][data-list-collapsable][data-list-collapsed] > .list-content > *:nth-child(n+2) {
|
|
86
|
+
display: none;
|
|
87
|
+
}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
import * as react from 'react';
|
|
2
|
+
import react__default from 'react';
|
|
3
|
+
import { RemirrorEventListenerProps, Extension, RemirrorManager as RemirrorManager$1, AnyExtension as AnyExtension$1 } from 'remirror';
|
|
4
|
+
import { AnyExtension, RemirrorManager } from '@remirror/core';
|
|
5
|
+
import { ReactFrameworkOutput } from '@remirror/react-core';
|
|
6
|
+
import { Node, Schema, Mark, NodeType } from '@remirror/pm/model';
|
|
7
|
+
export { useCommands, useHelpers, useKeymap, useRemirrorContext } from '@remirror/react';
|
|
8
|
+
import { CreateThemeOptions } from '@uiw/codemirror-themes';
|
|
9
|
+
export { CreateThemeOptions, createTheme } from '@uiw/codemirror-themes';
|
|
10
|
+
import { LanguageDescription, LanguageSupport } from '@codemirror/language';
|
|
11
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
12
|
+
import Token from 'markdown-it/lib/token';
|
|
13
|
+
|
|
14
|
+
type EditorRef = {
|
|
15
|
+
toggleType: (targetType: EditorViewType) => void;
|
|
16
|
+
getType: () => EditorViewType;
|
|
17
|
+
};
|
|
18
|
+
declare const Editor: react.MemoExoticComponent<react.ForwardRefExoticComponent<EditorProps & react.RefAttributes<EditorRef>>>;
|
|
19
|
+
type EditorChangeHandler = (params: RemirrorEventListenerProps<Extension>, content: string) => void;
|
|
20
|
+
interface EditorProps {
|
|
21
|
+
delegate?: EditorDelegate;
|
|
22
|
+
content: string;
|
|
23
|
+
isTesting?: boolean;
|
|
24
|
+
editable?: boolean;
|
|
25
|
+
offset?: {
|
|
26
|
+
top: number;
|
|
27
|
+
left: number;
|
|
28
|
+
};
|
|
29
|
+
onChange?: EditorChangeHandler;
|
|
30
|
+
hooks?: (() => void)[];
|
|
31
|
+
markdownToolBar?: React.ReactNode[];
|
|
32
|
+
wysiwygToolBar?: React.ReactNode[];
|
|
33
|
+
onContextMounted?: (context: EditorContext) => void;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
type StringToDoc = (content: string) => Node;
|
|
37
|
+
type DocToString = (doc: Node) => string;
|
|
38
|
+
type EditorDelegate<E extends AnyExtension = any> = {
|
|
39
|
+
manager: RemirrorManager<E>;
|
|
40
|
+
stringToDoc: StringToDoc;
|
|
41
|
+
docToString: DocToString;
|
|
42
|
+
view: 'SourceCode' | 'Wysiwyg';
|
|
43
|
+
};
|
|
44
|
+
/** @public */
|
|
45
|
+
interface Note {
|
|
46
|
+
content: string;
|
|
47
|
+
deleted: boolean;
|
|
48
|
+
}
|
|
49
|
+
type EditorViewType = 'wysiwyg' | 'sourceCode';
|
|
50
|
+
type BaseEditorState = {
|
|
51
|
+
mode: EditorViewType;
|
|
52
|
+
delegate?: EditorDelegate;
|
|
53
|
+
note: Note;
|
|
54
|
+
hasUnsavedChanges: boolean;
|
|
55
|
+
saveedUndoDepth: number;
|
|
56
|
+
loaded: boolean;
|
|
57
|
+
};
|
|
58
|
+
type EditorState = BaseEditorState;
|
|
59
|
+
type EditorContext = ReactFrameworkOutput<Remirror.Extensions>;
|
|
60
|
+
|
|
61
|
+
declare function createSourceCodeManager(): RemirrorManager$1<any>;
|
|
62
|
+
declare const createSourceCodeDelegate: () => EditorDelegate<any>;
|
|
63
|
+
|
|
64
|
+
declare const _default$1: react__default.NamedExoticComponent<EditorProps>;
|
|
65
|
+
|
|
66
|
+
type MarkdownItToken = string;
|
|
67
|
+
declare enum ParserRuleType {
|
|
68
|
+
text = 1,
|
|
69
|
+
block = 2,
|
|
70
|
+
ignore = 3,
|
|
71
|
+
free = 4,
|
|
72
|
+
context = 5,
|
|
73
|
+
inline = 6
|
|
74
|
+
}
|
|
75
|
+
type ParserRuleContext = 'bullet_list' | 'ordered_list';
|
|
76
|
+
type TextParserRule = {
|
|
77
|
+
type: ParserRuleType.text;
|
|
78
|
+
/** The name of the markdown-it token */
|
|
79
|
+
token: MarkdownItToken;
|
|
80
|
+
getText: (token: Token) => string;
|
|
81
|
+
};
|
|
82
|
+
type BlockParserRule = {
|
|
83
|
+
type: ParserRuleType.block;
|
|
84
|
+
/** The name of the prosemirror node type */
|
|
85
|
+
node: string;
|
|
86
|
+
/** The name of the markdown-it token */
|
|
87
|
+
token: MarkdownItToken;
|
|
88
|
+
/** Whether or not the markdown-it token has `_open` and `_close` suffix */
|
|
89
|
+
hasOpenClose: boolean;
|
|
90
|
+
/** Get prosemirror node attributes from markdown-it token */
|
|
91
|
+
getAttrs?: (token: Token) => Record<string, any>;
|
|
92
|
+
};
|
|
93
|
+
type ContextParserRule = {
|
|
94
|
+
type: ParserRuleType.context;
|
|
95
|
+
context: ParserRuleContext;
|
|
96
|
+
/** The name of the markdown-it token */
|
|
97
|
+
token: MarkdownItToken;
|
|
98
|
+
};
|
|
99
|
+
type IgnoreParserRule = {
|
|
100
|
+
type: ParserRuleType.ignore;
|
|
101
|
+
/** The name of the markdown-it token */
|
|
102
|
+
token: MarkdownItToken;
|
|
103
|
+
};
|
|
104
|
+
type FreeParserRule = {
|
|
105
|
+
type: ParserRuleType.free;
|
|
106
|
+
/** The name of the markdown-it token */
|
|
107
|
+
token: MarkdownItToken;
|
|
108
|
+
/** A function that can directly mutate the parser state */
|
|
109
|
+
handler: TokenHandler;
|
|
110
|
+
};
|
|
111
|
+
type InlineParserRule = {
|
|
112
|
+
type: ParserRuleType.inline;
|
|
113
|
+
/** The name of the markdown-it token */
|
|
114
|
+
token: MarkdownItToken;
|
|
115
|
+
/** Get prosemirror node attributes from markdown-it token */
|
|
116
|
+
getAttrs?: (token: Token) => Record<string, any>;
|
|
117
|
+
};
|
|
118
|
+
type ParserRule = TextParserRule | BlockParserRule | IgnoreParserRule | FreeParserRule | ContextParserRule | InlineParserRule;
|
|
119
|
+
|
|
120
|
+
interface StackItem {
|
|
121
|
+
type: NodeType;
|
|
122
|
+
attrs?: Record<string, any>;
|
|
123
|
+
content: Node[];
|
|
124
|
+
}
|
|
125
|
+
type TokenHandler = (state: MarkdownParseState, tok: Token) => void;
|
|
126
|
+
type TokenHandlers = Record<string, TokenHandler>;
|
|
127
|
+
declare class MarkdownParseState {
|
|
128
|
+
private schema;
|
|
129
|
+
private marks;
|
|
130
|
+
private tokenHandlers;
|
|
131
|
+
private contextStack;
|
|
132
|
+
stack: StackItem[];
|
|
133
|
+
constructor(schema: Schema, tokenHandlers: TokenHandlers);
|
|
134
|
+
top(): StackItem;
|
|
135
|
+
push(node: Node): void;
|
|
136
|
+
addText(text: string): void;
|
|
137
|
+
private mergeTextNode;
|
|
138
|
+
openMark(mark: Mark): void;
|
|
139
|
+
closeMark(mark: Mark): void;
|
|
140
|
+
parseTokens(toks: Token[]): void;
|
|
141
|
+
addNode(type: NodeType, attrs?: Record<string, any>, content?: Node[]): Node;
|
|
142
|
+
openNode(type: NodeType, attrs?: Record<string, any>): void;
|
|
143
|
+
closeNode(): Node;
|
|
144
|
+
openContext(context: ParserRuleContext): void;
|
|
145
|
+
closeContext(): void;
|
|
146
|
+
topContext(): ParserRuleContext | undefined;
|
|
147
|
+
}
|
|
148
|
+
declare class MarkdownParser {
|
|
149
|
+
private schema;
|
|
150
|
+
private tokenizer;
|
|
151
|
+
private tokenHandlers;
|
|
152
|
+
constructor(schema: Schema, parserRules: ParserRule[]);
|
|
153
|
+
parse(text: string): Node;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
type NodeSerializerOptions = {
|
|
157
|
+
state: MarkdownSerializerState;
|
|
158
|
+
node: Node;
|
|
159
|
+
parent: Node;
|
|
160
|
+
index: number;
|
|
161
|
+
counter: number;
|
|
162
|
+
};
|
|
163
|
+
type NodeSerializerSpec = (options: NodeSerializerOptions) => void;
|
|
164
|
+
type NodeSerializerSpecs = Record<string, NodeSerializerSpec>;
|
|
165
|
+
declare class MarkdownSerializerState {
|
|
166
|
+
private nodes;
|
|
167
|
+
private delimiter;
|
|
168
|
+
out: string;
|
|
169
|
+
private closed;
|
|
170
|
+
private inTightList;
|
|
171
|
+
constructor(nodes: NodeSerializerSpecs);
|
|
172
|
+
flushClose(size?: number): void;
|
|
173
|
+
wrapBlock(newDelimiter: string, firstDelim: string | null, node: Node, f: () => void): void;
|
|
174
|
+
atBlank(): boolean;
|
|
175
|
+
ensureNewLine(): void;
|
|
176
|
+
write(content?: string): void;
|
|
177
|
+
closeBlock(node: Node): void;
|
|
178
|
+
text(text: string, escape?: boolean): void;
|
|
179
|
+
render(node: Node, parent: Node, index: number, counter?: number): void;
|
|
180
|
+
renderContent(parent: Node): void;
|
|
181
|
+
renderInline(parent: Node): void;
|
|
182
|
+
renderList(node: Node, delim: string, firstDelim: (n: number) => string): void;
|
|
183
|
+
esc(str: string, startOfLine?: boolean): string;
|
|
184
|
+
quote(str: string): string;
|
|
185
|
+
repeat(str: string, n: number): string;
|
|
186
|
+
getEnclosingWhitespace(text: string): {
|
|
187
|
+
leading: string | undefined;
|
|
188
|
+
trailing: string | undefined;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
declare class MarkdownSerializer {
|
|
192
|
+
private nodes;
|
|
193
|
+
constructor(nodes: NodeSerializerSpecs);
|
|
194
|
+
serialize(content: Node): string;
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
type ExtensionsOptions = {
|
|
198
|
+
handleViewImgSrcUrl?: (src: string) => Promise<string>;
|
|
199
|
+
};
|
|
200
|
+
declare function extensions({ handleViewImgSrcUrl }: ExtensionsOptions): any[];
|
|
201
|
+
|
|
202
|
+
declare function buildMarkdownParser<Extension extends AnyExtension$1>(manager: RemirrorManager<Extension>): MarkdownParser;
|
|
203
|
+
declare function buildMarkdownSerializer<Extension extends AnyExtension$1>(manager: RemirrorManager<Extension>): MarkdownSerializer;
|
|
204
|
+
type CreateWysiwygDelegateOptions = {
|
|
205
|
+
handleViewImgSrcUrl?: ExtensionsOptions['handleViewImgSrcUrl'];
|
|
206
|
+
};
|
|
207
|
+
declare const createWysiwygDelegate: ({ handleViewImgSrcUrl, }?: CreateWysiwygDelegateOptions) => EditorDelegate<any>;
|
|
208
|
+
|
|
209
|
+
declare const OffsetContext: react.Context<{
|
|
210
|
+
top: number;
|
|
211
|
+
left: number;
|
|
212
|
+
}>;
|
|
213
|
+
declare const wysiwygTransformer: {
|
|
214
|
+
stringToDoc: StringToDoc | null;
|
|
215
|
+
docToString: DocToString | null;
|
|
216
|
+
};
|
|
217
|
+
declare const _default: react.NamedExoticComponent<EditorProps>;
|
|
218
|
+
|
|
219
|
+
declare const changeTheme: (theme: CreateThemeOptions) => void;
|
|
220
|
+
declare const getLanguageMap: () => Record<string, LanguageDescription>;
|
|
221
|
+
declare const loadLanguage: (languageName: string) => Promise<LanguageSupport> | LanguageSupport | undefined;
|
|
222
|
+
declare function computeChange(oldVal: string, newVal: string): {
|
|
223
|
+
from: number;
|
|
224
|
+
to: number;
|
|
225
|
+
text: string;
|
|
226
|
+
} | null;
|
|
227
|
+
|
|
228
|
+
type Props = {
|
|
229
|
+
children?: React.ReactNode;
|
|
230
|
+
theme: Record<string, any>;
|
|
231
|
+
};
|
|
232
|
+
declare const EditorProvider: ({ theme, children }: Props) => react_jsx_runtime.JSX.Element;
|
|
233
|
+
|
|
234
|
+
export { CreateWysiwygDelegateOptions, DocToString, Editor, EditorChangeHandler, EditorContext, EditorDelegate, extensions as EditorExtensions, EditorProps, EditorProvider, EditorRef, EditorState, EditorViewType, Note, OffsetContext, _default$1 as SourceEditor, StringToDoc, _default as WysiwygEditor, buildMarkdownParser, buildMarkdownSerializer, changeTheme, computeChange, createSourceCodeDelegate, createSourceCodeManager, createWysiwygDelegate, getLanguageMap, loadLanguage, wysiwygTransformer };
|