wysimark-lite 0.25.0 → 0.25.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/dist/index.js +126 -126
- package/dist/index.mjs +41 -106
- package/dist/index.mjs.map +1 -1
- package/dist/metafile-esm.json +1 -1
- package/package.json +3 -1
package/dist/index.mjs
CHANGED
|
@@ -1615,6 +1615,7 @@ var translations = {
|
|
|
1615
1615
|
selectFile: "\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E",
|
|
1616
1616
|
uploading: "\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u4E2D...",
|
|
1617
1617
|
saving: "\u4FDD\u5B58\u4E2D...",
|
|
1618
|
+
uploadComplete: "\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u5B8C\u4E86",
|
|
1618
1619
|
vaultPath: "\u4FDD\u5B58\u5148\u30D1\u30B9\uFF1A",
|
|
1619
1620
|
vaultPathHint: "vault\u5185\u306E\u4FDD\u5B58\u5148\u30D1\u30B9\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"
|
|
1620
1621
|
},
|
|
@@ -1666,6 +1667,7 @@ var translations = {
|
|
|
1666
1667
|
selectFile: "Select File",
|
|
1667
1668
|
uploading: "Uploading...",
|
|
1668
1669
|
saving: "Saving...",
|
|
1670
|
+
uploadComplete: "Upload Complete",
|
|
1669
1671
|
vaultPath: "Save Path:",
|
|
1670
1672
|
vaultPathHint: "Enter the path within the vault to save the file"
|
|
1671
1673
|
}
|
|
@@ -8386,16 +8388,15 @@ function ImageUrlDialog({
|
|
|
8386
8388
|
setDragOffset((prev) => ({ x: prev.x + deltaX, y: prev.y + deltaY }));
|
|
8387
8389
|
}, []);
|
|
8388
8390
|
const savedState = editor.wysimark?.imageDialogState;
|
|
8389
|
-
const
|
|
8391
|
+
const hasOnImageChange = !!editor.wysimark?.onImageChange;
|
|
8390
8392
|
const [url, setUrl] = useState9(savedState?.url ?? "");
|
|
8391
8393
|
const [alt, setAlt] = useState9(savedState?.alt ?? "");
|
|
8392
8394
|
const [title, setTitle] = useState9(savedState?.title ?? "");
|
|
8393
8395
|
const [titleManuallyEdited, setTitleManuallyEdited] = useState9(false);
|
|
8394
|
-
const [imageSource, setImageSource] = useState9(savedState?.imageSource ?? (
|
|
8395
|
-
const [
|
|
8396
|
-
const [
|
|
8397
|
-
const [
|
|
8398
|
-
const [previewUrl, setPreviewUrl] = useState9(null);
|
|
8396
|
+
const [imageSource, setImageSource] = useState9(savedState?.imageSource ?? (hasOnImageChange ? "file" : "url"));
|
|
8397
|
+
const [isUploading, setIsUploading] = useState9(false);
|
|
8398
|
+
const [uploadedUrl, setUploadedUrl] = useState9(savedState?.uploadedUrl ?? "");
|
|
8399
|
+
const [uploadedFileName, setUploadedFileName] = useState9("");
|
|
8399
8400
|
const handleAltChange = useCallback14((e) => {
|
|
8400
8401
|
const newAlt = e.target.value;
|
|
8401
8402
|
setAlt(newAlt);
|
|
@@ -8407,20 +8408,11 @@ function ImageUrlDialog({
|
|
|
8407
8408
|
setTitle(e.target.value);
|
|
8408
8409
|
setTitleManuallyEdited(true);
|
|
8409
8410
|
}, []);
|
|
8410
|
-
useEffect7(() => {
|
|
8411
|
-
if (selectedFile) {
|
|
8412
|
-
const url2 = URL.createObjectURL(selectedFile);
|
|
8413
|
-
setPreviewUrl(url2);
|
|
8414
|
-
return () => URL.revokeObjectURL(url2);
|
|
8415
|
-
} else {
|
|
8416
|
-
setPreviewUrl(null);
|
|
8417
|
-
}
|
|
8418
|
-
}, [selectedFile]);
|
|
8419
8411
|
useEffect7(() => {
|
|
8420
8412
|
if (editor.wysimark) {
|
|
8421
|
-
editor.wysimark.imageDialogState = { url, alt, title, imageSource,
|
|
8413
|
+
editor.wysimark.imageDialogState = { url, alt, title, imageSource, uploadedUrl };
|
|
8422
8414
|
}
|
|
8423
|
-
}, [url, alt, title, imageSource,
|
|
8415
|
+
}, [url, alt, title, imageSource, uploadedUrl]);
|
|
8424
8416
|
const clearState = () => {
|
|
8425
8417
|
if (editor.wysimark) {
|
|
8426
8418
|
editor.wysimark.imageDialogState = void 0;
|
|
@@ -8445,51 +8437,44 @@ function ImageUrlDialog({
|
|
|
8445
8437
|
left: baseStyle.left + dragOffset.x,
|
|
8446
8438
|
top: baseStyle.top + dragOffset.y
|
|
8447
8439
|
};
|
|
8448
|
-
|
|
8440
|
+
function handleSubmit(e) {
|
|
8449
8441
|
e.preventDefault();
|
|
8450
|
-
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
editor.image.insertImageFromUrl(resultPath, alt, title);
|
|
8457
|
-
clearState();
|
|
8458
|
-
close();
|
|
8459
|
-
} finally {
|
|
8460
|
-
setIsSaving(false);
|
|
8461
|
-
}
|
|
8462
|
-
} else if (imageSource === "url") {
|
|
8463
|
-
if (url.trim() === "")
|
|
8464
|
-
return;
|
|
8465
|
-
editor.image.insertImageFromUrl(url, alt, title);
|
|
8466
|
-
clearState();
|
|
8467
|
-
close();
|
|
8468
|
-
}
|
|
8442
|
+
const finalUrl = imageSource === "file" ? uploadedUrl : url;
|
|
8443
|
+
if (finalUrl.trim() === "")
|
|
8444
|
+
return;
|
|
8445
|
+
editor.image.insertImageFromUrl(finalUrl, alt, title);
|
|
8446
|
+
clearState();
|
|
8447
|
+
close();
|
|
8469
8448
|
}
|
|
8470
8449
|
function handleCancel() {
|
|
8471
8450
|
clearState();
|
|
8472
8451
|
close();
|
|
8473
8452
|
}
|
|
8474
|
-
function handleFileSelect(e) {
|
|
8453
|
+
async function handleFileSelect(e) {
|
|
8475
8454
|
const file = e.target.files?.[0];
|
|
8476
|
-
if (!file)
|
|
8455
|
+
if (!file || !editor.wysimark?.onImageChange)
|
|
8477
8456
|
return;
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8457
|
+
setUploadedFileName(file.name);
|
|
8458
|
+
setIsUploading(true);
|
|
8459
|
+
try {
|
|
8460
|
+
const resultUrl = await editor.wysimark.onImageChange(file);
|
|
8461
|
+
setUploadedUrl(resultUrl);
|
|
8462
|
+
} catch (error) {
|
|
8463
|
+
console.error("Failed to upload image:", error);
|
|
8464
|
+
} finally {
|
|
8465
|
+
setIsUploading(false);
|
|
8481
8466
|
}
|
|
8482
8467
|
}
|
|
8483
8468
|
function handleSelectFileClick() {
|
|
8484
8469
|
fileInputRef.current?.click();
|
|
8485
8470
|
}
|
|
8486
|
-
const isSubmitDisabled = imageSource === "file" ?
|
|
8471
|
+
const isSubmitDisabled = imageSource === "file" ? uploadedUrl.trim() === "" || isUploading : url.trim() === "";
|
|
8487
8472
|
return /* @__PURE__ */ jsxs29(Fragment8, { children: [
|
|
8488
8473
|
/* @__PURE__ */ jsx61(CloseMask, { close }),
|
|
8489
8474
|
/* @__PURE__ */ jsxs29($FileDialog, { ref, style, children: [
|
|
8490
8475
|
/* @__PURE__ */ jsx61(DraggableHeader, { onDrag: handleDrag }),
|
|
8491
8476
|
/* @__PURE__ */ jsxs29("form", { onSubmit: (e) => void handleSubmit(e), style: { padding: "8px" }, children: [
|
|
8492
|
-
|
|
8477
|
+
hasOnImageChange && /* @__PURE__ */ jsxs29("div", { style: { marginBottom: "12px" }, children: [
|
|
8493
8478
|
/* @__PURE__ */ jsxs29("label", { style: { display: "inline-flex", alignItems: "center", marginRight: "16px", cursor: "pointer" }, children: [
|
|
8494
8479
|
/* @__PURE__ */ jsx61(
|
|
8495
8480
|
"input",
|
|
@@ -8546,7 +8531,7 @@ function ImageUrlDialog({
|
|
|
8546
8531
|
ref: fileInputRef,
|
|
8547
8532
|
type: "file",
|
|
8548
8533
|
accept: "image/*",
|
|
8549
|
-
onChange: handleFileSelect,
|
|
8534
|
+
onChange: (e) => void handleFileSelect(e),
|
|
8550
8535
|
style: { display: "none" }
|
|
8551
8536
|
}
|
|
8552
8537
|
),
|
|
@@ -8555,76 +8540,26 @@ function ImageUrlDialog({
|
|
|
8555
8540
|
{
|
|
8556
8541
|
type: "button",
|
|
8557
8542
|
onClick: handleSelectFileClick,
|
|
8558
|
-
disabled:
|
|
8543
|
+
disabled: isUploading,
|
|
8559
8544
|
style: {
|
|
8560
8545
|
padding: "8px 16px",
|
|
8561
|
-
backgroundColor:
|
|
8562
|
-
color:
|
|
8546
|
+
backgroundColor: isUploading ? "#ccc" : "#0078d4",
|
|
8547
|
+
color: isUploading ? "#666" : "white",
|
|
8563
8548
|
border: "none",
|
|
8564
8549
|
borderRadius: "4px",
|
|
8565
|
-
cursor:
|
|
8550
|
+
cursor: isUploading ? "not-allowed" : "pointer",
|
|
8566
8551
|
marginBottom: "8px",
|
|
8567
8552
|
fontWeight: "bold"
|
|
8568
8553
|
},
|
|
8569
|
-
children: t("selectFile")
|
|
8554
|
+
children: isUploading ? t("uploading") : t("selectFile")
|
|
8570
8555
|
}
|
|
8571
8556
|
),
|
|
8572
|
-
|
|
8573
|
-
/* @__PURE__ */ jsxs29("div", { style: {
|
|
8574
|
-
|
|
8575
|
-
|
|
8576
|
-
gap: "8px",
|
|
8577
|
-
padding: "8px",
|
|
8578
|
-
backgroundColor: "var(--shade-100)",
|
|
8579
|
-
borderRadius: "4px",
|
|
8580
|
-
marginBottom: "8px"
|
|
8581
|
-
}, children: [
|
|
8582
|
-
previewUrl && /* @__PURE__ */ jsx61(
|
|
8583
|
-
"img",
|
|
8584
|
-
{
|
|
8585
|
-
src: previewUrl,
|
|
8586
|
-
alt: "Preview",
|
|
8587
|
-
style: {
|
|
8588
|
-
maxWidth: "60px",
|
|
8589
|
-
maxHeight: "60px",
|
|
8590
|
-
objectFit: "contain",
|
|
8591
|
-
borderRadius: "4px"
|
|
8592
|
-
}
|
|
8593
|
-
}
|
|
8594
|
-
),
|
|
8595
|
-
/* @__PURE__ */ jsxs29("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
8596
|
-
/* @__PURE__ */ jsx61("div", { style: {
|
|
8597
|
-
fontWeight: "bold",
|
|
8598
|
-
overflow: "hidden",
|
|
8599
|
-
textOverflow: "ellipsis",
|
|
8600
|
-
whiteSpace: "nowrap"
|
|
8601
|
-
}, children: selectedFile.name }),
|
|
8602
|
-
/* @__PURE__ */ jsxs29("div", { style: { fontSize: "12px", color: "var(--shade-500)" }, children: [
|
|
8603
|
-
(selectedFile.size / 1024).toFixed(1),
|
|
8604
|
-
" KB"
|
|
8605
|
-
] })
|
|
8606
|
-
] })
|
|
8557
|
+
uploadedUrl && /* @__PURE__ */ jsxs29("div", { style: { marginTop: "8px", padding: "8px", backgroundColor: "var(--shade-100)", borderRadius: "4px" }, children: [
|
|
8558
|
+
/* @__PURE__ */ jsxs29("div", { style: { color: "green", marginBottom: "4px" }, children: [
|
|
8559
|
+
"\u2713 ",
|
|
8560
|
+
t("uploadComplete")
|
|
8607
8561
|
] }),
|
|
8608
|
-
/* @__PURE__ */ jsx61("
|
|
8609
|
-
/* @__PURE__ */ jsx61(
|
|
8610
|
-
"input",
|
|
8611
|
-
{
|
|
8612
|
-
type: "text",
|
|
8613
|
-
value: vaultPath,
|
|
8614
|
-
onChange: (e) => setVaultPath(e.target.value),
|
|
8615
|
-
style: {
|
|
8616
|
-
width: "100%",
|
|
8617
|
-
padding: "6px",
|
|
8618
|
-
boxSizing: "border-box",
|
|
8619
|
-
border: "1px solid var(--shade-300)",
|
|
8620
|
-
borderRadius: "4px",
|
|
8621
|
-
backgroundColor: "var(--shade-50)",
|
|
8622
|
-
color: "var(--shade-700)"
|
|
8623
|
-
},
|
|
8624
|
-
placeholder: "attachments/image.png"
|
|
8625
|
-
}
|
|
8626
|
-
),
|
|
8627
|
-
/* @__PURE__ */ jsx61("div", { style: { fontSize: "12px", color: "var(--shade-500)", marginTop: "4px" }, children: t("vaultPathHint") })
|
|
8562
|
+
uploadedFileName && /* @__PURE__ */ jsx61("div", { style: { fontSize: "12px", color: "var(--shade-500)" }, children: uploadedFileName })
|
|
8628
8563
|
] })
|
|
8629
8564
|
] }),
|
|
8630
8565
|
/* @__PURE__ */ jsxs29("div", { style: { marginBottom: "8px" }, children: [
|
|
@@ -8686,7 +8621,7 @@ function ImageUrlDialog({
|
|
|
8686
8621
|
cursor: isSubmitDisabled ? "not-allowed" : "pointer",
|
|
8687
8622
|
fontWeight: "bold"
|
|
8688
8623
|
},
|
|
8689
|
-
children:
|
|
8624
|
+
children: t("register")
|
|
8690
8625
|
}
|
|
8691
8626
|
),
|
|
8692
8627
|
/* @__PURE__ */ jsx61(
|