Skip to content

book-reader plugin added#33

Closed
Serg-Kv wants to merge 1 commit intoONLYOFFICE:developfrom
Serg-Kv:master
Closed

book-reader plugin added#33
Serg-Kv wants to merge 1 commit intoONLYOFFICE:developfrom
Serg-Kv:master

Conversation

@Serg-Kv
Copy link
Copy Markdown

@Serg-Kv Serg-Kv commented Mar 11, 2026

book-reader plugin added

@LinneyS LinneyS requested a review from sshakndr March 11, 2026 12:41
Copy link
Copy Markdown
Contributor

@sshakndr sshakndr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • The modal window is too narrow in desktop mode, in my opinion.

  • Two scrollbars on desktop (the page switching buttons are pushed off-screen).

  • Is it possible to create proper pages, instead of just one chapter per page?

  • If this is the only way to implement pages, maybe you should try improving the bookmarks so they remember where the user scrolled? Using scrollTop / scrollHeight / clientHeight.

}
},
fileType: [FilesType.file],
fileExt: [".djvu", ".djv", ".epub", ".fb2", ".zip"],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem with ZIP without books:

ZIP does not contain a recognised book format. Supported: EPUB (with META-INF/container.xml), .fb2, or .djvu inside a ZIP.

Even if there is some book format based on the archive, all zip archives should not be associated with the book format.
Try opening it first, and if an error occurs, it's better to report it through iToast, instead of the console and a broken modal window.
In any case, I don't see the point in maintaining the archive, since it takes time to unpack it each time. If this is common practice among e-book readers, then of course this functionality could be retained.

},
};

export const zipFileItem: IFileItem = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file item shouldn't exist. Clicking on the archive should open it first (there's a plugin for that), rather than attempting to find and open books.

} from "@onlyoffice/docspace-plugin-sdk";
import { createReaderModal } from "../Modal";

export const epubFileItem: IFileItem = {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All file items can be dynamicaly defined and strored in one array like in Codemirror plugin for less code


export const epubFileItem: IFileItem = {
extension: ".epub",
fileTypeName: "EPUB Book",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't need to specify the format, as DocSpace will show it for you. You can just leave it as "Book." Also, for most, if not all, formats, DocSpace will automatically set the type to "Document."

fileTileIcon: "icon-16.png",
devices: [Devices.desktop, Devices.mobile, Devices.tablet],
onClick: (item: File): IMessage => {
console.log("Opening EPUB file in reader:", item.id);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary console.log

Comment on lines +16 to +31
console.log("Context menu clicked, File ID:", id);

try {
console.log("Fetching file metadata...");
const response = await fetch(`/api/2.0/files/file/${id}`, {
method: "GET",
headers: {
Accept: "application/json",
},
});

const fileData = await response.json();
const fileInfo = fileData.response;

console.log("File info loaded:", fileInfo.title, fileInfo.fileExst);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This piece of code can be moved to createReaderModal() and there you can check whether a File or a number has arrived.

remove unnecessary console.logs

Comment on lines +42 to +48
console.error("Error in reader:", error);

const errorModal = createReaderModal(id);
return {
actions: [Actions.showModal],
modalDialogProps: errorModal,
};
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use IToast to show errors

@LinneyS LinneyS changed the base branch from master to develop March 12, 2026 07:59
@Serg-Kv Serg-Kv closed this Mar 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants