Kanzi 0.6.19: kanzi.xpi + sharp black unified + pagination 50
- dist/kanzi.xpi (copy of kindle-zotero-importer.xpi) for Release v0.6.19 alongside old name for auto-update compat - plugin/manager.html: sharp black please give me money+ (0 radius) centred, pagination 50 for Integrated/Conflicts/Mappings (Prev/Next, 25/50/100/200/500/All, Expand 50) - README centred flat-square 111111 black sharp badge - 0.6.18 double [r] fix + 0.6.19 incremental recolours already in main
This commit is contained in:
parent
8e8bd31fc8
commit
d9062d9a33
5 changed files with 120 additions and 15 deletions
|
|
@ -13,7 +13,7 @@ Import Kindle `My Clippings.txt` highlights into Zotero as native annotations, d
|
||||||
|
|
||||||
# Install
|
# Install
|
||||||
|
|
||||||
1. Download `kindle-zotero-importer.xpi` from [Releases](../../releases) (latest `0.6.18`, or `0.6.17-beta` for preview).
|
1. Download `kindle-zotero-importer.xpi` from [Releases](../../releases) (latest `0.6.19`, or `0.6.18-beta` for preview).
|
||||||
2. In Zotero: `Tools` → `Plugins` → `gear` → `Install Plugin From File…` → pick the `.xpi` → restart Zotero.
|
2. In Zotero: `Tools` → `Plugins` → `gear` → `Install Plugin From File…` → pick the `.xpi` → restart Zotero.
|
||||||
3. `Tools` → `Kanzi…` to open the manager.
|
3. `Tools` → `Kanzi…` to open the manager.
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -103,6 +103,12 @@
|
||||||
startedAt: null,
|
startedAt: null,
|
||||||
timer: null,
|
timer: null,
|
||||||
lastClippingsPath: null,
|
lastClippingsPath: null,
|
||||||
|
integratedPage: 0,
|
||||||
|
integratedPageSize: 50,
|
||||||
|
conflictsPage: 0,
|
||||||
|
conflictsPageSize: 50,
|
||||||
|
mappingsPage: 0,
|
||||||
|
mappingsPageSize: 50,
|
||||||
|
|
||||||
initSafe() {
|
initSafe() {
|
||||||
try {
|
try {
|
||||||
|
|
@ -623,7 +629,7 @@
|
||||||
return map;
|
return map;
|
||||||
},
|
},
|
||||||
|
|
||||||
refreshIntegrated() {
|
refreshIntegrated(resetPage = false) {
|
||||||
const tbody = document.getElementById('integrated-rows');
|
const tbody = document.getElementById('integrated-rows');
|
||||||
const countEl = document.getElementById('integrated-count');
|
const countEl = document.getElementById('integrated-count');
|
||||||
if (!tbody) return;
|
if (!tbody) return;
|
||||||
|
|
@ -632,8 +638,83 @@
|
||||||
const all = this.getIntegratedHighlights();
|
const all = this.getIntegratedHighlights();
|
||||||
const dateMap = this.buildClippingDateMap();
|
const dateMap = this.buildClippingDateMap();
|
||||||
const filtered = needle ? all.filter(a => `${a.clipping_title} ${a.annotation?.text || ''} ${a.citation_key || ''} ${a.annotation?.pageLabel || ''} ${a.clipping_added_on_iso || ''} ${a.integrated_at || ''}`.toLowerCase().includes(needle)) : all;
|
const filtered = needle ? all.filter(a => `${a.clipping_title} ${a.annotation?.text || ''} ${a.citation_key || ''} ${a.annotation?.pageLabel || ''} ${a.clipping_added_on_iso || ''} ${a.integrated_at || ''}`.toLowerCase().includes(needle)) : all;
|
||||||
const toShow = filtered.slice(0, 400);
|
if (resetPage) this.integratedPage = 0;
|
||||||
if (countEl) countEl.textContent = `${filtered.length} of ${all.length} shown (first 400)`;
|
const totalPages = Math.max(1, Math.ceil(filtered.length / this.integratedPageSize));
|
||||||
|
if (this.integratedPage >= totalPages) this.integratedPage = totalPages - 1;
|
||||||
|
const start = this.integratedPage * this.integratedPageSize;
|
||||||
|
const toShow = filtered.slice(start, start + this.integratedPageSize);
|
||||||
|
if (countEl) countEl.textContent = `${filtered.length} of ${all.length} — page ${this.integratedPage + 1}/${totalPages} (${this.integratedPageSize} per page)`;
|
||||||
|
// pagination controls
|
||||||
|
let pag = document.getElementById('integrated-pagination');
|
||||||
|
if (!pag) {
|
||||||
|
pag = document.createElement('div');
|
||||||
|
pag.id = 'integrated-pagination';
|
||||||
|
pag.style.display = 'flex';
|
||||||
|
pag.style.justifyContent = 'space-between';
|
||||||
|
pag.style.alignItems = 'center';
|
||||||
|
pag.style.margin = '8px 0';
|
||||||
|
pag.style.gap = '8px';
|
||||||
|
pag.style.flexWrap = 'wrap';
|
||||||
|
tbody.parentElement.parentElement.appendChild(pag);
|
||||||
|
}
|
||||||
|
pag.textContent = '';
|
||||||
|
const mkBtn = (label, disabled, onClick) => {
|
||||||
|
const b = document.createElement('button');
|
||||||
|
b.textContent = label;
|
||||||
|
b.disabled = disabled;
|
||||||
|
b.style.padding = '4px 8px';
|
||||||
|
b.style.border = '1px solid var(--line)';
|
||||||
|
b.style.background = disabled ? 'var(--panel-soft)' : 'var(--panel)';
|
||||||
|
b.style.borderRadius = 'var(--radius)';
|
||||||
|
b.style.cursor = disabled ? 'not-allowed' : 'pointer';
|
||||||
|
b.style.fontSize = '11px';
|
||||||
|
if (!disabled) b.addEventListener('click', onClick);
|
||||||
|
return b;
|
||||||
|
};
|
||||||
|
const left = document.createElement('div');
|
||||||
|
left.style.display = 'flex';
|
||||||
|
left.style.gap = '4px';
|
||||||
|
left.appendChild(mkBtn('‹ Prev', this.integratedPage === 0, () => { this.integratedPage--; this.refreshIntegrated(); }));
|
||||||
|
left.appendChild(mkBtn('Next ›', this.integratedPage >= totalPages - 1, () => { this.integratedPage++; this.refreshIntegrated(); }));
|
||||||
|
const mid = document.createElement('span');
|
||||||
|
mid.className = 'muted';
|
||||||
|
mid.textContent = `Page ${this.integratedPage + 1} of ${totalPages}`;
|
||||||
|
left.appendChild(mid);
|
||||||
|
pag.appendChild(left);
|
||||||
|
const right = document.createElement('div');
|
||||||
|
right.style.display = 'flex';
|
||||||
|
right.style.gap = '6px';
|
||||||
|
right.style.alignItems = 'center';
|
||||||
|
const sel = document.createElement('select');
|
||||||
|
sel.style.padding = '4px';
|
||||||
|
sel.style.border = '1px solid var(--line)';
|
||||||
|
sel.style.borderRadius = 'var(--radius)';
|
||||||
|
sel.style.fontSize = '11px';
|
||||||
|
for (const n of [25, 50, 100, 200, 500]) {
|
||||||
|
const opt = document.createElement('option');
|
||||||
|
opt.value = n;
|
||||||
|
opt.textContent = n + ' per page';
|
||||||
|
if (n === this.integratedPageSize) opt.selected = true;
|
||||||
|
sel.appendChild(opt);
|
||||||
|
}
|
||||||
|
const optAll = document.createElement('option');
|
||||||
|
optAll.value = filtered.length || 500;
|
||||||
|
optAll.textContent = 'Show all';
|
||||||
|
sel.appendChild(optAll);
|
||||||
|
sel.addEventListener('change', () => { this.integratedPageSize = parseInt(sel.value, 10); this.integratedPage = 0; this.refreshIntegrated(); });
|
||||||
|
right.appendChild(sel);
|
||||||
|
const expand = document.createElement('button');
|
||||||
|
expand.textContent = 'Expand 50 →';
|
||||||
|
expand.title = 'Show next 50';
|
||||||
|
expand.style.padding = '4px 8px';
|
||||||
|
expand.style.border = '1px solid var(--line)';
|
||||||
|
expand.style.background = 'var(--panel)';
|
||||||
|
expand.style.borderRadius = 'var(--radius)';
|
||||||
|
expand.style.cursor = 'pointer';
|
||||||
|
expand.style.fontSize = '11px';
|
||||||
|
expand.addEventListener('click', () => { this.integratedPageSize += 50; this.refreshIntegrated(); });
|
||||||
|
right.appendChild(expand);
|
||||||
|
pag.appendChild(right);
|
||||||
if (!toShow.length) {
|
if (!toShow.length) {
|
||||||
const tr = document.createElement('tr');
|
const tr = document.createElement('tr');
|
||||||
const td = document.createElement('td');
|
const td = document.createElement('td');
|
||||||
|
|
@ -984,7 +1065,7 @@
|
||||||
iSearch.placeholder = 'Filter integrated highlights by title, text, citekey...';
|
iSearch.placeholder = 'Filter integrated highlights by title, text, citekey...';
|
||||||
iSearch.style.width = '320px';
|
iSearch.style.width = '320px';
|
||||||
iSearch.style.maxWidth = '50%';
|
iSearch.style.maxWidth = '50%';
|
||||||
iSearch.addEventListener('input', () => this.refreshIntegrated());
|
iSearch.addEventListener('input', () => this.refreshIntegrated(true));
|
||||||
iSearchWrap.appendChild(iSearch);
|
iSearchWrap.appendChild(iSearch);
|
||||||
integratedTab.appendChild(iSearchWrap);
|
integratedTab.appendChild(iSearchWrap);
|
||||||
const iCount = document.createElement('div');
|
const iCount = document.createElement('div');
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"manifest_version": 2,
|
"manifest_version": 2,
|
||||||
"name": "Kanzi",
|
"name": "Kanzi",
|
||||||
"version": "0.6.18",
|
"version": "0.6.19",
|
||||||
"description": "Kindle annotations to Zotero — My Clippings.txt → native annotations.",
|
"description": "Kindle annotations to Zotero — My Clippings.txt → native annotations.",
|
||||||
"homepage_url": "https://github.com/UtkuBilenDemir/kindle-zotero_importer",
|
"homepage_url": "https://github.com/UtkuBilenDemir/kindle-zotero_importer",
|
||||||
"author": "Utku Bilen Demir",
|
"author": "Utku Bilen Demir",
|
||||||
|
|
|
||||||
|
|
@ -416,17 +416,19 @@ def main(argv: list[str] | None = None) -> int:
|
||||||
if c.id in prev_integrated_ids and c.title in _ov_for_inc:
|
if c.id in prev_integrated_ids and c.title in _ov_for_inc:
|
||||||
to_process_ids.add(c.id)
|
to_process_ids.add(c.id)
|
||||||
# Also re-queue highlights whose bracket colour would change the annotation
|
# Also re-queue highlights whose bracket colour would change the annotation
|
||||||
# (so you can recolour a past highlight by adding [r]/[o] etc. to its note or highlight text)
|
# (so you can recolour a past highlight by adding [r]/[o] etc. to its note or highlight text,
|
||||||
|
# and also fix old double-bracket comments like "[r] note" + "note")
|
||||||
if colour_map:
|
if colour_map:
|
||||||
import re as _re
|
import re as _re
|
||||||
# Build map of new notes by title for quick lookup
|
# Build map of notes by title for quick lookup (for bracket on note)
|
||||||
new_notes_by_title: dict[str, list] = {}
|
notes_by_title: dict[str, list] = {}
|
||||||
for n in new_clippings_list:
|
for n in new_clippings_list:
|
||||||
if n.kind == "note" and n.id not in prev_integrated_ids:
|
if n.kind == "note":
|
||||||
# new note (not yet integrated) — check if it has a bracket colour
|
|
||||||
m = _re.match(r"^\s*\[([^\]]+)\]\s*", n.text or "")
|
m = _re.match(r"^\s*\[([^\]]+)\]\s*", n.text or "")
|
||||||
if m and m.group(1).strip().lower() in {k.lower() for k in colour_map.keys()}:
|
if m and m.group(1).strip().lower() in {k.lower() for k in colour_map.keys()}:
|
||||||
new_notes_by_title.setdefault(n.title, []).append(n)
|
notes_by_title.setdefault(n.title, []).append(n)
|
||||||
|
# also check for double-bracket case: note text without bracket but highlight already has [r] in Zotero
|
||||||
|
# For that, we need to re-queue if existing Zotero comment contains "[r]"
|
||||||
for c in new_clippings_list:
|
for c in new_clippings_list:
|
||||||
if c.id not in prev_integrated_ids:
|
if c.id not in prev_integrated_ids:
|
||||||
continue
|
continue
|
||||||
|
|
@ -439,10 +441,23 @@ def main(argv: list[str] | None = None) -> int:
|
||||||
if m and m.group(1).strip().lower() in {k.lower() for k in colour_map.keys()}:
|
if m and m.group(1).strip().lower() in {k.lower() for k in colour_map.keys()}:
|
||||||
has_bracket = True
|
has_bracket = True
|
||||||
break
|
break
|
||||||
# also check if a *new* note for same title would attach to this highlight (by location/page proximity)
|
# also check if any note for same title has bracket (new or old) — for already integrated highlights,
|
||||||
# Approximate: any new note with same title is considered for re-queue (conservative, ensures recolours)
|
# the note that would be attached is in new_clippings_list; check all notes for title
|
||||||
if not has_bracket and c.title in new_notes_by_title:
|
if not has_bracket and c.title in notes_by_title:
|
||||||
has_bracket = True
|
has_bracket = True
|
||||||
|
# also check if previous final plan's annotation for this clipping had a bracket comment that is now stripped
|
||||||
|
# (handles the double "[r] note" + "note" case)
|
||||||
|
if not has_bracket and prev_final_plan:
|
||||||
|
for ann in prev_final_plan.get("annotations", []):
|
||||||
|
if ann.get("clipping_id") == c.id:
|
||||||
|
prev_comment = ann.get("annotation", {}).get("comment") or ""
|
||||||
|
# if prev had "[r] note" and new would be "note", they differ
|
||||||
|
for part in prev_comment.split("\n\n"):
|
||||||
|
m = _re.match(r"^\s*\[([^\]]+)\]\s*", part.strip())
|
||||||
|
if m and m.group(1).strip().lower() in {k.lower() for k in colour_map.keys()}:
|
||||||
|
has_bracket = True
|
||||||
|
break
|
||||||
|
break
|
||||||
if has_bracket:
|
if has_bracket:
|
||||||
to_process_ids.add(c.id)
|
to_process_ids.add(c.id)
|
||||||
# If colourMap itself changed since last run, re-queue all prev integrated (so Settings change recolours)
|
# If colourMap itself changed since last run, re-queue all prev integrated (so Settings change recolours)
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,15 @@
|
||||||
"addons": {
|
"addons": {
|
||||||
"kindlezoteroimporter@utkubilen.de": {
|
"kindlezoteroimporter@utkubilen.de": {
|
||||||
"updates": [
|
"updates": [
|
||||||
|
{
|
||||||
|
"version": "0.6.19",
|
||||||
|
"update_link": "https://github.com/UtkuBilenDemir/kindle-zotero_importer/releases/download/v0.6.19/kindle-zotero-importer.xpi",
|
||||||
|
"applications": {
|
||||||
|
"zotero": {
|
||||||
|
"strict_min_version": "6.999"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"version": "0.6.18",
|
"version": "0.6.18",
|
||||||
"update_link": "https://github.com/UtkuBilenDemir/kindle-zotero_importer/releases/download/v0.6.18/kindle-zotero-importer.xpi",
|
"update_link": "https://github.com/UtkuBilenDemir/kindle-zotero_importer/releases/download/v0.6.18/kindle-zotero-importer.xpi",
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue