fix(bulk-context-menu): escape special characters in data-filepath selector to support double quotes in filenames (#845)

This commit is contained in:
Will Miao
2026-03-12 08:49:10 +08:00
parent 5c29e26c4e
commit 4fcf641d57
7 changed files with 34 additions and 10 deletions

View File

@@ -7,7 +7,10 @@ let pendingExcludePath = null;
export function showDeleteModal(filePath) {
pendingDeletePath = filePath;
const card = document.querySelector(`.model-card[data-filepath="${filePath}"]`);
const escapedPath = window.CSS && typeof window.CSS.escape === 'function'
? window.CSS.escape(filePath)
: filePath.replace(/["\\]/g, '\\$&');
const card = document.querySelector(`.model-card[data-filepath="${escapedPath}"]`);
const modelName = card ? card.dataset.name : filePath.split('/').pop();
const modal = modalManager.getModal('deleteModal').element;
const modelInfo = modal.querySelector('.delete-model-info');
@@ -47,7 +50,10 @@ export function closeDeleteModal() {
export function showExcludeModal(filePath) {
pendingExcludePath = filePath;
const card = document.querySelector(`.model-card[data-filepath="${filePath}"]`);
const escapedPath = window.CSS && typeof window.CSS.escape === 'function'
? window.CSS.escape(filePath)
: filePath.replace(/["\\]/g, '\\$&');
const card = document.querySelector(`.model-card[data-filepath="${escapedPath}"]`);
const modelName = card ? card.dataset.name : filePath.split('/').pop();
const modal = modalManager.getModal('excludeModal').element;
const modelInfo = modal.querySelector('.exclude-model-info');