@block-kit/plugin 1.0.1 → 1.0.4
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/es/align/{align/index.js → index.js} +1 -1
- package/dist/es/background/{background/index.js → index.js} +1 -1
- package/dist/es/bold/{bold/index.js → index.js} +1 -1
- package/dist/es/bullet-list/{bullet-list/index.js → index.js} +7 -7
- package/dist/es/bullet-list/utils/{bullet-list/utils/is.js → is.js} +1 -1
- package/dist/es/divider/{divider/index.js → index.js} +5 -5
- package/dist/es/emoji/{emoji/index.js → index.js} +2 -2
- package/dist/es/font-color/{font-color/index.js → index.js} +1 -1
- package/dist/es/font-size/{font-size/index.js → index.js} +1 -1
- package/dist/es/heading/{heading/index.js → index.js} +1 -1
- package/dist/es/image/{image/index.js → index.js} +7 -7
- package/dist/es/image/view/{image/view/image.js → image.js} +3 -3
- package/dist/es/image/view/{image/view/wrapper.js → wrapper.js} +3 -2
- package/dist/es/indent/{indent/index.js → index.js} +3 -3
- package/dist/es/index.css +1 -1
- package/dist/es/index.d.ts +4 -4
- package/dist/es/index.js +50 -50
- package/dist/es/inline-code/{inline-code/index.js → index.js} +9 -9
- package/dist/es/inline-code/types/index.d.ts +1 -1
- package/dist/es/inline-code/types/index.js +3 -0
- package/dist/es/italic/{italic/index.js → index.js} +1 -1
- package/dist/es/line-height/{line-height/index.js → index.js} +1 -1
- package/dist/es/link/{link/index.js → index.js} +3 -3
- package/dist/es/link/view/{link/view/a.js → a.js} +1 -1
- package/dist/es/mention/{mention/index.js → index.js} +2 -2
- package/dist/es/mention/modules/{mention/modules/suggest.js → suggest.js} +6 -6
- package/dist/es/mention/view/{mention/view/suggest.js → suggest.js} +4 -4
- package/dist/es/order-list/{order-list/index.js → index.js} +9 -9
- package/dist/es/order-list/utils/is.js +12 -0
- package/dist/es/order-list/utils/{order-list/utils/serial.js → serial.js} +2 -2
- package/dist/es/order-list/view/{order-list/view/list.js → list.js} +1 -1
- package/dist/es/quote/{quote/index.js → index.js} +4 -4
- package/dist/es/shared/modules/{shared/modules/selection.js → selection.js} +1 -1
- package/dist/es/shortcut/{shortcut/index.js → index.js} +8 -8
- package/dist/es/shortcut/modules/preset.js +46 -0
- package/dist/es/strike/{strike/index.js → index.js} +1 -1
- package/dist/es/toolbar/context/{toolbar/context/basic.js → basic.js} +6 -6
- package/dist/es/toolbar/context/float.d.ts +14 -0
- package/dist/es/toolbar/context/{toolbar/context/float.js → float.js} +3 -2
- package/dist/es/toolbar/index.d.ts +1 -1
- package/dist/es/toolbar/index.js +45 -0
- package/dist/es/toolbar/modules/{toolbar/modules/align.js → align.js} +9 -5
- package/dist/es/toolbar/modules/{toolbar/modules/bold.js → bold.js} +3 -3
- package/dist/es/toolbar/modules/{toolbar/modules/bullet-list.js → bullet-list.js} +4 -4
- package/dist/es/toolbar/modules/{toolbar/modules/divider.js → divider.js} +3 -3
- package/dist/es/toolbar/modules/{toolbar/modules/emoji.js → emoji.js} +5 -4
- package/dist/es/toolbar/modules/{toolbar/modules/font-color.js → font-color.js} +7 -6
- package/dist/es/toolbar/modules/{toolbar/modules/font-size.js → font-size.js} +7 -5
- package/dist/es/toolbar/modules/{toolbar/modules/heading.js → heading.js} +9 -5
- package/dist/es/toolbar/modules/{toolbar/modules/history.js → history.js} +3 -2
- package/dist/es/toolbar/modules/{toolbar/modules/image.js → image.js} +3 -3
- package/dist/es/toolbar/modules/inline-code.js +15 -0
- package/dist/es/toolbar/modules/{toolbar/modules/italic.js → italic.js} +3 -3
- package/dist/es/toolbar/modules/{toolbar/modules/line-height.js → line-height.js} +7 -5
- package/dist/es/toolbar/modules/{toolbar/modules/link.js → link.js} +16 -6
- package/dist/es/toolbar/modules/{toolbar/modules/order-list.js → order-list.js} +4 -4
- package/dist/es/toolbar/modules/{toolbar/modules/quote.js → quote.js} +3 -3
- package/dist/es/toolbar/modules/{toolbar/modules/strike.js → strike.js} +3 -3
- package/dist/es/toolbar/modules/{toolbar/modules/underline.js → underline.js} +3 -3
- package/dist/es/toolbar/types/index.js +7 -0
- package/dist/es/{node_modules/.pnpm/tslib@2.8.1/node_modules/tslib/tslib.es6.mjs.js → tslib.es6-82e53812.js} +1 -1
- package/dist/es/underline/{underline/index.js → index.js} +1 -1
- package/dist/lib/bullet-list/index.js +1 -1
- package/dist/lib/divider/index.js +1 -1
- package/dist/lib/emoji/index.js +1 -1
- package/dist/lib/image/index.js +2 -2
- package/dist/lib/image/view/image.js +6 -2
- package/dist/lib/image/view/wrapper.js +7 -2
- package/dist/lib/indent/index.js +1 -1
- package/dist/lib/index.css +1 -1
- package/dist/lib/index.d.ts +4 -4
- package/dist/lib/index.js +2 -4
- package/dist/lib/inline-code/index.js +8 -8
- package/dist/lib/inline-code/types/index.d.ts +1 -1
- package/dist/lib/inline-code/types/index.js +2 -2
- package/dist/lib/link/index.js +1 -1
- package/dist/lib/mention/modules/suggest.js +2 -2
- package/dist/lib/order-list/index.js +1 -1
- package/dist/lib/quote/index.js +1 -1
- package/dist/lib/shared/modules/selection.js +1 -1
- package/dist/lib/shortcut/index.js +4 -4
- package/dist/lib/shortcut/modules/preset.js +23 -0
- package/dist/lib/toolbar/context/basic.js +4 -4
- package/dist/lib/toolbar/context/float.d.ts +14 -0
- package/dist/lib/toolbar/context/float.js +2 -1
- package/dist/lib/toolbar/index.d.ts +1 -1
- package/dist/lib/toolbar/index.js +2 -2
- package/dist/lib/toolbar/modules/align.js +18 -6
- package/dist/lib/toolbar/modules/bold.js +6 -2
- package/dist/lib/toolbar/modules/bullet-list.js +6 -2
- package/dist/lib/toolbar/modules/emoji.js +4 -2
- package/dist/lib/toolbar/modules/font-color.js +10 -4
- package/dist/lib/toolbar/modules/font-size.js +11 -3
- package/dist/lib/toolbar/modules/heading.js +18 -6
- package/dist/lib/toolbar/modules/history.js +8 -2
- package/dist/lib/toolbar/modules/image.js +6 -2
- package/dist/lib/toolbar/modules/inline-code.js +8 -4
- package/dist/lib/toolbar/modules/italic.js +6 -2
- package/dist/lib/toolbar/modules/line-height.js +11 -3
- package/dist/lib/toolbar/modules/link.js +24 -7
- package/dist/lib/toolbar/modules/order-list.js +6 -2
- package/dist/lib/toolbar/modules/quote.js +6 -2
- package/dist/lib/toolbar/modules/strike.js +6 -2
- package/dist/lib/toolbar/modules/underline.js +6 -2
- package/dist/lib/toolbar/types/index.js +1 -1
- package/dist/styles/index.css +1 -1
- package/package.json +6 -5
- package/dist/es/inline-code/types/inline-code/types/index.js +0 -3
- package/dist/es/order-list/utils/order-list/utils/is.js +0 -12
- package/dist/es/shortcut/modules/shortcut/modules/preset.js +0 -23
- package/dist/es/toolbar/modules/toolbar/modules/inline-code.js +0 -15
- package/dist/es/toolbar/toolbar/index.js +0 -45
- package/dist/es/toolbar/types/toolbar/types/index.js +0 -7
- /package/dist/es/align/types/{align/types/index.js → index.js} +0 -0
- /package/dist/es/background/types/{background/types/index.js → index.js} +0 -0
- /package/dist/es/bold/types/{bold/types/index.js → index.js} +0 -0
- /package/dist/es/bullet-list/types/{bullet-list/types/index.js → index.js} +0 -0
- /package/dist/es/bullet-list/view/{bullet-list/view/list.js → list.js} +0 -0
- /package/dist/es/divider/types/{divider/types/index.js → index.js} +0 -0
- /package/dist/es/emoji/types/{emoji/types/index.js → index.js} +0 -0
- /package/dist/es/font-color/types/{font-color/types/index.js → index.js} +0 -0
- /package/dist/es/font-size/types/{font-size/types/index.js → index.js} +0 -0
- /package/dist/es/heading/types/{heading/types/index.js → index.js} +0 -0
- /package/dist/es/image/types/{image/types/index.js → index.js} +0 -0
- /package/dist/es/indent/types/{indent/types/index.js → index.js} +0 -0
- /package/dist/es/italic/types/{italic/types/index.js → index.js} +0 -0
- /package/dist/es/line-height/types/{line-height/types/index.js → index.js} +0 -0
- /package/dist/es/link/types/{link/types/index.js → index.js} +0 -0
- /package/dist/es/mention/types/{mention/types/index.js → index.js} +0 -0
- /package/dist/es/mention/utils/{mention/utils/constant.js → constant.js} +0 -0
- /package/dist/es/order-list/types/{order-list/types/index.js → index.js} +0 -0
- /package/dist/es/order-list/utils/{order-list/utils/format.js → format.js} +0 -0
- /package/dist/es/quote/types/{quote/types/index.js → index.js} +0 -0
- /package/dist/es/shared/components/{shared/components/selection.js → selection.js} +0 -0
- /package/dist/es/shared/icons/{shared/icons/divider.js → divider.js} +0 -0
- /package/dist/es/shared/icons/{shared/icons/emoji.js → emoji.js} +0 -0
- /package/dist/es/shared/icons/{shared/icons/font-color.js → font-color.js} +0 -0
- /package/dist/es/shared/icons/{shared/icons/font-size.js → font-size.js} +0 -0
- /package/dist/es/shared/icons/{shared/icons/justify.js → justify.js} +0 -0
- /package/dist/es/shared/icons/{shared/icons/line-height.js → line-height.js} +0 -0
- /package/dist/es/shared/icons/{shared/icons/text.js → text.js} +0 -0
- /package/dist/es/shared/utils/{shared/utils/dom.js → dom.js} +0 -0
- /package/dist/es/shared/utils/{shared/utils/event.js → event.js} +0 -0
- /package/dist/es/shared/utils/{shared/utils/is.js → is.js} +0 -0
- /package/dist/es/shortcut/types/{shortcut/types/index.js → index.js} +0 -0
- /package/dist/es/strike/types/{strike/types/index.js → index.js} +0 -0
- /package/dist/es/toolbar/context/{toolbar/context/provider.js → provider.js} +0 -0
- /package/dist/es/toolbar/modules/{toolbar/modules/cut.js → cut.js} +0 -0
- /package/dist/es/toolbar/utils/{toolbar/utils/marks.js → marks.js} +0 -0
- /package/dist/es/underline/types/{underline/types/index.js → index.js} +0 -0
- /package/dist/lib/{tslib.es6-82029525.js → tslib.es6-04264fd3.js} +0 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { __decorate } from '
|
|
1
|
+
import { _ as __decorate } from '../tslib.es6-82e53812.js';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { EDITOR_EVENT, RawPoint, Point } from '@block-kit/core';
|
|
4
4
|
import { Delta } from '@block-kit/delta';
|
|
5
5
|
import { InjectWrapKeys, EditorPlugin } from '@block-kit/react';
|
|
6
6
|
import { Bind, KEY_CODE, NIL, TRULY } from '@block-kit/utils';
|
|
7
|
-
import { preventContextEvent } from '
|
|
8
|
-
import { isKeyCode, isEmptyLine } from '
|
|
9
|
-
import { QUOTE_KEY } from '
|
|
7
|
+
import { preventContextEvent } from '../shared/utils/dom.js';
|
|
8
|
+
import { isKeyCode, isEmptyLine } from '../shared/utils/is.js';
|
|
9
|
+
import { QUOTE_KEY } from './types/index.js';
|
|
10
10
|
|
|
11
11
|
class QuotePlugin extends EditorPlugin {
|
|
12
12
|
constructor(editor) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { __decorate } from '
|
|
1
|
+
import { _ as __decorate } from '../tslib.es6-82e53812.js';
|
|
2
2
|
import { CorePlugin, EDITOR_EVENT } from '@block-kit/core';
|
|
3
3
|
import { Bind } from '@block-kit/utils';
|
|
4
|
-
import { PLUGIN_EVENTS } from '
|
|
5
|
-
import { filterLineMarkMap, filterMarkMap } from '
|
|
6
|
-
import { PRESET_SHORTCUT } from '
|
|
7
|
-
import { SHORTCUT_KEY } from '
|
|
4
|
+
import { PLUGIN_EVENTS } from '../shared/utils/event.js';
|
|
5
|
+
import { filterLineMarkMap, filterMarkMap } from '../toolbar/utils/marks.js';
|
|
6
|
+
import { PRESET_SHORTCUT } from './modules/preset.js';
|
|
7
|
+
import { SHORTCUT_KEY } from './types/index.js';
|
|
8
8
|
|
|
9
9
|
class Shortcut extends CorePlugin {
|
|
10
10
|
constructor(editor, config) {
|
|
@@ -29,15 +29,15 @@ class Shortcut extends CorePlugin {
|
|
|
29
29
|
const { start, end } = current;
|
|
30
30
|
const lineMarkMap = filterLineMarkMap(lines.slice(start.line, end.line + 1).map(line => line.attributes));
|
|
31
31
|
if (current.isCollapsed) {
|
|
32
|
-
return Object.assign(Object.assign({}, this.editor.
|
|
32
|
+
return Object.assign(Object.assign({}, this.editor.lookup.marks), lineMarkMap);
|
|
33
33
|
}
|
|
34
34
|
const ops = [];
|
|
35
35
|
if (current.isCollapsed) {
|
|
36
|
-
const op = this.editor.
|
|
36
|
+
const op = this.editor.lookup.getOpAtPoint(current.start);
|
|
37
37
|
op && ops.push(op);
|
|
38
38
|
}
|
|
39
39
|
else {
|
|
40
|
-
const fragment = this.editor.
|
|
40
|
+
const fragment = this.editor.lookup.getFragment();
|
|
41
41
|
fragment && ops.push(...fragment);
|
|
42
42
|
}
|
|
43
43
|
const markMap = filterMarkMap(ops);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { Range } from '@block-kit/core';
|
|
2
|
+
import { CTRL_KEY, KEY_CODE, NIL, TRULY } from '@block-kit/utils';
|
|
3
|
+
import { BOLD_KEY } from '../../bold/types/index.js';
|
|
4
|
+
import { LIST_TYPE_KEY, BULLET_LIST_KEY } from '../../bullet-list/types/index.js';
|
|
5
|
+
import { ITALIC_KEY } from '../../italic/types/index.js';
|
|
6
|
+
import { ORDER_LIST_KEY } from '../../order-list/types/index.js';
|
|
7
|
+
import { isKeyCode } from '../../shared/utils/is.js';
|
|
8
|
+
|
|
9
|
+
const PRESET_SHORTCUT = {
|
|
10
|
+
[BOLD_KEY]: (event, payload) => {
|
|
11
|
+
if (event[CTRL_KEY] && isKeyCode(event, KEY_CODE.B) && payload.sel) {
|
|
12
|
+
const { editor, keys, sel } = payload;
|
|
13
|
+
editor.perform.applyMarks(sel, { [BOLD_KEY]: keys[BOLD_KEY] ? NIL : TRULY });
|
|
14
|
+
return true;
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
[ITALIC_KEY]: (event, payload) => {
|
|
18
|
+
if (event[CTRL_KEY] && isKeyCode(event, KEY_CODE.I) && payload.sel) {
|
|
19
|
+
const { editor, keys, sel } = payload;
|
|
20
|
+
editor.perform.applyMarks(sel, { [ITALIC_KEY]: keys[ITALIC_KEY] ? NIL : TRULY });
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
[LIST_TYPE_KEY]: (event, payload) => {
|
|
25
|
+
if (isKeyCode(event, KEY_CODE.SPACE) && payload.sel && payload.sel.isCollapsed) {
|
|
26
|
+
const { editor, sel } = payload;
|
|
27
|
+
const line = editor.state.block.getLine(sel.start.line);
|
|
28
|
+
const firstLeaf = line && line.getFirstLeaf();
|
|
29
|
+
const text = firstLeaf && firstLeaf.getText();
|
|
30
|
+
if (text === "1.") {
|
|
31
|
+
editor.perform.deleteForward(Range.fromTuple([sel.start.line, 0], [sel.start.line, 2]));
|
|
32
|
+
editor.command.exec(ORDER_LIST_KEY, { value: TRULY });
|
|
33
|
+
event.preventDefault();
|
|
34
|
+
return true;
|
|
35
|
+
}
|
|
36
|
+
if (text === "-") {
|
|
37
|
+
editor.perform.deleteForward(Range.fromTuple([sel.start.line, 0], [sel.start.line, 1]));
|
|
38
|
+
editor.command.exec(BULLET_LIST_KEY, { value: TRULY });
|
|
39
|
+
event.preventDefault();
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
export { PRESET_SHORTCUT };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isMatchHTMLTag, applyMarker } from '@block-kit/core';
|
|
2
2
|
import { EditorPlugin } from '@block-kit/react';
|
|
3
3
|
import { isHTMLElement, TRULY } from '@block-kit/utils';
|
|
4
|
-
import { STRIKE_KEY } from '
|
|
4
|
+
import { STRIKE_KEY } from './types/index.js';
|
|
5
5
|
|
|
6
6
|
class StrikePlugin extends EditorPlugin {
|
|
7
7
|
destroy() { }
|
|
@@ -4,11 +4,11 @@ import { useEditorStatic } from '@block-kit/react';
|
|
|
4
4
|
import { cs } from '@block-kit/utils';
|
|
5
5
|
import { useMemoFn } from '@block-kit/utils/dist/es/hooks';
|
|
6
6
|
import { forwardRef, useState, useEffect } from 'react';
|
|
7
|
-
import { PLUGIN_EVENTS } from '
|
|
8
|
-
import { filterLineMarkMap, filterMarkMap } from '
|
|
7
|
+
import { PLUGIN_EVENTS } from '../../shared/utils/event.js';
|
|
8
|
+
import { filterLineMarkMap, filterMarkMap } from '../utils/marks.js';
|
|
9
9
|
import { ToolbarContext } from './provider.js';
|
|
10
10
|
|
|
11
|
-
const Toolbar = forwardRef((props, ref) => {
|
|
11
|
+
const Toolbar = /*#__PURE__*/ forwardRef((props, ref) => {
|
|
12
12
|
const { editor } = useEditorStatic();
|
|
13
13
|
const [keys, setKeys] = useState({});
|
|
14
14
|
const refreshMarks = useMemoFn(() => {
|
|
@@ -21,16 +21,16 @@ const Toolbar = forwardRef((props, ref) => {
|
|
|
21
21
|
const { start, end } = current;
|
|
22
22
|
const lineMarkMap = filterLineMarkMap(lines.slice(start.line, end.line + 1).map(line => line.attributes));
|
|
23
23
|
if (current.isCollapsed) {
|
|
24
|
-
setKeys(Object.assign(Object.assign({}, editor.
|
|
24
|
+
setKeys(Object.assign(Object.assign({}, editor.lookup.marks), lineMarkMap));
|
|
25
25
|
return void 0;
|
|
26
26
|
}
|
|
27
27
|
const ops = [];
|
|
28
28
|
if (current.isCollapsed) {
|
|
29
|
-
const op = editor.
|
|
29
|
+
const op = editor.lookup.getOpAtPoint(current.start);
|
|
30
30
|
op && ops.push(op);
|
|
31
31
|
}
|
|
32
32
|
else {
|
|
33
|
-
const fragment = editor.
|
|
33
|
+
const fragment = editor.lookup.getFragment();
|
|
34
34
|
fragment && ops.push(...fragment);
|
|
35
35
|
}
|
|
36
36
|
const markMap = filterMarkMap(ops);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import "../styles/float.scss";
|
|
2
2
|
import type { FC } from "react";
|
|
3
3
|
export declare const FloatToolbar: FC<{
|
|
4
|
+
/**
|
|
5
|
+
* 样式类名
|
|
6
|
+
*/
|
|
4
7
|
className?: string;
|
|
5
8
|
/**
|
|
6
9
|
* Top 偏移
|
|
@@ -10,4 +13,15 @@ export declare const FloatToolbar: FC<{
|
|
|
10
13
|
* Left 偏移
|
|
11
14
|
*/
|
|
12
15
|
offsetLeft?: number;
|
|
16
|
+
/**
|
|
17
|
+
* 挂载的 DOM
|
|
18
|
+
*/
|
|
19
|
+
mountDOM?: HTMLElement;
|
|
20
|
+
/**
|
|
21
|
+
* 重载工具栏位置
|
|
22
|
+
*/
|
|
23
|
+
overridePosition?: (left: number, top: number) => {
|
|
24
|
+
left: number;
|
|
25
|
+
top: number;
|
|
26
|
+
};
|
|
13
27
|
}>;
|
|
@@ -5,7 +5,7 @@ import { cs } from '@block-kit/utils';
|
|
|
5
5
|
import { useMemoFn } from '@block-kit/utils/dist/es/hooks';
|
|
6
6
|
import { useRef, useState, useEffect, useMemo } from 'react';
|
|
7
7
|
import ReactDOM from 'react-dom';
|
|
8
|
-
import { getMountDOM } from '
|
|
8
|
+
import { getMountDOM } from '../../shared/utils/dom.js';
|
|
9
9
|
import { Toolbar } from './basic.js';
|
|
10
10
|
|
|
11
11
|
const FloatToolbar = props => {
|
|
@@ -58,10 +58,11 @@ const FloatToolbar = props => {
|
|
|
58
58
|
}
|
|
59
59
|
return { top: -999999, left: -999999 };
|
|
60
60
|
}, [editor.rect, readonly, visible, isMouseDown, props.offsetLeft, props.offsetTop]);
|
|
61
|
+
const overlay = props.overridePosition ? props.overridePosition(left, top) : { left, top };
|
|
61
62
|
// 只读状态 / 不可见 / 鼠标按下 时隐藏
|
|
62
63
|
return readonly || !visible || isMouseDown
|
|
63
64
|
? null
|
|
64
|
-
: ReactDOM.createPortal(jsx(Toolbar, { ref: ref, className: cs("block-kit-float-toolbar", props.className), styles: { top: top, left: left }, children: props.children }), getMountDOM(editor));
|
|
65
|
+
: ReactDOM.createPortal(jsx(Toolbar, { ref: ref, className: cs("block-kit-float-toolbar", props.className), styles: { top: overlay.top, left: overlay.left }, children: props.children }), props.mountDOM || getMountDOM(editor));
|
|
65
66
|
};
|
|
66
67
|
|
|
67
68
|
export { FloatToolbar };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
export { Toolbar } from "./context/basic";
|
|
3
3
|
export { FloatToolbar } from "./context/float";
|
|
4
|
-
export declare const
|
|
4
|
+
export declare const ToolBarMixin: {
|
|
5
5
|
Cut: import("react").FC;
|
|
6
6
|
Bold: import("react").FC;
|
|
7
7
|
Link: import("react").FC<{
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Align } from './modules/align.js';
|
|
2
|
+
import { Bold } from './modules/bold.js';
|
|
3
|
+
import { BulletList } from './modules/bullet-list.js';
|
|
4
|
+
import { Cut } from './modules/cut.js';
|
|
5
|
+
import { Divider } from './modules/divider.js';
|
|
6
|
+
import { Emoji } from './modules/emoji.js';
|
|
7
|
+
import { FontColor } from './modules/font-color.js';
|
|
8
|
+
import { FontSize } from './modules/font-size.js';
|
|
9
|
+
import { Heading } from './modules/heading.js';
|
|
10
|
+
import { History } from './modules/history.js';
|
|
11
|
+
import { Image } from './modules/image.js';
|
|
12
|
+
import { InlineCode } from './modules/inline-code.js';
|
|
13
|
+
import { Italic } from './modules/italic.js';
|
|
14
|
+
import { LineHeight } from './modules/line-height.js';
|
|
15
|
+
import { Link } from './modules/link.js';
|
|
16
|
+
import { OrderList } from './modules/order-list.js';
|
|
17
|
+
import { Quote } from './modules/quote.js';
|
|
18
|
+
import { Strike } from './modules/strike.js';
|
|
19
|
+
import { Underline } from './modules/underline.js';
|
|
20
|
+
export { Toolbar } from './context/basic.js';
|
|
21
|
+
export { FloatToolbar } from './context/float.js';
|
|
22
|
+
|
|
23
|
+
const ToolBarMixin = {
|
|
24
|
+
Cut,
|
|
25
|
+
Bold,
|
|
26
|
+
Link,
|
|
27
|
+
Quote,
|
|
28
|
+
Image,
|
|
29
|
+
Align,
|
|
30
|
+
Emoji,
|
|
31
|
+
Italic,
|
|
32
|
+
Strike,
|
|
33
|
+
History,
|
|
34
|
+
Heading,
|
|
35
|
+
Divider,
|
|
36
|
+
FontSize,
|
|
37
|
+
FontColor,
|
|
38
|
+
OrderList,
|
|
39
|
+
Underline,
|
|
40
|
+
BulletList,
|
|
41
|
+
InlineCode,
|
|
42
|
+
LineHeight,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export { ToolBarMixin };
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import Trigger from '@arco-design/web-react/es/Trigger';
|
|
3
|
+
import '@arco-design/web-react/es/Trigger/style';
|
|
4
|
+
import IconAlignCenter from '@arco-design/web-react/icon/react-icon/IconAlignCenter';
|
|
5
|
+
import IconAlignLeft from '@arco-design/web-react/icon/react-icon/IconAlignLeft';
|
|
6
|
+
import IconAlignRight from '@arco-design/web-react/icon/react-icon/IconAlignRight';
|
|
7
|
+
import IconDown from '@arco-design/web-react/icon/react-icon/IconDown';
|
|
4
8
|
import { NIL } from '@block-kit/utils';
|
|
5
|
-
import { ALIGN_KEY } from '
|
|
6
|
-
import { JustifyIcon } from '
|
|
7
|
-
import { useToolbarContext } from '
|
|
9
|
+
import { ALIGN_KEY } from '../../align/types/index.js';
|
|
10
|
+
import { JustifyIcon } from '../../shared/icons/justify.js';
|
|
11
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
8
12
|
|
|
9
13
|
const MAP = {
|
|
10
14
|
left: jsx(IconAlignLeft, {}),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import IconBold from '@arco-design/web-react/icon/react-icon/IconBold';
|
|
3
3
|
import { cs, NIL, TRULY } from '@block-kit/utils';
|
|
4
|
-
import { BOLD_KEY } from '
|
|
5
|
-
import { useToolbarContext } from '
|
|
4
|
+
import { BOLD_KEY } from '../../bold/types/index.js';
|
|
5
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
6
6
|
|
|
7
7
|
const Bold = () => {
|
|
8
8
|
const { keys, refreshMarks, editor } = useToolbarContext();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import IconUnorderedList from '@arco-design/web-react/icon/react-icon/IconUnorderedList';
|
|
3
3
|
import { cs, TRULY } from '@block-kit/utils';
|
|
4
|
-
import { BULLET_LIST_KEY } from '
|
|
5
|
-
import { isBulletList } from '
|
|
6
|
-
import { useToolbarContext } from '
|
|
4
|
+
import { BULLET_LIST_KEY } from '../../bullet-list/types/index.js';
|
|
5
|
+
import { isBulletList } from '../../bullet-list/utils/is.js';
|
|
6
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
7
7
|
|
|
8
8
|
const BulletList = () => {
|
|
9
9
|
const { keys, refreshMarks, editor } = useToolbarContext();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import { cs, TRULY } from '@block-kit/utils';
|
|
3
|
-
import { DIVIDER_KEY } from '
|
|
4
|
-
import { DividerIcon } from '
|
|
5
|
-
import { useToolbarContext } from '
|
|
3
|
+
import { DIVIDER_KEY } from '../../divider/types/index.js';
|
|
4
|
+
import { DividerIcon } from '../../shared/icons/divider.js';
|
|
5
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
6
6
|
|
|
7
7
|
const Divider = () => {
|
|
8
8
|
const { refreshMarks, editor } = useToolbarContext();
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import Trigger from '@arco-design/web-react/es/Trigger';
|
|
3
|
+
import '@arco-design/web-react/es/Trigger/style';
|
|
3
4
|
import Picker from '@emoji-mart/react';
|
|
4
5
|
import { cs } from '@block-kit/utils';
|
|
5
|
-
import { EMOJI_KEY } from '
|
|
6
|
-
import { EmojiIcon } from '
|
|
7
|
-
import { useToolbarContext } from '
|
|
6
|
+
import { EMOJI_KEY } from '../../emoji/types/index.js';
|
|
7
|
+
import { EmojiIcon } from '../../shared/icons/emoji.js';
|
|
8
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
8
9
|
|
|
9
10
|
const Emoji = () => {
|
|
10
11
|
const { editor } = useToolbarContext();
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import Trigger from '@arco-design/web-react/es/Trigger';
|
|
3
|
+
import '@arco-design/web-react/es/Trigger/style';
|
|
4
|
+
import IconDown from '@arco-design/web-react/icon/react-icon/IconDown';
|
|
4
5
|
import { cs } from '@block-kit/utils';
|
|
5
|
-
import { BACKGROUND_KEY } from '
|
|
6
|
-
import { FONT_COLOR_KEY } from '
|
|
7
|
-
import { FontColorIcon } from '
|
|
8
|
-
import { useToolbarContext } from '
|
|
6
|
+
import { BACKGROUND_KEY } from '../../background/types/index.js';
|
|
7
|
+
import { FONT_COLOR_KEY } from '../../font-color/types/index.js';
|
|
8
|
+
import { FontColorIcon } from '../../shared/icons/font-color.js';
|
|
9
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
9
10
|
|
|
10
11
|
const COLOR = [
|
|
11
12
|
"",
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import Trigger from '@arco-design/web-react/es/Trigger';
|
|
3
|
+
import '@arco-design/web-react/es/Trigger/style';
|
|
4
|
+
import IconCheck from '@arco-design/web-react/icon/react-icon/IconCheck';
|
|
5
|
+
import IconDown from '@arco-design/web-react/icon/react-icon/IconDown';
|
|
4
6
|
import { NIL } from '@block-kit/utils';
|
|
5
7
|
import { useRef } from 'react';
|
|
6
|
-
import { FONT_SIZE_KEY } from '
|
|
7
|
-
import { FontSizeIcon } from '
|
|
8
|
-
import { useToolbarContext } from '
|
|
8
|
+
import { FONT_SIZE_KEY } from '../../font-size/types/index.js';
|
|
9
|
+
import { FontSizeIcon } from '../../shared/icons/font-size.js';
|
|
10
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
9
11
|
|
|
10
12
|
const STEP = Array(10)
|
|
11
13
|
.fill(null)
|
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import Trigger from '@arco-design/web-react/es/Trigger';
|
|
3
|
+
import '@arco-design/web-react/es/Trigger/style';
|
|
4
|
+
import IconDown from '@arco-design/web-react/icon/react-icon/IconDown';
|
|
5
|
+
import IconH1 from '@arco-design/web-react/icon/react-icon/IconH1';
|
|
6
|
+
import IconH2 from '@arco-design/web-react/icon/react-icon/IconH2';
|
|
7
|
+
import IconH3 from '@arco-design/web-react/icon/react-icon/IconH3';
|
|
4
8
|
import { NIL } from '@block-kit/utils';
|
|
5
|
-
import { HEADING_KEY } from '
|
|
6
|
-
import { TextIcon } from '
|
|
7
|
-
import { useToolbarContext } from '
|
|
9
|
+
import { HEADING_KEY } from '../../heading/types/index.js';
|
|
10
|
+
import { TextIcon } from '../../shared/icons/text.js';
|
|
11
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
8
12
|
|
|
9
13
|
const MAP = {
|
|
10
14
|
h1: jsx(IconH1, {}),
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import IconRedo from '@arco-design/web-react/icon/react-icon/IconRedo';
|
|
3
|
+
import IconUndo from '@arco-design/web-react/icon/react-icon/IconUndo';
|
|
3
4
|
import { EDITOR_EVENT } from '@block-kit/core';
|
|
4
5
|
import { cs } from '@block-kit/utils';
|
|
5
6
|
import { useMemoFn } from '@block-kit/utils/dist/es/hooks';
|
|
6
7
|
import { useState, useEffect, Fragment } from 'react';
|
|
7
|
-
import { useToolbarContext } from '
|
|
8
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
8
9
|
|
|
9
10
|
const History = () => {
|
|
10
11
|
const { editor, refreshMarks } = useToolbarContext();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import IconImage from '@arco-design/web-react/icon/react-icon/IconImage';
|
|
3
3
|
import { cs, TRULY } from '@block-kit/utils';
|
|
4
|
-
import { IMAGE_KEY } from '
|
|
5
|
-
import { useToolbarContext } from '
|
|
4
|
+
import { IMAGE_KEY } from '../../image/types/index.js';
|
|
5
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
6
6
|
|
|
7
7
|
const Image = () => {
|
|
8
8
|
const { refreshMarks, editor } = useToolbarContext();
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
|
+
import IconCode from '@arco-design/web-react/icon/react-icon/IconCode';
|
|
3
|
+
import { cs, NIL, TRULY } from '@block-kit/utils';
|
|
4
|
+
import { INLINE_CODE_KEY } from '../../inline-code/types/index.js';
|
|
5
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
6
|
+
|
|
7
|
+
const InlineCode = () => {
|
|
8
|
+
const { keys, refreshMarks, editor } = useToolbarContext();
|
|
9
|
+
return (jsx("div", { className: cs("menu-toolbar-item", keys[INLINE_CODE_KEY] && "active"), onClick: () => {
|
|
10
|
+
editor.command.exec(INLINE_CODE_KEY, { value: keys[INLINE_CODE_KEY] ? NIL : TRULY });
|
|
11
|
+
refreshMarks();
|
|
12
|
+
}, children: jsx(IconCode, {}) }));
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
export { InlineCode };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import IconItalic from '@arco-design/web-react/icon/react-icon/IconItalic';
|
|
3
3
|
import { cs, NIL, TRULY } from '@block-kit/utils';
|
|
4
|
-
import { ITALIC_KEY } from '
|
|
5
|
-
import { useToolbarContext } from '
|
|
4
|
+
import { ITALIC_KEY } from '../../italic/types/index.js';
|
|
5
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
6
6
|
|
|
7
7
|
const Italic = () => {
|
|
8
8
|
const { keys, refreshMarks, editor } = useToolbarContext();
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import Trigger from '@arco-design/web-react/es/Trigger';
|
|
3
|
+
import '@arco-design/web-react/es/Trigger/style';
|
|
4
|
+
import IconCheck from '@arco-design/web-react/icon/react-icon/IconCheck';
|
|
5
|
+
import IconDown from '@arco-design/web-react/icon/react-icon/IconDown';
|
|
4
6
|
import { NIL } from '@block-kit/utils';
|
|
5
|
-
import { LINE_HEIGHT_KEY } from '
|
|
6
|
-
import { LineHeightIcon } from '
|
|
7
|
-
import { useToolbarContext } from '
|
|
7
|
+
import { LINE_HEIGHT_KEY } from '../../line-height/types/index.js';
|
|
8
|
+
import { LineHeightIcon } from '../../shared/icons/line-height.js';
|
|
9
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
8
10
|
|
|
9
11
|
const STEP = [...Array.from({ length: 11 }, (_, i) => i * 0.1 + 1.5), 3].map(v => v.toFixed(1).toString());
|
|
10
12
|
const LineHeight = () => {
|
|
@@ -1,12 +1,22 @@
|
|
|
1
1
|
import { jsx, jsxs } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import Button from '@arco-design/web-react/es/Button';
|
|
3
|
+
import '@arco-design/web-react/es/Button/style';
|
|
4
|
+
import Form from '@arco-design/web-react/es/Form';
|
|
5
|
+
import '@arco-design/web-react/es/Form/style';
|
|
6
|
+
import Input from '@arco-design/web-react/es/Input';
|
|
7
|
+
import '@arco-design/web-react/es/Input/style';
|
|
8
|
+
import Switch from '@arco-design/web-react/es/Switch';
|
|
9
|
+
import '@arco-design/web-react/es/Switch/style';
|
|
10
|
+
import Trigger from '@arco-design/web-react/es/Trigger';
|
|
11
|
+
import '@arco-design/web-react/es/Trigger/style';
|
|
3
12
|
import useForm from '@arco-design/web-react/es/Form/useForm';
|
|
4
|
-
import
|
|
13
|
+
import IconLink from '@arco-design/web-react/icon/react-icon/IconLink';
|
|
14
|
+
import IconRight from '@arco-design/web-react/icon/react-icon/IconRight';
|
|
5
15
|
import { APPLY_SOURCE, EDITOR_EVENT } from '@block-kit/core';
|
|
6
16
|
import { cs, TRULY, NIL } from '@block-kit/utils';
|
|
7
17
|
import { useState, useEffect } from 'react';
|
|
8
|
-
import { LINK_KEY, LINK_BLANK_KEY, LINK_TEMP_KEY } from '
|
|
9
|
-
import { useToolbarContext } from '
|
|
18
|
+
import { LINK_KEY, LINK_BLANK_KEY, LINK_TEMP_KEY } from '../../link/types/index.js';
|
|
19
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
10
20
|
|
|
11
21
|
const Link = props => {
|
|
12
22
|
const [form] = useForm();
|
|
@@ -27,9 +37,9 @@ const Link = props => {
|
|
|
27
37
|
// 折叠选区的情况下则插入文本
|
|
28
38
|
if (!insert)
|
|
29
39
|
return void 0;
|
|
30
|
-
editor.
|
|
40
|
+
editor.lookup.marks = Object.assign(Object.assign({}, editor.lookup.marks), { [LINK_KEY]: filteredHref });
|
|
31
41
|
if (blank) {
|
|
32
|
-
editor.
|
|
42
|
+
editor.lookup.marks[LINK_BLANK_KEY] = TRULY;
|
|
33
43
|
}
|
|
34
44
|
editor.perform.insertText(sel, insert);
|
|
35
45
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import IconOrderedList from '@arco-design/web-react/icon/react-icon/IconOrderedList';
|
|
3
3
|
import { cs, TRULY } from '@block-kit/utils';
|
|
4
|
-
import { ORDER_LIST_KEY } from '
|
|
5
|
-
import { isOrderList } from '
|
|
6
|
-
import { useToolbarContext } from '
|
|
4
|
+
import { ORDER_LIST_KEY } from '../../order-list/types/index.js';
|
|
5
|
+
import { isOrderList } from '../../order-list/utils/is.js';
|
|
6
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
7
7
|
|
|
8
8
|
const OrderList = () => {
|
|
9
9
|
const { keys, refreshMarks, editor } = useToolbarContext();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import IconQuote from '@arco-design/web-react/icon/react-icon/IconQuote';
|
|
3
3
|
import { cs, TRULY } from '@block-kit/utils';
|
|
4
|
-
import { QUOTE_KEY } from '
|
|
5
|
-
import { useToolbarContext } from '
|
|
4
|
+
import { QUOTE_KEY } from '../../quote/types/index.js';
|
|
5
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
6
6
|
|
|
7
7
|
const Quote = () => {
|
|
8
8
|
const { keys, refreshMarks, editor } = useToolbarContext();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import IconStrikethrough from '@arco-design/web-react/icon/react-icon/IconStrikethrough';
|
|
3
3
|
import { cs, NIL, TRULY } from '@block-kit/utils';
|
|
4
|
-
import { STRIKE_KEY } from '
|
|
5
|
-
import { useToolbarContext } from '
|
|
4
|
+
import { STRIKE_KEY } from '../../strike/types/index.js';
|
|
5
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
6
6
|
|
|
7
7
|
const Strike = () => {
|
|
8
8
|
const { keys, refreshMarks, editor } = useToolbarContext();
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
|
-
import
|
|
2
|
+
import IconUnderline from '@arco-design/web-react/icon/react-icon/IconUnderline';
|
|
3
3
|
import { cs, NIL, TRULY } from '@block-kit/utils';
|
|
4
|
-
import { UNDERLINE_KEY } from '
|
|
5
|
-
import { useToolbarContext } from '
|
|
4
|
+
import { UNDERLINE_KEY } from '../../underline/types/index.js';
|
|
5
|
+
import { useToolbarContext } from '../context/provider.js';
|
|
6
6
|
|
|
7
7
|
const Underline = () => {
|
|
8
8
|
const { keys, refreshMarks, editor } = useToolbarContext();
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { BOLD_KEY } from '../../bold/types/index.js';
|
|
2
|
+
import { INLINE_CODE_KEY } from '../../inline-code/types/index.js';
|
|
3
|
+
|
|
4
|
+
const TOOLBAR_TYPES = [BOLD_KEY, INLINE_CODE_KEY];
|
|
5
|
+
const TOOLBAR_KEY_SET = new Set(TOOLBAR_TYPES);
|
|
6
|
+
|
|
7
|
+
export { TOOLBAR_KEY_SET, TOOLBAR_TYPES };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isMatchHTMLTag, applyMarker } from '@block-kit/core';
|
|
2
2
|
import { EditorPlugin } from '@block-kit/react';
|
|
3
3
|
import { isHTMLElement, TRULY } from '@block-kit/utils';
|
|
4
|
-
import { UNDERLINE_KEY } from '
|
|
4
|
+
import { UNDERLINE_KEY } from './types/index.js';
|
|
5
5
|
|
|
6
6
|
class UnderlinePlugin extends EditorPlugin {
|
|
7
7
|
destroy() { }
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var tslib_es6 = require('../tslib.es6-
|
|
5
|
+
var tslib_es6 = require('../tslib.es6-04264fd3.js');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
7
|
var core = require('@block-kit/core');
|
|
8
8
|
var delta = require('@block-kit/delta');
|