@milkdown/plugin-tooltip 4.14.2 → 5.1.1
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/lib/index.d.ts +17 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +33 -31
- package/lib/index.js.map +1 -1
- package/package.json +3 -3
- package/src/index.ts +47 -46
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,21 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PluginKey } from '@milkdown/prose';
|
|
2
2
|
import { AtomList } from '@milkdown/utils';
|
|
3
3
|
import { InputOptions } from './item';
|
|
4
4
|
export declare const key: PluginKey<any, any>;
|
|
5
|
-
export declare const tooltipPlugin: import("@milkdown/utils/lib/types").
|
|
6
|
-
|
|
5
|
+
export declare const tooltipPlugin: import("@milkdown/utils/lib/types").WithExtend<string, InputOptions, {
|
|
6
|
+
[x: string]: import("prosemirror-model").NodeType<any>;
|
|
7
|
+
} & {
|
|
8
|
+
[x: string]: import("prosemirror-model").MarkType<any>;
|
|
9
|
+
}, {
|
|
10
|
+
schema?: ((ctx: import("@milkdown/core").Ctx) => {
|
|
11
|
+
node?: Record<string, import("@milkdown/core").NodeSchema> | undefined;
|
|
12
|
+
mark?: Record<string, import("@milkdown/core").MarkSchema> | undefined;
|
|
13
|
+
}) | undefined;
|
|
14
|
+
view?: ((ctx: import("@milkdown/core").Ctx) => Partial<{
|
|
15
|
+
[x: string]: import("@milkdown/prose").NodeViewFactory;
|
|
16
|
+
} & {
|
|
17
|
+
[x: string]: import("@milkdown/prose").MarkViewFactory;
|
|
18
|
+
}>) | undefined;
|
|
19
|
+
}>;
|
|
20
|
+
export declare const tooltip: AtomList<import("@milkdown/utils/lib/types").Metadata<import("@milkdown/utils/lib/types").GetPlugin<string, InputOptions>> & import("@milkdown/core").MilkdownPlugin>;
|
|
7
21
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAU,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAA0B,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAuB,YAAY,EAAE,MAAM,QAAQ,CAAC;AAG3D,eAAO,MAAM,GAAG,qBAA2C,CAAC;AAE5D,eAAO,MAAM,aAAa;;;;;;;;;;;;;;EAiDxB,CAAC;AAEH,eAAO,MAAM,OAAO,uKAAqC,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,42 +1,44 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
2
|
import { schemaCtx } from '@milkdown/core';
|
|
3
3
|
import { Plugin, PluginKey } from '@milkdown/prose';
|
|
4
|
-
import { AtomList,
|
|
4
|
+
import { AtomList, createPlugin as create } from '@milkdown/utils';
|
|
5
5
|
import { buttonMap, inputMap } from './item';
|
|
6
6
|
import { createPlugin } from './selection-marks-tooltip';
|
|
7
7
|
export const key = new PluginKey('MILKDOWN_PLUGIN_TOOLTIP');
|
|
8
|
-
export const tooltipPlugin =
|
|
9
|
-
var _a, _b, _c;
|
|
10
|
-
const schema = utils.ctx.get(schemaCtx);
|
|
11
|
-
const manager = createPlugin(buttonMap(schema, utils.ctx), inputMap(schema, utils.ctx, {
|
|
12
|
-
link: Object.assign({ placeholder: 'Input Web Link', buttonText: 'APPLY' }, ((_a = options === null || options === void 0 ? void 0 : options.link) !== null && _a !== void 0 ? _a : {})),
|
|
13
|
-
image: Object.assign({ placeholder: 'Input Image Link', buttonText: 'APPLY' }, ((_b = options === null || options === void 0 ? void 0 : options.image) !== null && _b !== void 0 ? _b : {})),
|
|
14
|
-
inlineMath: Object.assign({ placeholder: 'Input Math' }, ((_c = options === null || options === void 0 ? void 0 : options.inlineMath) !== null && _c !== void 0 ? _c : {})),
|
|
15
|
-
}), utils);
|
|
16
|
-
const plugin = new Plugin({
|
|
17
|
-
key,
|
|
18
|
-
props: {
|
|
19
|
-
handleKeyDown: () => {
|
|
20
|
-
manager.setHide(true);
|
|
21
|
-
return false;
|
|
22
|
-
},
|
|
23
|
-
handleClick: (view) => {
|
|
24
|
-
manager.setHide(false);
|
|
25
|
-
manager.update(view);
|
|
26
|
-
return false;
|
|
27
|
-
},
|
|
28
|
-
},
|
|
29
|
-
view: (editorView) => {
|
|
30
|
-
manager.render(editorView);
|
|
31
|
-
return {
|
|
32
|
-
update: manager.update,
|
|
33
|
-
destroy: manager.destroy,
|
|
34
|
-
};
|
|
35
|
-
},
|
|
36
|
-
});
|
|
8
|
+
export const tooltipPlugin = create((utils, options) => {
|
|
37
9
|
return {
|
|
38
10
|
id: 'tooltip',
|
|
39
|
-
|
|
11
|
+
prosePlugins: (_, ctx) => {
|
|
12
|
+
var _a, _b, _c;
|
|
13
|
+
const schema = ctx.get(schemaCtx);
|
|
14
|
+
const manager = createPlugin(buttonMap(schema, ctx), inputMap(schema, ctx, {
|
|
15
|
+
link: Object.assign({ placeholder: 'Input Web Link', buttonText: 'APPLY' }, ((_a = options === null || options === void 0 ? void 0 : options.link) !== null && _a !== void 0 ? _a : {})),
|
|
16
|
+
image: Object.assign({ placeholder: 'Input Image Link', buttonText: 'APPLY' }, ((_b = options === null || options === void 0 ? void 0 : options.image) !== null && _b !== void 0 ? _b : {})),
|
|
17
|
+
inlineMath: Object.assign({ placeholder: 'Input Math' }, ((_c = options === null || options === void 0 ? void 0 : options.inlineMath) !== null && _c !== void 0 ? _c : {})),
|
|
18
|
+
}), utils);
|
|
19
|
+
const plugin = new Plugin({
|
|
20
|
+
key,
|
|
21
|
+
props: {
|
|
22
|
+
handleKeyDown: () => {
|
|
23
|
+
manager.setHide(true);
|
|
24
|
+
return false;
|
|
25
|
+
},
|
|
26
|
+
handleClick: (view) => {
|
|
27
|
+
manager.setHide(false);
|
|
28
|
+
manager.update(view);
|
|
29
|
+
return false;
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
view: (editorView) => {
|
|
33
|
+
manager.render(editorView);
|
|
34
|
+
return {
|
|
35
|
+
update: manager.update,
|
|
36
|
+
destroy: manager.destroy,
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
return [plugin];
|
|
41
|
+
},
|
|
40
42
|
};
|
|
41
43
|
});
|
|
42
44
|
export const tooltip = AtomList.create([tooltipPlugin()]);
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,QAAQ,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEnE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAgB,MAAM,QAAQ,CAAC;AAC3D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,MAAM,CAAC,MAAM,GAAG,GAAG,IAAI,SAAS,CAAC,yBAAyB,CAAC,CAAC;AAE5D,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAuB,CAAC,KAAK,EAAE,OAAO,EAAE,EAAE;IACzE,OAAO;QACH,EAAE,EAAE,SAAS;QACb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AAO,CAAC,OAAO;qBAC3B,CAAC;gBACN,CAAC;aACJ,CAAC,CAAC;YACH,OAAO,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC;KACJ,CAAC;AACN,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkdown/plugin-tooltip",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.1.1",
|
|
4
4
|
"main": "lib/index.js",
|
|
5
5
|
"module": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
23
|
"@emotion/css": "^11.1.3",
|
|
24
|
-
"@milkdown/utils": "
|
|
25
|
-
"tslib": "^2.
|
|
24
|
+
"@milkdown/utils": "5.1.1",
|
|
25
|
+
"tslib": "^2.3.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"concurrently": "^6.0.2"
|
package/src/index.ts
CHANGED
|
@@ -1,60 +1,61 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
2
|
import { schemaCtx } from '@milkdown/core';
|
|
3
3
|
import { Plugin, PluginKey } from '@milkdown/prose';
|
|
4
|
-
import { AtomList,
|
|
4
|
+
import { AtomList, createPlugin as create } from '@milkdown/utils';
|
|
5
5
|
|
|
6
6
|
import { buttonMap, inputMap, InputOptions } from './item';
|
|
7
7
|
import { createPlugin } from './selection-marks-tooltip';
|
|
8
8
|
|
|
9
9
|
export const key = new PluginKey('MILKDOWN_PLUGIN_TOOLTIP');
|
|
10
10
|
|
|
11
|
-
export const tooltipPlugin =
|
|
12
|
-
const schema = utils.ctx.get(schemaCtx);
|
|
13
|
-
const manager = createPlugin(
|
|
14
|
-
buttonMap(schema, utils.ctx),
|
|
15
|
-
inputMap(schema, utils.ctx, {
|
|
16
|
-
link: {
|
|
17
|
-
placeholder: 'Input Web Link',
|
|
18
|
-
buttonText: 'APPLY',
|
|
19
|
-
...(options?.link ?? {}),
|
|
20
|
-
},
|
|
21
|
-
image: {
|
|
22
|
-
placeholder: 'Input Image Link',
|
|
23
|
-
buttonText: 'APPLY',
|
|
24
|
-
...(options?.image ?? {}),
|
|
25
|
-
},
|
|
26
|
-
inlineMath: {
|
|
27
|
-
placeholder: 'Input Math',
|
|
28
|
-
...(options?.inlineMath ?? {}),
|
|
29
|
-
},
|
|
30
|
-
}),
|
|
31
|
-
utils,
|
|
32
|
-
);
|
|
33
|
-
const plugin = new Plugin({
|
|
34
|
-
key,
|
|
35
|
-
props: {
|
|
36
|
-
handleKeyDown: () => {
|
|
37
|
-
manager.setHide(true);
|
|
38
|
-
return false;
|
|
39
|
-
},
|
|
40
|
-
handleClick: (view) => {
|
|
41
|
-
manager.setHide(false);
|
|
42
|
-
manager.update(view);
|
|
43
|
-
return false;
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
view: (editorView) => {
|
|
47
|
-
manager.render(editorView);
|
|
48
|
-
return {
|
|
49
|
-
update: manager.update,
|
|
50
|
-
destroy: manager.destroy,
|
|
51
|
-
};
|
|
52
|
-
},
|
|
53
|
-
});
|
|
54
|
-
|
|
11
|
+
export const tooltipPlugin = create<string, InputOptions>((utils, options) => {
|
|
55
12
|
return {
|
|
56
13
|
id: 'tooltip',
|
|
57
|
-
|
|
14
|
+
prosePlugins: (_, ctx) => {
|
|
15
|
+
const schema = ctx.get(schemaCtx);
|
|
16
|
+
const manager = createPlugin(
|
|
17
|
+
buttonMap(schema, ctx),
|
|
18
|
+
inputMap(schema, ctx, {
|
|
19
|
+
link: {
|
|
20
|
+
placeholder: 'Input Web Link',
|
|
21
|
+
buttonText: 'APPLY',
|
|
22
|
+
...(options?.link ?? {}),
|
|
23
|
+
},
|
|
24
|
+
image: {
|
|
25
|
+
placeholder: 'Input Image Link',
|
|
26
|
+
buttonText: 'APPLY',
|
|
27
|
+
...(options?.image ?? {}),
|
|
28
|
+
},
|
|
29
|
+
inlineMath: {
|
|
30
|
+
placeholder: 'Input Math',
|
|
31
|
+
...(options?.inlineMath ?? {}),
|
|
32
|
+
},
|
|
33
|
+
}),
|
|
34
|
+
utils,
|
|
35
|
+
);
|
|
36
|
+
const plugin = new Plugin({
|
|
37
|
+
key,
|
|
38
|
+
props: {
|
|
39
|
+
handleKeyDown: () => {
|
|
40
|
+
manager.setHide(true);
|
|
41
|
+
return false;
|
|
42
|
+
},
|
|
43
|
+
handleClick: (view) => {
|
|
44
|
+
manager.setHide(false);
|
|
45
|
+
manager.update(view);
|
|
46
|
+
return false;
|
|
47
|
+
},
|
|
48
|
+
},
|
|
49
|
+
view: (editorView) => {
|
|
50
|
+
manager.render(editorView);
|
|
51
|
+
return {
|
|
52
|
+
update: manager.update,
|
|
53
|
+
destroy: manager.destroy,
|
|
54
|
+
};
|
|
55
|
+
},
|
|
56
|
+
});
|
|
57
|
+
return [plugin];
|
|
58
|
+
},
|
|
58
59
|
};
|
|
59
60
|
});
|
|
60
61
|
|