@milkdown/plugin-tooltip 5.4.1 → 6.0.0-next.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/README.md +3 -13
- package/lib/{src/button-manager → button-manager}/calc-button-pos.d.ts +1 -1
- package/lib/button-manager/calc-button-pos.d.ts.map +1 -0
- package/lib/{src/button-manager → button-manager}/create-tooltip.d.ts +1 -1
- package/lib/button-manager/create-tooltip.d.ts.map +1 -0
- package/lib/{src/button-manager → button-manager}/filter-button.d.ts +0 -0
- package/lib/button-manager/filter-button.d.ts.map +1 -0
- package/lib/{src/button-manager → button-manager}/index.d.ts +1 -1
- package/lib/button-manager/index.d.ts.map +1 -0
- package/lib/{src/button-manager → button-manager}/no-active.d.ts +0 -0
- package/lib/button-manager/no-active.d.ts.map +1 -0
- package/lib/button-manager/style.d.ts +3 -0
- package/lib/button-manager/style.d.ts.map +1 -0
- package/lib/index.d.ts +19 -1
- package/lib/index.d.ts.map +1 -0
- package/lib/index.es.js +65 -376
- package/lib/index.es.js.map +1 -1
- package/lib/item.d.ts +35 -0
- package/lib/item.d.ts.map +1 -0
- package/lib/{src/selection-marks-tooltip.d.ts → selection-marks-tooltip.d.ts} +2 -2
- package/lib/selection-marks-tooltip.d.ts.map +1 -0
- package/lib/{src/utility → utility}/element.d.ts +0 -0
- package/lib/utility/element.d.ts.map +1 -0
- package/lib/{src/utility → utility}/index.d.ts +0 -1
- package/lib/utility/index.d.ts.map +1 -0
- package/lib/{src/utility → utility}/prosemirror.d.ts +2 -2
- package/lib/utility/prosemirror.d.ts.map +1 -0
- package/lib/{src/utility → utility}/toggle.d.ts +1 -1
- package/lib/utility/toggle.d.ts.map +1 -0
- package/package.json +34 -10
- package/src/button-manager/calc-button-pos.ts +2 -3
- package/src/button-manager/create-tooltip.ts +8 -6
- package/src/button-manager/index.ts +8 -3
- package/src/button-manager/style.ts +11 -10
- package/src/index.ts +6 -22
- package/src/item.ts +47 -80
- package/src/selection-marks-tooltip.ts +3 -9
- package/src/utility/index.ts +0 -1
- package/src/utility/prosemirror.ts +5 -2
- package/src/utility/toggle.ts +5 -5
- package/lib/src/button-manager/calc-button-pos.d.ts.map +0 -1
- package/lib/src/button-manager/create-tooltip.d.ts.map +0 -1
- package/lib/src/button-manager/filter-button.d.ts.map +0 -1
- package/lib/src/button-manager/index.d.ts.map +0 -1
- package/lib/src/button-manager/no-active.d.ts.map +0 -1
- package/lib/src/button-manager/style.d.ts +0 -3
- package/lib/src/button-manager/style.d.ts.map +0 -1
- package/lib/src/index.d.ts +0 -21
- package/lib/src/index.d.ts.map +0 -1
- package/lib/src/input-manager/calc-input-pos.d.ts +0 -3
- package/lib/src/input-manager/calc-input-pos.d.ts.map +0 -1
- package/lib/src/input-manager/create-input.d.ts +0 -7
- package/lib/src/input-manager/create-input.d.ts.map +0 -1
- package/lib/src/input-manager/filter-input.d.ts +0 -19
- package/lib/src/input-manager/filter-input.d.ts.map +0 -1
- package/lib/src/input-manager/index.d.ts +0 -10
- package/lib/src/input-manager/index.d.ts.map +0 -1
- package/lib/src/input-manager/style.d.ts +0 -3
- package/lib/src/input-manager/style.d.ts.map +0 -1
- package/lib/src/item.d.ts +0 -53
- package/lib/src/item.d.ts.map +0 -1
- package/lib/src/selection-marks-tooltip.d.ts.map +0 -1
- package/lib/src/utility/element.d.ts.map +0 -1
- package/lib/src/utility/index.d.ts.map +0 -1
- package/lib/src/utility/input.d.ts +0 -9
- package/lib/src/utility/input.d.ts.map +0 -1
- package/lib/src/utility/prosemirror.d.ts.map +0 -1
- package/lib/src/utility/toggle.d.ts.map +0 -1
- package/src/input-manager/calc-input-pos.ts +0 -19
- package/src/input-manager/create-input.ts +0 -39
- package/src/input-manager/filter-input.ts +0 -33
- package/src/input-manager/index.ts +0 -55
- package/src/input-manager/style.ts +0 -66
- package/src/utility/input.ts +0 -132
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { Emotion, ThemeTool } from '@milkdown/core';
|
|
3
|
-
|
|
4
|
-
export const injectStyle = (themeTool: ThemeTool, { css }: Emotion) => {
|
|
5
|
-
const { palette, mixin, size } = themeTool;
|
|
6
|
-
|
|
7
|
-
return css`
|
|
8
|
-
${mixin.border?.()};
|
|
9
|
-
${mixin.shadow?.()};
|
|
10
|
-
|
|
11
|
-
display: inline-flex;
|
|
12
|
-
justify-content: space-between;
|
|
13
|
-
align-items: center;
|
|
14
|
-
position: absolute;
|
|
15
|
-
background: ${palette('surface')};
|
|
16
|
-
border-radius: ${size.radius};
|
|
17
|
-
font-size: 1rem;
|
|
18
|
-
|
|
19
|
-
height: 3.5rem;
|
|
20
|
-
box-sizing: border-box;
|
|
21
|
-
width: 25.5rem;
|
|
22
|
-
padding: 0 1rem;
|
|
23
|
-
gap: 1rem;
|
|
24
|
-
z-index: 2;
|
|
25
|
-
|
|
26
|
-
input,
|
|
27
|
-
button {
|
|
28
|
-
all: unset;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
input {
|
|
32
|
-
flex-grow: 1;
|
|
33
|
-
caret-color: ${palette('primary')};
|
|
34
|
-
&::placeholder {
|
|
35
|
-
color: ${palette('neutral', 0.6)};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
button {
|
|
40
|
-
cursor: pointer;
|
|
41
|
-
height: 2.25rem;
|
|
42
|
-
color: ${palette('primary')};
|
|
43
|
-
font-size: 0.875rem;
|
|
44
|
-
padding: 0 0.5rem;
|
|
45
|
-
font-weight: 500;
|
|
46
|
-
letter-spacing: 1.25px;
|
|
47
|
-
&:hover {
|
|
48
|
-
background-color: ${palette('secondary', 0.12)};
|
|
49
|
-
}
|
|
50
|
-
&.disable {
|
|
51
|
-
color: ${palette('neutral', 0.38)};
|
|
52
|
-
cursor: not-allowed;
|
|
53
|
-
&:hover {
|
|
54
|
-
background: transparent;
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
&.hide {
|
|
58
|
-
display: none;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
&.hide {
|
|
63
|
-
display: none;
|
|
64
|
-
}
|
|
65
|
-
`;
|
|
66
|
-
};
|
package/src/utility/input.ts
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
/* Copyright 2021, Milkdown by Mirone. */
|
|
2
|
-
import { commandsCtx, Ctx } from '@milkdown/core';
|
|
3
|
-
import { findSelectedNodeOfType, Node as ProseNode } from '@milkdown/prose';
|
|
4
|
-
|
|
5
|
-
import { Event2Command, Updater } from '../item';
|
|
6
|
-
import { elementIsTag } from './element';
|
|
7
|
-
|
|
8
|
-
export const modifyLink =
|
|
9
|
-
(ctx: Ctx): Event2Command =>
|
|
10
|
-
(e) => {
|
|
11
|
-
const { target } = e;
|
|
12
|
-
if (!(target instanceof HTMLElement)) {
|
|
13
|
-
return () => true;
|
|
14
|
-
}
|
|
15
|
-
if (elementIsTag(target, 'input')) {
|
|
16
|
-
target.focus();
|
|
17
|
-
return () => false;
|
|
18
|
-
}
|
|
19
|
-
const parent = target.parentNode;
|
|
20
|
-
if (!parent) return () => false;
|
|
21
|
-
|
|
22
|
-
const inputEl = Array.from(parent.children).find((el) => el.tagName === 'INPUT');
|
|
23
|
-
if (!(inputEl instanceof HTMLInputElement)) return () => false;
|
|
24
|
-
|
|
25
|
-
return ctx.get(commandsCtx).callByName('ModifyLink', inputEl.value);
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
export const modifyInlineMath =
|
|
29
|
-
(ctx: Ctx): Event2Command =>
|
|
30
|
-
(e) => {
|
|
31
|
-
const { target } = e;
|
|
32
|
-
if (!(target instanceof HTMLElement)) {
|
|
33
|
-
return () => true;
|
|
34
|
-
}
|
|
35
|
-
const parent = target.parentNode;
|
|
36
|
-
if (!parent) return () => false;
|
|
37
|
-
|
|
38
|
-
const inputEl = Array.from(parent.children).find((el) => el.tagName === 'INPUT');
|
|
39
|
-
if (!(inputEl instanceof HTMLInputElement)) return () => false;
|
|
40
|
-
|
|
41
|
-
return ctx.get(commandsCtx).callByName('ModifyInlineMath', inputEl.value);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
export const modifyImage =
|
|
45
|
-
(ctx: Ctx): Event2Command =>
|
|
46
|
-
(e) => {
|
|
47
|
-
const { target } = e;
|
|
48
|
-
if (!(target instanceof HTMLElement)) {
|
|
49
|
-
return () => true;
|
|
50
|
-
}
|
|
51
|
-
if (elementIsTag(target, 'input')) {
|
|
52
|
-
target.focus();
|
|
53
|
-
return () => false;
|
|
54
|
-
}
|
|
55
|
-
const parent = target.parentNode;
|
|
56
|
-
if (!parent) return () => false;
|
|
57
|
-
|
|
58
|
-
const inputEl = Array.from(parent.children).find((el) => el.tagName === 'INPUT');
|
|
59
|
-
if (!(inputEl instanceof HTMLInputElement)) return () => false;
|
|
60
|
-
|
|
61
|
-
return ctx.get(commandsCtx).callByName('ModifyImage', inputEl.value);
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
export const updateLinkView: Updater = (view, $) => {
|
|
65
|
-
const { marks } = view.state.schema;
|
|
66
|
-
const { firstChild, lastElementChild } = $;
|
|
67
|
-
if (!(firstChild instanceof HTMLInputElement) || !(lastElementChild instanceof HTMLButtonElement)) return;
|
|
68
|
-
|
|
69
|
-
const { selection } = view.state;
|
|
70
|
-
let node: ProseNode | undefined;
|
|
71
|
-
view.state.doc.nodesBetween(selection.from, selection.to, (n) => {
|
|
72
|
-
if (marks.link.isInSet(n.marks)) {
|
|
73
|
-
node = n;
|
|
74
|
-
return false;
|
|
75
|
-
}
|
|
76
|
-
return;
|
|
77
|
-
});
|
|
78
|
-
if (!node) return;
|
|
79
|
-
|
|
80
|
-
const mark = node.marks.find((m) => m.type === marks.link);
|
|
81
|
-
if (!mark) return;
|
|
82
|
-
|
|
83
|
-
const value = mark.attrs.href;
|
|
84
|
-
firstChild.value = value;
|
|
85
|
-
if (!value) {
|
|
86
|
-
lastElementChild.classList.add('disable');
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
if (lastElementChild.classList.contains('disable')) {
|
|
90
|
-
lastElementChild.classList.remove('disable');
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
export const updateInlineMathView: Updater = (view, $) => {
|
|
95
|
-
const { nodes } = view.state.schema;
|
|
96
|
-
const { firstChild, lastElementChild } = $;
|
|
97
|
-
if (!(firstChild instanceof HTMLInputElement) || !(lastElementChild instanceof HTMLButtonElement)) return;
|
|
98
|
-
|
|
99
|
-
const result = findSelectedNodeOfType(view.state.selection, nodes.math_inline);
|
|
100
|
-
if (!result) return;
|
|
101
|
-
const { node } = result;
|
|
102
|
-
|
|
103
|
-
const value = node.attrs.value;
|
|
104
|
-
firstChild.value = value;
|
|
105
|
-
if (!value) {
|
|
106
|
-
lastElementChild.classList.add('disable');
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
if (lastElementChild.classList.contains('disable')) {
|
|
110
|
-
lastElementChild.classList.remove('disable');
|
|
111
|
-
}
|
|
112
|
-
};
|
|
113
|
-
|
|
114
|
-
export const updateImageView: Updater = (view, $) => {
|
|
115
|
-
const { nodes } = view.state.schema;
|
|
116
|
-
const { firstChild, lastElementChild } = $;
|
|
117
|
-
if (!(firstChild instanceof HTMLInputElement) || !(lastElementChild instanceof HTMLButtonElement)) return;
|
|
118
|
-
|
|
119
|
-
const result = findSelectedNodeOfType(view.state.selection, nodes.image);
|
|
120
|
-
if (!result) return;
|
|
121
|
-
const { node } = result;
|
|
122
|
-
|
|
123
|
-
const value = node.attrs.src;
|
|
124
|
-
firstChild.value = value.length > 50 ? 'Url is too long to display.' : value;
|
|
125
|
-
if (!value) {
|
|
126
|
-
lastElementChild.classList.add('disable');
|
|
127
|
-
return;
|
|
128
|
-
}
|
|
129
|
-
if (lastElementChild.classList.contains('disable')) {
|
|
130
|
-
lastElementChild.classList.remove('disable');
|
|
131
|
-
}
|
|
132
|
-
};
|