mirror of
https://github.com/usero2/obsidian-plugins-cbz-reader.git
synced 2026-07-22 07:43:42 +00:00
1.0.4
This commit is contained in:
parent
92e69c223f
commit
d205ca75a9
5 changed files with 84 additions and 2 deletions
|
|
@ -53,6 +53,13 @@ Enjoy native smooth scrolling when navigating pages or clicking the minimap, pro
|
|||
- **Stable Slider Size:** Fixed an issue where the slider height would abruptly expand on double-page spreads. The slider height is now beautifully consistent.
|
||||
- **Linter Compliance:** Rewrote static styling to use Obsidian's `setCssStyles` API, ensuring full compliance with Obsidian's strict plugin guidelines.
|
||||
|
||||
## 🆕 What's New in v1.0.4
|
||||
|
||||
- **Context Menu on Images:** Right-click on any image or minimap thumbnail to view the original filename inside the CBZ archive. Word-wrapping is applied for very long filenames.
|
||||
- **Copy Image to Clipboard:** Easily copy comic images directly to your clipboard from the new context menu, even if you are clicking from the minimap before the main image has finished loading.
|
||||
|
||||

|
||||
|
||||
## ❤️ Support & Donate
|
||||
|
||||
If this plugin has improved your Obsidian workflow, saved you time, or you just want to support its continued development, please consider donating!
|
||||
|
|
|
|||
BIN
images/RuQUO2BG8S.png
Normal file
BIN
images/RuQUO2BG8S.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 335 KiB |
70
main.js
70
main.js
|
|
@ -17,7 +17,7 @@ https://github.com/nodeca/pako/blob/main/LICENSE
|
|||
|
||||
})(module_jszip, module_jszip.exports);
|
||||
var JSZip = module_jszip.exports;
|
||||
const { Plugin, ItemView } = require('obsidian');
|
||||
const { Plugin, ItemView, Menu, Notice } = require('obsidian');
|
||||
|
||||
const CBZ_VIEW_TYPE = "cbz-view";
|
||||
|
||||
|
|
@ -251,6 +251,72 @@ class CbzView extends ItemView {
|
|||
const img = pageContainer.createEl("img");
|
||||
this.imgElements.set(index, img);
|
||||
|
||||
const handleContextMenu = (event) => {
|
||||
event.preventDefault();
|
||||
const menu = new Menu();
|
||||
menu.dom.addClass('cbz-context-menu');
|
||||
menu.addItem((item) => {
|
||||
item.setTitle(zipEntry.name)
|
||||
.setIcon("image-file")
|
||||
.setDisabled(true);
|
||||
});
|
||||
menu.addSeparator();
|
||||
menu.addItem((item) => {
|
||||
item.setTitle("Copy image to clipboard")
|
||||
.setIcon("copy")
|
||||
.onClick(async () => {
|
||||
try {
|
||||
if (img.complete && img.naturalWidth > 0) {
|
||||
const tmpCanvas = document.createElement("canvas");
|
||||
tmpCanvas.width = img.naturalWidth;
|
||||
tmpCanvas.height = img.naturalHeight;
|
||||
const ctx = tmpCanvas.getContext("2d");
|
||||
ctx.drawImage(img, 0, 0);
|
||||
tmpCanvas.toBlob((blob) => {
|
||||
if (blob) {
|
||||
navigator.clipboard.write([new ClipboardItem({ 'image/png': blob })]).then(() => {
|
||||
new Notice('Image copied to clipboard');
|
||||
}).catch((err) => {
|
||||
console.error("Clipboard write error:", err);
|
||||
new Notice('Failed to copy image');
|
||||
});
|
||||
}
|
||||
}, 'image/png');
|
||||
} else {
|
||||
new Notice('Loading image to copy...');
|
||||
const imgData = await zipEntry.async("base64");
|
||||
const image = new Image();
|
||||
image.onload = () => {
|
||||
const tmpCanvas = document.createElement("canvas");
|
||||
tmpCanvas.width = image.width;
|
||||
tmpCanvas.height = image.height;
|
||||
const ctx = tmpCanvas.getContext("2d");
|
||||
ctx.drawImage(image, 0, 0);
|
||||
tmpCanvas.toBlob((blob) => {
|
||||
if (blob) {
|
||||
navigator.clipboard.write([new ClipboardItem({ 'image/png': blob })]).then(() => {
|
||||
new Notice('Image copied to clipboard');
|
||||
}).catch((err) => {
|
||||
console.error("Clipboard write error:", err);
|
||||
new Notice('Failed to copy image');
|
||||
});
|
||||
}
|
||||
}, 'image/png');
|
||||
};
|
||||
image.onerror = () => new Notice('Failed to decode image');
|
||||
image.src = "data:image/png;base64," + imgData;
|
||||
}
|
||||
} catch (e) {
|
||||
console.error("Context menu copy error:", e);
|
||||
new Notice('Failed to copy image');
|
||||
}
|
||||
});
|
||||
});
|
||||
menu.showAtMouseEvent(event);
|
||||
};
|
||||
|
||||
img.addEventListener('contextmenu', handleContextMenu);
|
||||
|
||||
this.observer.observe(pageContainer);
|
||||
|
||||
// Minimap items
|
||||
|
|
@ -260,6 +326,8 @@ class CbzView extends ItemView {
|
|||
this.canvasElements.set(index, canvas);
|
||||
this.minimapItems.set(index, minimapItem);
|
||||
|
||||
minimapItem.addEventListener('contextmenu', handleContextMenu);
|
||||
|
||||
this.minimapObserver.observe(minimapItem);
|
||||
|
||||
// The track click logic handles minimapItem clicks now through event bubbling
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"id": "cbz-reader",
|
||||
"name": "CBZ Reader",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.4",
|
||||
"minAppVersion": "1.0.0",
|
||||
"description": "A powerful and fast native CBZ Comic Book Archive reader",
|
||||
"author": "usero2-endofday",
|
||||
|
|
|
|||
|
|
@ -97,4 +97,11 @@
|
|||
object-fit: contain;
|
||||
}
|
||||
|
||||
.cbz-context-menu .menu-item-title {
|
||||
white-space: normal !important;
|
||||
word-break: break-word !important;
|
||||
max-width: 300px;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue