@block-kit/plugin 1.0.0
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/index.d.ts +12 -0
- package/dist/es/align/index.js +25 -0
- package/dist/es/align/types/index.d.ts +1 -0
- package/dist/es/align/types/index.js +3 -0
- package/dist/es/background/index.d.ts +12 -0
- package/dist/es/background/index.js +27 -0
- package/dist/es/background/types/index.d.ts +1 -0
- package/dist/es/background/types/index.js +3 -0
- package/dist/es/bold/index.d.ts +15 -0
- package/dist/es/bold/index.js +46 -0
- package/dist/es/bold/types/index.d.ts +1 -0
- package/dist/es/bold/types/index.js +3 -0
- package/dist/es/bullet-list/index.d.ts +16 -0
- package/dist/es/bullet-list/index.js +149 -0
- package/dist/es/bullet-list/types/index.d.ts +6 -0
- package/dist/es/bullet-list/types/index.js +8 -0
- package/dist/es/bullet-list/utils/is.d.ts +6 -0
- package/dist/es/bullet-list/view/list.d.ts +9 -0
- package/dist/es/divider/index.d.ts +17 -0
- package/dist/es/divider/index.js +60 -0
- package/dist/es/divider/types/index.d.ts +1 -0
- package/dist/es/divider/types/index.js +3 -0
- package/dist/es/dom-71a99400.js +45 -0
- package/dist/es/emoji/index.d.ts +16 -0
- package/dist/es/emoji/index.js +51 -0
- package/dist/es/emoji/types/index.d.ts +1 -0
- package/dist/es/emoji/types/index.js +3 -0
- package/dist/es/font-color/index.d.ts +12 -0
- package/dist/es/font-color/index.js +27 -0
- package/dist/es/font-color/types/index.d.ts +1 -0
- package/dist/es/font-color/types/index.js +3 -0
- package/dist/es/font-size/index.d.ts +12 -0
- package/dist/es/font-size/index.js +28 -0
- package/dist/es/font-size/types/index.d.ts +1 -0
- package/dist/es/font-size/types/index.js +3 -0
- package/dist/es/heading/index.d.ts +13 -0
- package/dist/es/heading/index.js +33 -0
- package/dist/es/heading/types/index.d.ts +1 -0
- package/dist/es/heading/types/index.js +3 -0
- package/dist/es/image/index.d.ts +21 -0
- package/dist/es/image/index.js +245 -0
- package/dist/es/image/types/index.d.ts +12 -0
- package/dist/es/image/types/index.js +14 -0
- package/dist/es/image/view/image.d.ts +10 -0
- package/dist/es/image/view/wrapper.d.ts +10 -0
- package/dist/es/indent/index.d.ts +14 -0
- package/dist/es/indent/index.js +67 -0
- package/dist/es/indent/types/index.d.ts +1 -0
- package/dist/es/indent/types/index.js +3 -0
- package/dist/es/index-1e46887d.js +205 -0
- package/dist/es/index-ddc2e5ac.js +493 -0
- package/dist/es/index.css +1 -0
- package/dist/es/index.d.ts +50 -0
- package/dist/es/index.js +64 -0
- package/dist/es/inline-code/index.d.ts +14 -0
- package/dist/es/inline-code/index.js +46 -0
- package/dist/es/inline-code/types/index.d.ts +1 -0
- package/dist/es/inline-code/types/index.js +3 -0
- package/dist/es/is-2b264ec8.js +11 -0
- package/dist/es/is-3de778e2.js +15 -0
- package/dist/es/is-7f3ae820.js +12 -0
- package/dist/es/italic/index.d.ts +15 -0
- package/dist/es/italic/index.js +43 -0
- package/dist/es/italic/types/index.d.ts +1 -0
- package/dist/es/italic/types/index.js +3 -0
- package/dist/es/line-height/index.d.ts +12 -0
- package/dist/es/line-height/index.js +25 -0
- package/dist/es/line-height/types/index.d.ts +1 -0
- package/dist/es/line-height/types/index.js +3 -0
- package/dist/es/link/index.d.ts +17 -0
- package/dist/es/link/index.js +64 -0
- package/dist/es/link/types/index.d.ts +3 -0
- package/dist/es/link/types/index.js +7 -0
- package/dist/es/link/view/a.d.ts +6 -0
- package/dist/es/marks-ac0ec630.js +46 -0
- package/dist/es/mention/index.d.ts +16 -0
- package/dist/es/mention/index.js +13 -0
- package/dist/es/mention/modules/suggest.d.ts +18 -0
- package/dist/es/mention/types/index.d.ts +2 -0
- package/dist/es/mention/types/index.js +4 -0
- package/dist/es/mention/utils/constant.d.ts +2 -0
- package/dist/es/mention/view/suggest.d.ts +9 -0
- package/dist/es/order-list/index.d.ts +16 -0
- package/dist/es/order-list/index.js +323 -0
- package/dist/es/order-list/types/index.d.ts +8 -0
- package/dist/es/order-list/types/index.js +10 -0
- package/dist/es/order-list/utils/format.d.ts +6 -0
- package/dist/es/order-list/utils/is.d.ts +6 -0
- package/dist/es/order-list/utils/serial.d.ts +10 -0
- package/dist/es/order-list/view/list.d.ts +10 -0
- package/dist/es/quote/index.d.ts +17 -0
- package/dist/es/quote/index.js +130 -0
- package/dist/es/quote/types/index.d.ts +1 -0
- package/dist/es/quote/types/index.js +3 -0
- package/dist/es/selection-badfb0bc.js +81 -0
- package/dist/es/shared/components/selection.d.ts +26 -0
- package/dist/es/shared/icons/divider.d.ts +2 -0
- package/dist/es/shared/icons/emoji.d.ts +2 -0
- package/dist/es/shared/icons/font-color.d.ts +2 -0
- package/dist/es/shared/icons/font-size.d.ts +2 -0
- package/dist/es/shared/icons/justify.d.ts +2 -0
- package/dist/es/shared/icons/line-height.d.ts +2 -0
- package/dist/es/shared/icons/text.d.ts +2 -0
- package/dist/es/shared/modules/selection.d.ts +12 -0
- package/dist/es/shared/utils/dom.d.ts +26 -0
- package/dist/es/shared/utils/event.d.ts +8 -0
- package/dist/es/shared/utils/is.d.ts +4 -0
- package/dist/es/shortcut/index.d.ts +14 -0
- package/dist/es/shortcut/index.js +85 -0
- package/dist/es/shortcut/modules/preset.d.ts +2 -0
- package/dist/es/shortcut/types/index.d.ts +10 -0
- package/dist/es/shortcut/types/index.js +3 -0
- package/dist/es/strike/index.d.ts +15 -0
- package/dist/es/strike/index.js +47 -0
- package/dist/es/strike/types/index.d.ts +1 -0
- package/dist/es/strike/types/index.js +3 -0
- package/dist/es/toolbar/context/basic.d.ts +4 -0
- package/dist/es/toolbar/context/float.d.ts +13 -0
- package/dist/es/toolbar/context/provider.d.ts +12 -0
- package/dist/es/toolbar/index.d.ts +26 -0
- package/dist/es/toolbar/index.js +34 -0
- package/dist/es/toolbar/modules/align.d.ts +2 -0
- package/dist/es/toolbar/modules/bold.d.ts +2 -0
- package/dist/es/toolbar/modules/bullet-list.d.ts +2 -0
- package/dist/es/toolbar/modules/cut.d.ts +3 -0
- package/dist/es/toolbar/modules/divider.d.ts +2 -0
- package/dist/es/toolbar/modules/emoji.d.ts +3 -0
- package/dist/es/toolbar/modules/font-color.d.ts +3 -0
- package/dist/es/toolbar/modules/font-size.d.ts +2 -0
- package/dist/es/toolbar/modules/heading.d.ts +2 -0
- package/dist/es/toolbar/modules/history.d.ts +2 -0
- package/dist/es/toolbar/modules/image.d.ts +2 -0
- package/dist/es/toolbar/modules/inline-code.d.ts +2 -0
- package/dist/es/toolbar/modules/italic.d.ts +2 -0
- package/dist/es/toolbar/modules/line-height.d.ts +3 -0
- package/dist/es/toolbar/modules/link.d.ts +5 -0
- package/dist/es/toolbar/modules/order-list.d.ts +2 -0
- package/dist/es/toolbar/modules/quote.d.ts +2 -0
- package/dist/es/toolbar/modules/strike.d.ts +2 -0
- package/dist/es/toolbar/modules/underline.d.ts +2 -0
- package/dist/es/toolbar/types/index.d.ts +8 -0
- package/dist/es/toolbar/types/index.js +7 -0
- package/dist/es/toolbar/utils/marks.d.ts +4 -0
- package/dist/es/tslib.es6-83956cc1.js +38 -0
- package/dist/es/underline/index.d.ts +15 -0
- package/dist/es/underline/index.js +45 -0
- package/dist/es/underline/types/index.d.ts +1 -0
- package/dist/es/underline/types/index.js +3 -0
- package/dist/lib/align/index.d.ts +12 -0
- package/dist/lib/align/index.js +29 -0
- package/dist/lib/align/types/index.d.ts +1 -0
- package/dist/lib/align/types/index.js +7 -0
- package/dist/lib/background/index.d.ts +12 -0
- package/dist/lib/background/index.js +31 -0
- package/dist/lib/background/types/index.d.ts +1 -0
- package/dist/lib/background/types/index.js +7 -0
- package/dist/lib/bold/index.d.ts +15 -0
- package/dist/lib/bold/index.js +50 -0
- package/dist/lib/bold/types/index.d.ts +1 -0
- package/dist/lib/bold/types/index.js +7 -0
- package/dist/lib/bullet-list/index.d.ts +16 -0
- package/dist/lib/bullet-list/index.js +153 -0
- package/dist/lib/bullet-list/types/index.d.ts +6 -0
- package/dist/lib/bullet-list/types/index.js +14 -0
- package/dist/lib/bullet-list/utils/is.d.ts +6 -0
- package/dist/lib/bullet-list/view/list.d.ts +9 -0
- package/dist/lib/divider/index.d.ts +17 -0
- package/dist/lib/divider/index.js +64 -0
- package/dist/lib/divider/types/index.d.ts +1 -0
- package/dist/lib/divider/types/index.js +7 -0
- package/dist/lib/dom-cb8b8e40.js +50 -0
- package/dist/lib/emoji/index.d.ts +16 -0
- package/dist/lib/emoji/index.js +59 -0
- package/dist/lib/emoji/types/index.d.ts +1 -0
- package/dist/lib/emoji/types/index.js +7 -0
- package/dist/lib/font-color/index.d.ts +12 -0
- package/dist/lib/font-color/index.js +31 -0
- package/dist/lib/font-color/types/index.d.ts +1 -0
- package/dist/lib/font-color/types/index.js +7 -0
- package/dist/lib/font-size/index.d.ts +12 -0
- package/dist/lib/font-size/index.js +32 -0
- package/dist/lib/font-size/types/index.d.ts +1 -0
- package/dist/lib/font-size/types/index.js +7 -0
- package/dist/lib/heading/index.d.ts +13 -0
- package/dist/lib/heading/index.js +37 -0
- package/dist/lib/heading/types/index.d.ts +1 -0
- package/dist/lib/heading/types/index.js +7 -0
- package/dist/lib/image/index.d.ts +21 -0
- package/dist/lib/image/index.js +249 -0
- package/dist/lib/image/types/index.d.ts +12 -0
- package/dist/lib/image/types/index.js +25 -0
- package/dist/lib/image/view/image.d.ts +10 -0
- package/dist/lib/image/view/wrapper.d.ts +10 -0
- package/dist/lib/indent/index.d.ts +14 -0
- package/dist/lib/indent/index.js +71 -0
- package/dist/lib/indent/types/index.d.ts +1 -0
- package/dist/lib/indent/types/index.js +7 -0
- package/dist/lib/index-f50053bf.js +506 -0
- package/dist/lib/index-ffc4bb34.js +212 -0
- package/dist/lib/index.css +1 -0
- package/dist/lib/index.d.ts +50 -0
- package/dist/lib/index.js +141 -0
- package/dist/lib/inline-code/index.d.ts +14 -0
- package/dist/lib/inline-code/index.js +50 -0
- package/dist/lib/inline-code/types/index.d.ts +1 -0
- package/dist/lib/inline-code/types/index.js +7 -0
- package/dist/lib/is-18806678.js +14 -0
- package/dist/lib/is-473d664a.js +18 -0
- package/dist/lib/is-fa1755d0.js +13 -0
- package/dist/lib/italic/index.d.ts +15 -0
- package/dist/lib/italic/index.js +47 -0
- package/dist/lib/italic/types/index.d.ts +1 -0
- package/dist/lib/italic/types/index.js +7 -0
- package/dist/lib/line-height/index.d.ts +12 -0
- package/dist/lib/line-height/index.js +29 -0
- package/dist/lib/line-height/types/index.d.ts +1 -0
- package/dist/lib/line-height/types/index.js +7 -0
- package/dist/lib/link/index.d.ts +17 -0
- package/dist/lib/link/index.js +68 -0
- package/dist/lib/link/types/index.d.ts +3 -0
- package/dist/lib/link/types/index.js +13 -0
- package/dist/lib/link/view/a.d.ts +6 -0
- package/dist/lib/marks-a30b8a0f.js +50 -0
- package/dist/lib/mention/index.d.ts +16 -0
- package/dist/lib/mention/index.js +21 -0
- package/dist/lib/mention/modules/suggest.d.ts +18 -0
- package/dist/lib/mention/types/index.d.ts +2 -0
- package/dist/lib/mention/types/index.js +9 -0
- package/dist/lib/mention/utils/constant.d.ts +2 -0
- package/dist/lib/mention/view/suggest.d.ts +9 -0
- package/dist/lib/order-list/index.d.ts +16 -0
- package/dist/lib/order-list/index.js +327 -0
- package/dist/lib/order-list/types/index.d.ts +8 -0
- package/dist/lib/order-list/types/index.js +17 -0
- package/dist/lib/order-list/utils/format.d.ts +6 -0
- package/dist/lib/order-list/utils/is.d.ts +6 -0
- package/dist/lib/order-list/utils/serial.d.ts +10 -0
- package/dist/lib/order-list/view/list.d.ts +10 -0
- package/dist/lib/quote/index.d.ts +17 -0
- package/dist/lib/quote/index.js +134 -0
- package/dist/lib/quote/types/index.d.ts +1 -0
- package/dist/lib/quote/types/index.js +7 -0
- package/dist/lib/selection-868f15c1.js +88 -0
- package/dist/lib/shared/components/selection.d.ts +26 -0
- package/dist/lib/shared/icons/divider.d.ts +2 -0
- package/dist/lib/shared/icons/emoji.d.ts +2 -0
- package/dist/lib/shared/icons/font-color.d.ts +2 -0
- package/dist/lib/shared/icons/font-size.d.ts +2 -0
- package/dist/lib/shared/icons/justify.d.ts +2 -0
- package/dist/lib/shared/icons/line-height.d.ts +2 -0
- package/dist/lib/shared/icons/text.d.ts +2 -0
- package/dist/lib/shared/modules/selection.d.ts +12 -0
- package/dist/lib/shared/utils/dom.d.ts +26 -0
- package/dist/lib/shared/utils/event.d.ts +8 -0
- package/dist/lib/shared/utils/is.d.ts +4 -0
- package/dist/lib/shortcut/index.d.ts +14 -0
- package/dist/lib/shortcut/index.js +89 -0
- package/dist/lib/shortcut/modules/preset.d.ts +2 -0
- package/dist/lib/shortcut/types/index.d.ts +10 -0
- package/dist/lib/shortcut/types/index.js +7 -0
- package/dist/lib/strike/index.d.ts +15 -0
- package/dist/lib/strike/index.js +51 -0
- package/dist/lib/strike/types/index.d.ts +1 -0
- package/dist/lib/strike/types/index.js +7 -0
- package/dist/lib/toolbar/context/basic.d.ts +4 -0
- package/dist/lib/toolbar/context/float.d.ts +13 -0
- package/dist/lib/toolbar/context/provider.d.ts +12 -0
- package/dist/lib/toolbar/index.d.ts +26 -0
- package/dist/lib/toolbar/index.js +44 -0
- package/dist/lib/toolbar/modules/align.d.ts +2 -0
- package/dist/lib/toolbar/modules/bold.d.ts +2 -0
- package/dist/lib/toolbar/modules/bullet-list.d.ts +2 -0
- package/dist/lib/toolbar/modules/cut.d.ts +3 -0
- package/dist/lib/toolbar/modules/divider.d.ts +2 -0
- package/dist/lib/toolbar/modules/emoji.d.ts +3 -0
- package/dist/lib/toolbar/modules/font-color.d.ts +3 -0
- package/dist/lib/toolbar/modules/font-size.d.ts +2 -0
- package/dist/lib/toolbar/modules/heading.d.ts +2 -0
- package/dist/lib/toolbar/modules/history.d.ts +2 -0
- package/dist/lib/toolbar/modules/image.d.ts +2 -0
- package/dist/lib/toolbar/modules/inline-code.d.ts +2 -0
- package/dist/lib/toolbar/modules/italic.d.ts +2 -0
- package/dist/lib/toolbar/modules/line-height.d.ts +3 -0
- package/dist/lib/toolbar/modules/link.d.ts +5 -0
- package/dist/lib/toolbar/modules/order-list.d.ts +2 -0
- package/dist/lib/toolbar/modules/quote.d.ts +2 -0
- package/dist/lib/toolbar/modules/strike.d.ts +2 -0
- package/dist/lib/toolbar/modules/underline.d.ts +2 -0
- package/dist/lib/toolbar/types/index.d.ts +8 -0
- package/dist/lib/toolbar/types/index.js +12 -0
- package/dist/lib/toolbar/utils/marks.d.ts +4 -0
- package/dist/lib/tslib.es6-d44c9a95.js +41 -0
- package/dist/lib/underline/index.d.ts +15 -0
- package/dist/lib/underline/index.js +49 -0
- package/dist/lib/underline/types/index.d.ts +1 -0
- package/dist/lib/underline/types/index.js +7 -0
- package/package.json +56 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
4
|
+
var react = require('@block-kit/react');
|
|
5
|
+
var tslib_es6 = require('./tslib.es6-d44c9a95.js');
|
|
6
|
+
var core = require('@block-kit/core');
|
|
7
|
+
var delta = require('@block-kit/delta');
|
|
8
|
+
var utils = require('@block-kit/utils');
|
|
9
|
+
var ReactDOM = require('react-dom');
|
|
10
|
+
var dom = require('./dom-cb8b8e40.js');
|
|
11
|
+
var is = require('./is-473d664a.js');
|
|
12
|
+
var hooks = require('@block-kit/utils/dist/es/hooks');
|
|
13
|
+
var React = require('react');
|
|
14
|
+
var mention_types_index = require('./mention/types/index.js');
|
|
15
|
+
|
|
16
|
+
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
17
|
+
|
|
18
|
+
var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
19
|
+
|
|
20
|
+
const SUGGEST_OFFSET = 5;
|
|
21
|
+
const DATA = [
|
|
22
|
+
"Alice",
|
|
23
|
+
"Bob",
|
|
24
|
+
"Charlie",
|
|
25
|
+
"David",
|
|
26
|
+
"Eve",
|
|
27
|
+
"Frank",
|
|
28
|
+
"Grace",
|
|
29
|
+
"Heidi",
|
|
30
|
+
"Ivan",
|
|
31
|
+
"Judy",
|
|
32
|
+
"Mallory",
|
|
33
|
+
"Oscar",
|
|
34
|
+
"Peggy",
|
|
35
|
+
"Romeo",
|
|
36
|
+
"Sybil",
|
|
37
|
+
"Trudy",
|
|
38
|
+
"Victor",
|
|
39
|
+
"Walter",
|
|
40
|
+
"Zoe",
|
|
41
|
+
];
|
|
42
|
+
|
|
43
|
+
const Suggest = props => {
|
|
44
|
+
const { controller } = props;
|
|
45
|
+
const editor = controller.editor;
|
|
46
|
+
const ref = React.useRef(null);
|
|
47
|
+
const [activeIndex, setActiveIndex] = React.useState(0);
|
|
48
|
+
const list = React.useMemo(() => {
|
|
49
|
+
setActiveIndex(0);
|
|
50
|
+
if (!props.text)
|
|
51
|
+
return DATA;
|
|
52
|
+
return DATA.filter(it => {
|
|
53
|
+
return it.toUpperCase().includes(props.text.toUpperCase());
|
|
54
|
+
});
|
|
55
|
+
}, [props.text]);
|
|
56
|
+
const onKeydown = hooks.useMemoFn((event, context) => {
|
|
57
|
+
if (is.isKeyCode(event, utils.KEY_CODE.DOWN)) {
|
|
58
|
+
const nextIndex = (activeIndex + 1) % list.length;
|
|
59
|
+
setActiveIndex(nextIndex);
|
|
60
|
+
const container = ref.current;
|
|
61
|
+
const child = container && container.children[nextIndex];
|
|
62
|
+
container && child && dom.scrollIfNeeded(container, child, 5);
|
|
63
|
+
dom.preventContextEvent(event, context);
|
|
64
|
+
}
|
|
65
|
+
if (is.isKeyCode(event, utils.KEY_CODE.UP)) {
|
|
66
|
+
const prevIndex = (activeIndex - 1 + list.length) % list.length;
|
|
67
|
+
setActiveIndex(prevIndex);
|
|
68
|
+
const container = ref.current;
|
|
69
|
+
const child = container && container.children[prevIndex];
|
|
70
|
+
container && child && dom.scrollIfNeeded(container, child, 5);
|
|
71
|
+
dom.preventContextEvent(event, context);
|
|
72
|
+
}
|
|
73
|
+
if (is.isKeyCode(event, utils.KEY_CODE.ENTER)) {
|
|
74
|
+
const item = list[activeIndex];
|
|
75
|
+
dom.preventContextEvent(event, context);
|
|
76
|
+
const sel = editor.selection.get();
|
|
77
|
+
if (!item || !sel)
|
|
78
|
+
return void 0;
|
|
79
|
+
const range = new core.Range(controller.point, sel.end);
|
|
80
|
+
const raw = core.RawRange.fromRange(editor, range);
|
|
81
|
+
if (!raw)
|
|
82
|
+
return void 0;
|
|
83
|
+
const delta$1 = new delta.Delta()
|
|
84
|
+
.retain(raw.start)
|
|
85
|
+
.delete(raw.len)
|
|
86
|
+
.insert(" ", {
|
|
87
|
+
[mention_types_index.MENTION_KEY]: utils.TRULY,
|
|
88
|
+
[mention_types_index.MENTION_NAME]: item,
|
|
89
|
+
});
|
|
90
|
+
editor.state.apply(delta$1);
|
|
91
|
+
controller.unmountSuggestPanel();
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
React.useEffect(() => {
|
|
95
|
+
editor.event.on(core.EDITOR_EVENT.KEY_DOWN, onKeydown, 80);
|
|
96
|
+
return () => {
|
|
97
|
+
editor.event.off(core.EDITOR_EVENT.KEY_DOWN, onKeydown);
|
|
98
|
+
};
|
|
99
|
+
}, [onKeydown, editor.event]);
|
|
100
|
+
return (jsxRuntime.jsxs("div", { ref: ref, className: "block-kit-suggest-panel", style: { top: props.top, left: props.left }, onMouseDown: utils.preventNativeEvent, children: [list.map((it, index) => (jsxRuntime.jsx("div", { className: utils.cs("block-kit-suggest-item", index === activeIndex && "active"), children: it }, index))), !list.length && jsxRuntime.jsx("div", { className: "block-kit-suggest-empty", children: "No result" })] }));
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
class SuggestModule {
|
|
104
|
+
constructor(editor) {
|
|
105
|
+
this.editor = editor;
|
|
106
|
+
this.rect = null;
|
|
107
|
+
this.isMountSuggest = false;
|
|
108
|
+
this.mountSuggestNode = null;
|
|
109
|
+
this.point = new core.Point(0, 0);
|
|
110
|
+
editor.event.on(core.EDITOR_EVENT.KEY_DOWN, this.onKeydown, 101);
|
|
111
|
+
}
|
|
112
|
+
destroy() {
|
|
113
|
+
this.unmountSuggestPanel();
|
|
114
|
+
this.editor.event.off(core.EDITOR_EVENT.KEY_DOWN, this.onKeydown);
|
|
115
|
+
this.editor.event.off(core.EDITOR_EVENT.SELECTION_CHANGE, this.onSelectionChange);
|
|
116
|
+
}
|
|
117
|
+
onKeydown(event) {
|
|
118
|
+
if (is.isKeyCode(event, utils.KEY_CODE.D2) && event.shiftKey) {
|
|
119
|
+
const sel = this.editor.selection.get();
|
|
120
|
+
const caretRect = this.editor.rect.getRawCaretRect();
|
|
121
|
+
if (!caretRect || !sel)
|
|
122
|
+
return void 0;
|
|
123
|
+
const editorRect = this.editor.rect.getEditorRect();
|
|
124
|
+
const rect = core.relativeTo(caretRect, editorRect);
|
|
125
|
+
// 这里是 CSS 预设的面板高度
|
|
126
|
+
const PANEL_HEIGHT = 150;
|
|
127
|
+
if (caretRect.bottom + PANEL_HEIGHT <= window.innerHeight) {
|
|
128
|
+
// 放置于下方
|
|
129
|
+
rect.top = rect.bottom + SUGGEST_OFFSET;
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
// 放置于上方
|
|
133
|
+
rect.top = rect.top - PANEL_HEIGHT - SUGGEST_OFFSET;
|
|
134
|
+
}
|
|
135
|
+
this.rect = { top: rect.top, left: rect.left };
|
|
136
|
+
this.point = sel.start.clone();
|
|
137
|
+
this.editor.event.on(core.EDITOR_EVENT.SELECTION_CHANGE, this.onSelectionChange);
|
|
138
|
+
}
|
|
139
|
+
if (this.isMountSuggest && is.isKeyCode(event, utils.KEY_CODE.ESC)) {
|
|
140
|
+
this.unmountSuggestPanel();
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
onSelectionChange(event) {
|
|
144
|
+
const { current } = event;
|
|
145
|
+
if (!current ||
|
|
146
|
+
!current.isCollapsed ||
|
|
147
|
+
current.start.line !== this.point.line ||
|
|
148
|
+
current.start.offset <= this.point.offset) {
|
|
149
|
+
this.unmountSuggestPanel();
|
|
150
|
+
return void 0;
|
|
151
|
+
}
|
|
152
|
+
const ops = this.editor.collect.getFragment(new core.Range(this.point, current.end));
|
|
153
|
+
if (!ops)
|
|
154
|
+
return void 0;
|
|
155
|
+
const text = delta.deltaToText(new delta.Delta(ops));
|
|
156
|
+
this.mountSuggestPanel(text.slice(1));
|
|
157
|
+
}
|
|
158
|
+
mountSuggestPanel(text = "") {
|
|
159
|
+
if (!this.rect)
|
|
160
|
+
return void 0;
|
|
161
|
+
if (!this.mountSuggestNode) {
|
|
162
|
+
this.mountSuggestNode = document.createElement("div");
|
|
163
|
+
this.mountSuggestNode.dataset.type = "mention";
|
|
164
|
+
dom.getMountDOM(this.editor).appendChild(this.mountSuggestNode);
|
|
165
|
+
}
|
|
166
|
+
const top = this.rect.top;
|
|
167
|
+
const left = this.rect.left;
|
|
168
|
+
const dom$1 = this.mountSuggestNode;
|
|
169
|
+
this.isMountSuggest = true;
|
|
170
|
+
ReactDOM__default["default"].render(jsxRuntime.jsx(Suggest, { controller: this, top: top, left: left, text: text }), dom$1);
|
|
171
|
+
}
|
|
172
|
+
unmountSuggestPanel() {
|
|
173
|
+
if (this.isMountSuggest && this.mountSuggestNode) {
|
|
174
|
+
ReactDOM__default["default"].unmountComponentAtNode(this.mountSuggestNode);
|
|
175
|
+
}
|
|
176
|
+
this.mountSuggestNode && this.mountSuggestNode.remove();
|
|
177
|
+
this.editor.event.off(core.EDITOR_EVENT.SELECTION_CHANGE, this.onSelectionChange);
|
|
178
|
+
this.mountSuggestNode = null;
|
|
179
|
+
this.isMountSuggest = false;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
tslib_es6.__decorate([
|
|
183
|
+
utils.Bind
|
|
184
|
+
], SuggestModule.prototype, "onKeydown", null);
|
|
185
|
+
tslib_es6.__decorate([
|
|
186
|
+
utils.Bind
|
|
187
|
+
], SuggestModule.prototype, "onSelectionChange", null);
|
|
188
|
+
|
|
189
|
+
class MentionPlugin extends react.EditorPlugin {
|
|
190
|
+
constructor(editor) {
|
|
191
|
+
super();
|
|
192
|
+
this.editor = editor;
|
|
193
|
+
this.key = mention_types_index.MENTION_KEY;
|
|
194
|
+
this.suggest = new SuggestModule(editor);
|
|
195
|
+
}
|
|
196
|
+
destroy() {
|
|
197
|
+
this.suggest.destroy();
|
|
198
|
+
}
|
|
199
|
+
match(attrs) {
|
|
200
|
+
return !!attrs[mention_types_index.MENTION_KEY];
|
|
201
|
+
}
|
|
202
|
+
renderLeaf(context) {
|
|
203
|
+
const attrs = context.attributes || {};
|
|
204
|
+
const name = attrs[mention_types_index.MENTION_NAME];
|
|
205
|
+
if (!name || !attrs[mention_types_index.MENTION_KEY])
|
|
206
|
+
return context.children;
|
|
207
|
+
return (jsxRuntime.jsx(react.Embed, { className: "block-kit-mention-embed", context: context, children: jsxRuntime.jsxs("span", { className: "block-kit-mention-name", children: ["@", name] }) }));
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
exports.MentionPlugin = MentionPlugin;
|
|
212
|
+
exports.SuggestModule = SuggestModule;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
.block-kit-bullet-list{list-style-type:none;margin:0;padding-left:0}.block-kit-bullet-list .block-kit-bullet-item::marker{color:rgb(var(--arcoblue-6));margin-right:0;text-align:unset!important;text-align-last:unset!important}.block-kit-bullet-list .block-kit-bullet-item.block-kit-li-level-0{list-style-type:disc;margin-left:20px}.block-kit-bullet-list .block-kit-bullet-item.block-kit-li-level-1{list-style-type:circle;margin-left:20px}.block-kit-bullet-list .block-kit-bullet-item.block-kit-li-level-2{list-style-type:square;margin-left:20px}.block-kit-divider-container{padding:6px 0}.block-kit-divider{background-color:var(--color-fill-4);height:1px}.block-kit-embed-selected{box-shadow:0 0 0 1px rgba(var(--blue-7),.9)}.block-kit-emoji{height:1em;width:1em}.block-kit-heading{font-weight:700}.block-kit-heading.h1{font-size:20px;margin:10px 0}.block-kit-heading.h2{font-size:16px;margin:8px 0}.block-kit-heading.h3{font-size:14px;margin:7px 0}.block-kit-image-container{display:inline-block;position:relative}.block-kit-image-container .block-kit-image{display:block;height:auto;max-height:100%;max-width:100%;object-fit:contain}.block-kit-image-container .block-kit-image-loading{align-items:center;background-color:rgba(var(--gray-3),.5);bottom:0;box-sizing:border-box;color:var(--color-text-2);display:flex;font-size:23px;justify-content:center;left:0;padding:1px;position:absolute;right:0;top:0;z-index:2}.block-kit-image-preview{cursor:zoom-in}.block-kit-image-resider{position:absolute;z-index:1}.block-kit-image-resider:after{background-color:var(--color-bg-1);border:1px solid rgb(var(--arcoblue-6));border-radius:10px;content:"";display:block;height:10px;width:10px;z-index:1}.block-kit-image-resider[data-type=lt]{cursor:nwse-resize;left:-5px;top:-5px}.block-kit-image-resider[data-type=rt]{cursor:nesw-resize;right:-5px;top:-5px}.block-kit-image-resider[data-type=lb]{bottom:-5px;cursor:nesw-resize;left:-5px}.block-kit-image-resider[data-type=rb]{bottom:-5px;cursor:nwse-resize;right:-5px}.block-kit-inline-code{background-color:var(--color-fill-2);border-bottom-style:solid;border-color:var(--color-border-2);border-top-style:solid;border-width:1px;box-sizing:border-box;padding-bottom:1px;padding-top:1px}.block-kit-inline-code-start{border-bottom-left-radius:3px;border-left-style:solid;border-top-left-radius:3px;margin-left:2px;padding-left:2px}.block-kit-inline-code-end{border-bottom-right-radius:3px;border-right-style:solid;border-top-right-radius:3px;margin-right:2px;padding-right:2px}.block-kit-hyper-link{color:rgb(var(--link-6));cursor:pointer;text-decoration:none}.block-kit-mention-embed{display:inline-block;line-height:1.3}.block-kit-mention-embed .block-kit-mention-name{background-color:rgba(var(--arcoblue-6),.9);border-radius:8px;box-sizing:border-box;color:var(--color-bg-5);display:inline-block;margin:0 3px;padding:0 4px}.block-kit-suggest-panel{-ms-overflow-style:none;background-color:var(--color-bg-1);border:1px solid var(--color-border-2);border-radius:3px;border-radius:5px;box-shadow:0 0 4px var(--color-border-2);box-sizing:border-box;color:var(--color-text-1);font-size:13px;height:150px;overflow:-moz-scrollbars-none;overflow-y:auto;overscroll-behavior:contain;padding:5px 7px;position:absolute;scrollbar-width:none;width:100px;z-index:999}.block-kit-suggest-panel::-webkit-scrollbar{display:none}.block-kit-suggest-panel .block-kit-suggest-item{border-radius:4px;overflow:hidden;padding:3px 5px;text-overflow:ellipsis;white-space:nowrap}.block-kit-suggest-panel .block-kit-suggest-item.active{background-color:var(--color-fill-2)}.block-kit-suggest-panel .block-kit-suggest-empty{color:var(--color-text-3);margin-top:10px;text-align:center}.block-kit-order-list{display:flex;list-style-type:none;margin-block-end:0;margin-block-start:0;margin-inline-end:0;margin-inline-start:0;padding-inline-start:0}.block-kit-order-list .block-kit-order-indicator{color:rgb(var(--arcoblue-6));margin-right:6px;user-select:none}.block-kit-order-list .block-kit-order-item{display:block;flex:1 0 0}.block-kit-quote{border-left:3px solid var(--color-border-2);color:var(--color-text-2);padding-left:10px}.block-kit-menu-toolbar .menu-toolbar-cut{background-color:var(--color-fill-3);box-sizing:border-box;margin:4px 6px;width:1px}.arco-trigger.menu-toolbar-emoji-trigger{width:352px}.arco-trigger.menu-toolbar-emoji-trigger .scroll{max-height:300px}.block-kit-color-picker{padding:10px;width:230px}.block-kit-color-picker .kit-color-picker-label{font-size:12px}.block-kit-color-picker .kit-picker-group{display:flex;flex-wrap:wrap;font-size:13px;justify-content:space-between;margin:5px 0}.block-kit-color-picker .kit-picker-item-wrapper{border:1px solid transparent;border-radius:3px;flex-shrink:0}.block-kit-color-picker .kit-picker-item-wrapper.active{border-color:rgb(var(--arcoblue-6))}.block-kit-color-picker .kit-picker-item{align-items:center;border:1px solid var(--color-border-1);border-radius:3px;box-sizing:border-box;cursor:pointer;display:flex;height:22px;justify-content:center;width:22px}.block-kit-color-picker .kit-picker-background-case .kit-picker-item-wrapper{margin-right:3px;margin-top:4px}.block-kit-color-picker .kit-picker-background-case .kit-picker-item{border-color:transparent}.block-kit-color-picker .kit-picker-background-case .kit-picker-item-empty-background{border-color:var(--color-border-2);overflow:hidden;position:relative}.block-kit-color-picker .kit-picker-background-case .kit-picker-item-empty-background:before{background-color:var(--color-border-3);content:"";height:33px;left:7px;position:absolute;top:-9px;transform:rotate(-45deg);width:1px;z-index:2}.block-kit-menu-toolbar .menu-toolbar-item.kit-color-case{align-items:center;display:flex;padding:3px 0}.block-kit-menu-toolbar .menu-toolbar-item.kit-color-case .kit-color-block{border-radius:3px;padding:0 5px}.block-kit-menu-toolbar .menu-toolbar-item.kit-color-case .menu-toolbar-icon-down{margin-left:0;margin-right:3px}.block-kit-toolbar-dropdown .block-kit-toolbar-height-item{position:relative}.block-kit-toolbar-dropdown .block-kit-toolbar-height-item .arco-icon-check{left:5px;position:absolute}.block-kit-link-popup{background-color:var(--color-bg-1);border-radius:3px;box-shadow:0 0 4px var(--color-border-2);padding:10px 15px;position:relative;width:330px}.block-kit-link-popup .arco-form-size-small .arco-form-label-item>label{font-size:13px}.block-kit-link-popup .arco-form-item{margin:5px 0}.block-kit-link-popup .block-kit-link-popup-button{bottom:15px;position:absolute;right:15px}.block-kit-link-popup .block-kit-link-popup-button .arco-btn{margin-left:10px}.block-kit-link-popup .block-kit-link-popup-go{cursor:pointer}.block-kit-menu-toolbar{border-bottom:1px solid var(--color-border-3);display:flex;padding:6px 5px;user-select:none}.block-kit-menu-toolbar .menu-toolbar-item{align-items:center;border-radius:3px;color:var(--color-text-1);cursor:pointer;display:flex;margin:0 3px;padding:3px 7px}.block-kit-menu-toolbar .menu-toolbar-item.active,.block-kit-menu-toolbar .menu-toolbar-item:hover{background-color:var(--color-fill-2);color:var(--color-text-1)}.block-kit-menu-toolbar .menu-toolbar-item.disable{background-color:unset;color:var(--color-text-3)}.block-kit-menu-toolbar .menu-toolbar-icon-down{font-size:12px;margin-left:3px}.block-kit-toolbar-dropdown{background-color:var(--color-bg-1);border:1px solid var(--color-border-2);border-radius:3px;box-shadow:0 0 4px var(--color-border-2);color:var(--color-text-1)}.block-kit-toolbar-dropdown>.kit-toolbar-node{align-items:center;cursor:pointer;display:flex;font-size:12px;height:30px;justify-content:center;margin:5px;width:70px}.block-kit-toolbar-dropdown>.kit-toolbar-node>.arco-icon{font-size:13px}.block-kit-toolbar-dropdown>.kit-toolbar-node:hover{background-color:var(--color-fill-2)}@keyframes fade-in{0%{opacity:0}to{opacity:1}}.block-kit-float-toolbar{animation:fade-in .3s;background-color:var(--color-bg-2);border:1px solid var(--color-border-1);border-radius:3px;box-shadow:1px 2px 4px var(--color-border-2);position:absolute;z-index:999}.block-kit-menu-toolbar.block-kit-float-toolbar{border-bottom:unset}.block-kit-menu-toolbar.block-kit-float-toolbar .menu-toolbar-item{color:var(--color-text-1);margin:0 5px}.block-kit-menu-toolbar.block-kit-float-toolbar .menu-toolbar-item.kit-color-case{margin:0 3px 0 -2px;padding:3px}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
export { AlignPlugin } from "./align";
|
|
2
|
+
export { ALIGN_KEY } from "./align/types";
|
|
3
|
+
export { BackgroundPlugin } from "./background";
|
|
4
|
+
export { BACKGROUND_KEY } from "./background/types";
|
|
5
|
+
export { BoldPlugin } from "./bold";
|
|
6
|
+
export { BOLD_KEY } from "./bold/types";
|
|
7
|
+
export { BulletListPlugin } from "./bullet-list";
|
|
8
|
+
export { BULLET_LIST_KEY, BULLET_LIST_TYPE, LIST_TYPE_KEY } from "./bullet-list/types";
|
|
9
|
+
export { DividerPlugin } from "./divider";
|
|
10
|
+
export { DIVIDER_KEY } from "./divider/types";
|
|
11
|
+
export { EmojiPlugin } from "./emoji";
|
|
12
|
+
export { EMOJI_KEY } from "./emoji/types";
|
|
13
|
+
export { FontColorPlugin } from "./font-color";
|
|
14
|
+
export { FONT_COLOR_KEY } from "./font-color/types";
|
|
15
|
+
export { FontSizePlugin } from "./font-size";
|
|
16
|
+
export { FONT_SIZE_KEY } from "./font-size/types";
|
|
17
|
+
export { HeadingPlugin } from "./heading/index";
|
|
18
|
+
export { HEADING_KEY } from "./heading/types";
|
|
19
|
+
export { ImagePlugin } from "./image/index";
|
|
20
|
+
export { IMAGE_HEIGHT, IMAGE_KEY, IMAGE_SCALE, IMAGE_SRC, IMAGE_STATUS, IMAGE_WIDTH, LOADING_STATUS, MIN_WIDTH, } from "./image/types";
|
|
21
|
+
export { IndentPlugin } from "./indent";
|
|
22
|
+
export { INDENT_LEVEL_KEY } from "./indent/types";
|
|
23
|
+
export { InlineCodePlugin } from "./inline-code";
|
|
24
|
+
export { INLINE_CODE } from "./inline-code/types/index";
|
|
25
|
+
export { ItalicPlugin } from "./italic/index";
|
|
26
|
+
export { ITALIC_KEY } from "./italic/types";
|
|
27
|
+
export { LineHeightPlugin } from "./line-height/index";
|
|
28
|
+
export { LINE_HEIGHT_KEY } from "./line-height/types";
|
|
29
|
+
export { LinkPlugin } from "./link";
|
|
30
|
+
export { LINK_BLANK_KEY, LINK_KEY, LINK_TEMP_KEY } from "./link/types";
|
|
31
|
+
export { MentionPlugin } from "./mention";
|
|
32
|
+
export { SuggestModule } from "./mention/modules/suggest";
|
|
33
|
+
export { MENTION_KEY, MENTION_NAME } from "./mention/types";
|
|
34
|
+
export { OrderListPlugin } from "./order-list";
|
|
35
|
+
export { LIST_RESTART_KEY, LIST_START_KEY, ORDER_LIST_KEY, ORDER_LIST_TYPE, } from "./order-list/types";
|
|
36
|
+
export { QuotePlugin } from "./quote";
|
|
37
|
+
export { QUOTE_KEY } from "./quote/types";
|
|
38
|
+
export { SelectionHOC } from "./shared/components/selection";
|
|
39
|
+
export { SelectionPlugin } from "./shared/modules/selection";
|
|
40
|
+
export { getMountDOM, preventContextEvent, scrollIfNeeded, setMountDOM } from "./shared/utils/dom";
|
|
41
|
+
export { isEmptyLine, isKeyCode } from "./shared/utils/is";
|
|
42
|
+
export { Shortcut } from "./shortcut";
|
|
43
|
+
export type { ShortcutFunc, ShortcutFuncMap } from "./shortcut/types";
|
|
44
|
+
export { StrikePlugin } from "./strike/index";
|
|
45
|
+
export { STRIKE_KEY } from "./strike/types";
|
|
46
|
+
export { FloatToolbar, Mixin, Toolbar } from "./toolbar";
|
|
47
|
+
export type { ToolbarContextType } from "./toolbar/context/provider";
|
|
48
|
+
export { ToolbarContext, useToolbarContext } from "./toolbar/context/provider";
|
|
49
|
+
export { UnderlinePlugin } from "./underline/index";
|
|
50
|
+
export { UNDERLINE_KEY } from "./underline/types";
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var align_index = require('./align/index.js');
|
|
6
|
+
var align_types_index = require('./align/types/index.js');
|
|
7
|
+
var background_index = require('./background/index.js');
|
|
8
|
+
var background_types_index = require('./background/types/index.js');
|
|
9
|
+
var bold_index = require('./bold/index.js');
|
|
10
|
+
var bold_types_index = require('./bold/types/index.js');
|
|
11
|
+
var bulletList_index = require('./bullet-list/index.js');
|
|
12
|
+
var bulletList_types_index = require('./bullet-list/types/index.js');
|
|
13
|
+
var divider_index = require('./divider/index.js');
|
|
14
|
+
var divider_types_index = require('./divider/types/index.js');
|
|
15
|
+
var emoji_index = require('./emoji/index.js');
|
|
16
|
+
var emoji_types_index = require('./emoji/types/index.js');
|
|
17
|
+
var fontColor_index = require('./font-color/index.js');
|
|
18
|
+
var fontColor_types_index = require('./font-color/types/index.js');
|
|
19
|
+
var fontSize_index = require('./font-size/index.js');
|
|
20
|
+
var fontSize_types_index = require('./font-size/types/index.js');
|
|
21
|
+
var heading_index = require('./heading/index.js');
|
|
22
|
+
var heading_types_index = require('./heading/types/index.js');
|
|
23
|
+
var image_index = require('./image/index.js');
|
|
24
|
+
var image_types_index = require('./image/types/index.js');
|
|
25
|
+
var indent_index = require('./indent/index.js');
|
|
26
|
+
var indent_types_index = require('./indent/types/index.js');
|
|
27
|
+
var inlineCode_index = require('./inline-code/index.js');
|
|
28
|
+
var inlineCode_types_index = require('./inline-code/types/index.js');
|
|
29
|
+
var italic_index = require('./italic/index.js');
|
|
30
|
+
var italic_types_index = require('./italic/types/index.js');
|
|
31
|
+
var lineHeight_index = require('./line-height/index.js');
|
|
32
|
+
var lineHeight_types_index = require('./line-height/types/index.js');
|
|
33
|
+
var link_index = require('./link/index.js');
|
|
34
|
+
var link_types_index = require('./link/types/index.js');
|
|
35
|
+
var mention_index = require('./index-ffc4bb34.js');
|
|
36
|
+
var mention_types_index = require('./mention/types/index.js');
|
|
37
|
+
var orderList_index = require('./order-list/index.js');
|
|
38
|
+
var orderList_types_index = require('./order-list/types/index.js');
|
|
39
|
+
var quote_index = require('./quote/index.js');
|
|
40
|
+
var quote_types_index = require('./quote/types/index.js');
|
|
41
|
+
var selection = require('./selection-868f15c1.js');
|
|
42
|
+
var dom = require('./dom-cb8b8e40.js');
|
|
43
|
+
var is = require('./is-473d664a.js');
|
|
44
|
+
var shortcut_index = require('./shortcut/index.js');
|
|
45
|
+
var strike_index = require('./strike/index.js');
|
|
46
|
+
var strike_types_index = require('./strike/types/index.js');
|
|
47
|
+
var toolbar_index = require('./index-f50053bf.js');
|
|
48
|
+
var underline_index = require('./underline/index.js');
|
|
49
|
+
var underline_types_index = require('./underline/types/index.js');
|
|
50
|
+
require('@block-kit/react');
|
|
51
|
+
require('@block-kit/core');
|
|
52
|
+
require('@block-kit/utils');
|
|
53
|
+
require('./tslib.es6-d44c9a95.js');
|
|
54
|
+
require('react/jsx-runtime');
|
|
55
|
+
require('@block-kit/delta');
|
|
56
|
+
require('./is-fa1755d0.js');
|
|
57
|
+
require('@emoji-mart/data');
|
|
58
|
+
require('emoji-mart');
|
|
59
|
+
require('@arco-design/web-react/icon');
|
|
60
|
+
require('@arco-design/web-react');
|
|
61
|
+
require('react');
|
|
62
|
+
require('react-dom');
|
|
63
|
+
require('@block-kit/utils/dist/es/hooks');
|
|
64
|
+
require('./is-18806678.js');
|
|
65
|
+
require('./marks-a30b8a0f.js');
|
|
66
|
+
require('./shortcut/types/index.js');
|
|
67
|
+
require('@emoji-mart/react');
|
|
68
|
+
require('@arco-design/web-react/es/Form/useForm');
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
exports.AlignPlugin = align_index.AlignPlugin;
|
|
73
|
+
exports.ALIGN_KEY = align_types_index.ALIGN_KEY;
|
|
74
|
+
exports.BackgroundPlugin = background_index.BackgroundPlugin;
|
|
75
|
+
exports.BACKGROUND_KEY = background_types_index.BACKGROUND_KEY;
|
|
76
|
+
exports.BoldPlugin = bold_index.BoldPlugin;
|
|
77
|
+
exports.BOLD_KEY = bold_types_index.BOLD_KEY;
|
|
78
|
+
exports.BulletListPlugin = bulletList_index.BulletListPlugin;
|
|
79
|
+
exports.BULLET_LIST_KEY = bulletList_types_index.BULLET_LIST_KEY;
|
|
80
|
+
exports.BULLET_LIST_TYPE = bulletList_types_index.BULLET_LIST_TYPE;
|
|
81
|
+
exports.LIST_TYPE_KEY = bulletList_types_index.LIST_TYPE_KEY;
|
|
82
|
+
exports.DividerPlugin = divider_index.DividerPlugin;
|
|
83
|
+
exports.DIVIDER_KEY = divider_types_index.DIVIDER_KEY;
|
|
84
|
+
exports.EmojiPlugin = emoji_index.EmojiPlugin;
|
|
85
|
+
exports.EMOJI_KEY = emoji_types_index.EMOJI_KEY;
|
|
86
|
+
exports.FontColorPlugin = fontColor_index.FontColorPlugin;
|
|
87
|
+
exports.FONT_COLOR_KEY = fontColor_types_index.FONT_COLOR_KEY;
|
|
88
|
+
exports.FontSizePlugin = fontSize_index.FontSizePlugin;
|
|
89
|
+
exports.FONT_SIZE_KEY = fontSize_types_index.FONT_SIZE_KEY;
|
|
90
|
+
exports.HeadingPlugin = heading_index.HeadingPlugin;
|
|
91
|
+
exports.HEADING_KEY = heading_types_index.HEADING_KEY;
|
|
92
|
+
exports.ImagePlugin = image_index.ImagePlugin;
|
|
93
|
+
exports.IMAGE_HEIGHT = image_types_index.IMAGE_HEIGHT;
|
|
94
|
+
exports.IMAGE_KEY = image_types_index.IMAGE_KEY;
|
|
95
|
+
exports.IMAGE_SCALE = image_types_index.IMAGE_SCALE;
|
|
96
|
+
exports.IMAGE_SRC = image_types_index.IMAGE_SRC;
|
|
97
|
+
exports.IMAGE_STATUS = image_types_index.IMAGE_STATUS;
|
|
98
|
+
exports.IMAGE_WIDTH = image_types_index.IMAGE_WIDTH;
|
|
99
|
+
exports.LOADING_STATUS = image_types_index.LOADING_STATUS;
|
|
100
|
+
exports.MIN_WIDTH = image_types_index.MIN_WIDTH;
|
|
101
|
+
exports.IndentPlugin = indent_index.IndentPlugin;
|
|
102
|
+
exports.INDENT_LEVEL_KEY = indent_types_index.INDENT_LEVEL_KEY;
|
|
103
|
+
exports.InlineCodePlugin = inlineCode_index.InlineCodePlugin;
|
|
104
|
+
exports.INLINE_CODE = inlineCode_types_index.INLINE_CODE;
|
|
105
|
+
exports.ItalicPlugin = italic_index.ItalicPlugin;
|
|
106
|
+
exports.ITALIC_KEY = italic_types_index.ITALIC_KEY;
|
|
107
|
+
exports.LineHeightPlugin = lineHeight_index.LineHeightPlugin;
|
|
108
|
+
exports.LINE_HEIGHT_KEY = lineHeight_types_index.LINE_HEIGHT_KEY;
|
|
109
|
+
exports.LinkPlugin = link_index.LinkPlugin;
|
|
110
|
+
exports.LINK_BLANK_KEY = link_types_index.LINK_BLANK_KEY;
|
|
111
|
+
exports.LINK_KEY = link_types_index.LINK_KEY;
|
|
112
|
+
exports.LINK_TEMP_KEY = link_types_index.LINK_TEMP_KEY;
|
|
113
|
+
exports.MentionPlugin = mention_index.MentionPlugin;
|
|
114
|
+
exports.SuggestModule = mention_index.SuggestModule;
|
|
115
|
+
exports.MENTION_KEY = mention_types_index.MENTION_KEY;
|
|
116
|
+
exports.MENTION_NAME = mention_types_index.MENTION_NAME;
|
|
117
|
+
exports.OrderListPlugin = orderList_index.OrderListPlugin;
|
|
118
|
+
exports.LIST_RESTART_KEY = orderList_types_index.LIST_RESTART_KEY;
|
|
119
|
+
exports.LIST_START_KEY = orderList_types_index.LIST_START_KEY;
|
|
120
|
+
exports.ORDER_LIST_KEY = orderList_types_index.ORDER_LIST_KEY;
|
|
121
|
+
exports.ORDER_LIST_TYPE = orderList_types_index.ORDER_LIST_TYPE;
|
|
122
|
+
exports.QuotePlugin = quote_index.QuotePlugin;
|
|
123
|
+
exports.QUOTE_KEY = quote_types_index.QUOTE_KEY;
|
|
124
|
+
exports.SelectionHOC = selection.SelectionHOC;
|
|
125
|
+
exports.SelectionPlugin = selection.SelectionPlugin;
|
|
126
|
+
exports.getMountDOM = dom.getMountDOM;
|
|
127
|
+
exports.preventContextEvent = dom.preventContextEvent;
|
|
128
|
+
exports.scrollIfNeeded = dom.scrollIfNeeded;
|
|
129
|
+
exports.setMountDOM = dom.setMountDOM;
|
|
130
|
+
exports.isEmptyLine = is.isEmptyLine;
|
|
131
|
+
exports.isKeyCode = is.isKeyCode;
|
|
132
|
+
exports.Shortcut = shortcut_index.Shortcut;
|
|
133
|
+
exports.StrikePlugin = strike_index.StrikePlugin;
|
|
134
|
+
exports.STRIKE_KEY = strike_types_index.STRIKE_KEY;
|
|
135
|
+
exports.FloatToolbar = toolbar_index.FloatToolbar;
|
|
136
|
+
exports.Mixin = toolbar_index.Mixin;
|
|
137
|
+
exports.Toolbar = toolbar_index.Toolbar;
|
|
138
|
+
exports.ToolbarContext = toolbar_index.ToolbarContext;
|
|
139
|
+
exports.useToolbarContext = toolbar_index.useToolbarContext;
|
|
140
|
+
exports.UnderlinePlugin = underline_index.UnderlinePlugin;
|
|
141
|
+
exports.UNDERLINE_KEY = underline_types_index.UNDERLINE_KEY;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import "./styles/index.scss";
|
|
2
|
+
import type { Editor, SerializeContext } from "@block-kit/core";
|
|
3
|
+
import type { AttributeMap } from "@block-kit/delta";
|
|
4
|
+
import type { ReactLeafContext } from "@block-kit/react";
|
|
5
|
+
import { EditorPlugin } from "@block-kit/react";
|
|
6
|
+
import type { ReactNode } from "react";
|
|
7
|
+
export declare class InlineCodePlugin extends EditorPlugin {
|
|
8
|
+
key: string;
|
|
9
|
+
destroy(): void;
|
|
10
|
+
constructor(editor: Editor);
|
|
11
|
+
match(attrs: AttributeMap): boolean;
|
|
12
|
+
serialize(context: SerializeContext): SerializeContext;
|
|
13
|
+
renderLeaf(context: ReactLeafContext): ReactNode;
|
|
14
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib_es6 = require('../tslib.es6-d44c9a95.js');
|
|
6
|
+
var core = require('@block-kit/core');
|
|
7
|
+
var react = require('@block-kit/react');
|
|
8
|
+
var inlineCode_types_index = require('./types/index.js');
|
|
9
|
+
|
|
10
|
+
class InlineCodePlugin extends react.EditorPlugin {
|
|
11
|
+
destroy() { }
|
|
12
|
+
constructor(editor) {
|
|
13
|
+
super();
|
|
14
|
+
this.key = inlineCode_types_index.INLINE_CODE;
|
|
15
|
+
editor.command.register(inlineCode_types_index.INLINE_CODE, context => {
|
|
16
|
+
const sel = editor.selection.get();
|
|
17
|
+
sel && editor.perform.applyMarks(sel, { [inlineCode_types_index.INLINE_CODE]: context.value });
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
match(attrs) {
|
|
21
|
+
return !!attrs[inlineCode_types_index.INLINE_CODE];
|
|
22
|
+
}
|
|
23
|
+
serialize(context) {
|
|
24
|
+
const { op, html } = context;
|
|
25
|
+
if (op.attributes && op.attributes[inlineCode_types_index.INLINE_CODE]) {
|
|
26
|
+
const strong = document.createElement("code");
|
|
27
|
+
strong.appendChild(html);
|
|
28
|
+
context.html = strong;
|
|
29
|
+
}
|
|
30
|
+
return context;
|
|
31
|
+
}
|
|
32
|
+
renderLeaf(context) {
|
|
33
|
+
const leaf = context.leafState;
|
|
34
|
+
const prev = leaf.prev(false);
|
|
35
|
+
const next = leaf.next(false);
|
|
36
|
+
if (!prev || !prev.op.attributes || !prev.op.attributes[inlineCode_types_index.INLINE_CODE]) {
|
|
37
|
+
context.classList.push("block-kit-inline-code-start");
|
|
38
|
+
}
|
|
39
|
+
context.classList.push("block-kit-inline-code");
|
|
40
|
+
if (!next || !next.op.attributes || !next.op.attributes[inlineCode_types_index.INLINE_CODE]) {
|
|
41
|
+
context.classList.push("block-kit-inline-code-end");
|
|
42
|
+
}
|
|
43
|
+
return context.children;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
tslib_es6.__decorate([
|
|
47
|
+
core.Priority(100)
|
|
48
|
+
], InlineCodePlugin.prototype, "renderLeaf", null);
|
|
49
|
+
|
|
50
|
+
exports.InlineCodePlugin = InlineCodePlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const INLINE_CODE = "inline-code";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var bulletList_types_index = require('./bullet-list/types/index.js');
|
|
4
|
+
var orderList_types_index = require('./order-list/types/index.js');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 检查有序列表
|
|
8
|
+
* @param attrs
|
|
9
|
+
*/
|
|
10
|
+
const isOrderList = (attrs) => {
|
|
11
|
+
return attrs[bulletList_types_index.LIST_TYPE_KEY] === orderList_types_index.ORDER_LIST_TYPE;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
exports.isOrderList = isOrderList;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var delta = require('@block-kit/delta');
|
|
4
|
+
|
|
5
|
+
const isEmptyLine = (line) => {
|
|
6
|
+
if (!line)
|
|
7
|
+
return true;
|
|
8
|
+
const lastLeaf = line.getLastLeaf();
|
|
9
|
+
const leaves = line.getLeaves();
|
|
10
|
+
// 没有最后的叶子结点, 或者仅单个节点且最后的叶子结点是换行符
|
|
11
|
+
return !lastLeaf || (leaves.length === 1 && delta.isEOLOp(lastLeaf.op));
|
|
12
|
+
};
|
|
13
|
+
const isKeyCode = (event, code) => {
|
|
14
|
+
return event.keyCode === code;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
exports.isEmptyLine = isEmptyLine;
|
|
18
|
+
exports.isKeyCode = isKeyCode;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var bulletList_types_index = require('./bullet-list/types/index.js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 检查无序列表
|
|
7
|
+
* @param attrs
|
|
8
|
+
*/
|
|
9
|
+
const isBulletList = (attrs) => {
|
|
10
|
+
return attrs[bulletList_types_index.LIST_TYPE_KEY] === bulletList_types_index.BULLET_LIST_TYPE;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
exports.isBulletList = isBulletList;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { DeserializeContext, SerializeContext } from "@block-kit/core";
|
|
2
|
+
import type { Editor } from "@block-kit/core";
|
|
3
|
+
import type { AttributeMap } from "@block-kit/delta";
|
|
4
|
+
import type { ReactLeafContext } from "@block-kit/react";
|
|
5
|
+
import { EditorPlugin } from "@block-kit/react";
|
|
6
|
+
import type { ReactNode } from "react";
|
|
7
|
+
export declare class ItalicPlugin extends EditorPlugin {
|
|
8
|
+
key: string;
|
|
9
|
+
destroy(): void;
|
|
10
|
+
constructor(editor: Editor);
|
|
11
|
+
match(attrs: AttributeMap): boolean;
|
|
12
|
+
serialize(context: SerializeContext): SerializeContext;
|
|
13
|
+
deserialize(context: DeserializeContext): DeserializeContext;
|
|
14
|
+
renderLeaf(context: ReactLeafContext): ReactNode;
|
|
15
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@block-kit/core');
|
|
6
|
+
var react = require('@block-kit/react');
|
|
7
|
+
var utils = require('@block-kit/utils');
|
|
8
|
+
var italic_types_index = require('./types/index.js');
|
|
9
|
+
|
|
10
|
+
class ItalicPlugin extends react.EditorPlugin {
|
|
11
|
+
destroy() { }
|
|
12
|
+
constructor(editor) {
|
|
13
|
+
super();
|
|
14
|
+
this.key = italic_types_index.ITALIC_KEY;
|
|
15
|
+
editor.command.register(italic_types_index.ITALIC_KEY, context => {
|
|
16
|
+
const sel = editor.selection.get();
|
|
17
|
+
sel && editor.perform.applyMarks(sel, { [italic_types_index.ITALIC_KEY]: context.value });
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
match(attrs) {
|
|
21
|
+
return !!attrs[italic_types_index.ITALIC_KEY];
|
|
22
|
+
}
|
|
23
|
+
serialize(context) {
|
|
24
|
+
const { op, html } = context;
|
|
25
|
+
if (op.attributes && op.attributes[italic_types_index.ITALIC_KEY]) {
|
|
26
|
+
const strong = document.createElement("em");
|
|
27
|
+
strong.appendChild(html);
|
|
28
|
+
context.html = strong;
|
|
29
|
+
}
|
|
30
|
+
return context;
|
|
31
|
+
}
|
|
32
|
+
deserialize(context) {
|
|
33
|
+
const { delta, html } = context;
|
|
34
|
+
if (!utils.isHTMLElement(html))
|
|
35
|
+
return context;
|
|
36
|
+
if (core.isMatchHTMLTag(html, "em") || html.style.fontStyle === "italic") {
|
|
37
|
+
core.applyMarker(delta, { [italic_types_index.ITALIC_KEY]: utils.TRULY });
|
|
38
|
+
}
|
|
39
|
+
return context;
|
|
40
|
+
}
|
|
41
|
+
renderLeaf(context) {
|
|
42
|
+
context.style.fontStyle = "italic";
|
|
43
|
+
return context.children;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
exports.ItalicPlugin = ItalicPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ITALIC_KEY = "italic";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Editor } from "@block-kit/core";
|
|
2
|
+
import type { AttributeMap } from "@block-kit/delta";
|
|
3
|
+
import type { ReactLineContext } from "@block-kit/react";
|
|
4
|
+
import { EditorPlugin } from "@block-kit/react";
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
export declare class LineHeightPlugin extends EditorPlugin {
|
|
7
|
+
key: string;
|
|
8
|
+
destroy(): void;
|
|
9
|
+
constructor(editor: Editor);
|
|
10
|
+
match(attrs: AttributeMap): boolean;
|
|
11
|
+
renderLine(context: ReactLineContext): ReactNode;
|
|
12
|
+
}
|