@teriusu/rich-editor 0.9.0 → 0.9.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileAttachment.d.ts","sourceRoot":"","sources":["../../src/extensions/FileAttachment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AAErD,MAAM,MAAM,iBAAiB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAC9E,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE1E,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,cAAc,EAAE;YACd,iBAAiB,EAAE,CAAC,KAAK,EAAE;gBACzB,GAAG,CAAC,EAAE,MAAM,CAAC;gBACb,MAAM,CAAC,EAAE,MAAM,CAAC;gBAChB,IAAI,EAAE,MAAM,CAAC;gBACb,IAAI,CAAC,EAAE,MAAM,CAAC;aACf,KAAK,UAAU,CAAC;SAClB,CAAC;KACH;CACF;AAkCD,eAAO,MAAM,cAAc,
|
|
1
|
+
{"version":3,"file":"FileAttachment.d.ts","sourceRoot":"","sources":["../../src/extensions/FileAttachment.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAmB,MAAM,cAAc,CAAC;AAErD,MAAM,MAAM,iBAAiB,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAC9E,MAAM,MAAM,YAAY,GAAG,CAAC,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,iBAAiB,CAAC,CAAC;AAE1E,MAAM,WAAW,qBAAqB;IACpC,cAAc,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACxC,QAAQ,EAAE,YAAY,GAAG,IAAI,CAAC;IAC9B,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,OAAO,QAAQ,cAAc,CAAC;IAC5B,UAAU,QAAQ,CAAC,UAAU;QAC3B,cAAc,EAAE;YACd,iBAAiB,EAAE,CAAC,KAAK,EAAE;gBACzB,GAAG,CAAC,EAAE,MAAM,CAAC;gBACb,MAAM,CAAC,EAAE,MAAM,CAAC;gBAChB,IAAI,EAAE,MAAM,CAAC;gBACb,IAAI,CAAC,EAAE,MAAM,CAAC;aACf,KAAK,UAAU,CAAC;SAClB,CAAC;KACH;CACF;AAkCD,eAAO,MAAM,cAAc,kCA4NzB,CAAC"}
|
|
@@ -112,8 +112,7 @@ export const FileAttachment = Node.create({
|
|
|
112
112
|
const icon = document.createElement("span");
|
|
113
113
|
icon.style.cssText = "font-size:22px;flex-shrink:0;line-height:1;";
|
|
114
114
|
icon.textContent = getFileIcon(node.attrs.name);
|
|
115
|
-
const nameEl = document.createElement("
|
|
116
|
-
nameEl.type = "button";
|
|
115
|
+
const nameEl = document.createElement("a");
|
|
117
116
|
nameEl.textContent = node.attrs.name;
|
|
118
117
|
nameEl.style.cssText =
|
|
119
118
|
"flex:1;min-width:0;font-size:15px;font-weight:600;color:var(--primary, #4A7DAC);text-decoration:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;cursor:pointer;background:none;border:0;padding:0;text-align:left;font-family:inherit;";
|
|
@@ -126,6 +125,16 @@ export const FileAttachment = Node.create({
|
|
|
126
125
|
const baseUrl = editor.storage.fileAttachment?.downloadBaseUrl || "/api/upload";
|
|
127
126
|
return `${baseUrl}/${fileId}/download`;
|
|
128
127
|
}
|
|
128
|
+
// href/download가 있어야 브라우저 우클릭의 "다른 이름으로 링크 저장"이 실제 파일을
|
|
129
|
+
// 가리킨다 — 없으면 현재 페이지 HTML이 저장된다.
|
|
130
|
+
function updateHref() {
|
|
131
|
+
const targetUrl = getProxyUrl() || resolvedSrc;
|
|
132
|
+
if (!targetUrl)
|
|
133
|
+
return;
|
|
134
|
+
nameEl.href = targetUrl;
|
|
135
|
+
nameEl.download = resolvedName;
|
|
136
|
+
}
|
|
137
|
+
updateHref();
|
|
129
138
|
let downloadInProgress = false;
|
|
130
139
|
function handleClick(e) {
|
|
131
140
|
e.preventDefault();
|
|
@@ -164,6 +173,7 @@ export const FileAttachment = Node.create({
|
|
|
164
173
|
// URL이 있으면 바로 표시
|
|
165
174
|
if (node.attrs.src) {
|
|
166
175
|
resolvedSrc = node.attrs.src;
|
|
176
|
+
updateHref();
|
|
167
177
|
if (node.attrs.size)
|
|
168
178
|
sizeEl.textContent = formatFileSize(node.attrs.size);
|
|
169
179
|
}
|
|
@@ -181,6 +191,7 @@ export const FileAttachment = Node.create({
|
|
|
181
191
|
nameEl.textContent = result.name;
|
|
182
192
|
icon.textContent = getFileIcon(result.name);
|
|
183
193
|
}
|
|
194
|
+
updateHref();
|
|
184
195
|
sizeEl.textContent = result.size ? formatFileSize(result.size) : "";
|
|
185
196
|
})
|
|
186
197
|
.catch(() => {
|