mirror of
https://github.com/alam00000/bentopdf.git
synced 2026-11-10 01:14:17 +01:00
feat: PDF text editor internationalization
This commit is contained in:
1 parent
0f65fdb2f4
commit
7f6bebf21f
27 files changed
+2936
-127
No files matched your search
+17
-2
@@ -9092,7 +9092,15 @@ async function saveFile() {
|
||||
a.click();
|
||||
URL.revokeObjectURL(a.href);
|
||||
state.dirty = false;
|
||||
toast('Saved ' + ((bytes.length / 1024) | 0) + ' KB');
|
||||
const savedKb = (bytes.length / 1024) | 0;
|
||||
if (onSaved) onSaved(savedKb, state.fileName);
|
||||
else toast('Saved ' + savedKb + ' KB');
|
||||
}
|
||||
|
||||
let onSaved = null;
|
||||
|
||||
function setOnSaved(fn) {
|
||||
onSaved = typeof fn === 'function' ? fn : null;
|
||||
}
|
||||
|
||||
function wireUI() {
|
||||
@@ -9975,4 +9983,11 @@ async function addImageFromFile(file) {
|
||||
} else if (state.undo.length) state.undo.pop();
|
||||
}
|
||||
|
||||
export { openFile, engineReady, setZoom, getZoom, getDocDescription };
|
||||
export {
|
||||
openFile,
|
||||
engineReady,
|
||||
setZoom,
|
||||
getZoom,
|
||||
getDocDescription,
|
||||
setOnSaved,
|
||||
};
|
||||
@@ -299,6 +299,13 @@ export function scriptFallbackFamilies(cps) {
|
||||
],
|
||||
[[[0x10a0, 0x10ff]], ['Noto Sans Georgian', 'Sylfaen', 'Arial Unicode MS']],
|
||||
[[[0x1200, 0x137f]], ['Kefa', 'Nyala', 'Noto Sans Ethiopic']],
|
||||
[
|
||||
[[0x0f00, 0x0fff]],
|
||||
['Kailasa', 'Microsoft Himalaya', 'Noto Sans Tibetan'],
|
||||
],
|
||||
[[[0x13a0, 0x13ff]], ['Plantagenet Cherokee', 'Noto Sans Cherokee']],
|
||||
[[[0x0700, 0x074f]], ['Noto Sans Syriac', 'Estrangelo Edessa']],
|
||||
[[[0x0780, 0x07bf]], ['Noto Sans Thaana', 'MV Boli']],
|
||||
];
|
||||
const out = [];
|
||||
for (const cp of cps) {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import '@phosphor-icons/web/regular';
|
||||
import { createIcons, icons } from 'lucide';
|
||||
import { showAlert, showLoader, hideLoader } from '../ui.js';
|
||||
import { t } from '../i18n/i18n';
|
||||
import { batchDecryptIfNeeded } from '../utils/password-prompt.js';
|
||||
import { setupFormatDock, setupFindSheet } from './edit-pdf-text-dock';
|
||||
|
||||
@@ -274,6 +275,7 @@ interface EditorAppModule {
|
||||
setZoom: (z: number) => void;
|
||||
getZoom: () => number;
|
||||
getDocDescription: () => DocDescription;
|
||||
setOnSaved: (fn: ((kb: number, fileName: string) => void) | null) => void;
|
||||
}
|
||||
|
||||
function relocateAddText() {
|
||||
@@ -398,6 +400,12 @@ function setupDocPanel() {
|
||||
}
|
||||
|
||||
let appModule: EditorAppModule | null = null;
|
||||
|
||||
function closeEditor() {
|
||||
document.getElementById('text-editor-app')?.setAttribute('hidden', '');
|
||||
document.getElementById('uploader')?.classList.remove('hidden');
|
||||
document.getElementById('tool-landing')?.classList.remove('hidden');
|
||||
}
|
||||
let launching = false;
|
||||
|
||||
function fitMobileWidth() {
|
||||
@@ -428,6 +436,16 @@ async function launchEditor(file: File) {
|
||||
document.getElementById('text-editor-app')?.removeAttribute('hidden');
|
||||
if (!appModule) {
|
||||
appModule = (await import('../editcore/app.js')) as EditorAppModule;
|
||||
appModule.setOnSaved((kb) => {
|
||||
showAlert(
|
||||
t('common.success'),
|
||||
t('tools:editPdfText.saved', { size: kb }),
|
||||
'success',
|
||||
() => {
|
||||
closeEditor();
|
||||
}
|
||||
);
|
||||
});
|
||||
relocateAddText();
|
||||
setupDocPanel();
|
||||
setupEditMenu();
|
||||
@@ -442,10 +460,8 @@ async function launchEditor(file: File) {
|
||||
if (window.matchMedia('(max-width: 768px)').matches) fitMobileWidth();
|
||||
} catch (error) {
|
||||
console.error('Error loading PDF Text Editor:', error);
|
||||
showAlert('Error', 'Failed to load the PDF Text Editor.');
|
||||
document.getElementById('text-editor-app')?.setAttribute('hidden', '');
|
||||
document.getElementById('uploader')?.classList.remove('hidden');
|
||||
document.getElementById('tool-landing')?.classList.remove('hidden');
|
||||
showAlert(t('common.error'), t('tools:editPdfText.failedToLoad'));
|
||||
closeEditor();
|
||||
} finally {
|
||||
hideLoader();
|
||||
launching = false;
|
||||
|
||||
Binary file not shown.
Reference in new issue
Block a user