Skip to content

Commit d26f1b5

Browse files
authored
Merge pull request #243 from jparkerweb/develop
v3.5.2
2 parents 926c7ab + 972e59f commit d26f1b5

File tree

6 files changed

+103
-18
lines changed

6 files changed

+103
-18
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
All notable changes to the Pixel Banner plugin will be documented in this file.
44

55
## 🎉 What's New
6+
### v3.5.2 - 2025-05-21
7+
#### 🐛 Fixed
8+
- Updated styles to remove overflow on images for mobile devices
9+
- Resolved issue with icon image selection modal not using the correct extension for non-svg images
10+
611
### v3.5.1 - 2025-05-19
712
#### ✨ Added
813
- Added Command Palette command for selecting a `Banner Icon Image`

UPDATE.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
</a>
44

55
## 🎉 What's New
6+
### v3.5.2 - 2025-05-21
7+
#### 🐛 Fixed
8+
- Updated styles to remove overflow on images for mobile devices
9+
- Resolved issue with icon image selection modal not using the correct extension for non-svg images
10+
611
### v3.5.1 - 2025-05-19
712
#### ✨ Added
813
- Added Command Palette command for selecting a `Banner Icon Image`

inventory.md

Lines changed: 57 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Inventory of Pixel Banner Plugin
22

3-
**Last Updated:** May 5, 2025
3+
**Last Updated:** May 19, 2025
44

55
Below is a concise overview of all files and their primary functions or methods. This document helps developers quickly locate and understand the key points in the codebase.
66

@@ -11,7 +11,7 @@ Below is a concise overview of all files and their primary functions or methods.
1111
### `manifest.json`
1212
**Description**:
1313
- Plugin manifest containing metadata like ID, name, version, minimum app version, description, author info, and funding URL.
14-
- Current Version: 3.4.5
14+
- Current Version: 3.5.1
1515

1616
### `package.json`
1717
**Description**:
@@ -92,7 +92,11 @@ Provides utility methods for managing the "icon overlay" feature on banners.
9292
Checks whether the existing icon overlay's styling or state differs from the desired icon state and thus needs an update.
9393
5. **handleSetBannerIcon(plugin)**
9494
Opens an emoji selection modal and updates frontmatter with the chosen banner icon.
95-
6. **cleanupIconOverlay(plugin, view)**
95+
6. **handleSetBannerIconImage(plugin)**
96+
Opens the Icon Image Selection modal for adding images to banner icons, supporting local images, web URLs, and online collections.
97+
7. **applyIconRotation(iconElement, rotationDegrees)**
98+
Applies rotation transformation to the banner icon based on user-defined degree values (0-360 degrees).
99+
8. **cleanupIconOverlay(plugin, view)**
96100
Removes any non-persistent icon overlays from the specified view.
97101

98102
---
@@ -403,6 +407,54 @@ Helps visually set or tweak the X/Y offsets for the banner and icon.
403407

404408
---
405409

410+
## `/src/modal/modals/iconImageSelectionModal.js`
411+
**Class**: `IconImageSelectionModal` (extends `Modal`)
412+
Provides image selection for banner icons, allowing users to choose from local images, web URLs, or online collections.
413+
414+
**Key Methods**:
415+
1. **onOpen()**
416+
Builds the modal interface with tabs for different icon image sources.
417+
2. **renderCollectionsTab()**
418+
Creates the interface for browsing and selecting from online icon collections.
419+
3. **renderLocalTab()**
420+
Displays local vault images that can be used as banner icons.
421+
4. **renderWebTab()**
422+
Provides an interface for entering web URLs for icon images.
423+
5. **handleImageSelection(imagePath)**
424+
Processes the selected image and updates the banner icon.
425+
426+
---
427+
428+
## `/src/modal/modals/iconFolderSelectionModal.js`
429+
**Class**: `IconFolderSelectionModal` (extends `FuzzySuggestModal`)
430+
Allows selection of a folder containing images to use as banner icons.
431+
432+
**Key Methods**:
433+
1. **getItems()**
434+
Returns a list of folders from the vault.
435+
2. **onChooseItem(folder)**
436+
Sets the selected folder as the source for banner icons.
437+
438+
---
439+
440+
## `/src/modal/modals/targetPositionModal.js`
441+
**Class**: `TargetPositionModal` (extends `Modal`)
442+
Provides an interactive UI for adjusting banner position, size, and appearance with enhanced controls for icon styling.
443+
444+
**Key Methods**:
445+
1. **onOpen()**
446+
Builds the UI with controls for banner position, size, alignment, and icon settings.
447+
2. **createBannerControls()**
448+
Creates sliders and inputs for banner position, size, and display settings.
449+
3. **createBorderRadiusControl()**
450+
Creates the new border radius slider control for adjusting banner corner rounding.
451+
4. **createIconControls()**
452+
Creates controls for banner icon styling, including size, position, opacity, and rotation.
453+
5. **onClose()**
454+
Cleans up the modal and saves any changes to banner settings.
455+
456+
---
457+
406458
## `/src/modal/modals/dailyGame.js`
407459
**Class**: `DailyGameModal` (extends `Modal`)
408460
Provides a daily game or challenge feature within the plugin.
@@ -437,6 +489,8 @@ Exports all modals from the `modal/modals` directory.
437489
- `PixelBannerStoreModal`
438490
- `WebAddressModal`
439491
- `DailyGameModal`
492+
- `IconImageSelectionModal`
493+
- `IconFolderSelectionModal`
440494

