@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,29 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var react = require('@block-kit/react');
|
|
6
|
+
var lineHeight_types_index = require('./types/index.js');
|
|
7
|
+
|
|
8
|
+
class LineHeightPlugin extends react.EditorPlugin {
|
|
9
|
+
destroy() { }
|
|
10
|
+
constructor(editor) {
|
|
11
|
+
super();
|
|
12
|
+
this.key = lineHeight_types_index.LINE_HEIGHT_KEY;
|
|
13
|
+
editor.command.register(lineHeight_types_index.LINE_HEIGHT_KEY, context => {
|
|
14
|
+
const sel = editor.selection.get();
|
|
15
|
+
sel && editor.perform.applyLineMarks(sel, { [lineHeight_types_index.LINE_HEIGHT_KEY]: context.value });
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
match(attrs) {
|
|
19
|
+
return !!attrs[lineHeight_types_index.LINE_HEIGHT_KEY];
|
|
20
|
+
}
|
|
21
|
+
renderLine(context) {
|
|
22
|
+
const attrs = context.attributes || {};
|
|
23
|
+
const height = attrs[lineHeight_types_index.LINE_HEIGHT_KEY];
|
|
24
|
+
context.style.lineHeight = height;
|
|
25
|
+
return context.children;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
exports.LineHeightPlugin = LineHeightPlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const LINE_HEIGHT_KEY = "line-height";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { Editor } from "@block-kit/core";
|
|
3
|
+
import type { CMDPayload } from "@block-kit/core";
|
|
4
|
+
import type { AttributeMap } from "@block-kit/delta";
|
|
5
|
+
import type { ReactLeafContext, ReactWrapLeafContext } from "@block-kit/react";
|
|
6
|
+
import { EditorPlugin } from "@block-kit/react";
|
|
7
|
+
export declare class LinkPlugin extends EditorPlugin {
|
|
8
|
+
protected editor: Editor;
|
|
9
|
+
key: string;
|
|
10
|
+
protected modal: HTMLDivElement | null;
|
|
11
|
+
constructor(editor: Editor);
|
|
12
|
+
destroy(): void;
|
|
13
|
+
match(attrs: AttributeMap): boolean;
|
|
14
|
+
wrapLeaf(context: ReactWrapLeafContext): React.ReactNode;
|
|
15
|
+
renderLeaf(context: ReactLeafContext): React.ReactNode;
|
|
16
|
+
onExec(payload: CMDPayload): undefined;
|
|
17
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib_es6 = require('../tslib.es6-d44c9a95.js');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var react = require('@block-kit/react');
|
|
8
|
+
var utils = require('@block-kit/utils');
|
|
9
|
+
var link_types_index = require('./types/index.js');
|
|
10
|
+
require('@block-kit/core');
|
|
11
|
+
|
|
12
|
+
const A = props => {
|
|
13
|
+
const { attrs } = props;
|
|
14
|
+
const { readonly } = react.useReadonly();
|
|
15
|
+
const href = attrs[link_types_index.LINK_KEY];
|
|
16
|
+
const target = attrs[link_types_index.LINK_BLANK_KEY] ? "_blank" : "_self";
|
|
17
|
+
const onClick = (e) => {
|
|
18
|
+
e[utils.CTRL_KEY] && window.open(href, "_blank");
|
|
19
|
+
e.preventDefault();
|
|
20
|
+
};
|
|
21
|
+
return (jsxRuntime.jsx("a", { href: href, target: target, rel: "noreferrer", className: "block-kit-hyper-link", onClick: readonly ? void 0 : onClick, children: props.children }));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
class LinkPlugin extends react.EditorPlugin {
|
|
25
|
+
constructor(editor) {
|
|
26
|
+
super();
|
|
27
|
+
this.editor = editor;
|
|
28
|
+
this.key = link_types_index.LINK_KEY;
|
|
29
|
+
this.modal = null;
|
|
30
|
+
editor.command.register(this.key, this.onExec);
|
|
31
|
+
}
|
|
32
|
+
destroy() {
|
|
33
|
+
this.modal && this.modal.remove();
|
|
34
|
+
this.modal = null;
|
|
35
|
+
}
|
|
36
|
+
match(attrs) {
|
|
37
|
+
return !!attrs[link_types_index.LINK_KEY] || !!attrs[link_types_index.LINK_TEMP_KEY];
|
|
38
|
+
}
|
|
39
|
+
wrapLeaf(context) {
|
|
40
|
+
const state = context.leafState;
|
|
41
|
+
const attrs = state.op.attributes || {};
|
|
42
|
+
const href = attrs[link_types_index.LINK_KEY];
|
|
43
|
+
if (!href)
|
|
44
|
+
return context.children;
|
|
45
|
+
return jsxRuntime.jsx(A, { attrs: attrs, children: context.children });
|
|
46
|
+
}
|
|
47
|
+
renderLeaf(context) {
|
|
48
|
+
const attrs = context.attributes;
|
|
49
|
+
if (attrs && attrs[link_types_index.LINK_TEMP_KEY]) {
|
|
50
|
+
context.style.backgroundColor = "rgba(0, 0, 0, 0.1)";
|
|
51
|
+
}
|
|
52
|
+
return context.children;
|
|
53
|
+
}
|
|
54
|
+
onExec(payload) {
|
|
55
|
+
const range = this.editor.selection.get() || payload.range;
|
|
56
|
+
const attrs = payload.attrs;
|
|
57
|
+
if (!range || attrs)
|
|
58
|
+
return void 0;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
tslib_es6.__decorate([
|
|
62
|
+
react.InjectWrapKeys(link_types_index.LINK_KEY)
|
|
63
|
+
], LinkPlugin.prototype, "wrapLeaf", null);
|
|
64
|
+
tslib_es6.__decorate([
|
|
65
|
+
utils.Bind
|
|
66
|
+
], LinkPlugin.prototype, "onExec", null);
|
|
67
|
+
|
|
68
|
+
exports.LinkPlugin = LinkPlugin;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var core = require('@block-kit/core');
|
|
6
|
+
|
|
7
|
+
const LINK_KEY = "link";
|
|
8
|
+
const LINK_BLANK_KEY = "link-blank";
|
|
9
|
+
const LINK_TEMP_KEY = core.CLIENT_KEY + "temp-link";
|
|
10
|
+
|
|
11
|
+
exports.LINK_BLANK_KEY = LINK_BLANK_KEY;
|
|
12
|
+
exports.LINK_KEY = LINK_KEY;
|
|
13
|
+
exports.LINK_TEMP_KEY = LINK_TEMP_KEY;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const PLUGIN_EVENTS = {
|
|
4
|
+
SHORTCUT_MARKS_CHANGE: "SHORTCUT_MARKS_CHANGE",
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const filterMarkMap = (ops) => {
|
|
8
|
+
const firstOp = ops[0];
|
|
9
|
+
if (!firstOp || !firstOp.attributes)
|
|
10
|
+
return {};
|
|
11
|
+
// FIX: 取首个对象会被 immutable 的设计影响
|
|
12
|
+
// 因此这里必须要将其 clone, 否则会影响渲染的内容
|
|
13
|
+
const target = Object.assign({}, firstOp.attributes);
|
|
14
|
+
// 全部存在且相同的属性才认为是此时存在的 mark
|
|
15
|
+
for (let i = 1; i < ops.length; i++) {
|
|
16
|
+
const op = ops[i];
|
|
17
|
+
const attrs = op.attributes;
|
|
18
|
+
const keys = attrs && Object.keys(attrs);
|
|
19
|
+
if (!keys || !keys.length)
|
|
20
|
+
return {};
|
|
21
|
+
for (const key of keys) {
|
|
22
|
+
if (attrs[key] !== target[key]) {
|
|
23
|
+
delete target[key];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
return target;
|
|
28
|
+
};
|
|
29
|
+
const filterLineMarkMap = (attrs) => {
|
|
30
|
+
if (!attrs.length)
|
|
31
|
+
return {};
|
|
32
|
+
// FIX: 取首个对象会被 immutable 的设计影响
|
|
33
|
+
// 因此这里必须要将其 clone, 否则会影响渲染的内容
|
|
34
|
+
const target = Object.assign({}, attrs[0]);
|
|
35
|
+
for (let i = 1; i < attrs.length; i++) {
|
|
36
|
+
const keys = Object.keys(attrs[i]);
|
|
37
|
+
if (!keys || !keys.length)
|
|
38
|
+
return {};
|
|
39
|
+
for (const key of keys) {
|
|
40
|
+
if (attrs[i][key] !== target[key]) {
|
|
41
|
+
delete target[key];
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
return target;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.PLUGIN_EVENTS = PLUGIN_EVENTS;
|
|
49
|
+
exports.filterLineMarkMap = filterLineMarkMap;
|
|
50
|
+
exports.filterMarkMap = filterMarkMap;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import "./styles/index.scss";
|
|
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
|
+
import { SuggestModule } from "./modules/suggest";
|
|
8
|
+
export declare class MentionPlugin extends EditorPlugin {
|
|
9
|
+
protected editor: Editor;
|
|
10
|
+
key: string;
|
|
11
|
+
protected suggest: SuggestModule;
|
|
12
|
+
constructor(editor: Editor);
|
|
13
|
+
destroy(): void;
|
|
14
|
+
match(attrs: AttributeMap): boolean;
|
|
15
|
+
renderLeaf(context: ReactLeafContext): ReactNode;
|
|
16
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
require('react/jsx-runtime');
|
|
6
|
+
require('@block-kit/react');
|
|
7
|
+
var mention_index = require('../index-ffc4bb34.js');
|
|
8
|
+
require('./types/index.js');
|
|
9
|
+
require('../tslib.es6-d44c9a95.js');
|
|
10
|
+
require('@block-kit/core');
|
|
11
|
+
require('@block-kit/delta');
|
|
12
|
+
require('@block-kit/utils');
|
|
13
|
+
require('react-dom');
|
|
14
|
+
require('../dom-cb8b8e40.js');
|
|
15
|
+
require('../is-473d664a.js');
|
|
16
|
+
require('@block-kit/utils/dist/es/hooks');
|
|
17
|
+
require('react');
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
exports.MentionPlugin = mention_index.MentionPlugin;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Editor, SelectionChangeEvent } from "@block-kit/core";
|
|
2
|
+
import { Point } from "@block-kit/core";
|
|
3
|
+
export declare class SuggestModule {
|
|
4
|
+
editor: Editor;
|
|
5
|
+
point: Point;
|
|
6
|
+
isMountSuggest: boolean;
|
|
7
|
+
mountSuggestNode: HTMLElement | null;
|
|
8
|
+
rect: {
|
|
9
|
+
top: number;
|
|
10
|
+
left: number;
|
|
11
|
+
} | null;
|
|
12
|
+
constructor(editor: Editor);
|
|
13
|
+
destroy(): void;
|
|
14
|
+
onKeydown(event: KeyboardEvent): void;
|
|
15
|
+
onSelectionChange(event: SelectionChangeEvent): void;
|
|
16
|
+
mountSuggestPanel(text?: string): undefined;
|
|
17
|
+
unmountSuggestPanel(): void;
|
|
18
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { CMDPayload, 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 { EventContext } from "@block-kit/utils";
|
|
6
|
+
import type { ReactNode } from "react";
|
|
7
|
+
export declare class OrderListPlugin extends EditorPlugin {
|
|
8
|
+
protected editor: Editor;
|
|
9
|
+
key: string;
|
|
10
|
+
constructor(editor: Editor);
|
|
11
|
+
destroy(): void;
|
|
12
|
+
match(attrs: AttributeMap): boolean;
|
|
13
|
+
renderLine(context: ReactLineContext): ReactNode;
|
|
14
|
+
protected onExec(payload: CMDPayload): undefined;
|
|
15
|
+
protected onKeyDown(event: KeyboardEvent, context: EventContext): undefined;
|
|
16
|
+
}
|
|
@@ -0,0 +1,327 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var tslib_es6 = require('../tslib.es6-d44c9a95.js');
|
|
6
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
7
|
+
var core = require('@block-kit/core');
|
|
8
|
+
var delta = require('@block-kit/delta');
|
|
9
|
+
var react = require('@block-kit/react');
|
|
10
|
+
var utils = require('@block-kit/utils');
|
|
11
|
+
var bulletList_types_index = require('../bullet-list/types/index.js');
|
|
12
|
+
var indent_types_index = require('../indent/types/index.js');
|
|
13
|
+
var dom = require('../dom-cb8b8e40.js');
|
|
14
|
+
var is$1 = require('../is-473d664a.js');
|
|
15
|
+
var orderList_types_index = require('./types/index.js');
|
|
16
|
+
var is = require('../is-18806678.js');
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 批量刷新选区的列表序号 [批量刷新简单方便]
|
|
20
|
+
* - 从选区开始的第一个列表项开始,逐个刷新序号
|
|
21
|
+
* - 全量刷新序号数据, 最后需要在渲染时批量刷新
|
|
22
|
+
* @param editor
|
|
23
|
+
* @param sel
|
|
24
|
+
*/
|
|
25
|
+
const applyNewOrderList = (editor, range) => {
|
|
26
|
+
const sel = range || editor.selection.get();
|
|
27
|
+
if (!sel)
|
|
28
|
+
return void 0;
|
|
29
|
+
const startPoint = sel.start;
|
|
30
|
+
const block = editor.state.block;
|
|
31
|
+
let start = startPoint.line;
|
|
32
|
+
const selStartLine = block.getLine(sel.start.line);
|
|
33
|
+
const selEndLine = block.getLine(sel.end.line);
|
|
34
|
+
const selEndNextLine = selEndLine && selEndLine.next();
|
|
35
|
+
// 如果当前行不是列表项,且选区结尾下一行是列表项,则从下一行开始探查
|
|
36
|
+
if (selStartLine &&
|
|
37
|
+
!is.isOrderList(selStartLine.attributes) &&
|
|
38
|
+
selEndNextLine &&
|
|
39
|
+
is.isOrderList(selEndNextLine.attributes)) {
|
|
40
|
+
start++;
|
|
41
|
+
}
|
|
42
|
+
// 如果 start 的行属性不存在列表项, 则无需刷新
|
|
43
|
+
const currentLine = block.getLine(start);
|
|
44
|
+
if (!currentLine || !is.isOrderList(currentLine.attributes)) {
|
|
45
|
+
return void 0;
|
|
46
|
+
}
|
|
47
|
+
// 向前查找到第一个列表项
|
|
48
|
+
while (--start >= 0) {
|
|
49
|
+
const line = block.getLine(start);
|
|
50
|
+
if (!line || !is.isOrderList(line.attributes)) {
|
|
51
|
+
start++;
|
|
52
|
+
break;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const delta$1 = new delta.Delta();
|
|
56
|
+
const startLine = block.getLine(start);
|
|
57
|
+
if (!startLine)
|
|
58
|
+
return void 0;
|
|
59
|
+
delta$1.retain(startLine.start);
|
|
60
|
+
// 逐行刷新序号
|
|
61
|
+
const levelToIndex = {};
|
|
62
|
+
for (let i = start; i < block.size; i++) {
|
|
63
|
+
const line = block.getLine(i);
|
|
64
|
+
const attrs = line && line.attributes;
|
|
65
|
+
if (!line || !attrs || !is.isOrderList(attrs))
|
|
66
|
+
break;
|
|
67
|
+
const level = attrs[indent_types_index.INDENT_LEVEL_KEY];
|
|
68
|
+
// 重置序号
|
|
69
|
+
if (attrs[orderList_types_index.LIST_RESTART_KEY]) {
|
|
70
|
+
levelToIndex[level] = 1;
|
|
71
|
+
}
|
|
72
|
+
const index = levelToIndex[level] || 1;
|
|
73
|
+
levelToIndex[level] = index + 1;
|
|
74
|
+
delta$1.retain(line.length - 1);
|
|
75
|
+
delta$1.retain(1, { [orderList_types_index.LIST_START_KEY]: String(index) });
|
|
76
|
+
}
|
|
77
|
+
editor.state.apply(delta$1, { autoCaret: false });
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
const latinCache = {};
|
|
81
|
+
const romanCache = {};
|
|
82
|
+
const startToLatin = (start) => {
|
|
83
|
+
if (start < 1)
|
|
84
|
+
return "";
|
|
85
|
+
const cache = latinCache[start];
|
|
86
|
+
if (cache)
|
|
87
|
+
return cache;
|
|
88
|
+
// 1 -> a, 27 -> aa
|
|
89
|
+
let res = "";
|
|
90
|
+
let n = start - 1;
|
|
91
|
+
while (n >= 0) {
|
|
92
|
+
res = String.fromCharCode((n % 26) + 97) + res;
|
|
93
|
+
n = Math.floor(n / 26) - 1;
|
|
94
|
+
}
|
|
95
|
+
latinCache[start] = res;
|
|
96
|
+
return res;
|
|
97
|
+
};
|
|
98
|
+
const startToRoman = (start) => {
|
|
99
|
+
if (start < 1 || start > 5000)
|
|
100
|
+
return "";
|
|
101
|
+
const cache = romanCache[start];
|
|
102
|
+
if (cache)
|
|
103
|
+
return cache;
|
|
104
|
+
// https://github.com/bpampuch/pdfmake/blob/7af85/src/DocMeasure.js#L315
|
|
105
|
+
const lookup = {
|
|
106
|
+
m: 1000,
|
|
107
|
+
cm: 900,
|
|
108
|
+
d: 500,
|
|
109
|
+
cd: 400,
|
|
110
|
+
c: 100,
|
|
111
|
+
xc: 90,
|
|
112
|
+
l: 50,
|
|
113
|
+
xl: 40,
|
|
114
|
+
x: 10,
|
|
115
|
+
ix: 9,
|
|
116
|
+
v: 5,
|
|
117
|
+
iv: 4,
|
|
118
|
+
i: 1,
|
|
119
|
+
};
|
|
120
|
+
let res = "";
|
|
121
|
+
let n = start;
|
|
122
|
+
for (const i of Object.keys(lookup)) {
|
|
123
|
+
while (n >= lookup[i]) {
|
|
124
|
+
res = res + i;
|
|
125
|
+
n = n - lookup[i];
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
romanCache[start] = res;
|
|
129
|
+
return res;
|
|
130
|
+
};
|
|
131
|
+
/**
|
|
132
|
+
* 序列化有序列表前缀值
|
|
133
|
+
* @param start
|
|
134
|
+
* @param level
|
|
135
|
+
*/
|
|
136
|
+
const formatListLevel = (start, level) => {
|
|
137
|
+
let serial = "";
|
|
138
|
+
const value = level % 3;
|
|
139
|
+
if (value === 0) {
|
|
140
|
+
// 1 -> 1
|
|
141
|
+
serial = start.toString();
|
|
142
|
+
}
|
|
143
|
+
else if (value === 1) {
|
|
144
|
+
// 1 -> a
|
|
145
|
+
serial = startToLatin(start);
|
|
146
|
+
}
|
|
147
|
+
else if (value === 2) {
|
|
148
|
+
// 1 -> i
|
|
149
|
+
serial = startToRoman(start);
|
|
150
|
+
}
|
|
151
|
+
return serial + ".";
|
|
152
|
+
};
|
|
153
|
+
|
|
154
|
+
const OrderListView = props => {
|
|
155
|
+
const { level, start, children } = props;
|
|
156
|
+
return (jsxRuntime.jsxs("ol", { className: "block-kit-order-list", children: [jsxRuntime.jsx("div", { contentEditable: false, className: "block-kit-order-indicator", onMouseDown: utils.preventNativeEvent, children: formatListLevel(start, level) }), jsxRuntime.jsx("li", { value: start, className: utils.cs("block-kit-order-item", `block-kit-li-level-${level % 3}`), children: children })] }));
|
|
157
|
+
};
|
|
158
|
+
|
|
159
|
+
class OrderListPlugin extends react.EditorPlugin {
|
|
160
|
+
constructor(editor) {
|
|
161
|
+
super();
|
|
162
|
+
this.editor = editor;
|
|
163
|
+
this.key = orderList_types_index.ORDER_LIST_KEY;
|
|
164
|
+
editor.command.register(this.key, this.onExec);
|
|
165
|
+
editor.event.on(core.EDITOR_EVENT.KEY_DOWN, this.onKeyDown);
|
|
166
|
+
}
|
|
167
|
+
destroy() {
|
|
168
|
+
this.editor.event.off(core.EDITOR_EVENT.KEY_DOWN, this.onKeyDown);
|
|
169
|
+
}
|
|
170
|
+
match(attrs) {
|
|
171
|
+
return is.isOrderList(attrs);
|
|
172
|
+
}
|
|
173
|
+
renderLine(context) {
|
|
174
|
+
const level = Number(context.attributes[indent_types_index.INDENT_LEVEL_KEY]) || 0;
|
|
175
|
+
const start = Number(context.attributes[orderList_types_index.LIST_START_KEY]) || 1;
|
|
176
|
+
return (jsxRuntime.jsx(OrderListView, { level: level, start: start, editor: this.editor, context: context, children: context.children }));
|
|
177
|
+
}
|
|
178
|
+
onExec(payload) {
|
|
179
|
+
const editor = this.editor;
|
|
180
|
+
const sel = editor.selection.get() || payload.range;
|
|
181
|
+
if (!sel)
|
|
182
|
+
return void 0;
|
|
183
|
+
const { start, end } = sel;
|
|
184
|
+
// 先检查当前需要设置/解除列表状态
|
|
185
|
+
const lines = editor.state.block.getLines().slice(start.line, end.line + 1);
|
|
186
|
+
const isList = lines.every(line => is.isOrderList(line.attributes));
|
|
187
|
+
// 计算需要操作的范围
|
|
188
|
+
const rawPoint = core.RawPoint.fromPoint(this.editor, core.Point.from(start.line, 0));
|
|
189
|
+
if (!rawPoint)
|
|
190
|
+
return void 0;
|
|
191
|
+
const block = this.editor.state.block;
|
|
192
|
+
const delta$1 = new delta.Delta();
|
|
193
|
+
delta$1.retain(rawPoint.offset);
|
|
194
|
+
// 根据行的状态, 逐行设置列表状态
|
|
195
|
+
for (let i = start.line; i <= end.line; i++) {
|
|
196
|
+
const lineState = block.getLine(i);
|
|
197
|
+
if (!lineState)
|
|
198
|
+
break;
|
|
199
|
+
delta$1.retain(lineState.length - 1);
|
|
200
|
+
const attrs = {
|
|
201
|
+
[bulletList_types_index.LIST_TYPE_KEY]: isList ? utils.NIL : orderList_types_index.ORDER_LIST_TYPE,
|
|
202
|
+
[orderList_types_index.LIST_START_KEY]: isList ? utils.NIL : "1",
|
|
203
|
+
};
|
|
204
|
+
if (!isList && lineState.attributes[indent_types_index.INDENT_LEVEL_KEY]) {
|
|
205
|
+
attrs[indent_types_index.INDENT_LEVEL_KEY] = lineState.attributes[indent_types_index.INDENT_LEVEL_KEY];
|
|
206
|
+
}
|
|
207
|
+
if (!isList && lineState.attributes[orderList_types_index.LIST_RESTART_KEY]) {
|
|
208
|
+
attrs[orderList_types_index.LIST_RESTART_KEY] = lineState.attributes[orderList_types_index.LIST_RESTART_KEY];
|
|
209
|
+
}
|
|
210
|
+
delta$1.retain(1, attrs);
|
|
211
|
+
}
|
|
212
|
+
this.editor.state.apply(delta$1, { autoCaret: false });
|
|
213
|
+
applyNewOrderList(this.editor, sel);
|
|
214
|
+
}
|
|
215
|
+
onKeyDown(event, context) {
|
|
216
|
+
const sel = this.editor.selection.get();
|
|
217
|
+
if (!sel)
|
|
218
|
+
return void 0;
|
|
219
|
+
const block = this.editor.state.block;
|
|
220
|
+
const startLine = block.getLine(sel.start.line);
|
|
221
|
+
if (!startLine)
|
|
222
|
+
return void 0;
|
|
223
|
+
const prevLine = startLine.prev();
|
|
224
|
+
const attrs = startLine.attributes;
|
|
225
|
+
// 当前行是列表行, 且按下回车键, 且选区折叠, 且当前行是空内容行
|
|
226
|
+
// => 处理列表的缩进等级
|
|
227
|
+
if (is$1.isKeyCode(event, utils.KEY_CODE.ENTER) &&
|
|
228
|
+
is.isOrderList(attrs) &&
|
|
229
|
+
sel.isCollapsed &&
|
|
230
|
+
is$1.isEmptyLine(startLine)) {
|
|
231
|
+
const level = Number(attrs[indent_types_index.INDENT_LEVEL_KEY]);
|
|
232
|
+
const nextAttrs = {};
|
|
233
|
+
if (level > 0) {
|
|
234
|
+
// 缩进等级大于 0, 则减少缩进等级
|
|
235
|
+
const nextLevel = level - 1 > 0 ? String(level - 1) : utils.NIL;
|
|
236
|
+
nextAttrs[indent_types_index.INDENT_LEVEL_KEY] = nextLevel;
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
// 否则, 取消列表状态
|
|
240
|
+
nextAttrs[bulletList_types_index.LIST_TYPE_KEY] = utils.NIL;
|
|
241
|
+
nextAttrs[orderList_types_index.LIST_START_KEY] = utils.NIL;
|
|
242
|
+
nextAttrs[orderList_types_index.LIST_RESTART_KEY] = utils.NIL;
|
|
243
|
+
}
|
|
244
|
+
const delta$1 = new delta.Delta().retain(startLine.start + startLine.length - 1).retain(1, nextAttrs);
|
|
245
|
+
this.editor.state.apply(delta$1, { autoCaret: false });
|
|
246
|
+
applyNewOrderList(this.editor, sel);
|
|
247
|
+
dom.preventContextEvent(event, context);
|
|
248
|
+
return void 0;
|
|
249
|
+
}
|
|
250
|
+
// 当前行是列表行, 且按下回车键, 且选区折叠, 且位于行首, 且上一行是列表行
|
|
251
|
+
// => 继续编号, 避免默认的处理, 保持列表的连续性
|
|
252
|
+
if (is$1.isKeyCode(event, utils.KEY_CODE.ENTER) &&
|
|
253
|
+
is.isOrderList(attrs) &&
|
|
254
|
+
sel.isCollapsed &&
|
|
255
|
+
!sel.start.offset &&
|
|
256
|
+
prevLine &&
|
|
257
|
+
is.isOrderList(prevLine.attributes)) {
|
|
258
|
+
const nextAttrs = Object.assign({}, prevLine.attributes);
|
|
259
|
+
if (attrs[indent_types_index.INDENT_LEVEL_KEY]) {
|
|
260
|
+
// 缩进层级优先取当前行的缩进层级
|
|
261
|
+
nextAttrs[indent_types_index.INDENT_LEVEL_KEY] = attrs[indent_types_index.INDENT_LEVEL_KEY];
|
|
262
|
+
}
|
|
263
|
+
const delta$1 = new delta.Delta().retain(startLine.start).insertEOL(nextAttrs);
|
|
264
|
+
this.editor.state.apply(delta$1);
|
|
265
|
+
applyNewOrderList(this.editor, sel);
|
|
266
|
+
dom.preventContextEvent(event, context);
|
|
267
|
+
return void 0;
|
|
268
|
+
}
|
|
269
|
+
// 当前行是列表行, 且按下回车键
|
|
270
|
+
// => 在列表行内部插入换行符, 且携带列表状态
|
|
271
|
+
if (is$1.isKeyCode(event, utils.KEY_CODE.ENTER) && is.isOrderList(attrs)) {
|
|
272
|
+
this.editor.perform.insertBreak(sel, attrs);
|
|
273
|
+
applyNewOrderList(this.editor, sel);
|
|
274
|
+
dom.preventContextEvent(event, context);
|
|
275
|
+
return void 0;
|
|
276
|
+
}
|
|
277
|
+
// 当前行是列表行, 且折叠选区, 且在行首, 且按下退格键
|
|
278
|
+
// => 将当前行的列表状态移除, 保留缩进的等级
|
|
279
|
+
if (is$1.isKeyCode(event, utils.KEY_CODE.BACKSPACE) &&
|
|
280
|
+
sel.isCollapsed &&
|
|
281
|
+
is.isOrderList(attrs) &&
|
|
282
|
+
!sel.start.offset) {
|
|
283
|
+
const delta$1 = new delta.Delta().retain(startLine.start + startLine.length - 1).retain(1, {
|
|
284
|
+
[bulletList_types_index.LIST_TYPE_KEY]: utils.NIL,
|
|
285
|
+
[orderList_types_index.LIST_START_KEY]: utils.NIL,
|
|
286
|
+
[orderList_types_index.LIST_RESTART_KEY]: utils.NIL,
|
|
287
|
+
});
|
|
288
|
+
this.editor.state.apply(delta$1, { autoCaret: false });
|
|
289
|
+
applyNewOrderList(this.editor, sel);
|
|
290
|
+
dom.preventContextEvent(event, context);
|
|
291
|
+
return void 0;
|
|
292
|
+
}
|
|
293
|
+
// 当前行是列表行, 按下 Tab 键
|
|
294
|
+
// => 由列表的缩进状态调整列表的序号
|
|
295
|
+
if (is$1.isKeyCode(event, utils.KEY_CODE.TAB) && is.isOrderList(attrs)) {
|
|
296
|
+
applyNewOrderList(this.editor, sel);
|
|
297
|
+
dom.preventContextEvent(event, context);
|
|
298
|
+
return void 0;
|
|
299
|
+
}
|
|
300
|
+
// 处于当前行的行首, 且不存在其他行属性, 且前一行是列表行
|
|
301
|
+
// => 将当前上一行属性移到当前行, 且刷新列表值
|
|
302
|
+
if (is$1.isKeyCode(event, utils.KEY_CODE.BACKSPACE) &&
|
|
303
|
+
!sel.start.offset &&
|
|
304
|
+
!Object.keys(attrs).length &&
|
|
305
|
+
prevLine &&
|
|
306
|
+
is.isOrderList(prevLine.attributes)) {
|
|
307
|
+
const prevAttrs = Object.assign({}, prevLine.attributes);
|
|
308
|
+
const delta$1 = new delta.Delta()
|
|
309
|
+
.retain(startLine.start - 1)
|
|
310
|
+
.delete(1)
|
|
311
|
+
.retain(startLine.length - 1)
|
|
312
|
+
.retain(1, prevAttrs);
|
|
313
|
+
this.editor.state.apply(delta$1);
|
|
314
|
+
applyNewOrderList(this.editor, sel);
|
|
315
|
+
dom.preventContextEvent(event, context);
|
|
316
|
+
return void 0;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
tslib_es6.__decorate([
|
|
321
|
+
utils.Bind
|
|
322
|
+
], OrderListPlugin.prototype, "onExec", null);
|
|
323
|
+
tslib_es6.__decorate([
|
|
324
|
+
utils.Bind
|
|
325
|
+
], OrderListPlugin.prototype, "onKeyDown", null);
|
|
326
|
+
|
|
327
|
+
exports.OrderListPlugin = OrderListPlugin;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** 有序列表标识 */
|
|
2
|
+
export declare const ORDER_LIST_KEY = "order-list";
|
|
3
|
+
/** 有序列表类型值 */
|
|
4
|
+
export declare const ORDER_LIST_TYPE = "order";
|
|
5
|
+
/** 有序列表序号 */
|
|
6
|
+
export declare const LIST_START_KEY = "list-start";
|
|
7
|
+
/** 重新编号标识 */
|
|
8
|
+
export declare const LIST_RESTART_KEY = "list-restart";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
/** 有序列表标识 */
|
|
6
|
+
const ORDER_LIST_KEY = "order-list";
|
|
7
|
+
/** 有序列表类型值 */
|
|
8
|
+
const ORDER_LIST_TYPE = "order";
|
|
9
|
+
/** 有序列表序号 */
|
|
10
|
+
const LIST_START_KEY = "list-start";
|
|
11
|
+
/** 重新编号标识 */
|
|
12
|
+
const LIST_RESTART_KEY = "list-restart";
|
|
13
|
+
|
|
14
|
+
exports.LIST_RESTART_KEY = LIST_RESTART_KEY;
|
|
15
|
+
exports.LIST_START_KEY = LIST_START_KEY;
|
|
16
|
+
exports.ORDER_LIST_KEY = ORDER_LIST_KEY;
|
|
17
|
+
exports.ORDER_LIST_TYPE = ORDER_LIST_TYPE;
|