@block-kit/plugin 1.0.7 → 1.0.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/es/bullet-list/index.js +1 -1
- package/dist/es/divider/index.js +1 -1
- package/dist/es/emoji/index.js +1 -1
- package/dist/es/font-size/index.js +2 -2
- package/dist/es/image/index.js +1 -1
- package/dist/es/image/view/image.js +2 -2
- package/dist/es/indent/index.js +1 -1
- package/dist/es/index.js +1 -1
- package/dist/es/inline-code/index.js +1 -1
- package/dist/es/link/index.d.ts +3 -2
- package/dist/es/link/index.js +32 -11
- package/dist/es/link/utils/constant.d.ts +1 -0
- package/dist/es/link/utils/constant.js +3 -0
- package/dist/es/mention/modules/suggest.js +1 -1
- package/dist/es/order-list/index.js +1 -1
- package/dist/es/quote/index.js +1 -1
- package/dist/es/shared/components/selection.js +1 -3
- package/dist/es/shared/modules/selection.js +1 -1
- package/dist/es/shortcut/index.js +1 -1
- package/dist/es/toolbar/context/float.js +13 -11
- 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/font-size/index.js +1 -1
- package/dist/lib/image/index.js +1 -1
- package/dist/lib/image/view/image.js +1 -1
- package/dist/lib/indent/index.js +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/inline-code/index.js +1 -1
- package/dist/lib/link/index.d.ts +3 -2
- package/dist/lib/link/index.js +31 -10
- package/dist/lib/link/utils/constant.d.ts +1 -0
- package/dist/lib/link/utils/constant.js +7 -0
- package/dist/lib/mention/modules/suggest.js +1 -1
- package/dist/lib/order-list/index.js +1 -1
- package/dist/lib/quote/index.js +1 -1
- package/dist/lib/shared/components/selection.js +1 -3
- package/dist/lib/shared/modules/selection.js +1 -1
- package/dist/lib/shortcut/index.js +1 -1
- package/dist/lib/toolbar/context/float.js +12 -10
- package/package.json +5 -5
- /package/dist/es/{tslib.es6-31bcb85d.js → tslib.es6-d7b0be1e.js} +0 -0
- /package/dist/lib/{tslib.es6-b94b9fac.js → tslib.es6-6418d6c4.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as __decorate } from '../tslib.es6-
|
|
1
|
+
import { _ as __decorate } from '../tslib.es6-d7b0be1e.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';
|
package/dist/es/divider/index.js
CHANGED
package/dist/es/emoji/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { EditorPlugin } from '@block-kit/react';
|
|
2
|
-
import {
|
|
2
|
+
import { Facade } from '@block-kit/utils';
|
|
3
3
|
import { FONT_SIZE_KEY } from './types/index.js';
|
|
4
4
|
|
|
5
5
|
class FontSizePlugin extends EditorPlugin {
|
|
@@ -19,7 +19,7 @@ class FontSizePlugin extends EditorPlugin {
|
|
|
19
19
|
const attrs = context.attributes || {};
|
|
20
20
|
const size = attrs[FONT_SIZE_KEY];
|
|
21
21
|
if (size) {
|
|
22
|
-
context.style.fontSize =
|
|
22
|
+
context.style.fontSize = Facade.pixelate(size);
|
|
23
23
|
}
|
|
24
24
|
return context.children;
|
|
25
25
|
}
|
package/dist/es/image/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as __decorate, a as __awaiter } from '../tslib.es6-
|
|
1
|
+
import { _ as __decorate, a as __awaiter } from '../tslib.es6-d7b0be1e.js';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { Point, Range, RawRange, APPLY_SOURCE } from '@block-kit/core';
|
|
4
4
|
import { Delta } from '@block-kit/delta';
|
|
@@ -3,7 +3,7 @@ import IconLoading from '@arco-design/web-react/icon/react-icon/IconLoading';
|
|
|
3
3
|
import { RawRange, APPLY_SOURCE } from '@block-kit/core';
|
|
4
4
|
import { Delta } from '@block-kit/delta';
|
|
5
5
|
import { Void } from '@block-kit/react';
|
|
6
|
-
import {
|
|
6
|
+
import { Facade } from '@block-kit/utils';
|
|
7
7
|
import { SelectionHOC } from '../../shared/components/selection.js';
|
|
8
8
|
import { IMAGE_SRC, IMAGE_WIDTH, IMAGE_HEIGHT, IMAGE_STATUS, LOADING_STATUS, IMAGE_SCALE } from '../types/index.js';
|
|
9
9
|
import { ImageWrapper } from './wrapper.js';
|
|
@@ -33,7 +33,7 @@ const ImageView = props => {
|
|
|
33
33
|
const delta = new Delta().retain(rawRange.start).retain(rawRange.len, next);
|
|
34
34
|
editor.state.apply(delta, { source: APPLY_SOURCE.NO_UNDO, autoCaret: false });
|
|
35
35
|
};
|
|
36
|
-
return (jsxs(Void, { className: "block-kit-image-container", context: context, children: [status === LOADING_STATUS.LOADING && (jsx("div", { className: "block-kit-image-loading", children: jsx(IconLoading, {}) })), jsx(SelectionHOC, { selection: selection, leaf: context.leafState, children: jsx(ImageWrapper, { editor: props.editor, src: src, leaf: context.leafState, children: jsx("img", { className: "block-kit-image", src: src, onLoad: onImageLoad, width:
|
|
36
|
+
return (jsxs(Void, { className: "block-kit-image-container", context: context, children: [status === LOADING_STATUS.LOADING && (jsx("div", { className: "block-kit-image-loading", children: jsx(IconLoading, {}) })), jsx(SelectionHOC, { selection: selection, leaf: context.leafState, children: jsx(ImageWrapper, { editor: props.editor, src: src, leaf: context.leafState, children: jsx("img", { className: "block-kit-image", src: src, onLoad: onImageLoad, width: Facade.pixelate(width), height: Facade.pixelate(height) }) }) })] }));
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
export { ImageView };
|
package/dist/es/indent/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as __decorate } from '../tslib.es6-
|
|
1
|
+
import { _ as __decorate } from '../tslib.es6-d7b0be1e.js';
|
|
2
2
|
import { EDITOR_EVENT, RawPoint, Point } from '@block-kit/core';
|
|
3
3
|
import { Delta } from '@block-kit/delta';
|
|
4
4
|
import { EditorPlugin } from '@block-kit/react';
|
package/dist/es/index.js
CHANGED
|
@@ -49,6 +49,6 @@ export { UNDERLINE_KEY } from './underline/types/index.js';
|
|
|
49
49
|
export { FloatToolbar } from './toolbar/context/float.js';
|
|
50
50
|
export { Toolbar } from './toolbar/context/basic.js';
|
|
51
51
|
|
|
52
|
-
const BLOCK_KIT_VERSION = "1.0.
|
|
52
|
+
const BLOCK_KIT_VERSION = "1.0.9" ;
|
|
53
53
|
|
|
54
54
|
export { BLOCK_KIT_VERSION };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as __decorate } from '../tslib.es6-
|
|
1
|
+
import { _ as __decorate } from '../tslib.es6-d7b0be1e.js';
|
|
2
2
|
import { Priority } from '@block-kit/core';
|
|
3
3
|
import { EditorPlugin } from '@block-kit/react';
|
|
4
4
|
import { INLINE_CODE_KEY } from './types/index.js';
|
package/dist/es/link/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { Editor } from "@block-kit/core";
|
|
2
|
+
import type { Editor, PasteContext } from "@block-kit/core";
|
|
3
3
|
import type { CMDPayload } from "@block-kit/core";
|
|
4
4
|
import type { AttributeMap } from "@block-kit/delta";
|
|
5
5
|
import type { ReactLeafContext, ReactWrapLeafContext } from "@block-kit/react";
|
|
@@ -11,7 +11,8 @@ export declare class LinkPlugin extends EditorPlugin {
|
|
|
11
11
|
constructor(editor: Editor);
|
|
12
12
|
destroy(): void;
|
|
13
13
|
match(attrs: AttributeMap): boolean;
|
|
14
|
+
onExec(payload: CMDPayload): undefined;
|
|
15
|
+
willApplyPasteDelta(context: PasteContext): PasteContext;
|
|
14
16
|
wrapLeaf(context: ReactWrapLeafContext): React.ReactNode;
|
|
15
17
|
renderLeaf(context: ReactLeafContext): React.ReactNode;
|
|
16
|
-
onExec(payload: CMDPayload): undefined;
|
|
17
18
|
}
|
package/dist/es/link/index.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import { _ as __decorate } from '../tslib.es6-
|
|
1
|
+
import { _ as __decorate } from '../tslib.es6-d7b0be1e.js';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
|
+
import { Delta, getOpLength } from '@block-kit/delta';
|
|
3
4
|
import { InjectWrapKeys, EditorPlugin } from '@block-kit/react';
|
|
4
5
|
import { Bind } from '@block-kit/utils';
|
|
5
|
-
import { LINK_KEY, LINK_TEMP_KEY } from './types/index.js';
|
|
6
|
+
import { LINK_KEY, LINK_TEMP_KEY, LINK_BLANK_KEY } from './types/index.js';
|
|
7
|
+
import { LINK_REG } from './utils/constant.js';
|
|
6
8
|
import { A } from './view/a.js';
|
|
7
9
|
|
|
8
10
|
class LinkPlugin extends EditorPlugin {
|
|
@@ -20,6 +22,31 @@ class LinkPlugin extends EditorPlugin {
|
|
|
20
22
|
match(attrs) {
|
|
21
23
|
return !!attrs[LINK_KEY] || !!attrs[LINK_TEMP_KEY];
|
|
22
24
|
}
|
|
25
|
+
onExec(payload) {
|
|
26
|
+
const range = this.editor.selection.get() || payload.range;
|
|
27
|
+
const attrs = payload.attrs;
|
|
28
|
+
if (!range || attrs) {
|
|
29
|
+
return void 0;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
willApplyPasteDelta(context) {
|
|
33
|
+
const delta = context.delta;
|
|
34
|
+
const changes = new Delta();
|
|
35
|
+
for (const op of delta.ops) {
|
|
36
|
+
const len = getOpLength(op);
|
|
37
|
+
// 粘贴文本内容自动应用为超链接状态
|
|
38
|
+
let res = null;
|
|
39
|
+
if (op.insert && (res = LINK_REG.exec(op.insert))) {
|
|
40
|
+
const link = res[0];
|
|
41
|
+
changes.retain(link.length, { [LINK_KEY]: link, [LINK_BLANK_KEY]: "true" });
|
|
42
|
+
changes.retain(len - link.length);
|
|
43
|
+
continue;
|
|
44
|
+
}
|
|
45
|
+
changes.retain(len);
|
|
46
|
+
}
|
|
47
|
+
context.delta = delta.compose(changes);
|
|
48
|
+
return context;
|
|
49
|
+
}
|
|
23
50
|
wrapLeaf(context) {
|
|
24
51
|
const state = context.leafState;
|
|
25
52
|
const attrs = state.op.attributes || {};
|
|
@@ -35,18 +62,12 @@ class LinkPlugin extends EditorPlugin {
|
|
|
35
62
|
}
|
|
36
63
|
return context.children;
|
|
37
64
|
}
|
|
38
|
-
onExec(payload) {
|
|
39
|
-
const range = this.editor.selection.get() || payload.range;
|
|
40
|
-
const attrs = payload.attrs;
|
|
41
|
-
if (!range || attrs)
|
|
42
|
-
return void 0;
|
|
43
|
-
}
|
|
44
65
|
}
|
|
45
|
-
__decorate([
|
|
46
|
-
InjectWrapKeys(LINK_KEY)
|
|
47
|
-
], LinkPlugin.prototype, "wrapLeaf", null);
|
|
48
66
|
__decorate([
|
|
49
67
|
Bind
|
|
50
68
|
], LinkPlugin.prototype, "onExec", null);
|
|
69
|
+
__decorate([
|
|
70
|
+
InjectWrapKeys(LINK_KEY)
|
|
71
|
+
], LinkPlugin.prototype, "wrapLeaf", null);
|
|
51
72
|
|
|
52
73
|
export { LinkPlugin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LINK_REG: RegExp;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as __decorate } from '../../tslib.es6-
|
|
1
|
+
import { _ as __decorate } from '../../tslib.es6-d7b0be1e.js';
|
|
2
2
|
import { jsx } from 'react/jsx-runtime';
|
|
3
3
|
import { Point, EDITOR_EVENT, relativeTo, Range } from '@block-kit/core';
|
|
4
4
|
import { deltaToText, Delta } from '@block-kit/delta';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as __decorate } from '../tslib.es6-
|
|
1
|
+
import { _ as __decorate } from '../tslib.es6-d7b0be1e.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';
|
package/dist/es/quote/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as __decorate } from '../tslib.es6-
|
|
1
|
+
import { _ as __decorate } from '../tslib.es6-d7b0be1e.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';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { _ as __decorate } from '../tslib.es6-
|
|
1
|
+
import { _ as __decorate } from '../tslib.es6-d7b0be1e.js';
|
|
2
2
|
import { CorePlugin, EDITOR_EVENT } from '@block-kit/core';
|
|
3
3
|
import { Bind } from '@block-kit/utils';
|
|
4
4
|
import { PLUGIN_EVENTS } from '../shared/utils/event.js';
|
|
@@ -2,7 +2,7 @@ import { jsx } from 'react/jsx-runtime';
|
|
|
2
2
|
import { EDITOR_EVENT } from '@block-kit/core';
|
|
3
3
|
import { useEditorStatic, useReadonly, MountNode } from '@block-kit/react';
|
|
4
4
|
import { cs } from '@block-kit/utils';
|
|
5
|
-
import { useMemoFn } from '@block-kit/utils/dist/es/hooks';
|
|
5
|
+
import { useForceUpdate, 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
8
|
import { Toolbar } from './basic.js';
|
|
@@ -11,11 +11,13 @@ const FloatToolbar = props => {
|
|
|
11
11
|
const { editor } = useEditorStatic();
|
|
12
12
|
const { readonly } = useReadonly();
|
|
13
13
|
const ref = useRef(null);
|
|
14
|
-
const
|
|
14
|
+
const { index, forceUpdate } = useForceUpdate();
|
|
15
15
|
const [isMouseDown, setIsMouseDown] = useState(false);
|
|
16
|
-
const
|
|
17
|
-
|
|
16
|
+
const [visible, setVisible] = useState(false);
|
|
17
|
+
const onCaretWeakUp = useMemoFn((wakeUp) => {
|
|
18
|
+
if (!readonly && editor.state.isFocused() && wakeUp) {
|
|
18
19
|
setVisible(true);
|
|
20
|
+
!isMouseDown && forceUpdate();
|
|
19
21
|
}
|
|
20
22
|
else {
|
|
21
23
|
setVisible(false);
|
|
@@ -36,7 +38,7 @@ const FloatToolbar = props => {
|
|
|
36
38
|
const onSelectionChange = (e) => {
|
|
37
39
|
const { current } = e;
|
|
38
40
|
const isWakeUp = current ? !current.isCollapsed : false;
|
|
39
|
-
|
|
41
|
+
onCaretWeakUp(isWakeUp);
|
|
40
42
|
};
|
|
41
43
|
document.addEventListener(EDITOR_EVENT.MOUSE_UP, onMouseUp);
|
|
42
44
|
document.addEventListener(EDITOR_EVENT.MOUSE_DOWN, onMouseDown);
|
|
@@ -46,14 +48,13 @@ const FloatToolbar = props => {
|
|
|
46
48
|
document.removeEventListener(EDITOR_EVENT.MOUSE_DOWN, onMouseDown);
|
|
47
49
|
editor.event.off(EDITOR_EVENT.SELECTION_CHANGE, onSelectionChange);
|
|
48
50
|
};
|
|
49
|
-
}, [editor,
|
|
50
|
-
const overridePosition = useRef(props.overridePosition);
|
|
51
|
+
}, [editor, onCaretWeakUp, readonly]);
|
|
51
52
|
const { left, top } = useMemo(() => {
|
|
52
53
|
if (!readonly && visible && !isMouseDown) {
|
|
53
|
-
if (overridePosition
|
|
54
|
-
return overridePosition
|
|
54
|
+
if (props.overridePosition) {
|
|
55
|
+
return props.overridePosition(); // overlay
|
|
55
56
|
}
|
|
56
|
-
const rect = editor.rect.
|
|
57
|
+
const rect = editor.rect.getCaretRect();
|
|
57
58
|
if (rect) {
|
|
58
59
|
const topOffset = props.offsetTop || 0;
|
|
59
60
|
const leftOffset = props.offsetLeft || 0;
|
|
@@ -63,7 +64,8 @@ const FloatToolbar = props => {
|
|
|
63
64
|
}
|
|
64
65
|
}
|
|
65
66
|
return { top: -999999, left: -999999 };
|
|
66
|
-
|
|
67
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
68
|
+
}, [index, readonly, visible, isMouseDown]);
|
|
67
69
|
// 只读状态 / 不可见 / 鼠标按下 时隐藏
|
|
68
70
|
return readonly || !visible || isMouseDown
|
|
69
71
|
? null
|
|
@@ -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-6418d6c4.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');
|
|
@@ -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-6418d6c4.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');
|
package/dist/lib/emoji/index.js
CHANGED
|
@@ -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-6418d6c4.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');
|
|
@@ -23,7 +23,7 @@ class FontSizePlugin extends react.EditorPlugin {
|
|
|
23
23
|
const attrs = context.attributes || {};
|
|
24
24
|
const size = attrs[fontSize_types_index.FONT_SIZE_KEY];
|
|
25
25
|
if (size) {
|
|
26
|
-
context.style.fontSize = utils.
|
|
26
|
+
context.style.fontSize = utils.Facade.pixelate(size);
|
|
27
27
|
}
|
|
28
28
|
return context.children;
|
|
29
29
|
}
|
package/dist/lib/image/index.js
CHANGED
|
@@ -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-6418d6c4.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');
|
|
@@ -41,7 +41,7 @@ const ImageView = props => {
|
|
|
41
41
|
const delta$1 = new delta.Delta().retain(rawRange.start).retain(rawRange.len, next);
|
|
42
42
|
editor.state.apply(delta$1, { source: core.APPLY_SOURCE.NO_UNDO, autoCaret: false });
|
|
43
43
|
};
|
|
44
|
-
return (jsxRuntime.jsxs(react.Void, { className: "block-kit-image-container", context: context, children: [status === image_types_index.LOADING_STATUS.LOADING && (jsxRuntime.jsx("div", { className: "block-kit-image-loading", children: jsxRuntime.jsx(IconLoading__default["default"], {}) })), jsxRuntime.jsx(shared_components_selection.SelectionHOC, { selection: selection, leaf: context.leafState, children: jsxRuntime.jsx(image_view_wrapper.ImageWrapper, { editor: props.editor, src: src, leaf: context.leafState, children: jsxRuntime.jsx("img", { className: "block-kit-image", src: src, onLoad: onImageLoad, width: utils.
|
|
44
|
+
return (jsxRuntime.jsxs(react.Void, { className: "block-kit-image-container", context: context, children: [status === image_types_index.LOADING_STATUS.LOADING && (jsxRuntime.jsx("div", { className: "block-kit-image-loading", children: jsxRuntime.jsx(IconLoading__default["default"], {}) })), jsxRuntime.jsx(shared_components_selection.SelectionHOC, { selection: selection, leaf: context.leafState, children: jsxRuntime.jsx(image_view_wrapper.ImageWrapper, { editor: props.editor, src: src, leaf: context.leafState, children: jsxRuntime.jsx("img", { className: "block-kit-image", src: src, onLoad: onImageLoad, width: utils.Facade.pixelate(width), height: utils.Facade.pixelate(height) }) }) })] }));
|
|
45
45
|
};
|
|
46
46
|
|
|
47
47
|
exports.ImageView = ImageView;
|
package/dist/lib/indent/index.js
CHANGED
|
@@ -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-6418d6c4.js');
|
|
6
6
|
var core = require('@block-kit/core');
|
|
7
7
|
var delta = require('@block-kit/delta');
|
|
8
8
|
var react = require('@block-kit/react');
|
package/dist/lib/index.js
CHANGED
|
@@ -53,7 +53,7 @@ var underline_types_index = require('./underline/types/index.js');
|
|
|
53
53
|
var toolbar_context_float = require('./toolbar/context/float.js');
|
|
54
54
|
var toolbar_context_basic = require('./toolbar/context/basic.js');
|
|
55
55
|
|
|
56
|
-
const BLOCK_KIT_VERSION = "1.0.
|
|
56
|
+
const BLOCK_KIT_VERSION = "1.0.9" ;
|
|
57
57
|
|
|
58
58
|
exports.AlignPlugin = align_index.AlignPlugin;
|
|
59
59
|
exports.ALIGN_KEY = align_types_index.ALIGN_KEY;
|
|
@@ -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-6418d6c4.js');
|
|
6
6
|
var core = require('@block-kit/core');
|
|
7
7
|
var react = require('@block-kit/react');
|
|
8
8
|
var inlineCode_types_index = require('./types/index.js');
|
package/dist/lib/link/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type { Editor } from "@block-kit/core";
|
|
2
|
+
import type { Editor, PasteContext } from "@block-kit/core";
|
|
3
3
|
import type { CMDPayload } from "@block-kit/core";
|
|
4
4
|
import type { AttributeMap } from "@block-kit/delta";
|
|
5
5
|
import type { ReactLeafContext, ReactWrapLeafContext } from "@block-kit/react";
|
|
@@ -11,7 +11,8 @@ export declare class LinkPlugin extends EditorPlugin {
|
|
|
11
11
|
constructor(editor: Editor);
|
|
12
12
|
destroy(): void;
|
|
13
13
|
match(attrs: AttributeMap): boolean;
|
|
14
|
+
onExec(payload: CMDPayload): undefined;
|
|
15
|
+
willApplyPasteDelta(context: PasteContext): PasteContext;
|
|
14
16
|
wrapLeaf(context: ReactWrapLeafContext): React.ReactNode;
|
|
15
17
|
renderLeaf(context: ReactLeafContext): React.ReactNode;
|
|
16
|
-
onExec(payload: CMDPayload): undefined;
|
|
17
18
|
}
|
package/dist/lib/link/index.js
CHANGED
|
@@ -2,11 +2,13 @@
|
|
|
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-6418d6c4.js');
|
|
6
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var delta = require('@block-kit/delta');
|
|
7
8
|
var react = require('@block-kit/react');
|
|
8
9
|
var utils = require('@block-kit/utils');
|
|
9
10
|
var link_types_index = require('./types/index.js');
|
|
11
|
+
var link_utils_constant = require('./utils/constant.js');
|
|
10
12
|
var link_view_a = require('./view/a.js');
|
|
11
13
|
|
|
12
14
|
class LinkPlugin extends react.EditorPlugin {
|
|
@@ -24,6 +26,31 @@ class LinkPlugin extends react.EditorPlugin {
|
|
|
24
26
|
match(attrs) {
|
|
25
27
|
return !!attrs[link_types_index.LINK_KEY] || !!attrs[link_types_index.LINK_TEMP_KEY];
|
|
26
28
|
}
|
|
29
|
+
onExec(payload) {
|
|
30
|
+
const range = this.editor.selection.get() || payload.range;
|
|
31
|
+
const attrs = payload.attrs;
|
|
32
|
+
if (!range || attrs) {
|
|
33
|
+
return void 0;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
willApplyPasteDelta(context) {
|
|
37
|
+
const delta$1 = context.delta;
|
|
38
|
+
const changes = new delta.Delta();
|
|
39
|
+
for (const op of delta$1.ops) {
|
|
40
|
+
const len = delta.getOpLength(op);
|
|
41
|
+
// 粘贴文本内容自动应用为超链接状态
|
|
42
|
+
let res = null;
|
|
43
|
+
if (op.insert && (res = link_utils_constant.LINK_REG.exec(op.insert))) {
|
|
44
|
+
const link = res[0];
|
|
45
|
+
changes.retain(link.length, { [link_types_index.LINK_KEY]: link, [link_types_index.LINK_BLANK_KEY]: "true" });
|
|
46
|
+
changes.retain(len - link.length);
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
changes.retain(len);
|
|
50
|
+
}
|
|
51
|
+
context.delta = delta$1.compose(changes);
|
|
52
|
+
return context;
|
|
53
|
+
}
|
|
27
54
|
wrapLeaf(context) {
|
|
28
55
|
const state = context.leafState;
|
|
29
56
|
const attrs = state.op.attributes || {};
|
|
@@ -39,18 +66,12 @@ class LinkPlugin extends react.EditorPlugin {
|
|
|
39
66
|
}
|
|
40
67
|
return context.children;
|
|
41
68
|
}
|
|
42
|
-
onExec(payload) {
|
|
43
|
-
const range = this.editor.selection.get() || payload.range;
|
|
44
|
-
const attrs = payload.attrs;
|
|
45
|
-
if (!range || attrs)
|
|
46
|
-
return void 0;
|
|
47
|
-
}
|
|
48
69
|
}
|
|
49
|
-
tslib_es6.__decorate([
|
|
50
|
-
react.InjectWrapKeys(link_types_index.LINK_KEY)
|
|
51
|
-
], LinkPlugin.prototype, "wrapLeaf", null);
|
|
52
70
|
tslib_es6.__decorate([
|
|
53
71
|
utils.Bind
|
|
54
72
|
], LinkPlugin.prototype, "onExec", null);
|
|
73
|
+
tslib_es6.__decorate([
|
|
74
|
+
react.InjectWrapKeys(link_types_index.LINK_KEY)
|
|
75
|
+
], LinkPlugin.prototype, "wrapLeaf", null);
|
|
55
76
|
|
|
56
77
|
exports.LinkPlugin = LinkPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LINK_REG: RegExp;
|
|
@@ -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-6418d6c4.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');
|
|
@@ -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-6418d6c4.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');
|
package/dist/lib/quote/index.js
CHANGED
|
@@ -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-6418d6c4.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');
|
|
@@ -50,9 +50,7 @@ class SelectionHOC extends React__default["default"].PureComponent {
|
|
|
50
50
|
const { props } = child;
|
|
51
51
|
return React__default["default"].cloneElement(child, Object.assign(Object.assign({}, props), { selected: selected }));
|
|
52
52
|
}
|
|
53
|
-
|
|
54
|
-
return child;
|
|
55
|
-
}
|
|
53
|
+
return child;
|
|
56
54
|
}) }));
|
|
57
55
|
}
|
|
58
56
|
}
|
|
@@ -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-6418d6c4.js');
|
|
6
6
|
var core = require('@block-kit/core');
|
|
7
7
|
var utils = require('@block-kit/utils');
|
|
8
8
|
|
|
@@ -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-6418d6c4.js');
|
|
6
6
|
var core = require('@block-kit/core');
|
|
7
7
|
var utils = require('@block-kit/utils');
|
|
8
8
|
var shared_utils_event = require('../shared/utils/event.js');
|
|
@@ -19,11 +19,13 @@ const FloatToolbar = props => {
|
|
|
19
19
|
const { editor } = react.useEditorStatic();
|
|
20
20
|
const { readonly } = react.useReadonly();
|
|
21
21
|
const ref = React.useRef(null);
|
|
22
|
-
const
|
|
22
|
+
const { index, forceUpdate } = hooks.useForceUpdate();
|
|
23
23
|
const [isMouseDown, setIsMouseDown] = React.useState(false);
|
|
24
|
-
const
|
|
25
|
-
|
|
24
|
+
const [visible, setVisible] = React.useState(false);
|
|
25
|
+
const onCaretWeakUp = hooks.useMemoFn((wakeUp) => {
|
|
26
|
+
if (!readonly && editor.state.isFocused() && wakeUp) {
|
|
26
27
|
setVisible(true);
|
|
28
|
+
!isMouseDown && forceUpdate();
|
|
27
29
|
}
|
|
28
30
|
else {
|
|
29
31
|
setVisible(false);
|
|
@@ -44,7 +46,7 @@ const FloatToolbar = props => {
|
|
|
44
46
|
const onSelectionChange = (e) => {
|
|
45
47
|
const { current } = e;
|
|
46
48
|
const isWakeUp = current ? !current.isCollapsed : false;
|
|
47
|
-
|
|
49
|
+
onCaretWeakUp(isWakeUp);
|
|
48
50
|
};
|
|
49
51
|
document.addEventListener(core.EDITOR_EVENT.MOUSE_UP, onMouseUp);
|
|
50
52
|
document.addEventListener(core.EDITOR_EVENT.MOUSE_DOWN, onMouseDown);
|
|
@@ -54,14 +56,13 @@ const FloatToolbar = props => {
|
|
|
54
56
|
document.removeEventListener(core.EDITOR_EVENT.MOUSE_DOWN, onMouseDown);
|
|
55
57
|
editor.event.off(core.EDITOR_EVENT.SELECTION_CHANGE, onSelectionChange);
|
|
56
58
|
};
|
|
57
|
-
}, [editor,
|
|
58
|
-
const overridePosition = React.useRef(props.overridePosition);
|
|
59
|
+
}, [editor, onCaretWeakUp, readonly]);
|
|
59
60
|
const { left, top } = React.useMemo(() => {
|
|
60
61
|
if (!readonly && visible && !isMouseDown) {
|
|
61
|
-
if (overridePosition
|
|
62
|
-
return overridePosition
|
|
62
|
+
if (props.overridePosition) {
|
|
63
|
+
return props.overridePosition(); // overlay
|
|
63
64
|
}
|
|
64
|
-
const rect = editor.rect.
|
|
65
|
+
const rect = editor.rect.getCaretRect();
|
|
65
66
|
if (rect) {
|
|
66
67
|
const topOffset = props.offsetTop || 0;
|
|
67
68
|
const leftOffset = props.offsetLeft || 0;
|
|
@@ -71,7 +72,8 @@ const FloatToolbar = props => {
|
|
|
71
72
|
}
|
|
72
73
|
}
|
|
73
74
|
return { top: -999999, left: -999999 };
|
|
74
|
-
|
|
75
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
76
|
+
}, [index, readonly, visible, isMouseDown]);
|
|
75
77
|
// 只读状态 / 不可见 / 鼠标按下 时隐藏
|
|
76
78
|
return readonly || !visible || isMouseDown
|
|
77
79
|
? null
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@block-kit/plugin",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.9",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "./dist/lib/index.js",
|
|
6
6
|
"types": "./dist/es/index.d.ts",
|
|
@@ -39,10 +39,10 @@
|
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@arco-design/web-react": "2.64.0",
|
|
42
|
-
"@block-kit/core": "1.0.
|
|
43
|
-
"@block-kit/delta": "1.0.
|
|
44
|
-
"@block-kit/react": "1.0.
|
|
45
|
-
"@block-kit/utils": "1.0.
|
|
42
|
+
"@block-kit/core": "1.0.9",
|
|
43
|
+
"@block-kit/delta": "1.0.9",
|
|
44
|
+
"@block-kit/react": "1.0.9",
|
|
45
|
+
"@block-kit/utils": "1.0.9",
|
|
46
46
|
"@emoji-mart/data": "1.2.1",
|
|
47
47
|
"@emoji-mart/react": "1.1.1",
|
|
48
48
|
"emoji-mart": "5.6.0"
|
|
File without changes
|
|
File without changes
|