feat: Erstellung der konstanten Variablen DEVICE_TYPE und IS_DESKTOP.

- Aufteilung der benutzerdefinierten Symbolleistenelemente in writableItems und mobileItems
 - beide werden abhängig von der jeweiligen Bedingung hinzugefügt
This commit is contained in:
Developer 02
2024-10-14 15:44:21 +02:00
parent 869493bd97
commit 6440dd09d1
5 changed files with 41 additions and 42 deletions

View File

@@ -10,6 +10,7 @@
'zoom-mode',
'spacer',
'search',
'export-pdf'
]
// Load the PSPDFKit UI by setting a target element as the container to render in
@@ -49,10 +50,16 @@
return UI.Instance;
}
static configurePSPDFKit(instance, handler) {
const toolbarItems = UI.getToolbarItems(instance, handler)
toolbarItems.push({ type: "export-pdf" })
instance.setToolbarItems(toolbarItems)
static addToolbarItems(instance, handler) {
var toolbarItems = instance.toolbarItems.filter((item) => UI.allowedToolbarItems.includes(item.type));
if(!IS_READONLY)
toolbarItems = toolbarItems.concat(UI.getWritableItems(handler));
if(!IS_DESKTOP)
toolbarItems = toolbarItems.concat(UI.getMobileItems(handler));
instance.setToolbarItems(toolbarItems)
}
static annotationRenderer(data) {
@@ -60,12 +67,6 @@
return null
}
static getToolbarItems(instance, handler) {
const customItems = UI.getWritableItems(handler)
const defaultItems = UI.getDefaultItems(instance.toolbarItems)
return defaultItems.concat(customItems)
}
static createElementFromHTML(html) {
const el = document.createElement('div')
el.innerHTML = html.trim()
@@ -74,24 +75,24 @@
}
static getWritableItems = function (callback) {
const items = new Array();
if (!IS_READONLY)
items.push(
{
type: 'custom',
id: 'button-share',
className: 'button-share',
title: 'Teilen',
onPress() {
callback('SHARE')
},
icon: `<svg width="30" height="30" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M20 13V17.5C20 20.5577 16 20.5 12 20.5C8 20.5 4 20.5577 4 17.5V13M12 3L12 15M12 3L16 7M12 3L8 7" stroke="#000000" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>`,
}
);
return [
{
type: 'custom',
id: 'button-share',
className: 'button-share',
title: 'Teilen',
onPress() {
callback('SHARE')
},
icon: `<svg width="30" height="30" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M20 13V17.5C20 20.5577 16 20.5 12 20.5C8 20.5 4 20.5577 4 17.5V13M12 3L12 15M12 3L16 7M12 3L8 7" stroke="#000000" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>`,
}
];
}
var otherItmes = [
static getMobileItems = function (callback) {
return [
{
type: 'custom',
id: 'button-reset',
@@ -125,14 +126,8 @@
onPress() {
callback('FINISH')
},
},
]
return items;
}
static getDefaultItems(items) {
return items.filter((item) => UI.allowedToolbarItems.includes(item.type))
}
];
}
static getPresets() {