@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,12 @@
|
|
|
1
|
+
import type { Editor, SelectionChangeEvent } from "@block-kit/core";
|
|
2
|
+
import type { SelectionHOC } from "../components/selection";
|
|
3
|
+
export declare class SelectionPlugin {
|
|
4
|
+
editor: Editor;
|
|
5
|
+
/** id <-> React.ReactNode */
|
|
6
|
+
protected idToView: Map<string, SelectionHOC>;
|
|
7
|
+
constructor(editor: Editor);
|
|
8
|
+
destroy(): void;
|
|
9
|
+
mountView(id: string, view: SelectionHOC): void;
|
|
10
|
+
unmountView(id: string): void;
|
|
11
|
+
protected onSelectionChange(e: SelectionChangeEvent): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { Editor } from "@block-kit/core";
|
|
2
|
+
import type { EventContext } from "@block-kit/utils";
|
|
3
|
+
/**
|
|
4
|
+
* 设置挂载 DOM
|
|
5
|
+
* @param editor
|
|
6
|
+
* @param dom
|
|
7
|
+
*/
|
|
8
|
+
export declare const setMountDOM: (editor: Editor, dom: HTMLElement | null) => void;
|
|
9
|
+
/**
|
|
10
|
+
* 获取挂载 DOM
|
|
11
|
+
* @param editor
|
|
12
|
+
* @param dom
|
|
13
|
+
*/
|
|
14
|
+
export declare const getMountDOM: (editor: Editor) => HTMLElement;
|
|
15
|
+
/**
|
|
16
|
+
* 阻止所有编辑器分发的事件
|
|
17
|
+
* @param event
|
|
18
|
+
* @param context
|
|
19
|
+
*/
|
|
20
|
+
export declare const preventContextEvent: (event: Event, context: EventContext) => void;
|
|
21
|
+
/**
|
|
22
|
+
* 滚动到指定元素
|
|
23
|
+
* @param container
|
|
24
|
+
* @param child
|
|
25
|
+
*/
|
|
26
|
+
export declare const scrollIfNeeded: (container: HTMLDivElement, child: Element, buffer?: number) => void;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Editor } from "@block-kit/core";
|
|
2
|
+
import { CorePlugin } from "@block-kit/core";
|
|
3
|
+
import type { O } from "@block-kit/utils/dist/es/types";
|
|
4
|
+
import type { ShortcutFunc, ShortcutFuncMap } from "./types";
|
|
5
|
+
export declare class Shortcut extends CorePlugin {
|
|
6
|
+
protected editor: Editor;
|
|
7
|
+
key: string;
|
|
8
|
+
protected config: ShortcutFunc[];
|
|
9
|
+
constructor(editor: Editor, config?: ShortcutFuncMap);
|
|
10
|
+
destroy(): void;
|
|
11
|
+
match(): boolean;
|
|
12
|
+
protected getKeys(): O.Map<string>;
|
|
13
|
+
protected onKeydown(event: KeyboardEvent): void;
|
|
14
|
+
}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { _ as __decorate } from '../tslib.es6-83956cc1.js';
|
|
2
|
+
import { CorePlugin, EDITOR_EVENT } from '@block-kit/core';
|
|
3
|
+
import { CTRL_KEY, KEY_CODE, NIL, TRULY, Bind } from '@block-kit/utils';
|
|
4
|
+
import { f as filterLineMarkMap, a as filterMarkMap, P as PLUGIN_EVENTS } from '../marks-ac0ec630.js';
|
|
5
|
+
import { BOLD_KEY } from '../bold/types/index.js';
|
|
6
|
+
import { ITALIC_KEY } from '../italic/types/index.js';
|
|
7
|
+
import { a as isKeyCode } from '../is-3de778e2.js';
|
|
8
|
+
import { SHORTCUT_KEY } from './types/index.js';
|
|
9
|
+
import '@block-kit/delta';
|
|
10
|
+
|
|
11
|
+
const PRESET_SHORTCUT = {
|
|
12
|
+
[BOLD_KEY]: (event, payload) => {
|
|
13
|
+
if (event[CTRL_KEY] && isKeyCode(event, KEY_CODE.B) && payload.sel) {
|
|
14
|
+
const { editor, keys, sel } = payload;
|
|
15
|
+
editor.perform.applyMarks(sel, { [BOLD_KEY]: keys[BOLD_KEY] ? NIL : TRULY });
|
|
16
|
+
return true;
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
[ITALIC_KEY]: (event, payload) => {
|
|
20
|
+
if (event[CTRL_KEY] && isKeyCode(event, KEY_CODE.I) && payload.sel) {
|
|
21
|
+
const { editor, keys, sel } = payload;
|
|
22
|
+
editor.perform.applyMarks(sel, { [ITALIC_KEY]: keys[ITALIC_KEY] ? NIL : TRULY });
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
class Shortcut extends CorePlugin {
|
|
29
|
+
constructor(editor, config) {
|
|
30
|
+
super();
|
|
31
|
+
this.editor = editor;
|
|
32
|
+
this.key = SHORTCUT_KEY;
|
|
33
|
+
this.config = Object.values(Object.assign(Object.assign({}, PRESET_SHORTCUT), config));
|
|
34
|
+
this.editor.event.on(EDITOR_EVENT.KEY_DOWN, this.onKeydown, 1000);
|
|
35
|
+
}
|
|
36
|
+
destroy() {
|
|
37
|
+
this.editor.event.off(EDITOR_EVENT.KEY_DOWN, this.onKeydown);
|
|
38
|
+
}
|
|
39
|
+
match() {
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
getKeys() {
|
|
43
|
+
const current = this.editor.selection.get();
|
|
44
|
+
if (!current) {
|
|
45
|
+
return {};
|
|
46
|
+
}
|
|
47
|
+
const lines = this.editor.state.block.getLines();
|
|
48
|
+
const { start, end } = current;
|
|
49
|
+
const lineMarkMap = filterLineMarkMap(lines.slice(start.line, end.line + 1).map(line => line.attributes));
|
|
50
|
+
if (current.isCollapsed) {
|
|
51
|
+
return Object.assign(Object.assign({}, this.editor.collect.marks), lineMarkMap);
|
|
52
|
+
}
|
|
53
|
+
const ops = [];
|
|
54
|
+
if (current.isCollapsed) {
|
|
55
|
+
const op = this.editor.collect.getOpAtPoint(current.start);
|
|
56
|
+
op && ops.push(op);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const fragment = this.editor.collect.getFragment();
|
|
60
|
+
fragment && ops.push(...fragment);
|
|
61
|
+
}
|
|
62
|
+
const markMap = filterMarkMap(ops);
|
|
63
|
+
return Object.assign(Object.assign({}, markMap), lineMarkMap);
|
|
64
|
+
}
|
|
65
|
+
onKeydown(event) {
|
|
66
|
+
const keys = this.getKeys();
|
|
67
|
+
const payload = {
|
|
68
|
+
keys,
|
|
69
|
+
editor: this.editor,
|
|
70
|
+
sel: this.editor.selection.get(),
|
|
71
|
+
};
|
|
72
|
+
for (const func of this.config) {
|
|
73
|
+
const result = func(event, payload);
|
|
74
|
+
if (!result)
|
|
75
|
+
continue;
|
|
76
|
+
this.editor.event.trigger(PLUGIN_EVENTS.SHORTCUT_MARKS_CHANGE, null);
|
|
77
|
+
break;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
__decorate([
|
|
82
|
+
Bind
|
|
83
|
+
], Shortcut.prototype, "onKeydown", null);
|
|
84
|
+
|
|
85
|
+
export { Shortcut };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { Editor } from "@block-kit/core";
|
|
2
|
+
import type { Range } from "@block-kit/core";
|
|
3
|
+
import type { O, P } from "@block-kit/utils/dist/es/types";
|
|
4
|
+
export declare const SHORTCUT_KEY = "SHORTCUT_KEY";
|
|
5
|
+
export type ShortcutFunc = (event: KeyboardEvent, payload: {
|
|
6
|
+
editor: Editor;
|
|
7
|
+
keys: O.Map<string>;
|
|
8
|
+
sel: Range | null;
|
|
9
|
+
}) => true | P.Nil;
|
|
10
|
+
export type ShortcutFuncMap = O.Map<ShortcutFunc>;
|
|
@@ -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 StrikePlugin 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
|
+
import { isMatchHTMLTag, applyMarker } from '@block-kit/core';
|
|
2
|
+
import { EditorPlugin } from '@block-kit/react';
|
|
3
|
+
import { isHTMLElement, TRULY } from '@block-kit/utils';
|
|
4
|
+
import { STRIKE_KEY } from './types/index.js';
|
|
5
|
+
|
|
6
|
+
class StrikePlugin extends EditorPlugin {
|
|
7
|
+
destroy() { }
|
|
8
|
+
constructor(editor) {
|
|
9
|
+
super();
|
|
10
|
+
this.key = STRIKE_KEY;
|
|
11
|
+
editor.command.register(STRIKE_KEY, context => {
|
|
12
|
+
const sel = editor.selection.get();
|
|
13
|
+
sel && editor.perform.applyMarks(sel, { [STRIKE_KEY]: context.value });
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
match(attrs) {
|
|
17
|
+
return !!attrs[STRIKE_KEY];
|
|
18
|
+
}
|
|
19
|
+
serialize(context) {
|
|
20
|
+
const { op, html } = context;
|
|
21
|
+
if (op.attributes && op.attributes[STRIKE_KEY]) {
|
|
22
|
+
const strong = document.createElement("del");
|
|
23
|
+
strong.appendChild(html);
|
|
24
|
+
context.html = strong;
|
|
25
|
+
}
|
|
26
|
+
return context;
|
|
27
|
+
}
|
|
28
|
+
deserialize(context) {
|
|
29
|
+
const { delta, html } = context;
|
|
30
|
+
if (!isHTMLElement(html))
|
|
31
|
+
return context;
|
|
32
|
+
if (isMatchHTMLTag(html, "s") ||
|
|
33
|
+
isMatchHTMLTag(html, "del") ||
|
|
34
|
+
html.style.textDecorationLine === "line-through") {
|
|
35
|
+
applyMarker(delta, { [STRIKE_KEY]: TRULY });
|
|
36
|
+
}
|
|
37
|
+
return context;
|
|
38
|
+
}
|
|
39
|
+
renderLeaf(context) {
|
|
40
|
+
context.style.textDecoration = context.style.textDecoration
|
|
41
|
+
? context.style.textDecoration + " line-through"
|
|
42
|
+
: "line-through";
|
|
43
|
+
return context.children;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export { StrikePlugin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const STRIKE_KEY = "strike";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Editor } from "@block-kit/core";
|
|
2
|
+
import type { Range } from "@block-kit/core";
|
|
3
|
+
import React from "react";
|
|
4
|
+
export type ToolbarContextType = {
|
|
5
|
+
editor: Editor;
|
|
6
|
+
refreshMarks: () => void;
|
|
7
|
+
keys: Record<string, string>;
|
|
8
|
+
setKeys: (v: Record<string, string>) => void;
|
|
9
|
+
selection: Range | null;
|
|
10
|
+
};
|
|
11
|
+
export declare const ToolbarContext: React.Context<ToolbarContextType>;
|
|
12
|
+
export declare const useToolbarContext: () => ToolbarContextType;
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export { Toolbar } from "./context/basic";
|
|
3
|
+
export { FloatToolbar } from "./context/float";
|
|
4
|
+
export declare const Mixin: {
|
|
5
|
+
Cut: import("react").FC;
|
|
6
|
+
Bold: import("react").FC;
|
|
7
|
+
Link: import("react").FC<{
|
|
8
|
+
filterXSS?: ((v: string) => string) | undefined;
|
|
9
|
+
}>;
|
|
10
|
+
Quote: import("react").FC;
|
|
11
|
+
Image: import("react").FC;
|
|
12
|
+
Align: import("react").FC;
|
|
13
|
+
Emoji: import("react").FC;
|
|
14
|
+
Italic: import("react").FC;
|
|
15
|
+
Strike: import("react").FC;
|
|
16
|
+
History: import("react").FC;
|
|
17
|
+
Heading: import("react").FC;
|
|
18
|
+
Divider: import("react").FC;
|
|
19
|
+
FontSize: import("react").FC;
|
|
20
|
+
FontColor: import("react").FC;
|
|
21
|
+
OrderList: import("react").FC;
|
|
22
|
+
Underline: import("react").FC;
|
|
23
|
+
BulletList: import("react").FC;
|
|
24
|
+
InlineCode: import("react").FC;
|
|
25
|
+
LineHeight: import("react").FC;
|
|
26
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
export { F as FloatToolbar, M as Mixin, T as Toolbar } from '../index-ddc2e5ac.js';
|
|
2
|
+
import 'react/jsx-runtime';
|
|
3
|
+
import '@arco-design/web-react';
|
|
4
|
+
import '@arco-design/web-react/icon';
|
|
5
|
+
import '@block-kit/utils';
|
|
6
|
+
import '../align/types/index.js';
|
|
7
|
+
import 'react';
|
|
8
|
+
import '../bold/types/index.js';
|
|
9
|
+
import '../bullet-list/types/index.js';
|
|
10
|
+
import '../is-2b264ec8.js';
|
|
11
|
+
import '../divider/types/index.js';
|
|
12
|
+
import '@emoji-mart/react';
|
|
13
|
+
import '../emoji/types/index.js';
|
|
14
|
+
import '../background/types/index.js';
|
|
15
|
+
import '../font-color/types/index.js';
|
|
16
|
+
import '../font-size/types/index.js';
|
|
17
|
+
import '../heading/types/index.js';
|
|
18
|
+
import '@block-kit/core';
|
|
19
|
+
import '@block-kit/utils/dist/es/hooks';
|
|
20
|
+
import '../image/types/index.js';
|
|
21
|
+
import '../inline-code/types/index.js';
|
|
22
|
+
import '../italic/types/index.js';
|
|
23
|
+
import '../line-height/types/index.js';
|
|
24
|
+
import '@arco-design/web-react/es/Form/useForm';
|
|
25
|
+
import '../link/types/index.js';
|
|
26
|
+
import '../order-list/types/index.js';
|
|
27
|
+
import '../is-7f3ae820.js';
|
|
28
|
+
import '../quote/types/index.js';
|
|
29
|
+
import '../strike/types/index.js';
|
|
30
|
+
import '../underline/types/index.js';
|
|
31
|
+
import '@block-kit/react';
|
|
32
|
+
import '../marks-ac0ec630.js';
|
|
33
|
+
import 'react-dom';
|
|
34
|
+
import '../dom-71a99400.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export declare const TOOLBAR_TYPES: readonly ["bold", "inline-code"];
|
|
3
|
+
export declare const TOOLBAR_KEY_SET: Set<"bold" | "inline-code">;
|
|
4
|
+
export type ToolbarProps = {
|
|
5
|
+
className?: string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
styles?: React.CSSProperties;
|
|
8
|
+
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/******************************************************************************
|
|
2
|
+
Copyright (c) Microsoft Corporation.
|
|
3
|
+
|
|
4
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
5
|
+
purpose with or without fee is hereby granted.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
8
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
9
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
10
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
11
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
12
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
13
|
+
PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
+
***************************************************************************** */
|
|
15
|
+
|
|
16
|
+
function __decorate(decorators, target, key, desc) {
|
|
17
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
18
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
19
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
20
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
function __awaiter(thisArg, _arguments, P, generator) {
|
|
24
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
25
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
26
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
27
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
28
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
29
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) {
|
|
34
|
+
var e = new Error(message);
|
|
35
|
+
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export { __decorate as _, __awaiter as a };
|
|
@@ -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 UnderlinePlugin 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,45 @@
|
|
|
1
|
+
import { isMatchHTMLTag, applyMarker } from '@block-kit/core';
|
|
2
|
+
import { EditorPlugin } from '@block-kit/react';
|
|
3
|
+
import { isHTMLElement, TRULY } from '@block-kit/utils';
|
|
4
|
+
import { UNDERLINE_KEY } from './types/index.js';
|
|
5
|
+
|
|
6
|
+
class UnderlinePlugin extends EditorPlugin {
|
|
7
|
+
destroy() { }
|
|
8
|
+
constructor(editor) {
|
|
9
|
+
super();
|
|
10
|
+
this.key = UNDERLINE_KEY;
|
|
11
|
+
editor.command.register(UNDERLINE_KEY, context => {
|
|
12
|
+
const sel = editor.selection.get();
|
|
13
|
+
sel && editor.perform.applyMarks(sel, { [UNDERLINE_KEY]: context.value });
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
match(attrs) {
|
|
17
|
+
return !!attrs[UNDERLINE_KEY];
|
|
18
|
+
}
|
|
19
|
+
serialize(context) {
|
|
20
|
+
const { op, html } = context;
|
|
21
|
+
if (op.attributes && op.attributes[UNDERLINE_KEY]) {
|
|
22
|
+
const strong = document.createElement("u");
|
|
23
|
+
strong.appendChild(html);
|
|
24
|
+
context.html = strong;
|
|
25
|
+
}
|
|
26
|
+
return context;
|
|
27
|
+
}
|
|
28
|
+
deserialize(context) {
|
|
29
|
+
const { delta, html } = context;
|
|
30
|
+
if (!isHTMLElement(html))
|
|
31
|
+
return context;
|
|
32
|
+
if (isMatchHTMLTag(html, "u") || html.style.textDecoration === "underline") {
|
|
33
|
+
applyMarker(delta, { [UNDERLINE_KEY]: TRULY });
|
|
34
|
+
}
|
|
35
|
+
return context;
|
|
36
|
+
}
|
|
37
|
+
renderLeaf(context) {
|
|
38
|
+
context.style.textDecoration = context.style.textDecoration
|
|
39
|
+
? context.style.textDecoration + " underline"
|
|
40
|
+
: "underline";
|
|
41
|
+
return context.children;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { UnderlinePlugin };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const UNDERLINE_KEY = "underline";
|
|
@@ -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 AlignPlugin extends EditorPlugin {
|
|
7
|
+
key: string;
|
|
8
|
+
destroy(): void;
|
|
9
|
+
constructor(editor: Editor);
|
|
10
|
+
match(attrs: AttributeMap): boolean;
|
|
11
|
+
renderLine(context: ReactLineContext): ReactNode;
|
|
12
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var react = require('@block-kit/react');
|
|
6
|
+
var align_types_index = require('./types/index.js');
|
|
7
|
+
|
|
8
|
+
class AlignPlugin extends react.EditorPlugin {
|
|
9
|
+
destroy() { }
|
|
10
|
+
constructor(editor) {
|
|
11
|
+
super();
|
|
12
|
+
this.key = align_types_index.ALIGN_KEY;
|
|
13
|
+
editor.command.register(align_types_index.ALIGN_KEY, context => {
|
|
14
|
+
const sel = editor.selection.get();
|
|
15
|
+
sel && editor.perform.applyLineMarks(sel, { [align_types_index.ALIGN_KEY]: context.value });
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
match(attrs) {
|
|
19
|
+
return !!attrs[align_types_index.ALIGN_KEY];
|
|
20
|
+
}
|
|
21
|
+
renderLine(context) {
|
|
22
|
+
const attrs = context.attributes || {};
|
|
23
|
+
const align = attrs[align_types_index.ALIGN_KEY];
|
|
24
|
+
context.style.textAlign = align;
|
|
25
|
+
return context.children;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
exports.AlignPlugin = AlignPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const ALIGN_KEY = "align";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Editor } from "@block-kit/core";
|
|
2
|
+
import type { AttributeMap } from "@block-kit/delta";
|
|
3
|
+
import type { ReactLeafContext } from "@block-kit/react";
|
|
4
|
+
import { EditorPlugin } from "@block-kit/react";
|
|
5
|
+
import type { ReactNode } from "react";
|
|
6
|
+
export declare class BackgroundPlugin extends EditorPlugin {
|
|
7
|
+
key: string;
|
|
8
|
+
destroy(): void;
|
|
9
|
+
constructor(editor: Editor);
|
|
10
|
+
match(attrs: AttributeMap): boolean;
|
|
11
|
+
renderLeaf(context: ReactLeafContext): ReactNode;
|
|
12
|
+
}
|