mirror of
https://github.com/obsqrbtz/goose-highlighter.git
synced 2026-04-08 20:19:06 +03:00
removed list manager window
This commit is contained in:
@@ -42,16 +42,16 @@
|
||||
"message": "Delete"
|
||||
},
|
||||
"disable_selected": {
|
||||
"message": "Disable"
|
||||
"message": "Disable selected"
|
||||
},
|
||||
"enable_selected": {
|
||||
"message": "Enable"
|
||||
"message": "Enable selected"
|
||||
},
|
||||
"import_list": {
|
||||
"message": "Import JSON"
|
||||
"message": "Import list"
|
||||
},
|
||||
"export_list": {
|
||||
"message": "Export JSON"
|
||||
"message": "Export list"
|
||||
},
|
||||
"import_list_list_manager": {
|
||||
"message": "Import list"
|
||||
@@ -203,6 +203,12 @@
|
||||
"copy_to_list": {
|
||||
"message": "Copy to list"
|
||||
},
|
||||
"move_selected": {
|
||||
"message": "Move selected"
|
||||
},
|
||||
"copy_selected": {
|
||||
"message": "Copy selected"
|
||||
},
|
||||
"no_other_lists": {
|
||||
"message": "No other lists"
|
||||
},
|
||||
|
||||
@@ -1,506 +0,0 @@
|
||||
@import url('../shared/fonts.css');
|
||||
@import url('../shared/colors.css');
|
||||
@import url('../shared/base.css');
|
||||
@import url('../shared/layout.css');
|
||||
@import url('../shared/word-list.css');
|
||||
@import url('../shared/ui-components.css');
|
||||
|
||||
html {
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
body {
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.app {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
height: 100vh;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.app button {
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.app .icon-btn {
|
||||
min-width: 28px;
|
||||
min-height: 28px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
/* List-manager–specific: compact header padding; shared .app-header does the rest */
|
||||
.topbar.app-header {
|
||||
padding: 8px 16px;
|
||||
}
|
||||
|
||||
.title.app-header-content {
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.topbar-actions .icon-toggle {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
padding: 0;
|
||||
border-radius: 6px;
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.layout {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(280px, 25%) 1fr;
|
||||
gap: 12px;
|
||||
padding: 12px;
|
||||
flex: 1;
|
||||
overflow: hidden;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.panel {
|
||||
background: var(--section-bg);
|
||||
border: 1px solid var(--input-border);
|
||||
border-radius: 8px;
|
||||
padding: 12px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 10px;
|
||||
overflow: hidden;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.panel-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
}
|
||||
|
||||
.lists-panel .panel-header {
|
||||
flex-direction: column;
|
||||
align-items: flex-start;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.lists-panel .panel-header h2 {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.panel-header h2 {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.panel-actions {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.lists-panel .panel-actions {
|
||||
justify-content: flex-start;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.lists-panel .panel-actions button {
|
||||
padding: 4px 8px;
|
||||
font-size: 12px;
|
||||
border-radius: 6px;
|
||||
min-height: 28px;
|
||||
}
|
||||
|
||||
.lists-panel .panel-actions button.ghost {
|
||||
background: var(--input-bg);
|
||||
border: 1px solid var(--input-border);
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.lists-panel .panel-actions button.ghost:hover {
|
||||
background: var(--section-bg);
|
||||
}
|
||||
|
||||
.panel-actions.secondary {
|
||||
margin-top: 0;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.panel-actions.secondary button {
|
||||
padding: 4px 8px;
|
||||
font-size: 12px;
|
||||
border-radius: 6px;
|
||||
min-height: 28px;
|
||||
}
|
||||
|
||||
.list-hint {
|
||||
font-size: 11px;
|
||||
opacity: 0.6;
|
||||
margin-top: -2px;
|
||||
}
|
||||
|
||||
.selection-hint {
|
||||
font-size: 12px;
|
||||
color: var(--text-color);
|
||||
opacity: 0.6;
|
||||
margin-top: 4px;
|
||||
font-style: italic;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.lists {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
overflow-y: auto;
|
||||
padding-right: 4px;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
.list-item {
|
||||
background: var(--input-bg);
|
||||
border: 2px solid transparent;
|
||||
border-radius: 8px;
|
||||
padding: 8px 10px;
|
||||
display: grid;
|
||||
grid-template-columns: 1fr auto;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.list-item:hover {
|
||||
background: var(--section-bg);
|
||||
border-color: var(--input-border);
|
||||
}
|
||||
|
||||
.list-item.active {
|
||||
border-color: var(--accent);
|
||||
box-shadow: var(--shadow-sm);
|
||||
background: var(--section-bg);
|
||||
}
|
||||
|
||||
.list-item.selected {
|
||||
background: var(--section-bg);
|
||||
border-color: rgba(204, 106, 42, 0.5);
|
||||
}
|
||||
|
||||
html.dark .list-item.selected,
|
||||
body.dark .list-item.selected {
|
||||
border-color: rgba(255, 140, 0, 0.5);
|
||||
}
|
||||
|
||||
.list-item.selected.active {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.list-item.drag-over {
|
||||
border-color: var(--accent-hover);
|
||||
transform: scale(1.02);
|
||||
}
|
||||
|
||||
.list-meta {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 4px;
|
||||
}
|
||||
|
||||
.list-name {
|
||||
font-weight: 600;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.list-stats {
|
||||
font-size: 11px;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.list-badge {
|
||||
font-size: 11px;
|
||||
padding: 2px 6px;
|
||||
border-radius: 999px;
|
||||
border: 1px solid var(--input-border);
|
||||
opacity: 0.8;
|
||||
cursor: pointer;
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
.list-badge:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.list-badge:focus-visible {
|
||||
outline: 2px solid var(--accent);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.details-panel {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 12px;
|
||||
min-height: 0;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.list-settings {
|
||||
display: none;
|
||||
gap: 8px;
|
||||
padding: 8px 10px;
|
||||
background: var(--input-bg);
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--input-border);
|
||||
}
|
||||
|
||||
.list-settings.expanded {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.list-settings input[type="text"] {
|
||||
width: 100%;
|
||||
padding: 6px 10px;
|
||||
font-size: 13px;
|
||||
border-radius: 6px;
|
||||
}
|
||||
|
||||
.color-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.compact-label {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.compact-label span {
|
||||
min-width: 24px;
|
||||
font-weight: 500;
|
||||
opacity: 0.8;
|
||||
}
|
||||
|
||||
.compact-label input[type="color"] {
|
||||
flex: 1;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.compact-btn {
|
||||
padding: 4px 10px;
|
||||
min-width: auto;
|
||||
height: 32px;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
.compact-header {
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
}
|
||||
|
||||
.list-title-section {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.list-title-section h2 {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
max-width: 300px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
|
||||
.word-controls {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.add-words {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
/* List-manager–specific: add-words button width; shared word-list.css does the rest */
|
||||
.add-words button {
|
||||
min-width: 100px;
|
||||
height: 32px;
|
||||
border-radius: 6px;
|
||||
font-size: 13px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.word-controls input[type="text"],
|
||||
.word-controls select {
|
||||
flex: 1;
|
||||
min-width: 140px;
|
||||
min-height: 32px;
|
||||
padding: 0 10px;
|
||||
font-size: 14px;
|
||||
border-radius: 8px;
|
||||
}
|
||||
|
||||
/* Search/move row: align input, select and buttons to same height */
|
||||
.word-controls .row:has(#wordSearch) button {
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.word-item .word-item-eye-toggle {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.app input[type="color"] {
|
||||
padding: 0;
|
||||
height: 32px;
|
||||
border-radius: 6px;
|
||||
border: 1px solid var(--input-border);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.app input[type="color"]:hover {
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
/* Subdued primary for compact buttons (e.g. Apply list settings) */
|
||||
.compact-btn.primary {
|
||||
background: rgba(255, 140, 0, 0.1);
|
||||
color: var(--accent);
|
||||
border: 1px solid rgba(255, 140, 0, 0.35);
|
||||
}
|
||||
|
||||
.compact-btn.primary:hover {
|
||||
background: rgba(255, 140, 0, 0.18);
|
||||
border-color: rgba(255, 140, 0, 0.5);
|
||||
}
|
||||
|
||||
html.dark .compact-btn.primary,
|
||||
body.dark .compact-btn.primary {
|
||||
background: rgba(255, 140, 0, 0.12);
|
||||
border-color: rgba(255, 140, 0, 0.4);
|
||||
}
|
||||
|
||||
html.dark .compact-btn.primary:hover,
|
||||
body.dark .compact-btn.primary:hover {
|
||||
background: rgba(255, 140, 0, 0.2);
|
||||
border-color: rgba(255, 140, 0, 0.55);
|
||||
}
|
||||
|
||||
.colors input[type="color"] {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.stats {
|
||||
font-size: 12px;
|
||||
opacity: 0.7;
|
||||
}
|
||||
|
||||
.pagination-container {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
gap: 10px;
|
||||
padding: 6px 10px;
|
||||
background: var(--section-bg);
|
||||
border: 1px solid var(--input-border);
|
||||
border-radius: 8px;
|
||||
flex-shrink: 0;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.pagination-info {
|
||||
font-size: 12px;
|
||||
opacity: 0.8;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.pagination-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.pagination-btn {
|
||||
background: var(--input-bg);
|
||||
border: 1px solid var(--input-border);
|
||||
color: var(--text-color);
|
||||
border-radius: 6px;
|
||||
padding: 4px 6px;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s ease;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
min-width: 28px;
|
||||
min-height: 28px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.pagination-btn:hover:not(:disabled) {
|
||||
background: var(--section-bg);
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
.pagination-btn:disabled {
|
||||
opacity: 0.4;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.pagination-pages {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0 6px;
|
||||
}
|
||||
|
||||
.page-info {
|
||||
font-size: 12px;
|
||||
opacity: 0.9;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.page-size-controls {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.page-size-controls label {
|
||||
opacity: 0.8;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.page-size-select {
|
||||
background: var(--input-bg);
|
||||
color: var(--text-color);
|
||||
border: 1px solid var(--input-border);
|
||||
border-radius: 6px;
|
||||
padding: 3px 6px;
|
||||
font-size: 12px;
|
||||
min-width: 55px;
|
||||
}
|
||||
|
||||
.page-size-select:focus {
|
||||
outline: none;
|
||||
border-color: var(--accent);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Removed single column layout - minimum width enforced for two-column layout */
|
||||
@@ -1,105 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=1280" />
|
||||
<title data-i18n="extension_name">Goose Highlighter - List Manager</title>
|
||||
<link rel="stylesheet" href="list-manager.css" />
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css" />
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="app">
|
||||
<header class="topbar app-header">
|
||||
<div class="title app-header-content">
|
||||
<div class="app-logo">
|
||||
<img src="../img/logo-outlined.png" alt="Goose Highlighter" />
|
||||
</div>
|
||||
<div>
|
||||
<div class="name app-title" data-i18n="extension_name">Goose Highlighter</div>
|
||||
<div class="subtitle app-subtitle" data-i18n="list_manager_title">List Manager</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="topbar-actions app-header-actions">
|
||||
<label class="icon-toggle" data-i18n-title="toggle_dark_mode_title" title="Toggle dark mode">
|
||||
<input type="checkbox" class="hidden-toggle" id="themeToggle" />
|
||||
<i class="toggle-icon theme-icon fa-solid"></i>
|
||||
</label>
|
||||
<button id="importListBtn" class="ghost"><i class="fa-solid fa-upload"></i> <span data-i18n="import_list_list_manager">Import list</span></button>
|
||||
<button id="exportListBtn" class="ghost"><i class="fa-solid fa-download"></i> <span data-i18n="export_list_list_manager">Export list</span></button>
|
||||
<button id="newListBtn" class="btn-primary-subdued"><i class="fa-solid fa-plus"></i> <span data-i18n="new_list">New List</span></button>
|
||||
</div>
|
||||
<input type="file" id="importFileInput" accept=".json" style="display: none;" />
|
||||
</header>
|
||||
|
||||
<main class="layout">
|
||||
<section class="panel lists-panel">
|
||||
<div class="panel-header">
|
||||
<h2 data-i18n="tab_lists">Lists</h2>
|
||||
<div class="panel-actions">
|
||||
<button id="duplicateListBtn" class="ghost"><i class="fa-solid fa-clone"></i> <span data-i18n="duplicate">Duplicate</span></button>
|
||||
<button id="mergeListsBtn" class="ghost"><i class="fa-solid fa-code-merge"></i> <span data-i18n="merge">Merge</span></button>
|
||||
<button id="deleteListsBtn" class="danger"><i class="fa-solid fa-trash"></i> <span data-i18n="delete_selected">Delete</span></button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="list-hint" data-i18n="drag_lists_hint">Drag lists to reorder • Ctrl+Click for multi-select</div>
|
||||
<div id="listsContainer" class="lists"></div>
|
||||
</section>
|
||||
|
||||
<section class="panel details-panel">
|
||||
<div class="panel-header compact-header">
|
||||
<div class="list-title-section">
|
||||
<h2 id="selectedListName">Selected List</h2>
|
||||
<button id="editListNameBtn" class="icon-btn" data-i18n-title="edit_list_name_and_colors_title" title="Edit list name and colors">
|
||||
<i class="fa-solid fa-pen"></i>
|
||||
</button>
|
||||
</div>
|
||||
<div class="stats" id="listStats">0 words</div>
|
||||
</div>
|
||||
<div class="list-settings collapsed" id="listSettingsPanel">
|
||||
<input type="text" id="listName" data-i18n="list_name" placeholder="List name" />
|
||||
<div class="color-row">
|
||||
<label class="compact-label">
|
||||
<span data-i18n="background">BG</span>
|
||||
<input type="color" id="listBg" data-i18n-title="background_color_title" />
|
||||
</label>
|
||||
<label class="compact-label">
|
||||
<span data-i18n="foreground">FG</span>
|
||||
<input type="color" id="listFg" data-i18n-title="text_color_title" />
|
||||
</label>
|
||||
<button id="applyListSettingsBtn" class="compact-btn primary"><i class="fa-solid fa-check"></i></button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="word-controls">
|
||||
<div class="add-words">
|
||||
<textarea id="bulkAddWords" data-i18n="paste_hint" placeholder="Paste words here..."></textarea>
|
||||
<button id="addWordsBtn" class="btn-primary-subdued"><i class="fa-solid fa-plus"></i> <span data-i18n="add_words">Add Words</span></button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<button id="selectAllWordsBtn" data-i18n="select_all">Select All</button>
|
||||
<button id="clearSelectedWordsBtn" data-i18n="deselect_all">Clear</button>
|
||||
<button id="enableWordsBtn" data-i18n="enable_selected">Enable</button>
|
||||
<button id="disableWordsBtn" data-i18n="disable_selected">Disable</button>
|
||||
<button id="deleteWordsBtn" class="danger" data-i18n="delete_selected">Delete</button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<input type="text" id="wordSearch" data-i18n="search_placeholder" placeholder="Search words..." />
|
||||
<select id="targetListSelect"></select>
|
||||
<button id="moveWordsBtn"><i class="fa-solid fa-arrow-right"></i> <span data-i18n="move">Move</span></button>
|
||||
<button id="copyWordsBtn"><i class="fa-solid fa-copy"></i> <span data-i18n="copy">Copy</span></button>
|
||||
</div>
|
||||
<div class="selection-hint" data-i18n="drag_words_hint">Click to select • Ctrl/Cmd+Click for multi-select • Drag words to lists to copy</div>
|
||||
</div>
|
||||
|
||||
<div id="wordList" class="word-list"></div>
|
||||
<div id="paginationControls" class="pagination-container"></div>
|
||||
</section>
|
||||
</main>
|
||||
</div>
|
||||
|
||||
<script type="module" src="../dist/list-manager/list-manager.js"></script>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -366,8 +366,14 @@ body {
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.manage-lists-btn {
|
||||
width: 100%;
|
||||
.list-export-import-row {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.list-export-import-btn {
|
||||
flex: 1;
|
||||
height: 28px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
@@ -383,11 +389,11 @@ body {
|
||||
color: var(--text-color);
|
||||
}
|
||||
|
||||
.manage-lists-btn:hover {
|
||||
.list-export-import-btn:hover {
|
||||
background: var(--section-bg);
|
||||
}
|
||||
|
||||
.manage-lists-btn i {
|
||||
.list-export-import-btn i {
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
@@ -752,6 +758,14 @@ body {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.word-item-menu-item.danger {
|
||||
color: var(--danger);
|
||||
}
|
||||
|
||||
.word-item-menu-item.danger:hover:not(.disabled) {
|
||||
background: rgba(239, 68, 68, 0.1);
|
||||
}
|
||||
|
||||
.word-item-menu-item i {
|
||||
font-size: 12px;
|
||||
opacity: 0.8;
|
||||
|
||||
@@ -85,11 +85,18 @@
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Manage Lists Button -->
|
||||
<button class="manage-lists-btn" id="manageListsBtn">
|
||||
<i class="fa-solid fa-layer-group"></i>
|
||||
<span data-i18n="manage_lists">Manage Lists</span>
|
||||
</button>
|
||||
<!-- Export / Import (Lists tab) -->
|
||||
<div class="list-export-import-row">
|
||||
<button class="list-export-import-btn" id="exportListBtn">
|
||||
<i class="fa-solid fa-download"></i>
|
||||
<span data-i18n="export_list">Export</span>
|
||||
</button>
|
||||
<button class="list-export-import-btn" id="importListBtn">
|
||||
<i class="fa-solid fa-upload"></i>
|
||||
<span data-i18n="import_list">Import</span>
|
||||
</button>
|
||||
<input type="file" id="importListInput" accept="application/json" hidden />
|
||||
</div>
|
||||
|
||||
<!-- Color Pickers -->
|
||||
<div class="color-pickers-row">
|
||||
@@ -169,25 +176,6 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<!-- Action Buttons -->
|
||||
<div class="word-actions-row">
|
||||
<button class="word-action-btn" id="selectAllBtn">
|
||||
<span data-i18n="select_all">Select</span>
|
||||
</button>
|
||||
<button class="word-action-btn" id="deselectAllBtn">
|
||||
<span data-i18n="deselect_all">Deselect</span>
|
||||
</button>
|
||||
<button class="word-action-btn" id="enableSelectedBtn">
|
||||
<span data-i18n="enable_selected">Enable</span>
|
||||
</button>
|
||||
<button class="word-action-btn" id="disableSelectedBtn">
|
||||
<span data-i18n="disable_selected">Disable</span>
|
||||
</button>
|
||||
<button class="word-action-btn danger" id="deleteSelectedBtn">
|
||||
<span data-i18n="delete_selected">Delete</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Search -->
|
||||
<div class="word-search-wrapper">
|
||||
<input type="text" id="wordSearch" class="word-search-input" data-i18n="search_placeholder" placeholder="Search..." />
|
||||
@@ -288,17 +276,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="options-buttons">
|
||||
<button class="option-button" id="importBtn">
|
||||
<i class="fa-solid fa-upload"></i>
|
||||
<span data-i18n="import_list">Import</span>
|
||||
</button>
|
||||
<input type="file" id="importInput" accept="application/json" hidden />
|
||||
<button class="option-button" id="exportBtn">
|
||||
<i class="fa-solid fa-download"></i>
|
||||
<span data-i18n="export_list">Export</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -8,7 +8,6 @@ class BackgroundService {
|
||||
private initialize(): void {
|
||||
this.setupTabUpdateListener();
|
||||
this.setupInstallListener();
|
||||
this.setupContextMenu();
|
||||
}
|
||||
|
||||
private setupTabUpdateListener(): void {
|
||||
@@ -30,21 +29,6 @@ class BackgroundService {
|
||||
if (!data.exceptionsList) {
|
||||
await StorageService.update('exceptionsList', []);
|
||||
}
|
||||
chrome.contextMenus.removeAll(() => {
|
||||
chrome.contextMenus.create({
|
||||
id: 'manage-lists',
|
||||
title: 'Manage Lists',
|
||||
contexts: ['action']
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
private setupContextMenu(): void {
|
||||
chrome.contextMenus.onClicked.addListener(async (info) => {
|
||||
if (info.menuItemId === 'manage-lists') {
|
||||
await chrome.tabs.create({ url: chrome.runtime.getURL('list-manager/list-manager.html') });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,40 +0,0 @@
|
||||
import { ListManagerController } from './ListManagerController.js';
|
||||
|
||||
function localizePage(): void {
|
||||
const elements = document.querySelectorAll('[data-i18n]');
|
||||
elements.forEach(element => {
|
||||
const message = (element as HTMLElement).dataset.i18n!;
|
||||
const localizedText = chrome.i18n.getMessage(message);
|
||||
if (localizedText) {
|
||||
if ((element.tagName === 'INPUT' || element.tagName === 'TEXTAREA') && (element as HTMLInputElement).hasAttribute('placeholder')) {
|
||||
(element as HTMLInputElement).placeholder = localizedText;
|
||||
} else {
|
||||
element.textContent = localizedText;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
const titleElements = document.querySelectorAll('[data-i18n-title]');
|
||||
titleElements.forEach(element => {
|
||||
const key = element.getAttribute('data-i18n-title');
|
||||
if (key) {
|
||||
const translation = chrome.i18n.getMessage(key);
|
||||
if (translation) {
|
||||
element.setAttribute('title', translation);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
const savedTheme = localStorage.getItem('theme');
|
||||
if (savedTheme === 'light') {
|
||||
document.documentElement.classList.add('light');
|
||||
} else {
|
||||
document.documentElement.classList.add('dark');
|
||||
}
|
||||
|
||||
document.addEventListener('DOMContentLoaded', async () => {
|
||||
localizePage();
|
||||
const controller = new ListManagerController();
|
||||
await controller.initialize();
|
||||
});
|
||||
@@ -1,4 +1,4 @@
|
||||
import { HighlightList, HighlightWord, ExportData, HighlightInfo } from '../types.js';
|
||||
import { HighlightList, HighlightWord, HighlightInfo } from '../types.js';
|
||||
import { StorageService } from '../services/StorageService.js';
|
||||
import { MessageService } from '../services/MessageService.js';
|
||||
import { DOMUtils } from '../utils/DOMUtils.js';
|
||||
@@ -213,11 +213,6 @@ export class PopupController {
|
||||
}
|
||||
});
|
||||
|
||||
// Manage lists
|
||||
document.getElementById('manageListsBtn')?.addEventListener('click', () => {
|
||||
void this.openListManager();
|
||||
});
|
||||
|
||||
// Color picker text inputs sync
|
||||
const listBg = document.getElementById('listBg') as HTMLInputElement;
|
||||
const listBgText = document.getElementById('listBgText') as HTMLInputElement;
|
||||
@@ -270,7 +265,6 @@ export class PopupController {
|
||||
});
|
||||
|
||||
this.setupWordListEvents(wordList);
|
||||
this.setupWordSelection();
|
||||
|
||||
wordSearch.addEventListener('input', (e) => {
|
||||
this.wordSearchQuery = (e.target as HTMLInputElement).value;
|
||||
@@ -446,20 +440,53 @@ export class PopupController {
|
||||
input.select();
|
||||
}
|
||||
|
||||
/** Effective selection for menu actions: multiple selected ? those indices : [wordIndex]. */
|
||||
private getEffectiveSelectionForMenu(wordIndex: number): number[] {
|
||||
if (this.selectedCheckboxes.size > 1 && this.selectedCheckboxes.has(wordIndex)) {
|
||||
return Array.from(this.selectedCheckboxes);
|
||||
}
|
||||
return [wordIndex];
|
||||
}
|
||||
|
||||
private openWordItemMenu(wordIndex: number, buttonEl: HTMLElement): void {
|
||||
const dropdown = document.getElementById('wordItemMenuDropdown');
|
||||
if (!dropdown) return;
|
||||
|
||||
this.closeWordItemMenu();
|
||||
|
||||
const effectiveIndices = this.getEffectiveSelectionForMenu(wordIndex);
|
||||
const isMultiple = effectiveIndices.length > 1;
|
||||
|
||||
const rect = buttonEl.getBoundingClientRect();
|
||||
const padding = 8;
|
||||
dropdown.style.left = `${rect.left}px`;
|
||||
dropdown.style.top = `${rect.bottom + 4}px`;
|
||||
dropdown.style.right = '';
|
||||
|
||||
const moveLabel = chrome.i18n.getMessage('move_to_list') || 'Move to list';
|
||||
const copyLabel = chrome.i18n.getMessage('copy_to_list') || 'Copy to list';
|
||||
const moveLabel = isMultiple
|
||||
? (chrome.i18n.getMessage('move_selected') || 'Move selected')
|
||||
: (chrome.i18n.getMessage('move_to_list') || 'Move to list');
|
||||
const copyLabel = isMultiple
|
||||
? (chrome.i18n.getMessage('copy_selected') || 'Copy selected')
|
||||
: (chrome.i18n.getMessage('copy_to_list') || 'Copy to list');
|
||||
const enableSelectedLabel = chrome.i18n.getMessage('enable_selected') || 'Enable selected';
|
||||
const disableSelectedLabel = chrome.i18n.getMessage('disable_selected') || 'Disable selected';
|
||||
const deleteLabel = isMultiple
|
||||
? (chrome.i18n.getMessage('delete_selected') || 'Delete selected')
|
||||
: (chrome.i18n.getMessage('delete_selected') || 'Delete');
|
||||
|
||||
const enableDisableItems = isMultiple
|
||||
? `
|
||||
<button type="button" class="word-item-menu-item" data-action="enable">
|
||||
<i class="fa-solid fa-eye"></i>
|
||||
<span>${DOMUtils.escapeHtml(enableSelectedLabel)}</span>
|
||||
</button>
|
||||
<button type="button" class="word-item-menu-item" data-action="disable">
|
||||
<i class="fa-solid fa-eye-slash"></i>
|
||||
<span>${DOMUtils.escapeHtml(disableSelectedLabel)}</span>
|
||||
</button>
|
||||
`
|
||||
: '';
|
||||
|
||||
dropdown.innerHTML = `
|
||||
<button type="button" class="word-item-menu-item" data-action="move">
|
||||
@@ -470,6 +497,11 @@ export class PopupController {
|
||||
<i class="fa-solid fa-copy"></i>
|
||||
<span>${DOMUtils.escapeHtml(copyLabel)}</span>
|
||||
</button>
|
||||
${enableDisableItems}
|
||||
<button type="button" class="word-item-menu-item danger" data-action="delete">
|
||||
<i class="fa-solid fa-trash"></i>
|
||||
<span>${DOMUtils.escapeHtml(deleteLabel)}</span>
|
||||
</button>
|
||||
`;
|
||||
|
||||
dropdown.querySelectorAll('.word-item-menu-item').forEach(item => {
|
||||
@@ -477,14 +509,33 @@ export class PopupController {
|
||||
e.stopPropagation();
|
||||
const action = (item as HTMLElement).dataset.action;
|
||||
if (action === 'move') {
|
||||
this.showWordMenuListPicker(wordIndex, false);
|
||||
this.showWordMenuListPickerForIndices(effectiveIndices, false);
|
||||
} else if (action === 'copy') {
|
||||
this.showWordMenuListPicker(wordIndex, true);
|
||||
this.showWordMenuListPickerForIndices(effectiveIndices, true);
|
||||
} else if (action === 'enable') {
|
||||
this.setSelectedWordsActive(effectiveIndices, true);
|
||||
this.closeWordItemMenu();
|
||||
this.save();
|
||||
this.renderWords();
|
||||
} else if (action === 'disable') {
|
||||
this.setSelectedWordsActive(effectiveIndices, false);
|
||||
this.closeWordItemMenu();
|
||||
this.save();
|
||||
this.renderWords();
|
||||
} else if (action === 'delete') {
|
||||
if (confirm(chrome.i18n.getMessage('confirm_delete_words') || 'Delete selected words?')) {
|
||||
this.deleteWordsByIndices(effectiveIndices);
|
||||
this.selectedCheckboxes.clear();
|
||||
this.closeWordItemMenu();
|
||||
this.save();
|
||||
this.renderWords();
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
this.wordMenuOpenForIndex = wordIndex;
|
||||
this.wordMenuCopyOnly = false;
|
||||
dropdown.classList.add('open');
|
||||
dropdown.setAttribute('aria-hidden', 'false');
|
||||
|
||||
@@ -520,12 +571,11 @@ export class PopupController {
|
||||
setTimeout(() => document.addEventListener('click', closeHandler), 0);
|
||||
}
|
||||
|
||||
private showWordMenuListPicker(wordIndex: number, copyOnly: boolean): void {
|
||||
private showWordMenuListPickerForIndices(indices: number[], copyOnly: boolean): void {
|
||||
const dropdown = document.getElementById('wordItemMenuDropdown');
|
||||
if (!dropdown || this.wordMenuOpenForIndex === null) return;
|
||||
|
||||
this.wordMenuCopyOnly = copyOnly;
|
||||
const currentList = this.lists[this.currentListIndex];
|
||||
const otherLists = this.lists
|
||||
.map((list, index) => ({ list, index }))
|
||||
.filter(({ index }) => index !== this.currentListIndex);
|
||||
@@ -553,9 +603,9 @@ export class PopupController {
|
||||
const targetIndex = Number((item as HTMLElement).dataset.targetIndex);
|
||||
if (Number.isNaN(targetIndex)) return;
|
||||
if (this.wordMenuCopyOnly) {
|
||||
this.copyWordToOtherList(wordIndex, targetIndex);
|
||||
this.copyWordsToOtherList(indices, targetIndex);
|
||||
} else {
|
||||
this.moveWordToOtherList(wordIndex, targetIndex);
|
||||
this.moveWordsToOtherList(indices, targetIndex);
|
||||
}
|
||||
this.closeWordItemMenu();
|
||||
this.save();
|
||||
@@ -565,6 +615,42 @@ export class PopupController {
|
||||
});
|
||||
}
|
||||
|
||||
private setSelectedWordsActive(indices: number[], active: boolean): void {
|
||||
const list = this.lists[this.currentListIndex];
|
||||
if (!list) return;
|
||||
indices.forEach(index => {
|
||||
const word = list.words[index];
|
||||
if (word) word.active = active;
|
||||
});
|
||||
}
|
||||
|
||||
private deleteWordsByIndices(indices: number[]): void {
|
||||
const list = this.lists[this.currentListIndex];
|
||||
if (!list) return;
|
||||
const toDelete = new Set(indices);
|
||||
this.lists[this.currentListIndex].words = list.words.filter((_, i) => !toDelete.has(i));
|
||||
}
|
||||
|
||||
private moveWordsToOtherList(indices: number[], targetListIndex: number): void {
|
||||
const list = this.lists[this.currentListIndex];
|
||||
const targetList = this.lists[targetListIndex];
|
||||
if (!list || !targetList) return;
|
||||
const sorted = [...indices].sort((a, b) => b - a);
|
||||
const wordsToMove = sorted.map(i => list.words[i]).filter(Boolean);
|
||||
sorted.forEach(i => list.words.splice(i, 1));
|
||||
targetList.words.push(...wordsToMove);
|
||||
}
|
||||
|
||||
private copyWordsToOtherList(indices: number[], targetListIndex: number): void {
|
||||
const list = this.lists[this.currentListIndex];
|
||||
const targetList = this.lists[targetListIndex];
|
||||
if (!list || !targetList) return;
|
||||
indices.forEach(index => {
|
||||
const word = list.words[index];
|
||||
if (word) targetList.words.push({ ...word });
|
||||
});
|
||||
}
|
||||
|
||||
private closeWordItemMenu(): void {
|
||||
const dropdown = document.getElementById('wordItemMenuDropdown');
|
||||
if (dropdown) {
|
||||
@@ -578,67 +664,6 @@ export class PopupController {
|
||||
}
|
||||
}
|
||||
|
||||
private moveWordToOtherList(wordIndex: number, targetListIndex: number): void {
|
||||
const list = this.lists[this.currentListIndex];
|
||||
const targetList = this.lists[targetListIndex];
|
||||
const word = list.words[wordIndex];
|
||||
if (!word || !targetList) return;
|
||||
targetList.words.push({ ...word });
|
||||
list.words.splice(wordIndex, 1);
|
||||
}
|
||||
|
||||
private copyWordToOtherList(wordIndex: number, targetListIndex: number): void {
|
||||
const list = this.lists[this.currentListIndex];
|
||||
const targetList = this.lists[targetListIndex];
|
||||
const word = list.words[wordIndex];
|
||||
if (!word || !targetList) return;
|
||||
targetList.words.push({ ...word });
|
||||
}
|
||||
|
||||
private setupWordSelection(): void {
|
||||
document.getElementById('selectAllBtn')?.addEventListener('click', () => {
|
||||
const list = this.lists[this.currentListIndex];
|
||||
list.words.forEach((_, index) => {
|
||||
this.selectedCheckboxes.add(index);
|
||||
});
|
||||
this.renderWords();
|
||||
});
|
||||
|
||||
document.getElementById('deselectAllBtn')?.addEventListener('click', () => {
|
||||
this.selectedCheckboxes.clear();
|
||||
this.renderWords();
|
||||
});
|
||||
|
||||
document.getElementById('deleteSelectedBtn')?.addEventListener('click', () => {
|
||||
if (confirm(chrome.i18n.getMessage('confirm_delete_words') || 'Delete selected words?')) {
|
||||
const list = this.lists[this.currentListIndex];
|
||||
const toDelete = Array.from(this.selectedCheckboxes);
|
||||
this.lists[this.currentListIndex].words = list.words.filter((_, i) => !toDelete.includes(i));
|
||||
this.selectedCheckboxes.clear();
|
||||
this.save();
|
||||
this.renderWords();
|
||||
}
|
||||
});
|
||||
|
||||
document.getElementById('enableSelectedBtn')?.addEventListener('click', () => {
|
||||
const list = this.lists[this.currentListIndex];
|
||||
this.selectedCheckboxes.forEach(index => {
|
||||
list.words[index].active = true;
|
||||
});
|
||||
this.save();
|
||||
this.renderWords();
|
||||
});
|
||||
|
||||
document.getElementById('disableSelectedBtn')?.addEventListener('click', () => {
|
||||
const list = this.lists[this.currentListIndex];
|
||||
this.selectedCheckboxes.forEach(index => {
|
||||
list.words[index].active = false;
|
||||
});
|
||||
this.save();
|
||||
this.renderWords();
|
||||
});
|
||||
}
|
||||
|
||||
private setupSettings(): void {
|
||||
const globalToggle = document.getElementById('globalHighlightToggle') as HTMLInputElement;
|
||||
const matchCase = document.getElementById('matchCase') as HTMLInputElement;
|
||||
@@ -824,27 +849,26 @@ export class PopupController {
|
||||
}
|
||||
|
||||
private setupImportExport(): void {
|
||||
const importInput = document.getElementById('importInput') as HTMLInputElement;
|
||||
const importListInput = document.getElementById('importListInput') as HTMLInputElement;
|
||||
|
||||
document.getElementById('exportBtn')?.addEventListener('click', () => {
|
||||
const exportData: ExportData = {
|
||||
lists: this.lists,
|
||||
exceptionsList: this.exceptionsList
|
||||
};
|
||||
const blob = new Blob([JSON.stringify(exportData, null, 2)], { type: 'application/json' });
|
||||
document.getElementById('exportListBtn')?.addEventListener('click', () => {
|
||||
const list = this.lists[this.currentListIndex];
|
||||
if (!list) return;
|
||||
const blob = new Blob([JSON.stringify(list, null, 2)], { type: 'application/json' });
|
||||
const url = URL.createObjectURL(blob);
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
a.download = 'highlight-lists.json';
|
||||
const safeName = (list.name || 'list').replace(/[^a-zA-Z0-9-_]/g, '-');
|
||||
a.download = `${safeName}.json`;
|
||||
a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
});
|
||||
|
||||
document.getElementById('importBtn')?.addEventListener('click', () => {
|
||||
importInput.click();
|
||||
document.getElementById('importListBtn')?.addEventListener('click', () => {
|
||||
importListInput?.click();
|
||||
});
|
||||
|
||||
importInput.addEventListener('change', (e) => {
|
||||
importListInput?.addEventListener('change', (e) => {
|
||||
const file = (e.target as HTMLInputElement).files?.[0];
|
||||
if (!file) return;
|
||||
|
||||
@@ -852,30 +876,52 @@ export class PopupController {
|
||||
reader.onload = (e) => {
|
||||
try {
|
||||
const data = JSON.parse(e.target?.result as string);
|
||||
const toAdd: HighlightList[] = [];
|
||||
|
||||
if (Array.isArray(data)) {
|
||||
this.lists = data;
|
||||
data.forEach((item: unknown) => {
|
||||
if (this.isValidList(item)) toAdd.push(item as HighlightList);
|
||||
});
|
||||
} else if (data && typeof data === 'object') {
|
||||
if (Array.isArray(data.lists)) {
|
||||
this.lists = data.lists;
|
||||
}
|
||||
if (Array.isArray(data.exceptionsList)) {
|
||||
this.exceptionsList = data.exceptionsList;
|
||||
data.lists.forEach((item: unknown) => {
|
||||
if (this.isValidList(item)) toAdd.push(item as HighlightList);
|
||||
});
|
||||
} else if (this.isValidList(data)) {
|
||||
toAdd.push(data as HighlightList);
|
||||
}
|
||||
}
|
||||
|
||||
this.currentListIndex = 0;
|
||||
this.updateExceptionButton();
|
||||
this.renderExceptions();
|
||||
if (toAdd.length === 0) {
|
||||
alert(chrome.i18n.getMessage('invalid_import_format') || 'Invalid list format. Please select a valid list file.');
|
||||
return;
|
||||
}
|
||||
const baseId = Date.now();
|
||||
toAdd.forEach((l, i) => {
|
||||
this.lists.push({ ...l, id: baseId + i });
|
||||
});
|
||||
this.save();
|
||||
this.renderLists();
|
||||
} catch (err) {
|
||||
alert(chrome.i18n.getMessage('invalid_json_error') + ': ' + (err as Error).message);
|
||||
}
|
||||
};
|
||||
reader.readAsText(file);
|
||||
importListInput.value = '';
|
||||
});
|
||||
}
|
||||
|
||||
private isValidList(obj: unknown): obj is HighlightList {
|
||||
if (!obj || typeof obj !== 'object') return false;
|
||||
const o = obj as Record<string, unknown>;
|
||||
return (
|
||||
typeof o.name === 'string' &&
|
||||
Array.isArray(o.words) &&
|
||||
(typeof o.background === 'string' || typeof o.background === 'undefined') &&
|
||||
(typeof o.foreground === 'string' || typeof o.foreground === 'undefined')
|
||||
);
|
||||
}
|
||||
|
||||
private setupTheme(): void {
|
||||
const themeToggle = document.getElementById('themeToggle') as HTMLInputElement;
|
||||
|
||||
@@ -941,10 +987,6 @@ export class PopupController {
|
||||
MessageService.sendToAllTabs({ type: 'WORD_LIST_UPDATED' });
|
||||
}
|
||||
|
||||
private async openListManager(): Promise<void> {
|
||||
await chrome.tabs.create({ url: chrome.runtime.getURL('list-manager/list-manager.html') });
|
||||
}
|
||||
|
||||
private setupStorageSync(): void {
|
||||
chrome.storage.onChanged.addListener((changes, areaName) => {
|
||||
if (areaName !== 'local') return;
|
||||
|
||||
Reference in New Issue
Block a user