@milkdown/crepe 7.5.9 → 7.6.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/cjs/index-6oBtF_11.js +26 -0
- package/lib/cjs/{index-BIXWL4Or.js.map → index-6oBtF_11.js.map} +1 -1
- package/lib/cjs/{index-Dt55rF23.js → index-8COAwUnB.js} +5 -5
- package/lib/cjs/{index-Dt55rF23.js.map → index-8COAwUnB.js.map} +1 -1
- package/lib/cjs/{index-By3ewOiO.js → index-B4NxKjEA.js} +52 -52
- package/lib/cjs/index-B4NxKjEA.js.map +1 -0
- package/lib/cjs/{index-Dub20F3z.js → index-BOmVuuoY.js} +3 -3
- package/lib/cjs/{index-Dub20F3z.js.map → index-BOmVuuoY.js.map} +1 -1
- package/lib/cjs/{index-BuSAwj4j.js → index-C4JjdSvv.js} +3 -3
- package/lib/cjs/{index-BuSAwj4j.js.map → index-C4JjdSvv.js.map} +1 -1
- package/lib/cjs/index-C6EzkFZ_.js +39 -0
- package/lib/cjs/{index-DmOOfQPi.js.map → index-C6EzkFZ_.js.map} +1 -1
- package/lib/cjs/index-D0OPKY6K.js +65 -0
- package/lib/cjs/index-D0OPKY6K.js.map +1 -0
- package/lib/cjs/index-DkHBuNoK.js +176 -0
- package/lib/cjs/index-DkHBuNoK.js.map +1 -0
- package/lib/cjs/index-DnFbvtbD.js +278 -0
- package/lib/cjs/index-DnFbvtbD.js.map +1 -0
- package/lib/cjs/{index-AlHHvSR_.js → index-YUwSTgPK.js} +3 -3
- package/lib/cjs/{index-AlHHvSR_.js.map → index-YUwSTgPK.js.map} +1 -1
- package/lib/cjs/{index-A8IrOmzS.js → index-koRsjvWB.js} +116 -18
- package/lib/cjs/index-koRsjvWB.js.map +1 -0
- package/lib/cjs/index-nDWnWxJ8.js +38 -0
- package/lib/cjs/{index-CtNE-wHT.js.map → index-nDWnWxJ8.js.map} +1 -1
- package/lib/cjs/index.js +13 -148
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/inline-latex-CwU8Nsfj.js +54 -0
- package/lib/cjs/inline-latex-CwU8Nsfj.js.map +1 -0
- package/lib/cjs/{todoList-V4JWO5-M.js → todo-list-V4JWO5-M.js} +1 -1
- package/lib/cjs/todo-list-V4JWO5-M.js.map +1 -0
- package/lib/esm/index-BOzN8fKq.js +36 -0
- package/lib/esm/{index-BEWessT5.js.map → index-BOzN8fKq.js.map} +1 -1
- package/lib/esm/index-BUFg1FSH.js +172 -0
- package/lib/esm/index-BUFg1FSH.js.map +1 -0
- package/lib/esm/index-BxpDIDRS.js +63 -0
- package/lib/esm/index-BxpDIDRS.js.map +1 -0
- package/lib/esm/index-C5_dM0IB.js +276 -0
- package/lib/esm/index-C5_dM0IB.js.map +1 -0
- package/lib/esm/{index-DlX33Dj0.js → index-C7Xr_l-d.js} +5 -5
- package/lib/esm/{index-DlX33Dj0.js.map → index-C7Xr_l-d.js.map} +1 -1
- package/lib/esm/{index-CxJ9fxJm.js → index-C7_YCA3P.js} +3 -3
- package/lib/esm/{index-CxJ9fxJm.js.map → index-C7_YCA3P.js.map} +1 -1
- package/lib/esm/index-C8tiRHTF.js +37 -0
- package/lib/esm/{index-BDGHz9p-.js.map → index-C8tiRHTF.js.map} +1 -1
- package/lib/esm/{index-D6fLMv29.js → index-CD8fvrRC.js} +3 -3
- package/lib/esm/{index-D6fLMv29.js.map → index-CD8fvrRC.js.map} +1 -1
- package/lib/esm/index-CEup1V8i.js +24 -0
- package/lib/esm/{index-6VoEpEnX.js.map → index-CEup1V8i.js.map} +1 -1
- package/lib/esm/{index-kGl7HgN2.js → index-DroARb55.js} +117 -19
- package/lib/esm/index-DroARb55.js.map +1 -0
- package/lib/esm/{index-zKiGjwHz.js → index-HnGoJxjJ.js} +52 -52
- package/lib/esm/index-HnGoJxjJ.js.map +1 -0
- package/lib/esm/{index-DOrkOhki.js → index-WCe-Xh61.js} +3 -3
- package/lib/esm/{index-DOrkOhki.js.map → index-WCe-Xh61.js.map} +1 -1
- package/lib/esm/index.js +11 -150
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/inline-latex-BLd2QrJC.js +51 -0
- package/lib/esm/inline-latex-BLd2QrJC.js.map +1 -0
- package/lib/esm/{todoList-CAbx4396.js → todo-list-B78GeGtK.js} +2 -2
- package/lib/esm/todo-list-B78GeGtK.js.map +1 -0
- package/lib/theme/common/code-mirror.css +93 -34
- package/lib/theme/common/latex.css +44 -0
- package/lib/theme/common/style.css +1 -0
- package/lib/types/core/crepe.d.ts +2 -0
- package/lib/types/core/crepe.d.ts.map +1 -1
- package/lib/types/feature/code-mirror/index.d.ts +6 -2
- package/lib/types/feature/code-mirror/index.d.ts.map +1 -1
- package/lib/types/feature/index.d.ts +4 -1
- package/lib/types/feature/index.d.ts.map +1 -1
- package/lib/types/feature/latex/block-latex.d.ts +2 -0
- package/lib/types/feature/latex/block-latex.d.ts.map +1 -0
- package/lib/types/feature/latex/index.d.ts +9 -0
- package/lib/types/feature/latex/index.d.ts.map +1 -0
- package/lib/types/feature/latex/inline-latex.d.ts +3 -0
- package/lib/types/feature/latex/inline-latex.d.ts.map +1 -0
- package/lib/types/feature/latex/inline-tooltip/component.d.ts +15 -0
- package/lib/types/feature/latex/inline-tooltip/component.d.ts.map +1 -0
- package/lib/types/feature/latex/inline-tooltip/tooltip.d.ts +2 -0
- package/lib/types/feature/latex/inline-tooltip/tooltip.d.ts.map +1 -0
- package/lib/types/feature/latex/inline-tooltip/view.d.ts +13 -0
- package/lib/types/feature/latex/inline-tooltip/view.d.ts.map +1 -0
- package/lib/types/feature/latex/input-rule.d.ts +3 -0
- package/lib/types/feature/latex/input-rule.d.ts.map +1 -0
- package/lib/types/feature/latex/remark.d.ts +3 -0
- package/lib/types/feature/latex/remark.d.ts.map +1 -0
- package/lib/types/feature/shared.d.ts +1 -1
- package/lib/types/feature/shared.d.ts.map +1 -1
- package/lib/types/feature/toolbar/component.d.ts +2 -0
- package/lib/types/feature/toolbar/component.d.ts.map +1 -1
- package/lib/types/feature/toolbar/index.d.ts +1 -0
- package/lib/types/feature/toolbar/index.d.ts.map +1 -1
- package/lib/types/icons/{alignCenter.d.ts → align-center.d.ts} +1 -1
- package/lib/types/icons/align-center.d.ts.map +1 -0
- package/lib/types/icons/{alignLeft.d.ts → align-left.d.ts} +1 -1
- package/lib/types/icons/align-left.d.ts.map +1 -0
- package/lib/types/icons/{alignRight.d.ts → align-right.d.ts} +1 -1
- package/lib/types/icons/align-right.d.ts.map +1 -0
- package/lib/types/icons/{bulletList.d.ts → bullet-list.d.ts} +1 -1
- package/lib/types/icons/bullet-list.d.ts.map +1 -0
- package/lib/types/icons/{checkBoxChecked.d.ts → check-box-checked.d.ts} +1 -1
- package/lib/types/icons/check-box-checked.d.ts.map +1 -0
- package/lib/types/icons/{checkBoxUnchecked.d.ts → check-box-unchecked.d.ts} +1 -1
- package/lib/types/icons/check-box-unchecked.d.ts.map +1 -0
- package/lib/types/icons/{chevronDown.d.ts → chevron-down.d.ts} +1 -1
- package/lib/types/icons/chevron-down.d.ts.map +1 -0
- package/lib/types/icons/{dragHandle.d.ts → drag-handle.d.ts} +1 -1
- package/lib/types/icons/drag-handle.d.ts.map +1 -0
- package/lib/types/icons/functions.d.ts +2 -0
- package/lib/types/icons/functions.d.ts.map +1 -0
- package/lib/types/icons/index.d.ts +10 -10
- package/lib/types/icons/index.d.ts.map +1 -1
- package/lib/types/icons/{orderedList.d.ts → ordered-list.d.ts} +1 -1
- package/lib/types/icons/ordered-list.d.ts.map +1 -0
- package/lib/types/icons/{todoList.d.ts → todo-list.d.ts} +1 -1
- package/lib/types/icons/todo-list.d.ts.map +1 -0
- package/lib/types/icons/visibility-off.d.ts +2 -0
- package/lib/types/icons/visibility-off.d.ts.map +1 -0
- package/package.json +7 -4
- package/src/core/crepe.ts +19 -0
- package/src/feature/block-edit/handle/index.ts +1 -1
- package/src/feature/code-mirror/index.ts +23 -3
- package/src/feature/index.ts +8 -0
- package/src/feature/latex/block-latex.ts +25 -0
- package/src/feature/latex/index.ts +73 -0
- package/src/feature/latex/inline-latex.ts +55 -0
- package/src/feature/latex/inline-tooltip/component.ts +38 -0
- package/src/feature/latex/inline-tooltip/tooltip.ts +3 -0
- package/src/feature/latex/inline-tooltip/view.ts +122 -0
- package/src/feature/latex/input-rule.ts +25 -0
- package/src/feature/latex/remark.ts +35 -0
- package/src/feature/shared.ts +1 -1
- package/src/feature/toolbar/component.ts +91 -3
- package/src/feature/toolbar/index.ts +3 -1
- package/src/icons/functions.ts +15 -0
- package/src/icons/index.ts +10 -10
- package/src/icons/visibility-off.ts +14 -0
- package/src/theme/common/code-mirror.css +95 -34
- package/src/theme/common/latex.css +44 -0
- package/src/theme/common/style.css +1 -0
- package/lib/cjs/index-3mj4YaCA.js +0 -43
- package/lib/cjs/index-3mj4YaCA.js.map +0 -1
- package/lib/cjs/index-A8IrOmzS.js.map +0 -1
- package/lib/cjs/index-BIXWL4Or.js +0 -26
- package/lib/cjs/index-By3ewOiO.js.map +0 -1
- package/lib/cjs/index-CtNE-wHT.js +0 -38
- package/lib/cjs/index-DmOOfQPi.js +0 -39
- package/lib/cjs/todoList-V4JWO5-M.js.map +0 -1
- package/lib/esm/index-6VoEpEnX.js +0 -24
- package/lib/esm/index-BB3Rq6BU.js +0 -41
- package/lib/esm/index-BB3Rq6BU.js.map +0 -1
- package/lib/esm/index-BDGHz9p-.js +0 -37
- package/lib/esm/index-BEWessT5.js +0 -36
- package/lib/esm/index-kGl7HgN2.js.map +0 -1
- package/lib/esm/index-zKiGjwHz.js.map +0 -1
- package/lib/esm/todoList-CAbx4396.js.map +0 -1
- package/lib/types/icons/alignCenter.d.ts.map +0 -1
- package/lib/types/icons/alignLeft.d.ts.map +0 -1
- package/lib/types/icons/alignRight.d.ts.map +0 -1
- package/lib/types/icons/bulletList.d.ts.map +0 -1
- package/lib/types/icons/checkBoxChecked.d.ts.map +0 -1
- package/lib/types/icons/checkBoxUnchecked.d.ts.map +0 -1
- package/lib/types/icons/chevronDown.d.ts.map +0 -1
- package/lib/types/icons/dragHandle.d.ts.map +0 -1
- package/lib/types/icons/orderedList.d.ts.map +0 -1
- package/lib/types/icons/todoList.d.ts.map +0 -1
- /package/src/icons/{alignCenter.ts → align-center.ts} +0 -0
- /package/src/icons/{alignLeft.ts → align-left.ts} +0 -0
- /package/src/icons/{alignRight.ts → align-right.ts} +0 -0
- /package/src/icons/{bulletList.ts → bullet-list.ts} +0 -0
- /package/src/icons/{checkBoxChecked.ts → check-box-checked.ts} +0 -0
- /package/src/icons/{checkBoxUnchecked.ts → check-box-unchecked.ts} +0 -0
- /package/src/icons/{chevronDown.ts → chevron-down.ts} +0 -0
- /package/src/icons/{dragHandle.ts → drag-handle.ts} +0 -0
- /package/src/icons/{orderedList.ts → ordered-list.ts} +0 -0
- /package/src/icons/{todoList.ts → todo-list.ts} +0 -0
|
@@ -11,7 +11,8 @@ import {
|
|
|
11
11
|
toggleInlineCodeCommand,
|
|
12
12
|
toggleStrongCommand,
|
|
13
13
|
} from '@milkdown/kit/preset/commonmark'
|
|
14
|
-
import type { MarkType } from '@milkdown/kit/prose/model'
|
|
14
|
+
import type { MarkType, Node, NodeType } from '@milkdown/kit/prose/model'
|
|
15
|
+
import type { Selection } from '@milkdown/kit/prose/state'
|
|
15
16
|
import clsx from 'clsx'
|
|
16
17
|
import { linkTooltipAPI } from '@milkdown/kit/component/link-tooltip'
|
|
17
18
|
import {
|
|
@@ -26,11 +27,17 @@ import {
|
|
|
26
27
|
strikethroughIcon,
|
|
27
28
|
} from '../../icons'
|
|
28
29
|
import type { ToolbarFeatureConfig } from './index'
|
|
30
|
+
import { functionsIcon } from '../../icons/functions'
|
|
31
|
+
import { NodeSelection, TextSelection } from '@milkdown/kit/prose/state'
|
|
32
|
+
import { mathInlineSchema } from '../latex/inline-latex'
|
|
33
|
+
import { FeaturesCtx } from '../../core/slice'
|
|
34
|
+
import { CrepeFeature } from '../..'
|
|
29
35
|
|
|
30
36
|
export interface ToolbarProps {
|
|
31
37
|
ctx: Ctx
|
|
32
38
|
hide: () => void
|
|
33
39
|
show: boolean
|
|
40
|
+
selection: Selection
|
|
34
41
|
config?: ToolbarFeatureConfig
|
|
35
42
|
}
|
|
36
43
|
|
|
@@ -39,6 +46,7 @@ export const toolbarComponent: Component<ToolbarProps> = ({
|
|
|
39
46
|
hide,
|
|
40
47
|
show,
|
|
41
48
|
config,
|
|
49
|
+
selection,
|
|
42
50
|
}) => {
|
|
43
51
|
const update = useUpdate()
|
|
44
52
|
useEffect(() => {
|
|
@@ -52,14 +60,82 @@ export const toolbarComponent: Component<ToolbarProps> = ({
|
|
|
52
60
|
}
|
|
53
61
|
|
|
54
62
|
const isActive = (mark: MarkType) => {
|
|
55
|
-
if (!ctx) return false
|
|
63
|
+
if (!ctx || !selection) return false
|
|
56
64
|
const view = ctx.get(editorViewCtx)
|
|
57
65
|
const {
|
|
58
|
-
state: { doc
|
|
66
|
+
state: { doc },
|
|
59
67
|
} = view
|
|
60
68
|
return doc.rangeHasMark(selection.from, selection.to, mark)
|
|
61
69
|
}
|
|
62
70
|
|
|
71
|
+
const containsNode = (node: NodeType) => {
|
|
72
|
+
if (!ctx || !selection) return false
|
|
73
|
+
const view = ctx.get(editorViewCtx)
|
|
74
|
+
const {
|
|
75
|
+
state: { doc },
|
|
76
|
+
} = view
|
|
77
|
+
if (selection instanceof NodeSelection) {
|
|
78
|
+
return selection.node.type === node
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
const { from, to } = selection
|
|
82
|
+
|
|
83
|
+
let hasNode = false
|
|
84
|
+
doc.nodesBetween(from, to, (n) => {
|
|
85
|
+
if (n.type === node) {
|
|
86
|
+
hasNode = true
|
|
87
|
+
return false
|
|
88
|
+
}
|
|
89
|
+
return true
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
return hasNode
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const flags = ctx?.get(FeaturesCtx)
|
|
96
|
+
const isLatexEnabled = flags?.includes(CrepeFeature.Latex)
|
|
97
|
+
|
|
98
|
+
const toggleLatex = (ctx: Ctx) => {
|
|
99
|
+
const hasLatex = containsNode(mathInlineSchema.type(ctx))
|
|
100
|
+
const view = ctx.get(editorViewCtx)
|
|
101
|
+
const { selection, doc, tr } = view.state
|
|
102
|
+
if (!hasLatex) {
|
|
103
|
+
const text = doc.textBetween(selection.from, selection.to)
|
|
104
|
+
let _tr = tr.replaceSelectionWith(
|
|
105
|
+
mathInlineSchema.type(ctx).create({
|
|
106
|
+
value: text,
|
|
107
|
+
})
|
|
108
|
+
)
|
|
109
|
+
view.dispatch(
|
|
110
|
+
_tr.setSelection(NodeSelection.create(_tr.doc, selection.from))
|
|
111
|
+
)
|
|
112
|
+
return
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
const { from, to } = selection
|
|
116
|
+
let pos = -1
|
|
117
|
+
let node: Node | null = null
|
|
118
|
+
doc.nodesBetween(from, to, (n, p) => {
|
|
119
|
+
if (node) return false
|
|
120
|
+
if (n.type === mathInlineSchema.type(ctx)) {
|
|
121
|
+
pos = p
|
|
122
|
+
node = n
|
|
123
|
+
return false
|
|
124
|
+
}
|
|
125
|
+
return true
|
|
126
|
+
})
|
|
127
|
+
if (!node || pos < 0) return
|
|
128
|
+
|
|
129
|
+
let _tr = tr.delete(pos, pos + 1)
|
|
130
|
+
const content = (node as Node).attrs.value
|
|
131
|
+
_tr = _tr.insertText(content, pos)
|
|
132
|
+
view.dispatch(
|
|
133
|
+
_tr.setSelection(
|
|
134
|
+
TextSelection.create(_tr.doc, from, to + content.length - 1)
|
|
135
|
+
)
|
|
136
|
+
)
|
|
137
|
+
}
|
|
138
|
+
|
|
63
139
|
return html`<host>
|
|
64
140
|
<button
|
|
65
141
|
type="button"
|
|
@@ -114,6 +190,17 @@ export const toolbarComponent: Component<ToolbarProps> = ({
|
|
|
114
190
|
>
|
|
115
191
|
${config?.codeIcon?.() ?? codeIcon}
|
|
116
192
|
</button>
|
|
193
|
+
${isLatexEnabled &&
|
|
194
|
+
html`<button
|
|
195
|
+
type="button"
|
|
196
|
+
class=${clsx(
|
|
197
|
+
'toolbar-item',
|
|
198
|
+
ctx && containsNode(mathInlineSchema.type(ctx)) && 'active'
|
|
199
|
+
)}
|
|
200
|
+
onmousedown=${onClick(toggleLatex)}
|
|
201
|
+
>
|
|
202
|
+
${config?.latexIcon?.() ?? functionsIcon}
|
|
203
|
+
</button>`}
|
|
117
204
|
<button
|
|
118
205
|
type="button"
|
|
119
206
|
class=${clsx(
|
|
@@ -143,6 +230,7 @@ toolbarComponent.props = {
|
|
|
143
230
|
hide: Function,
|
|
144
231
|
show: Boolean,
|
|
145
232
|
config: Object,
|
|
233
|
+
selection: Object,
|
|
146
234
|
}
|
|
147
235
|
|
|
148
236
|
export const ToolbarElement = c(toolbarComponent)
|
|
@@ -15,6 +15,7 @@ interface ToolbarConfig {
|
|
|
15
15
|
italicIcon: Icon
|
|
16
16
|
linkIcon: Icon
|
|
17
17
|
strikethroughIcon: Icon
|
|
18
|
+
latexIcon: Icon
|
|
18
19
|
}
|
|
19
20
|
|
|
20
21
|
export type ToolbarFeatureConfig = Partial<ToolbarConfig>
|
|
@@ -30,7 +31,7 @@ class ToolbarView implements PluginView {
|
|
|
30
31
|
this.#content.ctx = ctx
|
|
31
32
|
this.#content.hide = this.hide
|
|
32
33
|
this.#content.config = config
|
|
33
|
-
|
|
34
|
+
this.#content.selection = view.state.selection
|
|
34
35
|
this.#tooltipProvider = new TooltipProvider({
|
|
35
36
|
content: this.#content,
|
|
36
37
|
debounce: 20,
|
|
@@ -76,6 +77,7 @@ class ToolbarView implements PluginView {
|
|
|
76
77
|
|
|
77
78
|
update = (view: EditorView, prevState?: EditorState) => {
|
|
78
79
|
this.#tooltipProvider.update(view, prevState)
|
|
80
|
+
this.#content.selection = view.state.selection
|
|
79
81
|
}
|
|
80
82
|
|
|
81
83
|
destroy = () => {
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { html } from 'atomico'
|
|
2
|
+
|
|
3
|
+
export const functionsIcon = html`
|
|
4
|
+
<svg
|
|
5
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
+
width="32"
|
|
7
|
+
height="32"
|
|
8
|
+
viewBox="0 0 24 24"
|
|
9
|
+
>
|
|
10
|
+
<path
|
|
11
|
+
fill="currentColor"
|
|
12
|
+
d="M7 19v-.808L13.096 12L7 5.808V5h10v1.25H9.102L14.727 12l-5.625 5.77H17V19z"
|
|
13
|
+
/>
|
|
14
|
+
</svg>
|
|
15
|
+
`
|
package/src/icons/index.ts
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export * from './
|
|
2
|
-
export * from './
|
|
3
|
-
export * from './
|
|
1
|
+
export * from './align-center'
|
|
2
|
+
export * from './align-left'
|
|
3
|
+
export * from './align-right'
|
|
4
4
|
export * from './bold'
|
|
5
5
|
export * from './bullet'
|
|
6
|
-
export * from './
|
|
6
|
+
export * from './bullet-list'
|
|
7
7
|
export * from './caption'
|
|
8
|
-
export * from './
|
|
9
|
-
export * from './
|
|
10
|
-
export * from './
|
|
8
|
+
export * from './check-box-checked'
|
|
9
|
+
export * from './check-box-unchecked'
|
|
10
|
+
export * from './chevron-down'
|
|
11
11
|
export * from './clear'
|
|
12
12
|
export * from './code'
|
|
13
13
|
export * from './confirm'
|
|
14
14
|
export * from './copy'
|
|
15
15
|
export * from './divider'
|
|
16
|
-
export * from './
|
|
16
|
+
export * from './drag-handle'
|
|
17
17
|
export * from './edit'
|
|
18
18
|
export * from './h1'
|
|
19
19
|
export * from './h2'
|
|
@@ -25,7 +25,7 @@ export * from './image'
|
|
|
25
25
|
export * from './italic'
|
|
26
26
|
export * from './link'
|
|
27
27
|
export * from './menu'
|
|
28
|
-
export * from './
|
|
28
|
+
export * from './ordered-list'
|
|
29
29
|
export * from './plus'
|
|
30
30
|
export * from './quote'
|
|
31
31
|
export * from './remove'
|
|
@@ -33,4 +33,4 @@ export * from './search'
|
|
|
33
33
|
export * from './strikethrough'
|
|
34
34
|
export * from './table'
|
|
35
35
|
export * from './text'
|
|
36
|
-
export * from './
|
|
36
|
+
export * from './todo-list'
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { html } from 'atomico'
|
|
2
|
+
|
|
3
|
+
export const visibilityOffIcon = html`
|
|
4
|
+
<svg
|
|
5
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
6
|
+
height="24px"
|
|
7
|
+
viewBox="0 -960 960 960"
|
|
8
|
+
width="24px"
|
|
9
|
+
>
|
|
10
|
+
<path
|
|
11
|
+
d="m644-428-58-58q9-47-27-88t-93-32l-58-58q17-8 34.5-12t37.5-4q75 0 127.5 52.5T660-500q0 20-4 37.5T644-428Zm128 126-58-56q38-29 67.5-63.5T832-500q-50-101-143.5-160.5T480-720q-29 0-57 4t-55 12l-62-62q41-17 84-25.5t90-8.5q151 0 269 83.5T920-500q-23 59-60.5 109.5T772-302Zm20 246L624-222q-35 11-70.5 16.5T480-200q-151 0-269-83.5T40-500q21-53 53-98.5t73-81.5L56-792l56-56 736 736-56 56ZM222-624q-29 26-53 57t-41 67q50 101 143.5 160.5T480-280q20 0 39-2.5t39-5.5l-36-38q-11 3-21 4.5t-21 1.5q-75 0-127.5-52.5T300-500q0-11 1.5-21t4.5-21l-84-82Zm319 93Zm-151 75Z"
|
|
12
|
+
/>
|
|
13
|
+
</svg>
|
|
14
|
+
`
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
.hidden {
|
|
22
|
-
display: none;
|
|
22
|
+
display: none !important;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
&.selected {
|
|
@@ -36,49 +36,79 @@
|
|
|
36
36
|
background: var(--crepe-color-surface);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
.
|
|
39
|
+
.tools {
|
|
40
40
|
display: flex;
|
|
41
|
+
justify-content: space-between;
|
|
41
42
|
align-items: center;
|
|
42
|
-
font-family: var(--crepe-font-default);
|
|
43
|
-
gap: 6px;
|
|
44
|
-
padding: 2px 4px 2px 8px;
|
|
45
|
-
background: var(--crepe-color-surface-low);
|
|
46
|
-
color: var(--crepe-color-on-surface-variant);
|
|
47
|
-
border-radius: 4px;
|
|
48
|
-
font-size: 12px;
|
|
49
|
-
font-weight: 600;
|
|
50
|
-
line-height: 16px;
|
|
51
|
-
margin-bottom: 8px;
|
|
52
|
-
opacity: 0;
|
|
53
|
-
cursor: pointer;
|
|
54
|
-
transition: opacity 0.2s ease-in-out;
|
|
55
43
|
|
|
56
|
-
|
|
57
|
-
background: var(--crepe-color-
|
|
44
|
+
.preview-toggle-button {
|
|
45
|
+
background: var(--crepe-color-secondary);
|
|
46
|
+
color: var(--crepe-color-on-surface-variant);
|
|
47
|
+
padding: 4px 10px;
|
|
48
|
+
opacity: 0;
|
|
49
|
+
cursor: pointer;
|
|
50
|
+
border-radius: 100px;
|
|
51
|
+
font-size: 12px;
|
|
52
|
+
line-height: 16px;
|
|
53
|
+
font-weight: 600;
|
|
54
|
+
font-family: var(--crepe-font-default);
|
|
55
|
+
transition: opacity 0.2s ease-in-out;
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
justify-content: center;
|
|
59
|
+
gap: 4px;
|
|
60
|
+
|
|
61
|
+
svg {
|
|
62
|
+
width: 14px;
|
|
63
|
+
height: 14px;
|
|
64
|
+
fill: var(--crepe-color-on-surface-variant);
|
|
65
|
+
}
|
|
58
66
|
}
|
|
59
67
|
|
|
60
|
-
.
|
|
61
|
-
transition: transform 0.2s ease-in-out;
|
|
62
|
-
width: 18px;
|
|
63
|
-
height: 18px;
|
|
68
|
+
.language-button {
|
|
64
69
|
display: flex;
|
|
65
|
-
justify-content: center;
|
|
66
70
|
align-items: center;
|
|
67
|
-
|
|
71
|
+
font-family: var(--crepe-font-default);
|
|
72
|
+
gap: 6px;
|
|
73
|
+
padding: 2px 4px 2px 8px;
|
|
74
|
+
background: var(--crepe-color-surface-low);
|
|
75
|
+
color: var(--crepe-color-on-surface-variant);
|
|
76
|
+
border-radius: 4px;
|
|
77
|
+
font-size: 12px;
|
|
78
|
+
font-weight: 600;
|
|
79
|
+
line-height: 16px;
|
|
80
|
+
margin-bottom: 8px;
|
|
81
|
+
opacity: 0;
|
|
82
|
+
cursor: pointer;
|
|
83
|
+
transition: opacity 0.2s ease-in-out;
|
|
68
84
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
color: var(--crepe-color-outline);
|
|
73
|
-
}
|
|
85
|
+
&:hover {
|
|
86
|
+
background: var(--crepe-color-hover);
|
|
87
|
+
}
|
|
74
88
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
89
|
+
.expand-icon {
|
|
90
|
+
transition: transform 0.2s ease-in-out;
|
|
91
|
+
width: 18px;
|
|
92
|
+
height: 18px;
|
|
93
|
+
display: flex;
|
|
94
|
+
justify-content: center;
|
|
95
|
+
align-items: center;
|
|
96
|
+
}
|
|
78
97
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
98
|
+
.expand-icon svg {
|
|
99
|
+
width: 14px;
|
|
100
|
+
height: 14px;
|
|
101
|
+
color: var(--crepe-color-outline);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
&[data-expanded='true'] .expand-icon {
|
|
105
|
+
transform: rotate(180deg);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.expand-icon svg:focus,
|
|
109
|
+
.expand-icon:focus-visible {
|
|
110
|
+
outline: none;
|
|
111
|
+
}
|
|
82
112
|
}
|
|
83
113
|
}
|
|
84
114
|
|
|
@@ -86,6 +116,10 @@
|
|
|
86
116
|
opacity: 1;
|
|
87
117
|
}
|
|
88
118
|
|
|
119
|
+
&:hover .preview-toggle-button {
|
|
120
|
+
opacity: 1;
|
|
121
|
+
}
|
|
122
|
+
|
|
89
123
|
.list-wrapper {
|
|
90
124
|
background: var(--crepe-color-surface-low);
|
|
91
125
|
border-radius: 12px;
|
|
@@ -185,5 +219,32 @@
|
|
|
185
219
|
outline: none;
|
|
186
220
|
}
|
|
187
221
|
}
|
|
222
|
+
|
|
223
|
+
.preview-panel {
|
|
224
|
+
.preview-divider {
|
|
225
|
+
height: 1px;
|
|
226
|
+
opacity: 0.2;
|
|
227
|
+
background: var(--crepe-color-outline);
|
|
228
|
+
margin: 6px 0;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
.preview-label {
|
|
232
|
+
margin: 6px 0;
|
|
233
|
+
font-size: 12px;
|
|
234
|
+
color: color-mix(
|
|
235
|
+
in srgb,
|
|
236
|
+
var(--crepe-color-on-surface),
|
|
237
|
+
transparent 40%
|
|
238
|
+
);
|
|
239
|
+
font-weight: 600;
|
|
240
|
+
text-transform: uppercase;
|
|
241
|
+
font-family: var(--crepe-font-default);
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.preview {
|
|
245
|
+
text-align: center;
|
|
246
|
+
overflow-x: auto;
|
|
247
|
+
}
|
|
248
|
+
}
|
|
188
249
|
}
|
|
189
250
|
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
@import 'katex/dist/katex.min.css';
|
|
2
|
+
|
|
3
|
+
.milkdown {
|
|
4
|
+
span[data-type='math_inline'] {
|
|
5
|
+
padding: 0 4px;
|
|
6
|
+
display: inline-block;
|
|
7
|
+
vertical-align: bottom;
|
|
8
|
+
color: var(--crepe-color-primary);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
milkdown-latex-inline-edit {
|
|
12
|
+
&[data-show='false'] {
|
|
13
|
+
display: none;
|
|
14
|
+
}
|
|
15
|
+
position: absolute;
|
|
16
|
+
background: var(--crepe-color-surface);
|
|
17
|
+
box-shadow: var(--crepe-shadow-1);
|
|
18
|
+
border-radius: 8px;
|
|
19
|
+
padding: 2px 6px 2px 12px;
|
|
20
|
+
|
|
21
|
+
.container {
|
|
22
|
+
display: flex;
|
|
23
|
+
gap: 6px;
|
|
24
|
+
align-items: flex-start;
|
|
25
|
+
|
|
26
|
+
button {
|
|
27
|
+
width: 24px;
|
|
28
|
+
height: 24px;
|
|
29
|
+
cursor: pointer;
|
|
30
|
+
border-radius: 8px;
|
|
31
|
+
&:hover {
|
|
32
|
+
background: var(--crepe-color-hover);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.ProseMirror {
|
|
38
|
+
padding: 0;
|
|
39
|
+
min-width: 174px;
|
|
40
|
+
max-width: 294px;
|
|
41
|
+
font-family: var(--crepe-font-code);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var codeBlock = require('@milkdown/kit/component/code-block');
|
|
4
|
-
var codemirror = require('codemirror');
|
|
5
|
-
var view = require('@codemirror/view');
|
|
6
|
-
var commands = require('@codemirror/commands');
|
|
7
|
-
var todoList = require('./todoList-V4JWO5-M.js');
|
|
8
|
-
require('atomico');
|
|
9
|
-
|
|
10
|
-
const defineFeature = (editor, config = {}) => {
|
|
11
|
-
editor.config(async (ctx) => {
|
|
12
|
-
let { languages, theme } = config;
|
|
13
|
-
if (!languages) {
|
|
14
|
-
const { languages: langList } = await import('@codemirror/language-data');
|
|
15
|
-
languages = langList;
|
|
16
|
-
}
|
|
17
|
-
if (!theme) {
|
|
18
|
-
const { oneDark } = await import('@codemirror/theme-one-dark');
|
|
19
|
-
theme = oneDark;
|
|
20
|
-
}
|
|
21
|
-
ctx.update(codeBlock.codeBlockConfig.key, (defaultConfig) => {
|
|
22
|
-
var _a;
|
|
23
|
-
return {
|
|
24
|
-
extensions: [
|
|
25
|
-
view.keymap.of(commands.defaultKeymap.concat(commands.indentWithTab)),
|
|
26
|
-
codemirror.basicSetup,
|
|
27
|
-
theme,
|
|
28
|
-
...(_a = config == null ? void 0 : config.extensions) != null ? _a : []
|
|
29
|
-
],
|
|
30
|
-
languages,
|
|
31
|
-
expandIcon: config.expandIcon || (() => todoList.chevronDownIcon),
|
|
32
|
-
searchIcon: config.searchIcon || (() => todoList.searchIcon),
|
|
33
|
-
clearSearchIcon: config.clearSearchIcon || (() => todoList.clearIcon),
|
|
34
|
-
searchPlaceholder: config.searchPlaceholder || "Search language",
|
|
35
|
-
noResultText: config.noResultText || "No result",
|
|
36
|
-
renderLanguage: config.renderLanguage || defaultConfig.renderLanguage
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
}).use(codeBlock.codeBlockComponent);
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
exports.defineFeature = defineFeature;
|
|
43
|
-
//# sourceMappingURL=index-3mj4YaCA.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-3mj4YaCA.js","sources":["../../src/feature/code-mirror/index.ts"],"sourcesContent":["import {\n codeBlockComponent,\n codeBlockConfig,\n} from '@milkdown/kit/component/code-block'\nimport type { LanguageDescription } from '@codemirror/language'\nimport type { Extension } from '@codemirror/state'\nimport { basicSetup } from 'codemirror'\nimport { keymap } from '@codemirror/view'\nimport { defaultKeymap, indentWithTab } from '@codemirror/commands'\nimport type { html } from 'atomico'\nimport type { DefineFeature, Icon } from '../shared'\nimport { chevronDownIcon, clearIcon, searchIcon } from '../../icons'\n\ninterface CodeMirrorConfig {\n extensions: Extension[]\n languages: LanguageDescription[]\n theme: Extension\n\n expandIcon: Icon\n searchIcon: Icon\n clearSearchIcon: Icon\n\n searchPlaceholder: string\n noResultText: string\n\n renderLanguage: (\n language: string,\n selected: boolean\n ) => ReturnType<typeof html> | string | HTMLElement\n}\nexport type CodeMirrorFeatureConfig = Partial<CodeMirrorConfig>\n\nexport const defineFeature: DefineFeature<CodeMirrorFeatureConfig> = (\n editor,\n config = {}\n) => {\n editor\n .config(async (ctx) => {\n let { languages, theme } = config\n if (!languages) {\n const { languages: langList } = await import(\n '@codemirror/language-data'\n )\n languages = langList\n }\n if (!theme) {\n const { oneDark } = await import('@codemirror/theme-one-dark')\n theme = oneDark\n }\n ctx.update(codeBlockConfig.key, (defaultConfig) => ({\n extensions: [\n keymap.of(defaultKeymap.concat(indentWithTab)),\n basicSetup,\n theme,\n ...(config?.extensions ?? []),\n ],\n languages,\n\n expandIcon: config.expandIcon || (() => chevronDownIcon),\n searchIcon: config.searchIcon || (() => searchIcon),\n clearSearchIcon: config.clearSearchIcon || (() => clearIcon),\n searchPlaceholder: config.searchPlaceholder || 'Search language',\n noResultText: config.noResultText || 'No result',\n renderLanguage: config.renderLanguage || defaultConfig.renderLanguage,\n }))\n })\n .use(codeBlockComponent)\n}\n"],"names":["codeBlockConfig","keymap","defaultKeymap","indentWithTab","basicSetup","chevronDownIcon","searchIcon","clearIcon","codeBlockComponent"],"mappings":";;;;;;;;;AAgCO,MAAM,aAAwD,GAAA,CACnE,MACA,EAAA,MAAA,GAAS,EACN,KAAA;AACH,EACG,MAAA,CAAA,MAAA,CAAO,OAAO,GAAQ,KAAA;AACrB,IAAI,IAAA,EAAE,SAAW,EAAA,KAAA,EAAU,GAAA,MAAA;AAC3B,IAAA,IAAI,CAAC,SAAW,EAAA;AACd,MAAA,MAAM,EAAE,SAAW,EAAA,QAAA,EAAa,GAAA,MAAM,OACpC,2BACF,CAAA;AACA,MAAY,SAAA,GAAA,QAAA;AAAA;AAEd,IAAA,IAAI,CAAC,KAAO,EAAA;AACV,MAAA,MAAM,EAAE,OAAA,EAAY,GAAA,MAAM,OAAO,4BAA4B,CAAA;AAC7D,MAAQ,KAAA,GAAA,OAAA;AAAA;AAEV,IAAA,GAAA,CAAI,MAAO,CAAAA,yBAAA,CAAgB,GAAK,EAAA,CAAC,aAAe,KAAA;AAjDtD,MAAA,IAAA,EAAA;AAiD0D,MAAA,OAAA;AAAA,QAClD,UAAY,EAAA;AAAA,UACVC,WAAO,CAAA,EAAA,CAAGC,sBAAc,CAAA,MAAA,CAAOC,sBAAa,CAAC,CAAA;AAAA,UAC7CC,qBAAA;AAAA,UACA,KAAA;AAAA,UACA,GAAI,CAAA,EAAA,GAAA,MAAA,IAAA,IAAA,GAAA,KAAA,CAAA,GAAA,MAAA,CAAQ,UAAR,KAAA,IAAA,GAAA,EAAA,GAAsB;AAAC,SAC7B;AAAA,QACA,SAAA;AAAA,QAEA,UAAA,EAAY,MAAO,CAAA,UAAA,KAAe,MAAMC,wBAAA,CAAA;AAAA,QACxC,UAAA,EAAY,MAAO,CAAA,UAAA,KAAe,MAAMC,mBAAA,CAAA;AAAA,QACxC,eAAA,EAAiB,MAAO,CAAA,eAAA,KAAoB,MAAMC,kBAAA,CAAA;AAAA,QAClD,iBAAA,EAAmB,OAAO,iBAAqB,IAAA,iBAAA;AAAA,QAC/C,YAAA,EAAc,OAAO,YAAgB,IAAA,WAAA;AAAA,QACrC,cAAA,EAAgB,MAAO,CAAA,cAAA,IAAkB,aAAc,CAAA;AAAA,OACzD;AAAA,KAAE,CAAA;AAAA,GACH,CACA,CAAA,GAAA,CAAIC,4BAAkB,CAAA;AAC3B;;;;"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-A8IrOmzS.js","sources":["../../src/feature/toolbar/component.ts","../../src/feature/toolbar/index.ts"],"sourcesContent":["import type { Component } from 'atomico'\nimport { c, html, useEffect, useUpdate } from 'atomico'\nimport type { Ctx } from '@milkdown/kit/ctx'\nimport { commandsCtx, editorViewCtx } from '@milkdown/kit/core'\nimport {\n emphasisSchema,\n inlineCodeSchema,\n linkSchema,\n strongSchema,\n toggleEmphasisCommand,\n toggleInlineCodeCommand,\n toggleStrongCommand,\n} from '@milkdown/kit/preset/commonmark'\nimport type { MarkType } from '@milkdown/kit/prose/model'\nimport clsx from 'clsx'\nimport { linkTooltipAPI } from '@milkdown/kit/component/link-tooltip'\nimport {\n strikethroughSchema,\n toggleStrikethroughCommand,\n} from '@milkdown/kit/preset/gfm'\nimport {\n boldIcon,\n codeIcon,\n italicIcon,\n linkIcon,\n strikethroughIcon,\n} from '../../icons'\nimport type { ToolbarFeatureConfig } from './index'\n\nexport interface ToolbarProps {\n ctx: Ctx\n hide: () => void\n show: boolean\n config?: ToolbarFeatureConfig\n}\n\nexport const toolbarComponent: Component<ToolbarProps> = ({\n ctx,\n hide,\n show,\n config,\n}) => {\n const update = useUpdate()\n useEffect(() => {\n update()\n }, [show])\n\n const onClick = (fn: (ctx: Ctx) => void) => (e: MouseEvent) => {\n e.preventDefault()\n ctx && fn(ctx)\n update()\n }\n\n const isActive = (mark: MarkType) => {\n if (!ctx) return false\n const view = ctx.get(editorViewCtx)\n const {\n state: { doc, selection },\n } = view\n return doc.rangeHasMark(selection.from, selection.to, mark)\n }\n\n return html`<host>\n <button\n type=\"button\"\n class=${clsx(\n 'toolbar-item',\n ctx && isActive(strongSchema.type(ctx)) && 'active'\n )}\n onmousedown=${onClick((ctx) => {\n const commands = ctx.get(commandsCtx)\n commands.call(toggleStrongCommand.key)\n })}\n >\n ${config?.boldIcon?.() ?? boldIcon}\n </button>\n <button\n type=\"button\"\n class=${clsx(\n 'toolbar-item',\n ctx && isActive(emphasisSchema.type(ctx)) && 'active'\n )}\n onmousedown=${onClick((ctx) => {\n const commands = ctx.get(commandsCtx)\n commands.call(toggleEmphasisCommand.key)\n })}\n >\n ${config?.italicIcon?.() ?? italicIcon}\n </button>\n <button\n type=\"button\"\n class=${clsx(\n 'toolbar-item',\n ctx && isActive(strikethroughSchema.type(ctx)) && 'active'\n )}\n onmousedown=${onClick((ctx) => {\n const commands = ctx.get(commandsCtx)\n commands.call(toggleStrikethroughCommand.key)\n })}\n >\n ${config?.strikethroughIcon?.() ?? strikethroughIcon}\n </button>\n <div class=\"divider\"></div>\n <button\n type=\"button\"\n class=${clsx(\n 'toolbar-item',\n ctx && isActive(inlineCodeSchema.type(ctx)) && 'active'\n )}\n onmousedown=${onClick((ctx) => {\n const commands = ctx.get(commandsCtx)\n commands.call(toggleInlineCodeCommand.key)\n })}\n >\n ${config?.codeIcon?.() ?? codeIcon}\n </button>\n <button\n type=\"button\"\n class=${clsx(\n 'toolbar-item',\n ctx && isActive(linkSchema.type(ctx)) && 'active'\n )}\n onmousedown=${onClick((ctx) => {\n const view = ctx.get(editorViewCtx)\n const { selection } = view.state\n\n if (isActive(linkSchema.type(ctx))) {\n ctx.get(linkTooltipAPI.key).removeLink(selection.from, selection.to)\n return\n }\n\n ctx.get(linkTooltipAPI.key).addLink(selection.from, selection.to)\n hide?.()\n })}\n >\n ${config?.linkIcon?.() ?? linkIcon}\n </button>\n </host>`\n}\n\ntoolbarComponent.props = {\n ctx: Object,\n hide: Function,\n show: Boolean,\n config: Object,\n}\n\nexport const ToolbarElement = c(toolbarComponent)\n","import { TooltipProvider, tooltipFactory } from '@milkdown/kit/plugin/tooltip'\nimport type { EditorState, PluginView } from '@milkdown/kit/prose/state'\nimport { TextSelection } from '@milkdown/kit/prose/state'\nimport type { Ctx } from '@milkdown/kit/ctx'\nimport type { EditorView } from '@milkdown/kit/prose/view'\nimport type { AtomicoThis } from 'atomico/types/dom'\nimport type { DefineFeature, Icon } from '../shared'\nimport { defIfNotExists } from '../../utils'\nimport type { ToolbarProps } from './component'\nimport { ToolbarElement } from './component'\n\ninterface ToolbarConfig {\n boldIcon: Icon\n codeIcon: Icon\n italicIcon: Icon\n linkIcon: Icon\n strikethroughIcon: Icon\n}\n\nexport type ToolbarFeatureConfig = Partial<ToolbarConfig>\n\nconst toolbar = tooltipFactory('CREPE_TOOLBAR')\n\nclass ToolbarView implements PluginView {\n #tooltipProvider: TooltipProvider\n #content: AtomicoThis<ToolbarProps>\n constructor(ctx: Ctx, view: EditorView, config?: ToolbarFeatureConfig) {\n const content = new ToolbarElement()\n this.#content = content\n this.#content.ctx = ctx\n this.#content.hide = this.hide\n this.#content.config = config\n\n this.#tooltipProvider = new TooltipProvider({\n content: this.#content,\n debounce: 20,\n offset: 10,\n shouldShow(view: EditorView) {\n const { doc, selection } = view.state\n const { empty, from, to } = selection\n\n const isEmptyTextBlock =\n !doc.textBetween(from, to).length &&\n selection instanceof TextSelection\n\n const isNotTextBlock = !(selection instanceof TextSelection)\n\n const activeElement = (view.dom.getRootNode() as ShadowRoot | Document)\n .activeElement\n const isTooltipChildren = content.contains(activeElement)\n\n const notHasFocus = !view.hasFocus() && !isTooltipChildren\n\n const isReadonly = !view.editable\n\n if (\n notHasFocus ||\n isNotTextBlock ||\n empty ||\n isEmptyTextBlock ||\n isReadonly\n )\n return false\n\n return true\n },\n })\n this.#tooltipProvider.onShow = () => {\n this.#content.show = true\n }\n this.#tooltipProvider.onHide = () => {\n this.#content.show = false\n }\n this.update(view)\n }\n\n update = (view: EditorView, prevState?: EditorState) => {\n this.#tooltipProvider.update(view, prevState)\n }\n\n destroy = () => {\n this.#tooltipProvider.destroy()\n this.#content.remove()\n }\n\n hide = () => {\n this.#tooltipProvider.hide()\n }\n}\n\ndefIfNotExists('milkdown-toolbar', ToolbarElement)\nexport const defineFeature: DefineFeature<ToolbarFeatureConfig> = (\n editor,\n config\n) => {\n editor\n .config((ctx) => {\n ctx.set(toolbar.key, {\n view: (view) => new ToolbarView(ctx, view, config),\n })\n })\n .use(toolbar)\n}\n"],"names":["useUpdate","useEffect","editorViewCtx","html","strongSchema","ctx","commandsCtx","toggleStrongCommand","boldIcon","emphasisSchema","toggleEmphasisCommand","italicIcon","strikethroughSchema","toggleStrikethroughCommand","strikethroughIcon","inlineCodeSchema","toggleInlineCodeCommand","codeIcon","linkSchema","linkTooltipAPI","linkIcon","c","tooltipFactory","TooltipProvider","view","TextSelection","defIfNotExists"],"mappings":";;;;;;;;;;;;;AAoCO,MAAM,mBAA4C,CAAC;AAAA,EACxD,GAAA;AAAA,EACA,IAAA;AAAA,EACA,IAAA;AAAA,EACA;AACF,CAAM,KAAA;AAzCN,EAAA,IAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA,EAAA;AA0CE,EAAA,MAAM,SAASA,iBAAU,EAAA;AACzB,EAAAC,iBAAA,CAAU,MAAM;AACd,IAAO,MAAA,EAAA;AAAA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A;AACT,KACD,CAAA,CAAA;AACD,IAAK,YAAA,CAAA,IAAA,EAAA,gBAAA,CAAA,CAAiB,SAAS,MAAM;AACnC,MAAA,YAAA,CAAA,IAAA,EAAK,UAAS,IAAO,GAAA,IAAA;AAAA,KACvB;AACA,IAAK,YAAA,CAAA,IAAA,EAAA,gBAAA,CAAA,CAAiB,SAAS,MAAM;AACnC,MAAA,YAAA,CAAA,IAAA,EAAK,UAAS,IAAO,GAAA,KAAA;AAAA,KACvB;AACA,IAAA,IAAA,CAAK,OAAO,IAAI,CAAA;AAAA;AAepB;AAhEE,gBAAA,GAAA,IAAA,OAAA,EAAA;AACA,QAAA,GAAA,IAAA,OAAA,EAAA;AAiEFE,oBAAA,CAAe,oBAAoB,cAAc,CAAA;AACpC,MAAA,aAAA,GAAqD,CAChE,MAAA,EACA,MACG,KAAA;AACH,EACG,MAAA,CAAA,MAAA,CAAO,CAAC,GAAQ,KAAA;AACf,IAAI,GAAA,CAAA,GAAA,CAAI,QAAQ,GAAK,EAAA;AAAA,MACnB,MAAM,CAAC,IAAA,KAAS,IAAI,WAAY,CAAA,GAAA,EAAK,MAAM,MAAM;AAAA,KAClD,CAAA;AAAA,GACF,CACA,CAAA,GAAA,CAAI,OAAO,CAAA;AAChB;;;;"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var linkTooltip = require('@milkdown/kit/component/link-tooltip');
|
|
4
|
-
var todoList = require('./todoList-V4JWO5-M.js');
|
|
5
|
-
require('atomico');
|
|
6
|
-
|
|
7
|
-
const defineFeature = (editor, config) => {
|
|
8
|
-
editor.config(linkTooltip.configureLinkTooltip).config((ctx) => {
|
|
9
|
-
ctx.update(linkTooltip.linkTooltipConfig.key, (prev) => {
|
|
10
|
-
var _a, _b, _c, _d, _e, _f;
|
|
11
|
-
return {
|
|
12
|
-
...prev,
|
|
13
|
-
linkIcon: (_a = config == null ? void 0 : config.linkIcon) != null ? _a : () => todoList.copyIcon,
|
|
14
|
-
editButton: (_b = config == null ? void 0 : config.editButton) != null ? _b : () => todoList.editIcon,
|
|
15
|
-
removeButton: (_c = config == null ? void 0 : config.removeButton) != null ? _c : () => todoList.removeIcon,
|
|
16
|
-
confirmButton: (_d = config == null ? void 0 : config.confirmButton) != null ? _d : () => todoList.confirmIcon,
|
|
17
|
-
inputPlaceholder: (_e = config == null ? void 0 : config.inputPlaceholder) != null ? _e : "Paste link...",
|
|
18
|
-
onCopyLink: (_f = config == null ? void 0 : config.onCopyLink) != null ? _f : () => {
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
});
|
|
22
|
-
}).use(linkTooltip.linkTooltipPlugin);
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
exports.defineFeature = defineFeature;
|
|
26
|
-
//# sourceMappingURL=index-BIXWL4Or.js.map
|