@wangeditor-next/yjs-for-react 0.1.7 → 0.1.9
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/basic-modules/src/modules/link/menu/config.d.ts +1 -1
- package/dist/basic-modules/src/modules/link/menu/index.d.ts +2 -2
- package/dist/core/src/config/interface.d.ts +136 -3
- package/dist/core/src/config/register.d.ts +1 -1
- package/dist/core/src/editor/interface.d.ts +4 -3
- package/dist/core/src/menus/interface.d.ts +2 -3
- package/dist/core/src/menus/register.d.ts +3 -4
- package/dist/core/src/text-area/event-handlers/copy.d.ts +1 -1
- package/dist/editor/src/Boot.d.ts +3 -4
- package/package.json +4 -4
|
@@ -8,7 +8,7 @@ export declare function genLinkMenuConfig(): {
|
|
|
8
8
|
* @param text link text
|
|
9
9
|
* @param url link url
|
|
10
10
|
*/
|
|
11
|
-
checkLink(
|
|
11
|
+
checkLink(_text: string, _url: string): boolean | string | undefined;
|
|
12
12
|
/**
|
|
13
13
|
* parse link url
|
|
14
14
|
* @param url url
|
|
@@ -10,7 +10,7 @@ declare const insertLinkMenuConf: {
|
|
|
10
10
|
key: string;
|
|
11
11
|
factory(): InsertLink;
|
|
12
12
|
config: {
|
|
13
|
-
checkLink(
|
|
13
|
+
checkLink(_text: string, _url: string): boolean | string | undefined;
|
|
14
14
|
parseLinkUrl(url: string): string;
|
|
15
15
|
};
|
|
16
16
|
};
|
|
@@ -18,7 +18,7 @@ declare const editLinkMenuConf: {
|
|
|
18
18
|
key: string;
|
|
19
19
|
factory(): EditLink;
|
|
20
20
|
config: {
|
|
21
|
-
checkLink(
|
|
21
|
+
checkLink(_text: string, _url: string): boolean | string | undefined;
|
|
22
22
|
parseLinkUrl(url: string): string;
|
|
23
23
|
};
|
|
24
24
|
};
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
* @description config interface
|
|
3
3
|
* @author wangfupeng
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { ImageElement } from 'packages/basic-modules/src/modules/image/custom-types';
|
|
6
|
+
import { VideoElement } from 'packages/video-module/src/module/custom-types';
|
|
7
|
+
import { Node, NodeEntry, Range } from 'slate';
|
|
6
8
|
import { IDomEditor } from '../editor/interface';
|
|
7
9
|
import { IMenuGroup } from '../menus/interface';
|
|
10
|
+
import { IUploadConfig } from '../upload';
|
|
8
11
|
interface IHoverbarConf {
|
|
9
12
|
[key: string]: {
|
|
10
13
|
match?: (editor: IDomEditor, n: Node) => boolean;
|
|
@@ -14,9 +17,139 @@ interface IHoverbarConf {
|
|
|
14
17
|
export type AlertType = 'success' | 'info' | 'warning' | 'error';
|
|
15
18
|
export interface ISingleMenuConfig {
|
|
16
19
|
[key: string]: any;
|
|
20
|
+
iconSvg?: string;
|
|
21
|
+
}
|
|
22
|
+
interface IColorConfig {
|
|
23
|
+
colors: string[];
|
|
24
|
+
}
|
|
25
|
+
interface IFontSizeItem {
|
|
26
|
+
name: string;
|
|
27
|
+
value: string;
|
|
28
|
+
}
|
|
29
|
+
interface IFontSizeConfig {
|
|
30
|
+
fontSizeList: (string | IFontSizeItem)[];
|
|
31
|
+
}
|
|
32
|
+
interface IFontFamilyItem {
|
|
33
|
+
name: string;
|
|
34
|
+
value: string;
|
|
35
|
+
}
|
|
36
|
+
interface IFontFamilyConfig {
|
|
37
|
+
fontFamilyList: (string | IFontFamilyItem)[];
|
|
38
|
+
}
|
|
39
|
+
interface ILineHeightConfig {
|
|
40
|
+
lineHeightList: string[];
|
|
41
|
+
}
|
|
42
|
+
interface IImageMenuBaseConfig {
|
|
43
|
+
checkImage?: (src: string, alt: string, url: string) => boolean | undefined | string;
|
|
44
|
+
parseImageSrc?: (src: string) => string;
|
|
45
|
+
}
|
|
46
|
+
interface IInsertImageConfig extends IImageMenuBaseConfig {
|
|
47
|
+
onInsertedImage?: (imageNode: ImageElement | null) => void;
|
|
48
|
+
}
|
|
49
|
+
interface IEditImageConfig extends IImageMenuBaseConfig {
|
|
50
|
+
onUpdatedImage?: (imageNode: ImageElement | null) => void;
|
|
51
|
+
}
|
|
52
|
+
interface IEmotionConfig {
|
|
53
|
+
emotions: string[];
|
|
54
|
+
}
|
|
55
|
+
interface IInsertTableConfig {
|
|
56
|
+
minWidth: number;
|
|
57
|
+
tableHeader: {
|
|
58
|
+
selected: boolean;
|
|
59
|
+
};
|
|
60
|
+
tableFullWidth: {
|
|
61
|
+
selected: boolean;
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
interface ILinkConfig {
|
|
65
|
+
checkLink: (text: string, url: string) => string | boolean | undefined;
|
|
66
|
+
parseLinkUrl: (url: string) => string;
|
|
67
|
+
}
|
|
68
|
+
interface IInsertVideoConfig {
|
|
69
|
+
onInsertedVideo: (videoNode: VideoElement) => NodeEntry | Range;
|
|
70
|
+
checkVideo: (src: string, poster: string) => string | boolean | undefined;
|
|
71
|
+
parseVideoSrc: (url: string) => string;
|
|
72
|
+
}
|
|
73
|
+
interface IUploadVideoConfig extends IUploadConfig {
|
|
74
|
+
}
|
|
75
|
+
interface IUploadImageConfig extends IUploadConfig {
|
|
76
|
+
base64LimitSize?: number;
|
|
77
|
+
}
|
|
78
|
+
interface ICodeLangConfig {
|
|
79
|
+
codeLangs: {
|
|
80
|
+
text: string;
|
|
81
|
+
value: string;
|
|
82
|
+
}[];
|
|
17
83
|
}
|
|
18
84
|
export interface IMenuConfig {
|
|
19
|
-
|
|
85
|
+
bold: ISingleMenuConfig;
|
|
86
|
+
underline: ISingleMenuConfig;
|
|
87
|
+
italic: ISingleMenuConfig;
|
|
88
|
+
through: ISingleMenuConfig;
|
|
89
|
+
code: ISingleMenuConfig;
|
|
90
|
+
sub: ISingleMenuConfig;
|
|
91
|
+
sup: ISingleMenuConfig;
|
|
92
|
+
clearStyle: ISingleMenuConfig;
|
|
93
|
+
color: IColorConfig;
|
|
94
|
+
bgColor: IColorConfig;
|
|
95
|
+
fontSize: IFontSizeConfig;
|
|
96
|
+
fontFamily: IFontFamilyConfig;
|
|
97
|
+
indent: ISingleMenuConfig;
|
|
98
|
+
delIndent: ISingleMenuConfig;
|
|
99
|
+
justifyLeft: ISingleMenuConfig;
|
|
100
|
+
justifyRight: ISingleMenuConfig;
|
|
101
|
+
justifyCenter: ISingleMenuConfig;
|
|
102
|
+
justifyJustify: ISingleMenuConfig;
|
|
103
|
+
lineHeight: ILineHeightConfig;
|
|
104
|
+
insertImage: IInsertImageConfig;
|
|
105
|
+
deleteImage: ISingleMenuConfig;
|
|
106
|
+
editImage: IEditImageConfig;
|
|
107
|
+
viewImageLink: ISingleMenuConfig;
|
|
108
|
+
imageWidth30: ISingleMenuConfig;
|
|
109
|
+
imageWidth50: ISingleMenuConfig;
|
|
110
|
+
imageWidth100: ISingleMenuConfig;
|
|
111
|
+
editorImageSizeMenu: ISingleMenuConfig;
|
|
112
|
+
divider: ISingleMenuConfig;
|
|
113
|
+
emotion: IEmotionConfig;
|
|
114
|
+
insertLink: ILinkConfig;
|
|
115
|
+
editLink: ILinkConfig;
|
|
116
|
+
unLink: ISingleMenuConfig;
|
|
117
|
+
viewLink: ISingleMenuConfig;
|
|
118
|
+
codeBlock: ISingleMenuConfig;
|
|
119
|
+
blockquote: ISingleMenuConfig;
|
|
120
|
+
headerSelect: ISingleMenuConfig;
|
|
121
|
+
header1: ISingleMenuConfig;
|
|
122
|
+
header2: ISingleMenuConfig;
|
|
123
|
+
header3: ISingleMenuConfig;
|
|
124
|
+
header4: ISingleMenuConfig;
|
|
125
|
+
header5: ISingleMenuConfig;
|
|
126
|
+
header6: ISingleMenuConfig;
|
|
127
|
+
todo: ISingleMenuConfig;
|
|
128
|
+
formatPainter: ISingleMenuConfig;
|
|
129
|
+
redo: ISingleMenuConfig;
|
|
130
|
+
undo: ISingleMenuConfig;
|
|
131
|
+
fullScreen: ISingleMenuConfig;
|
|
132
|
+
enter: ISingleMenuConfig;
|
|
133
|
+
bulletedList: ISingleMenuConfig;
|
|
134
|
+
numberedList: ISingleMenuConfig;
|
|
135
|
+
insertTable: ISingleMenuConfig;
|
|
136
|
+
deleteTable: ISingleMenuConfig;
|
|
137
|
+
insertTableRow: IInsertTableConfig;
|
|
138
|
+
deleteTableRow: ISingleMenuConfig;
|
|
139
|
+
insertTableCol: ISingleMenuConfig;
|
|
140
|
+
deleteTableCol: ISingleMenuConfig;
|
|
141
|
+
tableHeader: ISingleMenuConfig;
|
|
142
|
+
tableFullWidth: ISingleMenuConfig;
|
|
143
|
+
mergeTableCell: ISingleMenuConfig;
|
|
144
|
+
splitTableCell: ISingleMenuConfig;
|
|
145
|
+
setTableProperty: ISingleMenuConfig;
|
|
146
|
+
setTableCellProperty: ISingleMenuConfig;
|
|
147
|
+
insertVideo: IInsertVideoConfig;
|
|
148
|
+
uploadVideo: IUploadVideoConfig;
|
|
149
|
+
editVideoSize: ISingleMenuConfig;
|
|
150
|
+
editVideoSrc: ISingleMenuConfig;
|
|
151
|
+
uploadImage: IUploadImageConfig;
|
|
152
|
+
codeSelectLang: ICodeLangConfig;
|
|
20
153
|
}
|
|
21
154
|
/**
|
|
22
155
|
* editor config
|
|
@@ -39,7 +172,7 @@ export interface IEditorConfig {
|
|
|
39
172
|
autoFocus: boolean;
|
|
40
173
|
decorate?: (nodeEntry: NodeEntry) => Range[];
|
|
41
174
|
maxLength?: number;
|
|
42
|
-
MENU_CONF?: IMenuConfig
|
|
175
|
+
MENU_CONF?: Partial<IMenuConfig>;
|
|
43
176
|
hoverbarKeys?: IHoverbarConf;
|
|
44
177
|
EXTEND_CONF?: any;
|
|
45
178
|
}
|
|
@@ -2,14 +2,15 @@
|
|
|
2
2
|
* @description editor interface
|
|
3
3
|
* @author wangfupeng
|
|
4
4
|
*/
|
|
5
|
-
import { Editor, Location, Node, Ancestor, Element } from 'slate';
|
|
6
5
|
import ee from 'event-emitter';
|
|
7
|
-
import {
|
|
6
|
+
import { Ancestor, Editor, Element, Location, Node } from 'slate';
|
|
7
|
+
import { AlertType, IEditorConfig, IMenuConfig, ISingleMenuConfig } from '../config/interface';
|
|
8
8
|
import { IPositionStyle } from '../menus/interface';
|
|
9
9
|
import { DOMElement } from '../utils/dom';
|
|
10
10
|
export type ElementWithId = Element & {
|
|
11
11
|
id: string;
|
|
12
12
|
};
|
|
13
|
+
export type getMenuConfigReturnType<K> = K extends keyof IMenuConfig ? IMenuConfig[K] : ISingleMenuConfig;
|
|
13
14
|
/**
|
|
14
15
|
* 扩展 slate Editor 接口
|
|
15
16
|
*/
|
|
@@ -17,7 +18,7 @@ export interface IDomEditor extends Editor {
|
|
|
17
18
|
insertData: (data: DataTransfer) => void;
|
|
18
19
|
setFragmentData: (data: Pick<DataTransfer, 'getData' | 'setData'>) => void;
|
|
19
20
|
getConfig: () => IEditorConfig;
|
|
20
|
-
getMenuConfig: (menuKey:
|
|
21
|
+
getMenuConfig: <K extends string>(menuKey: K) => getMenuConfigReturnType<K>;
|
|
21
22
|
getAllMenuKeys: () => string[];
|
|
22
23
|
alert: (info: string, type: AlertType) => void;
|
|
23
24
|
handleTab: () => void;
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
* @author wangfupeng
|
|
4
4
|
*/
|
|
5
5
|
import { Node } from 'slate';
|
|
6
|
+
import { ISingleMenuConfig } from '../config/interface';
|
|
6
7
|
import { IDomEditor } from '../editor/interface';
|
|
7
8
|
import { DOMElement } from '../utils/dom';
|
|
8
9
|
export interface IMenuGroup {
|
|
@@ -59,8 +60,6 @@ export type MenuFactoryType = () => IButtonMenu | ISelectMenu | IDropPanelMenu |
|
|
|
59
60
|
export interface IRegisterMenuConf {
|
|
60
61
|
key: string;
|
|
61
62
|
factory: MenuFactoryType;
|
|
62
|
-
config?:
|
|
63
|
-
[key: string]: any;
|
|
64
|
-
};
|
|
63
|
+
config?: ISingleMenuConfig;
|
|
65
64
|
}
|
|
66
65
|
export {};
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* @description register menu
|
|
3
3
|
* @author wangfupeng
|
|
4
4
|
*/
|
|
5
|
-
import {
|
|
5
|
+
import { ISingleMenuConfig } from '../config/interface';
|
|
6
|
+
import { IRegisterMenuConf, MenuFactoryType } from './interface';
|
|
6
7
|
export declare const MENU_ITEM_FACTORIES: {
|
|
7
8
|
[key: string]: MenuFactoryType;
|
|
8
9
|
};
|
|
@@ -11,6 +12,4 @@ export declare const MENU_ITEM_FACTORIES: {
|
|
|
11
12
|
* @param registerMenuConf { key, factory, config } ,各个 menu key 不能重复
|
|
12
13
|
* @param customConfig 自定义 menu config
|
|
13
14
|
*/
|
|
14
|
-
export declare function registerMenu(registerMenuConf: IRegisterMenuConf, customConfig?:
|
|
15
|
-
[key: string]: any;
|
|
16
|
-
}): void;
|
|
15
|
+
export declare function registerMenu(registerMenuConf: IRegisterMenuConf, customConfig?: ISingleMenuConfig): void;
|
|
@@ -4,5 +4,5 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { IDomEditor } from '../../editor/interface';
|
|
6
6
|
import TextArea from '../TextArea';
|
|
7
|
-
declare function handleOnCopy(e: Event,
|
|
7
|
+
declare function handleOnCopy(e: Event, _textarea: TextArea, editor: IDomEditor): void;
|
|
8
8
|
export default handleOnCopy;
|
|
@@ -2,7 +2,8 @@
|
|
|
2
2
|
* @description Editor View class
|
|
3
3
|
* @author wangfupeng
|
|
4
4
|
*/
|
|
5
|
-
import { IDomEditor, IEditorConfig,
|
|
5
|
+
import { IDomEditor, IEditorConfig, IElemToHtmlConf, IModuleConf, IParseElemHtmlConf, IPreParseHtmlConf, IRegisterMenuConf, IRenderElemConf, IToolbarConfig, ParseStyleHtmlFnType, RenderStyleFnType, styleToHtmlFnType } from '@wangeditor-next/core';
|
|
6
|
+
import { ISingleMenuConfig } from 'packages/core/src/config/interface';
|
|
6
7
|
type PluginType = <T extends IDomEditor>(editor: T) => T;
|
|
7
8
|
declare class Boot {
|
|
8
9
|
constructor();
|
|
@@ -16,9 +17,7 @@ declare class Boot {
|
|
|
16
17
|
static setSimpleToolbarConfig(newConfig?: Partial<IToolbarConfig>): void;
|
|
17
18
|
static plugins: PluginType[];
|
|
18
19
|
static registerPlugin(plugin: PluginType): void;
|
|
19
|
-
static registerMenu(menuConf: IRegisterMenuConf, customConfig?:
|
|
20
|
-
[key: string]: any;
|
|
21
|
-
}): void;
|
|
20
|
+
static registerMenu(menuConf: IRegisterMenuConf, customConfig?: ISingleMenuConfig): void;
|
|
22
21
|
static registerRenderElem(renderElemConf: IRenderElemConf): void;
|
|
23
22
|
static registerRenderStyle(fn: RenderStyleFnType): void;
|
|
24
23
|
static registerElemToHtml(elemToHtmlConf: IElemToHtmlConf): void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wangeditor-next/yjs-for-react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.9",
|
|
4
4
|
"description": "React specific components/utils for wangeditor-next-yjs.",
|
|
5
5
|
"author": "cycleccc <2991205548@qq.com>",
|
|
6
6
|
"type": "module",
|
|
@@ -55,9 +55,9 @@
|
|
|
55
55
|
"y-protocols": "^1.0.5"
|
|
56
56
|
},
|
|
57
57
|
"peerDependencies": {
|
|
58
|
-
"@wangeditor-next/core": "1.7.
|
|
59
|
-
"@wangeditor-next/editor": "5.6.
|
|
60
|
-
"@wangeditor-next/yjs": "^0.1.
|
|
58
|
+
"@wangeditor-next/core": "1.7.10",
|
|
59
|
+
"@wangeditor-next/editor": "5.6.1",
|
|
60
|
+
"@wangeditor-next/yjs": "^0.1.8",
|
|
61
61
|
"react": ">=16.8.0",
|
|
62
62
|
"slate": "^0.72.0",
|
|
63
63
|
"yjs": "^13.5.29"
|