@milkdown/plugin-tooltip 5.2.0 → 5.3.2
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/button-manager/calc-button-pos.d.ts.map +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.es.js +595 -0
- package/lib/index.es.js.map +1 -0
- package/lib/input-manager/calc-input-pos.d.ts.map +1 -1
- package/lib/item.d.ts.map +1 -1
- package/package.json +15 -18
- package/src/button-manager/calc-button-pos.ts +6 -2
- package/src/index.ts +6 -0
- package/src/input-manager/calc-input-pos.ts +6 -1
- package/src/item.ts +5 -2
- package/src/utility/input.ts +1 -1
- package/lib/button-manager/calc-button-pos.js +0 -17
- package/lib/button-manager/calc-button-pos.js.map +0 -1
- package/lib/button-manager/create-tooltip.js +0 -20
- package/lib/button-manager/create-tooltip.js.map +0 -1
- package/lib/button-manager/filter-button.js +0 -22
- package/lib/button-manager/filter-button.js.map +0 -1
- package/lib/button-manager/index.js +0 -35
- package/lib/button-manager/index.js.map +0 -1
- package/lib/button-manager/no-active.js +0 -6
- package/lib/button-manager/no-active.js.map +0 -1
- package/lib/button-manager/style.js +0 -50
- package/lib/button-manager/style.js.map +0 -1
- package/lib/index.js +0 -45
- package/lib/index.js.map +0 -1
- package/lib/input-manager/calc-input-pos.js +0 -13
- package/lib/input-manager/calc-input-pos.js.map +0 -1
- package/lib/input-manager/create-input.js +0 -30
- package/lib/input-manager/create-input.js.map +0 -1
- package/lib/input-manager/filter-input.js +0 -19
- package/lib/input-manager/filter-input.js.map +0 -1
- package/lib/input-manager/index.js +0 -49
- package/lib/input-manager/index.js.map +0 -1
- package/lib/input-manager/style.js +0 -66
- package/lib/input-manager/style.js.map +0 -1
- package/lib/item.js +0 -36
- package/lib/item.js.map +0 -1
- package/lib/selection-marks-tooltip.js +0 -39
- package/lib/selection-marks-tooltip.js.map +0 -1
- package/lib/utility/element.js +0 -3
- package/lib/utility/element.js.map +0 -1
- package/lib/utility/index.js +0 -6
- package/lib/utility/index.js.map +0 -1
- package/lib/utility/input.js +0 -121
- package/lib/utility/input.js.map +0 -1
- package/lib/utility/prosemirror.js +0 -22
- package/lib/utility/prosemirror.js.map +0 -1
- package/lib/utility/toggle.js +0 -11
- package/lib/utility/toggle.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calc-input-pos.d.ts","sourceRoot":"","sources":["../../src/input-manager/calc-input-pos.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEpE,eAAO,MAAM,YAAY,SAAU,UAAU,SAAS,cAAc,
|
|
1
|
+
{"version":3,"file":"calc-input-pos.d.ts","sourceRoot":"","sources":["../../src/input-manager/calc-input-pos.ts"],"names":[],"mappings":"AACA,OAAO,EAAyB,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAEpE,eAAO,MAAM,YAAY,SAAU,UAAU,SAAS,cAAc,SAenE,CAAC"}
|
package/lib/item.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../src/item.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,UAAU,EAA0B,MAAM,
|
|
1
|
+
{"version":3,"file":"item.d.ts","sourceRoot":"","sources":["../src/item.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAErC,OAAO,EAAE,UAAU,EAA0B,MAAM,EAAiB,MAAM,iBAAiB,CAAC;AAa5F,oBAAY,IAAI,GAAG,CAAC,IAAI,EAAE,UAAU,KAAK,OAAO,CAAC;AACjD,oBAAY,OAAO,GAAG,CAAC,IAAI,EAAE,UAAU,EAAE,CAAC,EAAE,WAAW,KAAK,IAAI,CAAC;AACjE,oBAAY,aAAa,GAAG,CAAC,CAAC,EAAE,KAAK,KAAK,IAAI,CAAC;AA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json
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@milkdown/plugin-tooltip",
|
|
3
|
-
"version": "5.2
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
"types": "lib/index.d.ts",
|
|
3
|
+
"version": "5.3.2",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./lib/index.es.js",
|
|
6
|
+
"types": "./lib/index.d.ts",
|
|
7
7
|
"sideEffects": false,
|
|
8
8
|
"license": "MIT",
|
|
9
9
|
"files": [
|
|
@@ -14,24 +14,21 @@
|
|
|
14
14
|
"milkdown",
|
|
15
15
|
"milkdown plugin"
|
|
16
16
|
],
|
|
17
|
-
"peerDependencies": {
|
|
18
|
-
"@milkdown/core": "*",
|
|
19
|
-
"@milkdown/preset-gfm": "*",
|
|
20
|
-
"@milkdown/plugin-math": "*"
|
|
21
|
-
},
|
|
22
17
|
"dependencies": {
|
|
23
18
|
"@emotion/css": "^11.1.3",
|
|
24
|
-
"@milkdown/
|
|
19
|
+
"@milkdown/core": "5.3.2",
|
|
20
|
+
"@milkdown/prose": "5.3.2",
|
|
21
|
+
"@milkdown/preset-gfm": "5.3.2",
|
|
22
|
+
"@milkdown/design-system": "5.3.2",
|
|
23
|
+
"@milkdown/plugin-math": "5.3.2",
|
|
24
|
+
"@milkdown/utils": "5.3.2",
|
|
25
25
|
"tslib": "^2.3.1"
|
|
26
26
|
},
|
|
27
|
-
"devDependencies": {
|
|
28
|
-
"concurrently": "^6.0.2"
|
|
29
|
-
},
|
|
30
27
|
"scripts": {
|
|
31
|
-
"start": "vite",
|
|
32
|
-
"
|
|
33
|
-
"test": "jest",
|
|
28
|
+
"start": "vite build --watch",
|
|
29
|
+
"test": "vitest",
|
|
34
30
|
"tsc": "tsc --noEmit",
|
|
35
|
-
"build": "tsc"
|
|
36
|
-
}
|
|
31
|
+
"build": "vite build && tsc --emitDeclarationOnly"
|
|
32
|
+
},
|
|
33
|
+
"readme": "# @milkdown/plugin-tooltip\n\nTooltip plugin for [milkdown](https://saul-mirone.github.io/milkdown/).\nAdd support for tooltip commands.\n\n# Example Usage\n\n```typescript\nimport { Editor } from '@milkdown/core';\nimport { commonmark } from '@milkdown/preset-commonmark';\nimport { nord } from '@milkdown/theme-nord';\n\nimport { tooltip } from '@milkdown/plugin-tooltip';\n\nEditor.make().use(nord).use(commonmark).use(tooltip).create();\n```\n\n# Placeholder\n\nModify the input widgets of link and image.\n\nExample:\n\n```typescript\nimport { tooltipPlugin, tooltip } from '@milkdown/plugin-tooltip';\n\nEditor.make().use(\n tooltip.configure(tooltipPlugin, {\n link: {\n placeholder: 'Please input link...',\n buttonText: 'Confirm',\n },\n image: {\n placeholder: 'Please input image link...',\n buttonText: 'OK',\n },\n inlineMath: {\n placeholder: 'Please input inline math...',\n },\n }),\n);\n```\n\n# License\n\nMilkdown is open sourced software licensed under [MIT license](https://github.com/Saul-Mirone/milkdown/blob/main/LICENSE).\n"
|
|
37
34
|
}
|
|
@@ -4,14 +4,18 @@ import { calculateTextPosition, EditorView } from '@milkdown/prose';
|
|
|
4
4
|
export const calcButtonPos = (buttons: HTMLElement, view: EditorView) => {
|
|
5
5
|
buttons.classList.remove('hide');
|
|
6
6
|
calculateTextPosition(view, buttons, (start, end, target, parent) => {
|
|
7
|
+
const $editor = buttons.parentElement;
|
|
8
|
+
if (!$editor) {
|
|
9
|
+
throw new Error();
|
|
10
|
+
}
|
|
7
11
|
const selectionWidth = end.left - start.left;
|
|
8
12
|
let left = start.left - parent.left - (target.width - selectionWidth) / 2;
|
|
9
|
-
let top = start.top - parent.top - target.height - 14;
|
|
13
|
+
let top = start.top - parent.top - target.height - 14 + $editor.scrollTop;
|
|
10
14
|
|
|
11
15
|
if (left < 0) left = 0;
|
|
12
16
|
|
|
13
17
|
if (start.top < target.height) {
|
|
14
|
-
top = start.bottom - parent.top + 14;
|
|
18
|
+
top = start.bottom - parent.top + 14 + $editor.scrollTop;
|
|
15
19
|
}
|
|
16
20
|
|
|
17
21
|
return [top, left];
|
package/src/index.ts
CHANGED
|
@@ -45,6 +45,12 @@ export const tooltipPlugin = create<string, InputOptions>((utils, options) => {
|
|
|
45
45
|
manager.update(view);
|
|
46
46
|
return false;
|
|
47
47
|
},
|
|
48
|
+
handleDOMEvents: {
|
|
49
|
+
mousedown: () => {
|
|
50
|
+
manager.setHide(false);
|
|
51
|
+
return false;
|
|
52
|
+
},
|
|
53
|
+
},
|
|
48
54
|
},
|
|
49
55
|
view: (editorView) => {
|
|
50
56
|
manager.render(editorView);
|
|
@@ -3,9 +3,14 @@ import { calculateTextPosition, EditorView } from '@milkdown/prose';
|
|
|
3
3
|
|
|
4
4
|
export const calcInputPos = (view: EditorView, input: HTMLDivElement) => {
|
|
5
5
|
calculateTextPosition(view, input, (start, end, target, parent) => {
|
|
6
|
+
const $editor = input.parentElement;
|
|
7
|
+
if (!$editor) {
|
|
8
|
+
throw new Error();
|
|
9
|
+
}
|
|
10
|
+
|
|
6
11
|
const selectionWidth = end.left - start.left;
|
|
7
12
|
let left = start.left - parent.left - (target.width - selectionWidth) / 2;
|
|
8
|
-
const top = start.bottom - parent.top + 14;
|
|
13
|
+
const top = start.bottom - parent.top + 14 + $editor.scrollTop;
|
|
9
14
|
|
|
10
15
|
if (left < 0) left = 0;
|
|
11
16
|
|
package/src/item.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
2
|
import { Ctx } from '@milkdown/core';
|
|
3
3
|
import { ToggleBold, ToggleInlineCode, ToggleItalic, ToggleLink, ToggleStrikeThrough } from '@milkdown/preset-gfm';
|
|
4
|
-
import { EditorView, findSelectedNodeOfType, Schema } from '@milkdown/prose';
|
|
4
|
+
import { EditorView, findSelectedNodeOfType, Schema, TextSelection } from '@milkdown/prose';
|
|
5
5
|
|
|
6
6
|
import {
|
|
7
7
|
createToggleIcon,
|
|
@@ -76,7 +76,10 @@ export const inputMap = (schema: Schema, ctx: Ctx, inputOptions: InputOptions):
|
|
|
76
76
|
const { marks, nodes } = schema;
|
|
77
77
|
return {
|
|
78
78
|
[InputAction.ModifyLink]: {
|
|
79
|
-
display: (view) =>
|
|
79
|
+
display: (view) =>
|
|
80
|
+
view.state.selection.empty &&
|
|
81
|
+
view.state.selection instanceof TextSelection &&
|
|
82
|
+
hasMark(view.state, marks.link),
|
|
80
83
|
command: modifyLink(ctx),
|
|
81
84
|
update: updateLinkView,
|
|
82
85
|
...inputOptions.link,
|
package/src/utility/input.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
2
|
import { commandsCtx, Ctx } from '@milkdown/core';
|
|
3
3
|
import { ModifyInlineMath } from '@milkdown/plugin-math';
|
|
4
|
-
import { ModifyImage, ModifyLink } from '@milkdown/preset-
|
|
4
|
+
import { ModifyImage, ModifyLink } from '@milkdown/preset-gfm';
|
|
5
5
|
import { findSelectedNodeOfType, Node as ProseNode } from '@milkdown/prose';
|
|
6
6
|
|
|
7
7
|
import { Event2Command, Updater } from '../item';
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { calculateTextPosition } from '@milkdown/prose';
|
|
3
|
-
export const calcButtonPos = (buttons, view) => {
|
|
4
|
-
buttons.classList.remove('hide');
|
|
5
|
-
calculateTextPosition(view, buttons, (start, end, target, parent) => {
|
|
6
|
-
const selectionWidth = end.left - start.left;
|
|
7
|
-
let left = start.left - parent.left - (target.width - selectionWidth) / 2;
|
|
8
|
-
let top = start.top - parent.top - target.height - 14;
|
|
9
|
-
if (left < 0)
|
|
10
|
-
left = 0;
|
|
11
|
-
if (start.top < target.height) {
|
|
12
|
-
top = start.bottom - parent.top + 14;
|
|
13
|
-
}
|
|
14
|
-
return [top, left];
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=calc-button-pos.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"calc-button-pos.js","sourceRoot":"","sources":["../../src/button-manager/calc-button-pos.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,qBAAqB,EAAc,MAAM,iBAAiB,CAAC;AAEpE,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,OAAoB,EAAE,IAAgB,EAAE,EAAE;IACpE,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACjC,qBAAqB,CAAC,IAAI,EAAE,OAAO,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;QAChE,MAAM,cAAc,GAAG,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QAC7C,IAAI,IAAI,GAAG,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;QAC1E,IAAI,GAAG,GAAG,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,GAAG,EAAE,CAAC;QAEtD,IAAI,IAAI,GAAG,CAAC;YAAE,IAAI,GAAG,CAAC,CAAC;QAEvB,IAAI,KAAK,CAAC,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE;YAC3B,GAAG,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,GAAG,EAAE,CAAC;SACxC;QAED,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { injectStyle } from './style';
|
|
2
|
-
export const createTooltip = (buttonMap, utils) => {
|
|
3
|
-
const div = document.createElement('div');
|
|
4
|
-
const style = utils.getStyle(injectStyle) || '';
|
|
5
|
-
if (style) {
|
|
6
|
-
div.classList.add(style);
|
|
7
|
-
}
|
|
8
|
-
div.classList.add('tooltip');
|
|
9
|
-
return {
|
|
10
|
-
dom: div,
|
|
11
|
-
render: (editorView) => {
|
|
12
|
-
var _a;
|
|
13
|
-
Object.values(buttonMap)
|
|
14
|
-
.filter((item) => item.enable(editorView))
|
|
15
|
-
.forEach(({ $ }) => div.appendChild($));
|
|
16
|
-
(_a = editorView.dom.parentNode) === null || _a === void 0 ? void 0 : _a.appendChild(div);
|
|
17
|
-
},
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
//# sourceMappingURL=create-tooltip.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-tooltip.js","sourceRoot":"","sources":["../../src/button-manager/create-tooltip.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAOtC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,SAAoB,EAAE,KAAY,EAAW,EAAE;IACzE,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;IAChD,IAAI,KAAK,EAAE;QACP,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KAC5B;IAED,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;IAE7B,OAAO;QACH,GAAG,EAAE,GAAG;QACR,MAAM,EAAE,CAAC,UAAsB,EAAE,EAAE;;YAC/B,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;iBACnB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;iBACzC,OAAO,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;YAE5C,MAAA,UAAU,CAAC,GAAG,CAAC,UAAU,0CAAE,WAAW,CAAC,GAAG,CAAC,CAAC;QAChD,CAAC;KACJ,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { noActive } from './no-active';
|
|
2
|
-
export const filterButton = (buttonMap, view) => {
|
|
3
|
-
Object.values(buttonMap)
|
|
4
|
-
.filter((item) => item.enable(view))
|
|
5
|
-
.forEach((item) => {
|
|
6
|
-
var _a;
|
|
7
|
-
const disable = (_a = item.disable) === null || _a === void 0 ? void 0 : _a.call(item, view);
|
|
8
|
-
if (disable) {
|
|
9
|
-
item.$.classList.add('hide');
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
item.$.classList.remove('hide');
|
|
13
|
-
const active = item.active(view);
|
|
14
|
-
if (active) {
|
|
15
|
-
item.$.classList.add('active');
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
item.$.classList.remove('active');
|
|
19
|
-
});
|
|
20
|
-
return noActive(buttonMap, view);
|
|
21
|
-
};
|
|
22
|
-
//# sourceMappingURL=filter-button.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filter-button.js","sourceRoot":"","sources":["../../src/button-manager/filter-button.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,SAAoB,EAAE,IAAgB,EAAE,EAAE;IACnE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;SACnB,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SACnC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;;QACd,MAAM,OAAO,GAAG,MAAA,IAAI,CAAC,OAAO,+CAAZ,IAAI,EAAW,IAAI,CAAC,CAAC;QACrC,IAAI,OAAO,EAAE;YACT,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC7B,OAAO;SACV;QAED,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAEhC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,MAAM,EAAE;YACR,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;YAC/B,OAAO;SACV;QACD,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACtC,CAAC,CAAC,CAAC;IAEP,OAAO,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;AACrC,CAAC,CAAC"}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { calcButtonPos } from './calc-button-pos';
|
|
2
|
-
import { createTooltip } from './create-tooltip';
|
|
3
|
-
import { filterButton } from './filter-button';
|
|
4
|
-
export const createButtonManager = (buttonMap, utils) => {
|
|
5
|
-
const { dom: buttons, render } = createTooltip(buttonMap, utils);
|
|
6
|
-
const onClick = (e) => {
|
|
7
|
-
const target = Object.values(buttonMap).find(({ $ }) => e.target instanceof Element && $.contains(e.target));
|
|
8
|
-
if (!target)
|
|
9
|
-
return;
|
|
10
|
-
e.stopPropagation();
|
|
11
|
-
e.preventDefault();
|
|
12
|
-
target.command();
|
|
13
|
-
};
|
|
14
|
-
const hide = () => {
|
|
15
|
-
buttons.classList.add('hide');
|
|
16
|
-
};
|
|
17
|
-
buttons.addEventListener('mousedown', onClick);
|
|
18
|
-
return {
|
|
19
|
-
destroy: () => {
|
|
20
|
-
buttons.removeEventListener('mousedown', onClick);
|
|
21
|
-
buttons.remove();
|
|
22
|
-
},
|
|
23
|
-
hide,
|
|
24
|
-
update: (editorView) => {
|
|
25
|
-
const noActive = filterButton(buttonMap, editorView);
|
|
26
|
-
if (noActive) {
|
|
27
|
-
hide();
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
calcButtonPos(buttons, editorView);
|
|
31
|
-
},
|
|
32
|
-
render,
|
|
33
|
-
};
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/button-manager/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE/C,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAoB,EAAE,KAAY,EAAE,EAAE;IACtE,MAAM,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,aAAa,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;IAEjE,MAAM,OAAO,GAAG,CAAC,CAAQ,EAAE,EAAE;QACzB,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,YAAY,OAAO,IAAI,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7G,IAAI,CAAC,MAAM;YAAE,OAAO;QAEpB,CAAC,CAAC,eAAe,EAAE,CAAC;QACpB,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,MAAM,CAAC,OAAO,EAAE,CAAC;IACrB,CAAC,CAAC;IAEF,MAAM,IAAI,GAAG,GAAG,EAAE;QACd,OAAO,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,CAAC,CAAC;IAEF,OAAO,CAAC,gBAAgB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAE/C,OAAO;QACH,OAAO,EAAE,GAAG,EAAE;YACV,OAAO,CAAC,mBAAmB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YAClD,OAAO,CAAC,MAAM,EAAE,CAAC;QACrB,CAAC;QACD,IAAI;QACJ,MAAM,EAAE,CAAC,UAAsB,EAAE,EAAE;YAC/B,MAAM,QAAQ,GAAG,YAAY,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;YACrD,IAAI,QAAQ,EAAE;gBACV,IAAI,EAAE,CAAC;gBACP,OAAO;aACV;YACD,aAAa,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC;QACvC,CAAC;QACD,MAAM;KACT,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"no-active.js","sourceRoot":"","sources":["../../src/button-manager/no-active.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,SAAoB,EAAE,IAAgB,EAAE,EAAE;IAC/D,OAAO,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;SAC1B,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;SACnC,KAAK,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;AACxD,CAAC,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { css } from '@emotion/css';
|
|
3
|
-
export const injectStyle = (themeTool) => {
|
|
4
|
-
var _a, _b;
|
|
5
|
-
const { palette, mixin, size } = themeTool;
|
|
6
|
-
return css `
|
|
7
|
-
display: inline-flex;
|
|
8
|
-
cursor: pointer;
|
|
9
|
-
justify-content: space-evenly;
|
|
10
|
-
position: absolute;
|
|
11
|
-
border-radius: ${size.radius};
|
|
12
|
-
z-index: 2;
|
|
13
|
-
|
|
14
|
-
${(_a = mixin.border) === null || _a === void 0 ? void 0 : _a.call(mixin)};
|
|
15
|
-
${(_b = mixin.shadow) === null || _b === void 0 ? void 0 : _b.call(mixin)};
|
|
16
|
-
|
|
17
|
-
overflow: hidden;
|
|
18
|
-
background: ${palette('surface')};
|
|
19
|
-
|
|
20
|
-
.icon {
|
|
21
|
-
position: relative;
|
|
22
|
-
color: ${palette('solid', 0.87)};
|
|
23
|
-
|
|
24
|
-
width: 3rem;
|
|
25
|
-
line-height: 3rem;
|
|
26
|
-
text-align: center;
|
|
27
|
-
transition: all 0.4s ease-in-out;
|
|
28
|
-
&:hover {
|
|
29
|
-
background-color: ${palette('secondary', 0.12)};
|
|
30
|
-
}
|
|
31
|
-
&.active {
|
|
32
|
-
color: ${palette('primary')};
|
|
33
|
-
}
|
|
34
|
-
&:not(:last-child)::after {
|
|
35
|
-
content: '';
|
|
36
|
-
position: absolute;
|
|
37
|
-
top: 0;
|
|
38
|
-
right: calc(-0.5 * ${size.lineWidth});
|
|
39
|
-
width: ${size.lineWidth};
|
|
40
|
-
bottom: 0;
|
|
41
|
-
background: ${palette('line')};
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
&.hide,
|
|
45
|
-
.hide {
|
|
46
|
-
display: none;
|
|
47
|
-
}
|
|
48
|
-
`;
|
|
49
|
-
};
|
|
50
|
-
//# sourceMappingURL=style.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sourceRoot":"","sources":["../../src/button-manager/style.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGnC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,SAAoB,EAAE,EAAE;;IAChD,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC;IAC3C,OAAO,GAAG,CAAA;;;;;yBAKW,IAAI,CAAC,MAAM;;;UAG1B,MAAA,KAAK,CAAC,MAAM,+CAAZ,KAAK,CAAW;UAChB,MAAA,KAAK,CAAC,MAAM,+CAAZ,KAAK,CAAW;;;sBAGJ,OAAO,CAAC,SAAS,CAAC;;;;qBAInB,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC;;;;;;;oCAOP,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC;;;yBAGrC,OAAO,CAAC,SAAS,CAAC;;;;;;qCAMN,IAAI,CAAC,SAAS;yBAC1B,IAAI,CAAC,SAAS;;8BAET,OAAO,CAAC,MAAM,CAAC;;;;;;;KAOxC,CAAC;AACN,CAAC,CAAC"}
|
package/lib/index.js
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { schemaCtx } from '@milkdown/core';
|
|
3
|
-
import { Plugin, PluginKey } from '@milkdown/prose';
|
|
4
|
-
import { AtomList, createPlugin as create } from '@milkdown/utils';
|
|
5
|
-
import { buttonMap, inputMap } from './item';
|
|
6
|
-
import { createPlugin } from './selection-marks-tooltip';
|
|
7
|
-
export const key = new PluginKey('MILKDOWN_PLUGIN_TOOLTIP');
|
|
8
|
-
export const tooltipPlugin = create((utils, options) => {
|
|
9
|
-
return {
|
|
10
|
-
id: 'tooltip',
|
|
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
|
-
},
|
|
42
|
-
};
|
|
43
|
-
});
|
|
44
|
-
export const tooltip = AtomList.create([tooltipPlugin()]);
|
|
45
|
-
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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,YAAY,EAAE,CAAC,CAAC,EA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AC;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"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { calculateTextPosition } from '@milkdown/prose';
|
|
3
|
-
export const calcInputPos = (view, input) => {
|
|
4
|
-
calculateTextPosition(view, input, (start, end, target, parent) => {
|
|
5
|
-
const selectionWidth = end.left - start.left;
|
|
6
|
-
let left = start.left - parent.left - (target.width - selectionWidth) / 2;
|
|
7
|
-
const top = start.bottom - parent.top + 14;
|
|
8
|
-
if (left < 0)
|
|
9
|
-
left = 0;
|
|
10
|
-
return [top, left];
|
|
11
|
-
});
|
|
12
|
-
};
|
|
13
|
-
//# sourceMappingURL=calc-input-pos.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"calc-input-pos.js","sourceRoot":"","sources":["../../src/input-manager/calc-input-pos.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,qBAAqB,EAAc,MAAM,iBAAiB,CAAC;AAEpE,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAgB,EAAE,KAAqB,EAAE,EAAE;IACpE,qBAAqB,CAAC,IAAI,EAAE,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;QAC9D,MAAM,cAAc,GAAG,GAAG,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC;QAC7C,IAAI,IAAI,GAAG,KAAK,CAAC,IAAI,GAAG,MAAM,CAAC,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC;QAC1E,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC,GAAG,GAAG,EAAE,CAAC;QAE3C,IAAI,IAAI,GAAG,CAAC;YAAE,IAAI,GAAG,CAAC,CAAC;QAEvB,OAAO,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;IACvB,CAAC,CAAC,CAAC;AACP,CAAC,CAAC"}
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { injectStyle } from './style';
|
|
2
|
-
export const createInput = (utils) => {
|
|
3
|
-
const div = document.createElement('div');
|
|
4
|
-
const style = utils.getStyle(injectStyle);
|
|
5
|
-
if (style) {
|
|
6
|
-
div.classList.add(style);
|
|
7
|
-
}
|
|
8
|
-
div.classList.add('tooltip-input');
|
|
9
|
-
const input = document.createElement('input');
|
|
10
|
-
div.appendChild(input);
|
|
11
|
-
const button = document.createElement('button');
|
|
12
|
-
div.appendChild(button);
|
|
13
|
-
input.addEventListener('input', (e) => {
|
|
14
|
-
const { target } = e;
|
|
15
|
-
if (!(target instanceof HTMLInputElement)) {
|
|
16
|
-
return;
|
|
17
|
-
}
|
|
18
|
-
if (!target.value) {
|
|
19
|
-
button.classList.add('disable');
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
button.classList.remove('disable');
|
|
23
|
-
});
|
|
24
|
-
return {
|
|
25
|
-
div,
|
|
26
|
-
input,
|
|
27
|
-
button,
|
|
28
|
-
};
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=create-input.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"create-input.js","sourceRoot":"","sources":["../../src/input-manager/create-input.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAY,EAAE,EAAE;IACxC,MAAM,GAAG,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IAC1C,IAAI,KAAK,EAAE;QACP,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;KAC5B;IAED,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;IAEnC,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IAC9C,GAAG,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;IACvB,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,GAAG,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAExB,KAAK,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,EAAE;QAClC,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QACrB,IAAI,CAAC,CAAC,MAAM,YAAY,gBAAgB,CAAC,EAAE;YACvC,OAAO;SACV;QAED,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE;YACf,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;YAChC,OAAO;SACV;QAED,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,OAAO;QACH,GAAG;QACH,KAAK;QACL,MAAM;KACA,CAAC;AACf,CAAC,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export const filterInput = (currentView, inputMap, div, input, button) => {
|
|
2
|
-
const target = Object.values(inputMap).find((input) => input.display(currentView));
|
|
3
|
-
if (!target) {
|
|
4
|
-
div.classList.add('hide');
|
|
5
|
-
return;
|
|
6
|
-
}
|
|
7
|
-
div.classList.remove('hide');
|
|
8
|
-
if (target.bind) {
|
|
9
|
-
button.classList.add('hide');
|
|
10
|
-
}
|
|
11
|
-
else {
|
|
12
|
-
button.classList.remove('hide');
|
|
13
|
-
button.textContent = target.buttonText;
|
|
14
|
-
}
|
|
15
|
-
input.placeholder = target.placeholder;
|
|
16
|
-
target.update(currentView, div);
|
|
17
|
-
return target;
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=filter-input.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"filter-input.js","sourceRoot":"","sources":["../../src/input-manager/filter-input.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,WAAW,GAAG,CACvB,WAAuB,EACvB,QAAkB,EAClB,GAAmB,EACnB,KAAuB,EACvB,MAAyB,EAC3B,EAAE;IACA,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;IAEnF,IAAI,CAAC,MAAM,EAAE;QACT,GAAG,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QAC1B,OAAO;KACV;IAED,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IAE7B,IAAI,MAAM,CAAC,IAAI,EAAE;QACb,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;KAChC;SAAM;QACH,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAChC,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC;KAC1C;IAED,KAAK,CAAC,WAAW,GAAG,MAAM,CAAC,WAAW,CAAC;IACvC,MAAM,CAAC,MAAM,CAAC,WAAW,EAAE,GAAG,CAAC,CAAC;IAEhC,OAAO,MAAM,CAAC;AAClB,CAAC,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { calcInputPos } from './calc-input-pos';
|
|
2
|
-
import { createInput } from './create-input';
|
|
3
|
-
import { filterInput } from './filter-input';
|
|
4
|
-
export const createInputManager = (inputMap, utils) => {
|
|
5
|
-
let inputCommand;
|
|
6
|
-
let binding = false;
|
|
7
|
-
const setCommand = (x) => (inputCommand = x);
|
|
8
|
-
const { div, button, input } = createInput(utils);
|
|
9
|
-
const onClick = (e) => {
|
|
10
|
-
if (!inputCommand || button.classList.contains('disable'))
|
|
11
|
-
return;
|
|
12
|
-
e.stopPropagation();
|
|
13
|
-
inputCommand(e);
|
|
14
|
-
div.classList.add('hide');
|
|
15
|
-
};
|
|
16
|
-
const onInput = (e) => {
|
|
17
|
-
if (!binding || !inputCommand)
|
|
18
|
-
return;
|
|
19
|
-
inputCommand(e);
|
|
20
|
-
};
|
|
21
|
-
input.addEventListener('input', onInput);
|
|
22
|
-
button.addEventListener('mousedown', onClick);
|
|
23
|
-
return {
|
|
24
|
-
destroy: () => {
|
|
25
|
-
input.removeEventListener('input', onInput);
|
|
26
|
-
div.removeEventListener('mousedown', onClick);
|
|
27
|
-
div.remove();
|
|
28
|
-
},
|
|
29
|
-
hide: () => {
|
|
30
|
-
div.classList.add('hide');
|
|
31
|
-
setCommand();
|
|
32
|
-
},
|
|
33
|
-
update: (editorView) => {
|
|
34
|
-
const result = filterInput(editorView, inputMap, div, input, button);
|
|
35
|
-
if (!result)
|
|
36
|
-
return;
|
|
37
|
-
binding = !!result.bind;
|
|
38
|
-
setCommand(result.command);
|
|
39
|
-
calcInputPos(editorView, div);
|
|
40
|
-
},
|
|
41
|
-
render: (editorView) => {
|
|
42
|
-
const wrapper = editorView.dom.parentNode;
|
|
43
|
-
if (!wrapper)
|
|
44
|
-
throw new Error();
|
|
45
|
-
wrapper.appendChild(div);
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/input-manager/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,WAAW,E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AC,SAAS,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAC1B,UAAU,EAAE,CAAC;QACjB,CAAC;QACD,MAAM,EAAE,CAAC,UAAsB,EAAE,EAAE;YAC/B,MAAM,MAAM,GAAG,WAAW,CAAC,UAAU,EAAE,QAAQ,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,CAAC;YACrE,IAAI,CAAC,MAAM;gBAAE,OAAO;YACpB,OAAO,GAAG,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC;YACxB,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;YAC3B,YAAY,CAAC,UAAU,EAAE,GAAG,CAAC,CAAC;QAClC,CAAC;QACD,MAAM,EAAE,CAAC,UAAsB,EAAE,EAAE;YAC/B,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,CAAC,UAAU,CAAC;YAC1C,IAAI,CAAC,OAAO;gBAAE,MAAM,IAAI,KAAK,EAAE,CAAC;YAChC,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;KACJ,CAAC;AACN,CAAC,CAAC"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { css } from '@emotion/css';
|
|
3
|
-
export const injectStyle = (themeTool) => {
|
|
4
|
-
var _a, _b;
|
|
5
|
-
const { palette, mixin, size } = themeTool;
|
|
6
|
-
return css `
|
|
7
|
-
${(_a = mixin.border) === null || _a === void 0 ? void 0 : _a.call(mixin)};
|
|
8
|
-
${(_b = mixin.shadow) === null || _b === void 0 ? void 0 : _b.call(mixin)};
|
|
9
|
-
|
|
10
|
-
display: inline-flex;
|
|
11
|
-
justify-content: space-between;
|
|
12
|
-
align-items: center;
|
|
13
|
-
position: absolute;
|
|
14
|
-
background: ${palette('surface')};
|
|
15
|
-
border-radius: ${size.radius};
|
|
16
|
-
font-size: 1rem;
|
|
17
|
-
|
|
18
|
-
height: 3.5rem;
|
|
19
|
-
box-sizing: border-box;
|
|
20
|
-
width: 25.5rem;
|
|
21
|
-
padding: 0 1rem;
|
|
22
|
-
gap: 1rem;
|
|
23
|
-
z-index: 2;
|
|
24
|
-
|
|
25
|
-
input,
|
|
26
|
-
button {
|
|
27
|
-
all: unset;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
input {
|
|
31
|
-
flex-grow: 1;
|
|
32
|
-
caret-color: ${palette('primary')};
|
|
33
|
-
&::placeholder {
|
|
34
|
-
color: ${palette('neutral', 0.6)};
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
button {
|
|
39
|
-
cursor: pointer;
|
|
40
|
-
height: 2.25rem;
|
|
41
|
-
color: ${palette('primary')};
|
|
42
|
-
font-size: 0.875rem;
|
|
43
|
-
padding: 0 0.5rem;
|
|
44
|
-
font-weight: 500;
|
|
45
|
-
letter-spacing: 1.25px;
|
|
46
|
-
&:hover {
|
|
47
|
-
background-color: ${palette('secondary', 0.12)};
|
|
48
|
-
}
|
|
49
|
-
&.disable {
|
|
50
|
-
color: ${palette('neutral', 0.38)};
|
|
51
|
-
cursor: not-allowed;
|
|
52
|
-
&:hover {
|
|
53
|
-
background: transparent;
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
&.hide {
|
|
57
|
-
display: none;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
&.hide {
|
|
62
|
-
display: none;
|
|
63
|
-
}
|
|
64
|
-
`;
|
|
65
|
-
};
|
|
66
|
-
//# sourceMappingURL=style.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"style.js","sourceRoot":"","sources":["../../src/input-manager/style.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAGnC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,SAAoB,EAAE,EAAE;;IAChD,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,SAAS,CAAC;IAE3C,OAAO,GAAG,CAAA;UACJ,MAAA,KAAK,CAAC,MAAM,+CAAZ,KAAK,CAAW;UAChB,MAAA,KAAK,CAAC,MAAM,+CAAZ,KAAK,CAAW;;;;;;sBAMJ,OAAO,CAAC,SAAS,CAAC;yBACf,IAAI,CAAC,MAAM;;;;;;;;;;;;;;;;;2BAiBT,OAAO,CAAC,SAAS,CAAC;;yBAEpB,OAAO,CAAC,SAAS,EAAE,GAAG,CAAC;;;;;;;qBAO3B,OAAO,CAAC,SAAS,CAAC;;;;;;oCAMH,OAAO,CAAC,WAAW,EAAE,IAAI,CAAC;;;yBAGrC,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC;;;;;;;;;;;;;;KAc5C,CAAC;AACN,CAAC,CAAC"}
|
package/lib/item.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { ToggleBold, ToggleInlineCode, ToggleItalic, ToggleLink, ToggleStrikeThrough } from '@milkdown/preset-gfm';
|
|
2
|
-
import { findSelectedNodeOfType } from '@milkdown/prose';
|
|
3
|
-
import { createToggleIcon, hasMark, modifyImage, modifyInlineMath, modifyLink, updateImageView, updateInlineMathView, updateLinkView, } from './utility';
|
|
4
|
-
export var ButtonAction;
|
|
5
|
-
(function (ButtonAction) {
|
|
6
|
-
ButtonAction[ButtonAction["ToggleBold"] = 0] = "ToggleBold";
|
|
7
|
-
ButtonAction[ButtonAction["ToggleItalic"] = 1] = "ToggleItalic";
|
|
8
|
-
ButtonAction[ButtonAction["ToggleStrike"] = 2] = "ToggleStrike";
|
|
9
|
-
ButtonAction[ButtonAction["ToggleCode"] = 3] = "ToggleCode";
|
|
10
|
-
ButtonAction[ButtonAction["ToggleLink"] = 4] = "ToggleLink";
|
|
11
|
-
})(ButtonAction || (ButtonAction = {}));
|
|
12
|
-
export var InputAction;
|
|
13
|
-
(function (InputAction) {
|
|
14
|
-
InputAction[InputAction["ModifyLink"] = 0] = "ModifyLink";
|
|
15
|
-
InputAction[InputAction["ModifyImage"] = 1] = "ModifyImage";
|
|
16
|
-
InputAction[InputAction["ModifyInlineMath"] = 2] = "ModifyInlineMath";
|
|
17
|
-
})(InputAction || (InputAction = {}));
|
|
18
|
-
export const inputMap = (schema, ctx, inputOptions) => {
|
|
19
|
-
const { marks, nodes } = schema;
|
|
20
|
-
return {
|
|
21
|
-
[InputAction.ModifyLink]: Object.assign({ display: (view) => view.state.selection.empty && hasMark(view.state, marks.link), command: modifyLink(ctx), update: updateLinkView }, inputOptions.link),
|
|
22
|
-
[InputAction.ModifyInlineMath]: Object.assign({ display: (view) => Boolean(findSelectedNodeOfType(view.state.selection, nodes.math_inline)), command: modifyInlineMath(ctx), update: updateInlineMathView, bind: true }, inputOptions.inlineMath),
|
|
23
|
-
[InputAction.ModifyImage]: Object.assign({ display: (view) => Boolean(findSelectedNodeOfType(view.state.selection, nodes.image)), command: modifyImage(ctx), update: updateImageView }, inputOptions.image),
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export const buttonMap = (schema, ctx) => {
|
|
27
|
-
const { marks } = schema;
|
|
28
|
-
return {
|
|
29
|
-
[ButtonAction.ToggleBold]: createToggleIcon(ctx, 'bold', ToggleBold, marks.strong, marks.code_inline),
|
|
30
|
-
[ButtonAction.ToggleItalic]: createToggleIcon(ctx, 'italic', ToggleItalic, marks.em, marks.code_inline),
|
|
31
|
-
[ButtonAction.ToggleStrike]: createToggleIcon(ctx, 'strikeThrough', ToggleStrikeThrough, marks.strike_through, marks.code_inline),
|
|
32
|
-
[ButtonAction.ToggleCode]: createToggleIcon(ctx, 'code', ToggleInlineCode, marks.code_inline, marks.link),
|
|
33
|
-
[ButtonAction.ToggleLink]: createToggleIcon(ctx, 'link', ToggleLink, marks.link, marks.code_inline),
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
//# sourceMappingURL=item.js.map
|