@milkdown/crepe 7.3.3
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/LICENSE +21 -0
- package/README.md +11 -0
- package/lib/apl-p0IPP13W.js +76 -0
- package/lib/asciiarmor-lJsBxlJJ.js +34 -0
- package/lib/asn1-Q9v1zIy5.js +102 -0
- package/lib/asterisk-foNkeTjy.js +273 -0
- package/lib/brainfuck-0XqyXpNS.js +35 -0
- package/lib/clike-ak6Z6Yhe.js +639 -0
- package/lib/clojure-iYO8U8Sg.js +810 -0
- package/lib/clsx-7d8NmkQq.js +21 -0
- package/lib/cmake-SVzjkxV_.js +28 -0
- package/lib/cobol-APHEnAOX.js +74 -0
- package/lib/coffeescript-KqQa0SYG.js +182 -0
- package/lib/commonlisp-bwqNqR5V.js +79 -0
- package/lib/core/crepe.d.ts +21 -0
- package/lib/core/crepe.d.ts.map +1 -0
- package/lib/core/index.d.ts +3 -0
- package/lib/core/index.d.ts.map +1 -0
- package/lib/core/slice.d.ts +12 -0
- package/lib/core/slice.d.ts.map +1 -0
- package/lib/crystal-BViWuDpA.js +217 -0
- package/lib/css-KHXHXfXg.js +1572 -0
- package/lib/cypher-XpTt4zQ3.js +69 -0
- package/lib/d-fLig6yqY.js +139 -0
- package/lib/diff-WoKGLpy6.js +18 -0
- package/lib/dockerfile-u6f6Vw2s.js +194 -0
- package/lib/dtd-SIJRUW6K.js +91 -0
- package/lib/dylan-4HCLhpWP.js +238 -0
- package/lib/ebnf-h_0lged5.js +77 -0
- package/lib/ecl-Lf4FF0lf.js +133 -0
- package/lib/eiffel-qlw8KUyf.js +112 -0
- package/lib/elm-QRnB3zXs.js +108 -0
- package/lib/erlang-fyVKb7eK.js +488 -0
- package/lib/factor-BEeN4upY.js +65 -0
- package/lib/fcl-lRek3hEb.js +106 -0
- package/lib/feature/block-edit/handle/component.d.ts +9 -0
- package/lib/feature/block-edit/handle/component.d.ts.map +1 -0
- package/lib/feature/block-edit/handle/index.d.ts +12 -0
- package/lib/feature/block-edit/handle/index.d.ts.map +1 -0
- package/lib/feature/block-edit/index.d.ts +3 -0
- package/lib/feature/block-edit/index.d.ts.map +1 -0
- package/lib/feature/block-edit/menu/component.d.ts +14 -0
- package/lib/feature/block-edit/menu/component.d.ts.map +1 -0
- package/lib/feature/block-edit/menu/config.d.ts +21 -0
- package/lib/feature/block-edit/menu/config.d.ts.map +1 -0
- package/lib/feature/block-edit/menu/icons.d.ts +14 -0
- package/lib/feature/block-edit/menu/icons.d.ts.map +1 -0
- package/lib/feature/block-edit/menu/index.d.ts +9 -0
- package/lib/feature/block-edit/menu/index.d.ts.map +1 -0
- package/lib/feature/code-mirror/index.d.ts +3 -0
- package/lib/feature/code-mirror/index.d.ts.map +1 -0
- package/lib/feature/gap-cursor/index.d.ts +3 -0
- package/lib/feature/gap-cursor/index.d.ts.map +1 -0
- package/lib/feature/image-block/index.d.ts +3 -0
- package/lib/feature/image-block/index.d.ts.map +1 -0
- package/lib/feature/index.d.ts +18 -0
- package/lib/feature/index.d.ts.map +1 -0
- package/lib/feature/link-tooltip/consts.d.ts +5 -0
- package/lib/feature/link-tooltip/consts.d.ts.map +1 -0
- package/lib/feature/link-tooltip/index.d.ts +3 -0
- package/lib/feature/link-tooltip/index.d.ts.map +1 -0
- package/lib/feature/list-item/consts.d.ts +2 -0
- package/lib/feature/list-item/consts.d.ts.map +1 -0
- package/lib/feature/list-item/index.d.ts +3 -0
- package/lib/feature/list-item/index.d.ts.map +1 -0
- package/lib/feature/placeholder/index.d.ts +10 -0
- package/lib/feature/placeholder/index.d.ts.map +1 -0
- package/lib/feature/shared.d.ts +3 -0
- package/lib/feature/shared.d.ts.map +1 -0
- package/lib/feature/toolbar/component.d.ts +13 -0
- package/lib/feature/toolbar/component.d.ts.map +1 -0
- package/lib/feature/toolbar/consts.d.ts +5 -0
- package/lib/feature/toolbar/consts.d.ts.map +1 -0
- package/lib/feature/toolbar/index.d.ts +3 -0
- package/lib/feature/toolbar/index.d.ts.map +1 -0
- package/lib/forth-ua2bRd8T.js +60 -0
- package/lib/fortran-WnF7znuN.js +443 -0
- package/lib/gas-wowve1o7.js +183 -0
- package/lib/gherkin-m7GIChu3.js +34 -0
- package/lib/go-th443Dhb.js +158 -0
- package/lib/groovy-tR4RiZnc.js +161 -0
- package/lib/haskell-jxVBofv5.js +375 -0
- package/lib/haxe-kWPI2tq3.js +390 -0
- package/lib/hooks-82sqkbtE.js +21 -0
- package/lib/http-3GIFWUlG.js +45 -0
- package/lib/icons-HYkfuR-O.js +50 -0
- package/lib/idl-PvpMZg-l.js +947 -0
- package/lib/index-0RbcZMbq.js +8 -0
- package/lib/index-4afXjFMY.js +517 -0
- package/lib/index-7MeyepDG.js +78 -0
- package/lib/index-7QgQq3x3.js +551 -0
- package/lib/index-7pgP6qYs.js +107 -0
- package/lib/index-8DvtgRVa.js +19511 -0
- package/lib/index-8Gg-jEP4.js +288 -0
- package/lib/index-8S8qcncB.js +507 -0
- package/lib/index-9A_GmGh4.js +1039 -0
- package/lib/index-EJJfYLzA.js +928 -0
- package/lib/index-Eg39w5kL.js +984 -0
- package/lib/index-FIk_7oPb.js +168 -0
- package/lib/index-LlbrXb_n.js +368 -0
- package/lib/index-MovKtgMG.js +121 -0
- package/lib/index-N9GtIS4X.js +64 -0
- package/lib/index-Pwn25-kf.js +8 -0
- package/lib/index-SdFSDosa.js +1295 -0
- package/lib/index-W5Th22-Z.js +1744 -0
- package/lib/index-XiXSFLmI.js +20975 -0
- package/lib/index-bknOViGv.js +47 -0
- package/lib/index-bkuIUPFS.js +275 -0
- package/lib/index-jPA8J9Eo.js +8 -0
- package/lib/index-lsG76a9s.js +552 -0
- package/lib/index-oTRzPo3B.js +146 -0
- package/lib/index-rrf6_6DC.js +317 -0
- package/lib/index-vJbZIHYF.js +81 -0
- package/lib/index-vPRh55CO.js +137 -0
- package/lib/index-vxy63hib.js +323 -0
- package/lib/index-wn1_LgCS.js +99 -0
- package/lib/index-xHADmDT3.js +12 -0
- package/lib/index-yt2EpMtv.js +141 -0
- package/lib/index.d.ts +4 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.es.js +7 -0
- package/lib/javascript-8ZHqHagw.js +758 -0
- package/lib/jinja2-vsOFe0qD.js +154 -0
- package/lib/julia-dlp_pbN1.js +241 -0
- package/lib/livescript-Gf5R-LT6.js +273 -0
- package/lib/lua-c5Y_JsBp.js +221 -0
- package/lib/mathematica-iiGTGmUs.js +35 -0
- package/lib/mbox-ZJh86H8B.js +78 -0
- package/lib/meta-tAGyVRPE.js +511 -0
- package/lib/mirc-i0qkCa0y.js +73 -0
- package/lib/mllike-Dy551fZW.js +275 -0
- package/lib/modelica-n6tGqUT9.js +94 -0
- package/lib/mscgen-aKSbB7D9.js +104 -0
- package/lib/mumps-lNiKA6sp.js +25 -0
- package/lib/nginx--YmuCfDj.js +93 -0
- package/lib/nsis-zhS8iA09.js +62 -0
- package/lib/ntriples-E3jQl3MC.js +79 -0
- package/lib/octave-EQvkGIeG.js +144 -0
- package/lib/oz-W2cpqFf6.js +152 -0
- package/lib/pascal-lCh6ouNZ.js +79 -0
- package/lib/perl-PxEQBX0B.js +915 -0
- package/lib/pig-Y_bNcrzS.js +56 -0
- package/lib/powershell-GaQP-TZr.js +249 -0
- package/lib/properties-mbRyn54L.js +26 -0
- package/lib/prosemirror-noTDkx-k.js +4 -0
- package/lib/protobuf-8CJideyJ.js +49 -0
- package/lib/puppet-ABBaChNZ.js +45 -0
- package/lib/python-sKdHg3Ka.js +321 -0
- package/lib/q-_1yG40Nm.js +89 -0
- package/lib/r-Ziz56bHT.js +108 -0
- package/lib/rpm-ORjGOHaQ.js +57 -0
- package/lib/ruby-jlbYq0dT.js +233 -0
- package/lib/sas-2n7xeUuO.js +107 -0
- package/lib/schema-tKk3m1fu.js +62 -0
- package/lib/scheme-XCs-NPeU.js +126 -0
- package/lib/shell-0_1Um7Dq.js +184 -0
- package/lib/sieve-7uyJD1x1.js +73 -0
- package/lib/simple-mode--HIzBxba.js +95 -0
- package/lib/smalltalk-PEFzrlQ-.js +48 -0
- package/lib/solr-BLBaHahN.js +41 -0
- package/lib/sparql-4F9ZWf1b.js +204 -0
- package/lib/spreadsheet-SGSo6blj.js +49 -0
- package/lib/sql-tebLBzN0.js +291 -0
- package/lib/stex-SFJcFGOO.js +130 -0
- package/lib/stylus-rwwWYWFm.js +256 -0
- package/lib/swift-eorJ0tCv.js +238 -0
- package/lib/tcl-IwXMB8U4.js +82 -0
- package/lib/textile-ok2VyjwC.js +299 -0
- package/lib/theme/classic/index.d.ts +3 -0
- package/lib/theme/classic/index.d.ts.map +1 -0
- package/lib/theme/classic-dark/index.d.ts +3 -0
- package/lib/theme/classic-dark/index.d.ts.map +1 -0
- package/lib/theme/headless/index.d.ts +3 -0
- package/lib/theme/headless/index.d.ts.map +1 -0
- package/lib/theme/index.d.ts +8 -0
- package/lib/theme/index.d.ts.map +1 -0
- package/lib/theme/shared.d.ts +3 -0
- package/lib/theme/shared.d.ts.map +1 -0
- package/lib/tiddlywiki-DLhz8_pc.js +156 -0
- package/lib/tiki-DFAqFElY.js +183 -0
- package/lib/tippy.esm-MZ2vxByW.js +1813 -0
- package/lib/toml-ryxpTZEV.js +49 -0
- package/lib/tooltip-plugin-gcwyQdiT.js +119 -0
- package/lib/troff-ZzZyvNct.js +36 -0
- package/lib/ttcn-6gvkqqpW.js +136 -0
- package/lib/ttcn-cfg-oSu-Dq5C.js +98 -0
- package/lib/turtle-10ofr5au.js +87 -0
- package/lib/use-css-light-dom-EKWZDmbJ.js +82 -0
- package/lib/utils/index.d.ts +4 -0
- package/lib/utils/index.d.ts.map +1 -0
- package/lib/vb-a6n6fzrD.js +74 -0
- package/lib/vbscript-dgvo8jPt.js +324 -0
- package/lib/velocity-CBncCrwO.js +97 -0
- package/lib/verilog-KlcACt6C.js +271 -0
- package/lib/vhdl-NMd7Gf35.js +117 -0
- package/lib/webidl-z1UE5DN_.js +160 -0
- package/lib/xquery-hDt5jWTp.js +431 -0
- package/lib/yacas-ftgh_qwr.js +74 -0
- package/lib/yaml-DnNTfjXK.js +53 -0
- package/lib/z80-dA1PqWe1.js +62 -0
- package/package.json +87 -0
- package/src/core/crepe.ts +98 -0
- package/src/core/index.ts +4 -0
- package/src/core/slice.ts +44 -0
- package/src/feature/block-edit/handle/component.ts +68 -0
- package/src/feature/block-edit/handle/index.ts +81 -0
- package/src/feature/block-edit/index.ts +17 -0
- package/src/feature/block-edit/menu/component.ts +210 -0
- package/src/feature/block-edit/menu/config.ts +335 -0
- package/src/feature/block-edit/menu/icons.ts +171 -0
- package/src/feature/block-edit/menu/index.ts +113 -0
- package/src/feature/block-edit/style.css +126 -0
- package/src/feature/code-mirror/index.ts +60 -0
- package/src/feature/code-mirror/style.css +159 -0
- package/src/feature/gap-cursor/index.ts +31 -0
- package/src/feature/image-block/index.ts +59 -0
- package/src/feature/image-block/style.css +215 -0
- package/src/feature/index.ts +66 -0
- package/src/feature/link-tooltip/consts.ts +47 -0
- package/src/feature/link-tooltip/index.ts +22 -0
- package/src/feature/link-tooltip/style.css +107 -0
- package/src/feature/list-item/consts.ts +15 -0
- package/src/feature/list-item/index.ts +30 -0
- package/src/feature/list-item/style.css +23 -0
- package/src/feature/placeholder/index.ts +87 -0
- package/src/feature/placeholder/style.css +9 -0
- package/src/feature/shared.ts +4 -0
- package/src/feature/toolbar/component.ts +101 -0
- package/src/feature/toolbar/consts.ts +26 -0
- package/src/feature/toolbar/index.ts +92 -0
- package/src/feature/toolbar/style.css +37 -0
- package/src/index.ts +5 -0
- package/src/theme/classic/index.ts +12 -0
- package/src/theme/classic/style.css +192 -0
- package/src/theme/classic-dark/index.ts +12 -0
- package/src/theme/classic-dark/style.css +197 -0
- package/src/theme/headless/index.ts +9 -0
- package/src/theme/index.ts +26 -0
- package/src/theme/shared.ts +4 -0
- package/src/utils/index.ts +12 -0
- package/src/vite-env.d.ts +2 -0
|
@@ -0,0 +1,507 @@
|
|
|
1
|
+
import { I as X, i as M } from "./schema-tKk3m1fu.js";
|
|
2
|
+
import { w as C, h, e as q, a as U, c as S, u as P } from "./meta-tAGyVRPE.js";
|
|
3
|
+
import { g as J, v as Q, $ as V, h as A, i as ee } from "./index-XiXSFLmI.js";
|
|
4
|
+
import { i as _, a as ie } from "./icons-HYkfuR-O.js";
|
|
5
|
+
import { u as f } from "./hooks-82sqkbtE.js";
|
|
6
|
+
import { c as j, u as D, $ as O } from "./use-css-light-dom-EKWZDmbJ.js";
|
|
7
|
+
import { c as k } from "./clsx-7d8NmkQq.js";
|
|
8
|
+
function te(n) {
|
|
9
|
+
return Q(n, "paragraph", (a, l, d) => {
|
|
10
|
+
var m, w;
|
|
11
|
+
if (((m = a.children) == null ? void 0 : m.length) !== 1)
|
|
12
|
+
return;
|
|
13
|
+
const e = (w = a.children) == null ? void 0 : w[0];
|
|
14
|
+
if (!e || e.type !== "image")
|
|
15
|
+
return;
|
|
16
|
+
const { url: i, alt: o, title: t } = e, p = {
|
|
17
|
+
type: "image-block",
|
|
18
|
+
url: i,
|
|
19
|
+
alt: o,
|
|
20
|
+
title: t
|
|
21
|
+
};
|
|
22
|
+
d.children.splice(l, 1, p);
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const R = J("remark-image-block", () => () => te);
|
|
26
|
+
C(R.plugin, {
|
|
27
|
+
displayName: "Remark<remarkImageBlock>",
|
|
28
|
+
group: "ImageBlock"
|
|
29
|
+
});
|
|
30
|
+
C(R.options, {
|
|
31
|
+
displayName: "RemarkConfig<remarkImageBlock>",
|
|
32
|
+
group: "ImageBlock"
|
|
33
|
+
});
|
|
34
|
+
const ne = {
|
|
35
|
+
imageIcon: () => _,
|
|
36
|
+
captionIcon: () => ie,
|
|
37
|
+
uploadButton: () => h`Upload file`,
|
|
38
|
+
confirmButton: () => h`Confirm ⏎`,
|
|
39
|
+
uploadPlaceholderText: "or paste the image link ...",
|
|
40
|
+
captionPlaceholderText: "Image caption",
|
|
41
|
+
onUpload: (n) => Promise.resolve(URL.createObjectURL(n))
|
|
42
|
+
}, N = V(ne, "imageBlockConfigCtx");
|
|
43
|
+
C(N, {
|
|
44
|
+
displayName: "Config<image-block>",
|
|
45
|
+
group: "ImageBlock"
|
|
46
|
+
});
|
|
47
|
+
function oe({
|
|
48
|
+
image: n,
|
|
49
|
+
resizeHandle: a,
|
|
50
|
+
ratio: l,
|
|
51
|
+
setRatio: d,
|
|
52
|
+
src: e
|
|
53
|
+
}) {
|
|
54
|
+
const i = q();
|
|
55
|
+
U(() => {
|
|
56
|
+
const o = n.current;
|
|
57
|
+
o && (delete o.dataset.origin, delete o.dataset.height, o.style.height = "");
|
|
58
|
+
}, [e]), U(() => {
|
|
59
|
+
const o = a.current, t = n.current;
|
|
60
|
+
if (!o || !t)
|
|
61
|
+
return;
|
|
62
|
+
const p = (c) => {
|
|
63
|
+
c.preventDefault();
|
|
64
|
+
const g = t.getBoundingClientRect().top, u = c.clientY - g, v = Number(u < 100 ? 100 : u).toFixed(2);
|
|
65
|
+
t.dataset.height = v, t.style.height = `${v}px`;
|
|
66
|
+
}, m = () => {
|
|
67
|
+
document.removeEventListener("pointermove", p), document.removeEventListener("pointerup", m);
|
|
68
|
+
const c = Number(t.dataset.origin), g = Number(t.dataset.height), u = Number.parseFloat(Number(g / c).toFixed(2));
|
|
69
|
+
Number.isNaN(u) || d(u);
|
|
70
|
+
}, w = (c) => {
|
|
71
|
+
c.preventDefault(), document.addEventListener("pointermove", p), document.addEventListener("pointerup", m);
|
|
72
|
+
}, y = (c) => {
|
|
73
|
+
const g = i.current.getBoundingClientRect().width;
|
|
74
|
+
if (!g)
|
|
75
|
+
return;
|
|
76
|
+
const u = c.target, v = u.height, x = u.width, I = x < g ? v : g * (v / x), s = (I * l).toFixed(2);
|
|
77
|
+
t.dataset.origin = I.toFixed(2), t.dataset.height = s, t.style.height = `${s}px`;
|
|
78
|
+
};
|
|
79
|
+
return t.addEventListener("load", y), o.addEventListener("pointerdown", w), () => {
|
|
80
|
+
t.removeEventListener("load", y), o.removeEventListener("pointerdown", w);
|
|
81
|
+
};
|
|
82
|
+
}, []);
|
|
83
|
+
}
|
|
84
|
+
const ae = j`
|
|
85
|
+
:host {
|
|
86
|
+
outline: none;
|
|
87
|
+
margin: 16px 0;
|
|
88
|
+
display: block;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
:host > .image-wrapper {
|
|
92
|
+
position: relative;
|
|
93
|
+
width: fit-content;
|
|
94
|
+
margin: 0 auto;
|
|
95
|
+
min-width: 100px;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
:host > .image-wrapper .operation {
|
|
99
|
+
position: absolute;
|
|
100
|
+
display: flex;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
:host > .image-wrapper .operation > .operation-item {
|
|
104
|
+
cursor: pointer;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
:host > .image-wrapper img {
|
|
108
|
+
max-width: 100%;
|
|
109
|
+
min-height: 100px;
|
|
110
|
+
display: block;
|
|
111
|
+
object-fit: cover;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
:host > .image-wrapper > .image-resize-handle {
|
|
115
|
+
position: absolute;
|
|
116
|
+
left: 50%;
|
|
117
|
+
transform: translateX(-50%);
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
:host > .image-wrapper > .image-resize-handle:hover {
|
|
121
|
+
cursor: row-resize;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
:host input {
|
|
125
|
+
background: transparent;
|
|
126
|
+
outline: none;
|
|
127
|
+
border: 0;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
:host > .caption-input {
|
|
131
|
+
display: block;
|
|
132
|
+
width: 100%;
|
|
133
|
+
text-align: center;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
:host > .image-edit {
|
|
137
|
+
display: flex;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
:host > .image-edit .confirm {
|
|
141
|
+
cursor: pointer;
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
:host > .image-edit .link-importer {
|
|
145
|
+
position: relative;
|
|
146
|
+
flex: 1;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
:host > .image-edit .link-importer > .link-input-area {
|
|
150
|
+
width: 100%;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
:host > .image-edit .link-importer .placeholder {
|
|
154
|
+
position: absolute;
|
|
155
|
+
top: 0;
|
|
156
|
+
left: 0;
|
|
157
|
+
bottom: 0;
|
|
158
|
+
display: flex;
|
|
159
|
+
align-items: center;
|
|
160
|
+
cursor: text;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
:host > .image-edit .link-importer .placeholder .uploader {
|
|
164
|
+
cursor: pointer;
|
|
165
|
+
display: flex;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
:host .hidden {
|
|
169
|
+
display: none !important;
|
|
170
|
+
}
|
|
171
|
+
`, Z = ({
|
|
172
|
+
src: n = "",
|
|
173
|
+
caption: a = "",
|
|
174
|
+
ratio: l = 1,
|
|
175
|
+
selected: d = !1,
|
|
176
|
+
setAttr: e,
|
|
177
|
+
config: i
|
|
178
|
+
}) => {
|
|
179
|
+
const o = P(), t = P(), p = P(), [m, w] = f(a.length > 0), [y, c] = f(n.length !== 0), [g] = f(crypto.randomUUID()), [u, v] = f(!1), [x, I] = f(n);
|
|
180
|
+
D(ae), oe({
|
|
181
|
+
image: o,
|
|
182
|
+
resizeHandle: t,
|
|
183
|
+
ratio: l,
|
|
184
|
+
setRatio: (r) => e == null ? void 0 : e("ratio", r),
|
|
185
|
+
src: n
|
|
186
|
+
}), U(() => {
|
|
187
|
+
d || w(a.length > 0);
|
|
188
|
+
}, [d]);
|
|
189
|
+
const s = (r) => {
|
|
190
|
+
const $ = r.target.value;
|
|
191
|
+
e == null || e("caption", $);
|
|
192
|
+
}, L = (r) => {
|
|
193
|
+
const $ = r.target.value;
|
|
194
|
+
c($.length !== 0), I($);
|
|
195
|
+
}, b = async (r) => {
|
|
196
|
+
var z;
|
|
197
|
+
const E = (z = r.target.files) == null ? void 0 : z[0];
|
|
198
|
+
if (!E)
|
|
199
|
+
return;
|
|
200
|
+
const $ = await (i == null ? void 0 : i.onUpload(E));
|
|
201
|
+
$ && (e == null || e("src", $), c(!0));
|
|
202
|
+
}, B = () => {
|
|
203
|
+
w((r) => !r);
|
|
204
|
+
}, T = () => {
|
|
205
|
+
var r;
|
|
206
|
+
e == null || e("src", ((r = p.current) == null ? void 0 : r.value) ?? "");
|
|
207
|
+
}, G = (r) => {
|
|
208
|
+
r.key === "Enter" && T();
|
|
209
|
+
};
|
|
210
|
+
return h`<host class=${k(d && "selected")}>
|
|
211
|
+
<div class=${k("image-edit", n.length > 0 && "hidden")}>
|
|
212
|
+
<div class="image-icon">
|
|
213
|
+
${i == null ? void 0 : i.imageIcon()}
|
|
214
|
+
</div>
|
|
215
|
+
<div class=${k("link-importer", u && "focus")}>
|
|
216
|
+
<input
|
|
217
|
+
ref=${p}
|
|
218
|
+
class="link-input-area"
|
|
219
|
+
value=${x}
|
|
220
|
+
oninput=${L}
|
|
221
|
+
onkeydown=${G}
|
|
222
|
+
onfocus=${() => v(!0)}
|
|
223
|
+
onblur=${() => v(!1)}
|
|
224
|
+
/>
|
|
225
|
+
<div class=${k("placeholder", y && "hidden")}>
|
|
226
|
+
<input class="hidden" id=${g} type="file" accept="image/*" onchange=${b} />
|
|
227
|
+
<label class="uploader" for=${g}>
|
|
228
|
+
${i == null ? void 0 : i.uploadButton()}
|
|
229
|
+
</label>
|
|
230
|
+
<span class="text" onclick=${() => {
|
|
231
|
+
var r;
|
|
232
|
+
return (r = p.current) == null ? void 0 : r.focus();
|
|
233
|
+
}}>
|
|
234
|
+
${i == null ? void 0 : i.uploadPlaceholderText}
|
|
235
|
+
</span>
|
|
236
|
+
</div>
|
|
237
|
+
</div>
|
|
238
|
+
<div
|
|
239
|
+
class=${k("confirm", x.length === 0 && "hidden")}
|
|
240
|
+
onclick=${() => T()}
|
|
241
|
+
>
|
|
242
|
+
${i == null ? void 0 : i.confirmButton()}
|
|
243
|
+
</div>
|
|
244
|
+
</div>
|
|
245
|
+
<div class=${k("image-wrapper", n.length === 0 && "hidden")}>
|
|
246
|
+
<div class="operation">
|
|
247
|
+
<div class="operation-item" onmousedown=${B}>${i == null ? void 0 : i.captionIcon()}</div>
|
|
248
|
+
</div>
|
|
249
|
+
<img ref=${o} data-type=${X} src=${n} alt=${a} ratio=${l} />
|
|
250
|
+
<div ref=${t} class="image-resize-handle"></div>
|
|
251
|
+
</div>
|
|
252
|
+
<input
|
|
253
|
+
class=${k("caption-input", !m && "hidden")}
|
|
254
|
+
placeholder=${i == null ? void 0 : i.captionPlaceholderText}
|
|
255
|
+
oninput=${s}
|
|
256
|
+
value=${a}
|
|
257
|
+
/>
|
|
258
|
+
</host>`;
|
|
259
|
+
};
|
|
260
|
+
Z.props = {
|
|
261
|
+
src: String,
|
|
262
|
+
caption: String,
|
|
263
|
+
ratio: Number,
|
|
264
|
+
selected: Boolean,
|
|
265
|
+
setAttr: Function,
|
|
266
|
+
config: Object
|
|
267
|
+
};
|
|
268
|
+
const le = S(Z);
|
|
269
|
+
customElements.define("milkdown-image-block", le);
|
|
270
|
+
const K = O(M.node, (n) => (a, l, d) => {
|
|
271
|
+
const e = document.createElement("milkdown-image-block"), i = n.get(N.key), o = (t) => {
|
|
272
|
+
e.src = t.attrs.src, e.ratio = t.attrs.ratio, e.caption = t.attrs.caption;
|
|
273
|
+
};
|
|
274
|
+
return o(a), e.selected = !1, e.setAttr = (t, p) => {
|
|
275
|
+
const m = d();
|
|
276
|
+
m != null && l.dispatch(l.state.tr.setNodeAttribute(m, t, p));
|
|
277
|
+
}, e.config = i, {
|
|
278
|
+
dom: e,
|
|
279
|
+
update: (t) => t.type !== a.type ? !1 : (o(t), !0),
|
|
280
|
+
stopEvent: (t) => !!(e.selected && t.target instanceof HTMLInputElement),
|
|
281
|
+
selectNode: () => {
|
|
282
|
+
e.selected = !0;
|
|
283
|
+
},
|
|
284
|
+
deselectNode: () => {
|
|
285
|
+
e.selected = !1;
|
|
286
|
+
},
|
|
287
|
+
destroy: () => {
|
|
288
|
+
e.remove();
|
|
289
|
+
}
|
|
290
|
+
};
|
|
291
|
+
});
|
|
292
|
+
C(K, {
|
|
293
|
+
displayName: "NodeView<image-block>",
|
|
294
|
+
group: "ImageBlock"
|
|
295
|
+
});
|
|
296
|
+
const re = [
|
|
297
|
+
R,
|
|
298
|
+
M,
|
|
299
|
+
K,
|
|
300
|
+
N
|
|
301
|
+
].flat(), me = {
|
|
302
|
+
imageIcon: () => _,
|
|
303
|
+
uploadButton: () => h`Upload`,
|
|
304
|
+
confirmButton: () => h`⏎`,
|
|
305
|
+
uploadPlaceholderText: "/Paste",
|
|
306
|
+
onUpload: (n) => Promise.resolve(URL.createObjectURL(n))
|
|
307
|
+
}, H = V(me, "inlineImageConfigCtx");
|
|
308
|
+
C(H, {
|
|
309
|
+
displayName: "Config<image-inline>",
|
|
310
|
+
group: "ImageInline"
|
|
311
|
+
});
|
|
312
|
+
const se = j`
|
|
313
|
+
:host {
|
|
314
|
+
outline: none;
|
|
315
|
+
display: inline;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
:host input {
|
|
319
|
+
background: transparent;
|
|
320
|
+
outline: none;
|
|
321
|
+
border: 0;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
:host.empty {
|
|
325
|
+
vertical-align: bottom;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
:host > .empty-image-inline {
|
|
329
|
+
display: inline-flex;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
:host > .empty-image-inline .confirm {
|
|
333
|
+
cursor: pointer;
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
:host > .empty-image-inline .link-importer {
|
|
337
|
+
position: relative;
|
|
338
|
+
flex: 1;
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
:host > .empty-image-inline .link-importer > .link-input-area {
|
|
342
|
+
width: 208px;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
:host > .empty-image-inline .link-importer .placeholder {
|
|
346
|
+
position: absolute;
|
|
347
|
+
top: 0;
|
|
348
|
+
left: 0;
|
|
349
|
+
bottom: 0;
|
|
350
|
+
display: flex;
|
|
351
|
+
align-items: center;
|
|
352
|
+
cursor: text;
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
:host > .empty-image-inline .link-importer .placeholder .uploader {
|
|
356
|
+
cursor: pointer;
|
|
357
|
+
display: flex;
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
:host .hidden {
|
|
361
|
+
display: none !important;
|
|
362
|
+
}
|
|
363
|
+
`, W = ({
|
|
364
|
+
src: n = "",
|
|
365
|
+
selected: a = !1,
|
|
366
|
+
alt: l,
|
|
367
|
+
title: d,
|
|
368
|
+
setAttr: e,
|
|
369
|
+
config: i
|
|
370
|
+
}) => {
|
|
371
|
+
const o = P(), [t] = f(crypto.randomUUID()), [p, m] = f(!1), [w, y] = f(n.length !== 0), [c, g] = f(n);
|
|
372
|
+
D(se);
|
|
373
|
+
const u = (s) => {
|
|
374
|
+
const b = s.target.value;
|
|
375
|
+
y(b.length !== 0), g(b);
|
|
376
|
+
}, v = async (s) => {
|
|
377
|
+
var B;
|
|
378
|
+
const L = (B = s.target.files) == null ? void 0 : B[0];
|
|
379
|
+
if (!L)
|
|
380
|
+
return;
|
|
381
|
+
const b = await (i == null ? void 0 : i.onUpload(L));
|
|
382
|
+
b && (e == null || e("src", b), y(!0));
|
|
383
|
+
}, x = () => {
|
|
384
|
+
var s;
|
|
385
|
+
e == null || e("src", ((s = o.current) == null ? void 0 : s.value) ?? "");
|
|
386
|
+
}, I = (s) => {
|
|
387
|
+
s.key === "Enter" && x();
|
|
388
|
+
};
|
|
389
|
+
return h`<host class=${k(a && "selected", !n && "empty")}>
|
|
390
|
+
${n ? h`<img class="image-inline" src=${n} alt=${l} title=${d} />` : h`<div class="empty-image-inline">
|
|
391
|
+
<div class="image-icon">
|
|
392
|
+
${i == null ? void 0 : i.imageIcon()}
|
|
393
|
+
</div>
|
|
394
|
+
<div class=${k("link-importer", p && "focus")}>
|
|
395
|
+
<input
|
|
396
|
+
ref=${o}
|
|
397
|
+
class="link-input-area"
|
|
398
|
+
value=${c}
|
|
399
|
+
oninput=${u}
|
|
400
|
+
onkeydown=${I}
|
|
401
|
+
onfocus=${() => m(!0)}
|
|
402
|
+
onblur=${() => m(!1)}
|
|
403
|
+
/>
|
|
404
|
+
<div class=${k("placeholder", w && "hidden")}>
|
|
405
|
+
<input class="hidden" id=${t} type="file" accept="image/*" onchange=${v} />
|
|
406
|
+
<label class="uploader" for=${t}>
|
|
407
|
+
${i == null ? void 0 : i.uploadButton()}
|
|
408
|
+
</label>
|
|
409
|
+
<span class="text" onclick=${() => {
|
|
410
|
+
var s;
|
|
411
|
+
return (s = o.current) == null ? void 0 : s.focus();
|
|
412
|
+
}}>
|
|
413
|
+
${i == null ? void 0 : i.uploadPlaceholderText}
|
|
414
|
+
</span>
|
|
415
|
+
</div>
|
|
416
|
+
</div>
|
|
417
|
+
<div
|
|
418
|
+
class=${k("confirm", c.length === 0 && "hidden")}
|
|
419
|
+
onclick=${() => x()}
|
|
420
|
+
>
|
|
421
|
+
${i == null ? void 0 : i.confirmButton()}
|
|
422
|
+
</div>
|
|
423
|
+
</div>`}
|
|
424
|
+
</host>`;
|
|
425
|
+
};
|
|
426
|
+
W.props = {
|
|
427
|
+
src: String,
|
|
428
|
+
alt: String,
|
|
429
|
+
title: String,
|
|
430
|
+
selected: Boolean,
|
|
431
|
+
setAttr: Function,
|
|
432
|
+
config: Object
|
|
433
|
+
};
|
|
434
|
+
const pe = S(W);
|
|
435
|
+
customElements.define("milkdown-image-inline", pe);
|
|
436
|
+
const Y = O(A.node, (n) => (a, l, d) => {
|
|
437
|
+
const e = document.createElement("milkdown-image-inline"), i = n.get(H.key), o = (t) => {
|
|
438
|
+
e.src = t.attrs.src, e.alt = t.attrs.alt, e.title = t.attrs.title;
|
|
439
|
+
};
|
|
440
|
+
return o(a), e.selected = !1, e.setAttr = (t, p) => {
|
|
441
|
+
const m = d();
|
|
442
|
+
m != null && l.dispatch(l.state.tr.setNodeAttribute(m, t, p));
|
|
443
|
+
}, e.config = i, {
|
|
444
|
+
dom: e,
|
|
445
|
+
update: (t) => t.type !== a.type ? !1 : (o(t), !0),
|
|
446
|
+
stopEvent: (t) => !!(e.selected && t.target instanceof HTMLInputElement),
|
|
447
|
+
selectNode: () => {
|
|
448
|
+
e.selected = !0;
|
|
449
|
+
},
|
|
450
|
+
deselectNode: () => {
|
|
451
|
+
e.selected = !1;
|
|
452
|
+
},
|
|
453
|
+
destroy: () => {
|
|
454
|
+
e.remove();
|
|
455
|
+
}
|
|
456
|
+
};
|
|
457
|
+
});
|
|
458
|
+
C(Y, {
|
|
459
|
+
displayName: "NodeView<image-inline>",
|
|
460
|
+
group: "ImageInline"
|
|
461
|
+
});
|
|
462
|
+
const ce = [
|
|
463
|
+
H,
|
|
464
|
+
Y
|
|
465
|
+
], de = ".milkdown milkdown-image-inline.empty.selected{background:none;outline:none}.milkdown milkdown-image-inline.empty.selected .empty-image-inline{box-shadow:var(--crepe-shadow-1)}.milkdown milkdown-image-inline.selected{background:none;outline:1px solid var(--crepe-color-primary)}.milkdown milkdown-image-inline.selected ::selection{background:transparent}.milkdown milkdown-image-inline img.image-inline{vertical-align:text-bottom}.milkdown milkdown-image-inline .empty-image-inline{align-items:center;padding:4px 10px;gap:10px;background:var(--crepe-color-surface);font-family:var(--crepe-font-default);border-radius:8px}.milkdown milkdown-image-inline .empty-image-inline .image-icon{padding:3px;width:24px;height:24px}.milkdown milkdown-image-inline .empty-image-inline .image-icon svg{width:18px;height:18px}.milkdown milkdown-image-inline .empty-image-inline .link-importer{height:24px}.milkdown milkdown-image-inline .empty-image-inline .link-importer .placeholder{color:color-mix(in srgb,var(--crepe-color-on-background),transparent 60%)}.milkdown milkdown-image-inline .empty-image-inline .link-importer .placeholder ::selection{background:transparent}.milkdown milkdown-image-inline .empty-image-inline .link-importer .link-input-area{line-height:24px}.milkdown milkdown-image-inline .empty-image-inline .link-importer .placeholder .uploader{gap:8px;color:var(--crepe-color-primary);justify-content:center;transition:color .2s;font-family:var(--crepe-font-default)}.milkdown milkdown-image-inline .empty-image-inline .link-importer.focus .placeholder .uploader{color:unset}.milkdown milkdown-image-inline .empty-image-inline .link-importer .placeholder .uploader:hover{color:var(--crepe-color-primary)}.milkdown milkdown-image-inline .empty-image-inline .link-importer .placeholder .text{margin-left:8px}.milkdown milkdown-image-inline .empty-image-inline .confirm{width:24px;height:24px;padding:3px;border-radius:8px;color:var(--crepe-color-primary)}.milkdown milkdown-image-inline .empty-image-inline .confirm svg{width:18px;height:18px}.milkdown milkdown-image-inline .empty-image-inline .confirm:hover{background:var(--crepe-color-hover)}.milkdown milkdown-image-block.selected>.image-edit{outline:1px solid var(--crepe-color-outline)}.milkdown milkdown-image-block.selected>.image-wrapper img{outline:1px solid var(--crepe-color-outline)}.milkdown milkdown-image-block.selected ::selection{background:transparent}.milkdown milkdown-image-block .image-wrapper{display:flex;justify-content:center;align-items:center}.milkdown milkdown-image-block .image-wrapper .operation{gap:16px;right:16px;top:16px;opacity:0;transition:all .2s}.milkdown milkdown-image-block:hover>.image-wrapper .operation{opacity:1}.milkdown milkdown-image-block .image-wrapper .operation>.operation-item{color:var(--crepe-color-on-inverse);padding:8px;background:var(--crepe-color-inverse);opacity:.6;border-radius:50%;width:40px;height:40px}.milkdown milkdown-image-block .image-wrapper .operation>.operation-item svg{width:24px;height:24px}.milkdown milkdown-image-block .image-wrapper .image-resize-handle{height:4px;bottom:-3px;max-width:160px;width:100%;background:var(--crepe-color-outline);opacity:0;transition:all .2s;border-radius:4px}.milkdown milkdown-image-block:hover>.image-wrapper .image-resize-handle{opacity:1}.milkdown milkdown-image-block .caption-input{margin:16px auto;font-family:var(--crepe-font-default)}.milkdown milkdown-image-block .image-edit{align-items:center;padding:16px 24px;gap:16px;background:var(--crepe-color-surface);height:56px}.milkdown milkdown-image-block .image-edit .image-icon{color:var(--crepe-color-outline)}.milkdown milkdown-image-block .image-edit .image-icon svg{width:24px;height:24px}.milkdown milkdown-image-block .image-edit .link-importer .placeholder{color:color-mix(in srgb,var(--crepe-color-on-background),transparent 60%)}.milkdown milkdown-image-block .image-edit .link-importer .placeholder ::selection{background:transparent}.milkdown milkdown-image-block .image-edit .link-importer .link-input-area{line-height:24px}.milkdown milkdown-image-block .image-edit .link-importer .placeholder .uploader{gap:8px;color:var(--crepe-color-primary);justify-content:center;transition:color .2s}.milkdown milkdown-image-block .image-edit .link-importer.focus .placeholder .uploader{color:unset}.milkdown milkdown-image-block .image-edit .link-importer .placeholder .uploader:hover{color:var(--crepe-color-primary)}.milkdown milkdown-image-block .image-edit .link-importer .placeholder .text{margin-left:8px}.milkdown milkdown-image-block .image-edit .confirm{background:var(--crepe-color-secondary);color:var(--crepe-color-on-secondary);line-height:40px;padding:0 24px;border-radius:100px;font-size:14px}", F = h`
|
|
466
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
467
|
+
<g clip-path="url(#clip0_1013_1596)">
|
|
468
|
+
<path d="M19 5V19H5V5H19ZM19 3H5C3.9 3 3 3.9 3 5V19C3 20.1 3.9 21 5 21H19C20.1 21 21 20.1 21 19V5C21 3.9 20.1 3 19 3ZM14.14 11.86L11.14 15.73L9 13.14L6 17H18L14.14 11.86Z" fill="#817567"/>
|
|
469
|
+
</g>
|
|
470
|
+
<defs>
|
|
471
|
+
<clipPath id="clip0_1013_1596">
|
|
472
|
+
<rect width="24" height="24" fill="white"/>
|
|
473
|
+
</clipPath>
|
|
474
|
+
</defs>
|
|
475
|
+
</svg>
|
|
476
|
+
`, ge = h`
|
|
477
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
|
|
478
|
+
<g clip-path="url(#clip0_1013_1606)">
|
|
479
|
+
<path d="M9.00012 16.1998L5.50012 12.6998C5.11012 12.3098 4.49012 12.3098 4.10012 12.6998C3.71012 13.0898 3.71012 13.7098 4.10012 14.0998L8.29012 18.2898C8.68012 18.6798 9.31012 18.6798 9.70012 18.2898L20.3001 7.69982C20.6901 7.30982 20.6901 6.68982 20.3001 6.29982C19.9101 5.90982 19.2901 5.90982 18.9001 6.29982L9.00012 16.1998Z" fill="#817567"/>
|
|
480
|
+
</g>
|
|
481
|
+
<defs>
|
|
482
|
+
<clipPath id="clip0_1013_1606">
|
|
483
|
+
<rect width="24" height="24" fill="white"/>
|
|
484
|
+
</clipPath>
|
|
485
|
+
</defs>
|
|
486
|
+
</svg>
|
|
487
|
+
`, ue = h`
|
|
488
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" viewBox="0 0 24 24"><path fill="currentColor" d="M9 22a1 1 0 0 1-1-1v-3H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2h-6.1l-3.7 3.71c-.2.19-.45.29-.7.29zm1-6v3.08L13.08 16H20V4H4v12z"/></svg>
|
|
489
|
+
`, be = (n) => {
|
|
490
|
+
n.config(ee(de)).config((a) => {
|
|
491
|
+
a.update(H.key, (l) => ({
|
|
492
|
+
...l,
|
|
493
|
+
imageIcon: () => F,
|
|
494
|
+
confirmButton: () => ge,
|
|
495
|
+
uploadPlaceholderText: "or paste link"
|
|
496
|
+
})), a.update(N.key, (l) => ({
|
|
497
|
+
...l,
|
|
498
|
+
imageIcon: () => F,
|
|
499
|
+
captionIcon: () => ue,
|
|
500
|
+
confirmButton: () => h`Confirm`,
|
|
501
|
+
captionPlaceholderText: "Write Image Caption"
|
|
502
|
+
}));
|
|
503
|
+
}).use(re).use(ce);
|
|
504
|
+
};
|
|
505
|
+
export {
|
|
506
|
+
be as defineFeature
|
|
507
|
+
};
|