441495
---
442496

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"id": "pexels-banner",
33
"name": "Pixel Banner",
4-
"version": "3.5.1",
4+
"version": "3.5.2",
55
"minAppVersion": "1.6.0",
66
"description": "Enhance your notes with customizable banner images, including AI-generated designs and a curated store of downloadable banners. Transform your workspace with visually stunning headers that add context, improve aesthetics, and take your note-taking beyond the ordinary.",
77
"author": "Justin Parker (eQui\\\\ Labs)",

src/modal/modals/iconImageSelectionModal.js

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ export class IconImageSelectionModal extends Modal {
238238
.pixel-banner-image-container {
239239
cursor: pointer;
240240
border-radius: 6px;
241-
overflow: hidden;
242241
border: 1px solid var(--background-modifier-border);
243242
transition: transform 0.2s ease, box-shadow 0.2s ease;
244243
position: relative;
@@ -1344,6 +1343,7 @@ export class IconImageSelectionModal extends Modal {
13441343
try {
13451344
const url = `${PIXEL_BANNER_PLUS.API_URL}${PIXEL_BANNER_PLUS.ENDPOINTS.BANNER_ICONS_ID.replace(':id', icon.id)}?key=${PIXEL_BANNER_PLUS.BANNER_ICON_KEY}`;
13461345

1346+
// Get the icon details from the API
13471347
const response = await fetch(url, {
13481348
headers: {
13491349
'Accept': 'application/json'
@@ -1362,13 +1362,25 @@ export class IconImageSelectionModal extends Modal {
13621362

13631363
const iconData = data.bannerIcon;
13641364

1365-
// Extract extension from file_name or description, defaulting to the original format
1366-
// Look for extension in file_name first
1367-
let extension = 'svg'; // Default to svg as mentioned by user
1368-
let fileName = iconData.file_name || '';
1365+
// Extract extension from the base64 image string's MIME type
1366+
let extension = 'png'; // Default as fallback
13691367

1370-
if (fileName) {
1371-
const parts = fileName.split('.');
1368+
// Check if we have a base64 image with MIME type info
1369+
if (iconData.base64Image) {
1370+
1371+
// regex to handle MIME type formats
1372+
const mimeTypeMatch = iconData.base64Image.match(/data:image\/([\w\+\-\.]+);base64/);
1373+
1374+
if (mimeTypeMatch && mimeTypeMatch[1]) {
1375+
extension = mimeTypeMatch[1];
1376+
1377+
if (extension === 'jpeg') extension = 'jpg';
1378+
if (extension === 'svg+xml') extension = 'svg';
1379+
}
1380+
}
1381+
// Fallback: try to get extension from file_name
1382+
else if (iconData.file_name) {
1383+
const parts = iconData.file_name.split('.');
13721384
if (parts.length > 1) {
13731385
extension = parts[parts.length - 1].toLowerCase();
13741386
}
@@ -1396,21 +1408,31 @@ export class IconImageSelectionModal extends Modal {
13961408
await this.app.vault.createFolder(folderPath);
13971409
}
13981410

1399-
// Get a safe filename
1400-
const suggestedName = `${iconData.description || 'icon'}.${extension}`;
1401-
const fileName = await new Promise((resolve) => {
1411+
// Get a safe filename without extension - we'll add it later
1412+
const suggestedName = `${iconData.description || 'icon'}`;
1413+
const userFileName = await new Promise((resolve) => {
14021414
new SaveImageModal(this.app, suggestedName, (result) => {
14031415
resolve(result);
14041416
}).open();
14051417
});
14061418

1407-
if (!fileName) {
1419+
if (!userFileName) {
14081420
new Notice('No file name provided');
14091421
return;
14101422
}
14111423

1424+
// Remove any extension the user might have added
1425+
let baseName = userFileName;
1426+
if (baseName.includes('.')) {
1427+
baseName = baseName.substring(0, baseName.lastIndexOf('.'));
1428+
}
1429+
1430+
// Add the correct extension from our MIME type detection
1431+
const finalFileName = `${baseName}.${extension}`;
1432+
14121433
// Convert base64 to binary
1413-
const base64Data = iconData.base64Image.split(',')[1]; // Remove the data:image/png;base64, part
1434+
const base64Parts = iconData.base64Image.split(',');
1435+
const base64Data = base64Parts[1];
14141436
const binaryString = window.atob(base64Data);
14151437
const bytes = new Uint8Array(binaryString.length);
14161438
for (let i = 0; i < binaryString.length; i++) {
@@ -1419,7 +1441,7 @@ export class IconImageSelectionModal extends Modal {
14191441

14201442
try {
14211443
// Create the file in the vault
1422-
const fullPath = `${folderPath}/${fileName}`.replace(/\/+/g, '/');
1444+
const fullPath = `${folderPath}/${finalFileName}`.replace(/\/+/g, '/');
14231445
const newFile = await this.app.vault.createBinary(fullPath, bytes.buffer);
14241446

14251447
// Call onChoose with the new file

src/modal/modals/imageSelectionModal.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,6 @@ export class ImageSelectionModal extends Modal {
219219
.pixel-banner-image-container {
220220
cursor: pointer;
221221
border-radius: 6px;
222-
overflow: hidden;
223222
border: 1px solid var(--background-modifier-border);
224223
transition: transform 0.2s ease, box-shadow 0.2s ease;
225224
position: relative;

0 commit comments

Comments
 (0)