Commit graph

1698 commits

Author SHA1 Message Date
Dan Stillman
2bc0c4861c Fix changed object data not being passed in notifier extraData
Which I apparently broke a decade ago in afe0412c5

And add support for 'deleted' and 'tags', which now use a different
mechanism
2025-05-12 23:36:58 -04:00
Tom Najdek
ed24cce4a1
Fix custom trash header persisting after items are restored or deleted. Fixes #5279.
This was due to a logic bug in `getCurrentPane()`, which returned the wrong pane, causing the incorrect one to be updated.
2025-05-12 17:28:11 +02:00
Abe Jellinek
9ed3f6363c Add test for synchronous Zotero.done() call
No one should do this nowadays, but EM still does.

zotero/translate@c858ce9613
2025-05-09 14:42:06 -04:00
abaevbog
e625c0009e
Fixes to annotation row behavior in trash (#5266)
- right-click on annotation rows in trash will display
  "Delete Permanently" option, instead of an empty menu
- in trash and other non-editable collection rows, disable
  "Add Note from Annotations" button in itemPane header
- remove ability to add tags to annotations and other
  items by dragging them into tag selector from trash
- remove ability to add items to collections by
  dragging them into collection tree from trash
- fix attachment row being removed from trash if
  its child annotation row is erased

Also:
- fix contextPane in reader tab being editable for item in trash
- fix title being editable in attachmentBox for item in trash

Fixes: #5261
2025-05-09 02:05:53 -04:00
Dan Stillman
f539d7439d Fix test failure after #5263 2025-05-09 01:52:26 -04:00
Dan Stillman
c1cea87743 Disable advanced search test
Completely, not just in CI, since it's failing for me locally
2025-05-09 01:41:05 -04:00
Abe Jellinek
3102b6b67a
Always show item/context pane toggle (#5263) 2025-05-09 01:27:20 -04:00
abaevbog
929bacaac7
Fix unintentional title transfer between attachments on item switch (#5245)
Also added similar test for item details table

Fixes #5244
2025-05-03 01:34:06 -04:00
abaevbog
3fc8e4d02e
Fix leftover annotation rows and disappearing attachment rows after drag-drop (#5248)
- collapse all rows before removing them. It makes
  sure that annotation rows will be cleaned up properly
  when an attachment row is moved into another parent.
- refactor conditionals to handle changes of parent
  regardless of whether the item is a container
  (attachment with annotations) or not (a note).
- added tests for itemTree's handling of changing the
  parent of attachments and notes, as well as ensuring
  there are no leftover annotation rows in Unfiled Items.

Fixes: zotero#5246
2025-05-03 01:30:50 -04:00
Abe Jellinek
230e3d8065
Skip invalid relative path when changing LABD (#5239) 2025-04-30 01:06:40 -04:00
abaevbog
48fd23ccec
annotations showing in itemTree (#3416)
- Annotations are displayed in itemTree under their file attachments
  on a third level. The annotation spans the entire row.
- The title is constructed on the go. When possible, it
  includes annotation quote and comment as pseudo-columns
  of the row. The comment occupies about twice as much space as
  the quote. Otherwise, (if there is no quote) only the annotation
  comment
  is included as the "title" part of the row
- Non-CJK segments of the quote part of the annotation row are
  italicized. CJK segments are left as is. If CJK segments are present,
  there is more padding between quote and comment parts.
- Search matches the actual attachment instead of its parent file.
- Can create child notes from annotations of the same item or
  standalone notes from annotations across different items from
  the context menu or the header button.
- When an annotation (or multiple annotations) are selected, the
  annotationItemPane component is displayed where annotations are
  grouped by their top-level item. Annotations are displayed fully,
  without having their content cut off.
- Special treatment for annotations to always prompt
  to erase the item regardless of what collectionTree row
  is selected (e.g., if a collection is selected, we
  still want one to be able to delete the annotation).
  This only applies if all selected items are annotations.
  If multiple items are selected, some annotations and
  some not, do nothing. This is until the trash is
  ready. In the future, we may send annotations to trash
- strip all HTML tags from annotation for now, until the logic to
  properly render annotation markup is copied over from the reader
  (applies to both annotation-row component and the annotation
  item rendered in the itemTree)
- Added a generalized "expandToItem" function to itemTree to
  expand all ancestors of a given item, similar to "expandToCollection"
  from collectionTree
- add annotation conditions to advanced search
- show [Image not available] if no annotation file for ink or image
  annotations
- only keep annotation-specific context menu options when some
  annotations are selected in itemTree
- enable Quick Copy of annotations from itemTree via drag-drop,
  shortcut key, or Edit → Copy Annotation
- Minor refactoring of Zotero.Annotation.toJSON() to pull out async code
  that handles ink and image annotations, so that
  Zotero.Annotation.toJSONsync() for highlight, underline, and note
  annotations does not have to be awaited. Since ink and image
  annotation don't seem to work for drag-drop Quick Copy, they are just
  skipped for now.
2025-04-28 04:10:28 -04:00
windingwind
a63cb647ff
Fix item pane test after #5214 (#5220) 2025-04-23 17:09:24 -04:00
Adomas Venčkauskas
cc87ff3af6 Remove old and unused Connector Server endpoints (#5148) 2025-04-22 09:47:58 -04:00
Adomas Venčkauskas
2cd4ba205a Update Connector Server tests (#5148) 2025-04-22 09:47:58 -04:00
Adomas Venčkauskas
d6d01f66b9 Update recognizer tests to use sinon stub pattern (#5148) 2025-04-22 09:47:58 -04:00
Adomas Venčkauskas
5e18337cc6 Simple attachment saving via Connector (instead of Zotero) (#5148) 2025-04-22 09:47:58 -04:00
Adomas Venčkauskas
d781151b9a Make server.js use mozilla httpd and support application/octet-stream (#5148) 2025-04-22 09:47:58 -04:00
Adomas Venčkauskas
67b5a0bb19 Use the bundled mozilla httpd (#5148) 2025-04-22 09:47:58 -04:00
Adomas Venčkauskas
db1c542a50 Remove unused connector server code (#5148) 2025-04-22 09:47:58 -04:00
Dan Stillman
8c7ab1eb6a Remove unnecessary DB resets in storageLocal tests 2025-04-14 04:22:16 -04:00
Dan Stillman
f616d41546 Mark locally missing files marked for upload for download instead
Z7 removed an `OS.File.open()` in `_checkForUpdatedFiles()` that would
throw on missing files and cause them to be marked for download in a
`catch`.

This likely caused the fix for #1753 not to work in Z7.
2025-04-14 04:22:16 -04:00
windingwind
0b8b4c0ff6
Draggable item pane sections (#5094) 2025-04-03 21:32:37 -04:00
Tom Najdek
fcfb6e16d0
Reword the confusing example in the #generateHTMLFromTemplate() test 2025-04-02 14:01:52 +02:00
Tom Najdek
4f03c5d360
File renaming: add support for counting creators (#5175)
Also extends the templating engine to support inequality comparisons.
2025-04-02 05:31:50 -04:00
abaevbog
f1244d824c
Remove old citation dialogs (#5177)
- removed quickFormat, insertNoteDialog, and addCitationDialog
.xhtml and .js files, since all of them are now replaced
with new citationDialog
- removed quickFormat and insertNote strings from
en-US localization files
- replaced all mentions of quickFormat in comments and
variables of integration.js and editorInstance.js with
citationDialog
- removed big-sur-specific styling for quickFormat

Closes #5046
2025-04-02 05:26:06 -04:00
abaevbog
929147b33a
citation dlg: miscellaneous followup fixes (#5095)
- last-closed -> last-used for citationDialogMode pref value
- pref label citationDialogLastClosedMode -> citationDialogLastUsedMode
- update Zotero.Prefs version. While migrating, if
integration.useClassicAddCitationDialog is true, set
integration.citationDialogLastUsedMode to 'library'
so the citation dialog opens in library mode on the first run.
If citationDialogLastClosedMode pref exists, it is
migrated to citationDialogLastUsedMode and cleared
- redone logic of extracting the locator to allow for better
detection of locators and to not rely on long regular
expressions that are hard to troubleshoot. Added tests for it.

These are the new rules for extracting locators:
- locator value can be either a set of numbers potentially
with some punctuation in between OR text surrounded with
single or double quotes
- locator labels can be typed in any of 3 formats:
full (chapter), short (chap.), or short with no
punctuation (chap)
- locator labels go before the locator values and there
may or may not be a space in between. For example,
chap.10 is the same as chap. 10.

Fixes: #5092
Fixes: #5093
2025-03-27 03:45:31 -04:00
Abe Jellinek
93b677aaf4
Fix HiddenBrowser test failures (#5134)
Wait for 'complete', not 'interactive', so we know the image has been
loaded.

And use single documentIsReady() implementation instead of copy-pasting.
2025-03-20 23:32:02 -04:00
Bogdan Abaev
4a00304925 Redesigned citation dialog (#4872)
Implemented redesigned citation dialog with library
and list modes one can switch between. This dialog is
a direct replacement of quickFormat and classic citation
dialogs.

In Library Mode:
- items table has a new + button column to add items from the
citation and rows of selected items are highlighted
- open, cited and selected items appear in a section
between the items table and bubbleInput. When there are no
matches, a message is shown.
- only top-level items are shown when citing
items and only notes/notes' parents - when adding a note
- selected items are gathered in a collapsible deck to save space.
Click on the deck will expand it. All selected items can be
added via "Add all" button.
- when an item is added, bubble-input may increase in height and
push itemTree lower. To try to preserve relative positioning
of the mouse, itemTree will scroll to be over the row that was just clicked

In List mode:
- arrow up/down from the input will change the selected item
with the focus remaining in the input
- selected items are a collapsible list section

Other behaviors and fixes:
- one can add any locator (not just pages) by typing its full or short name
in an input and pressing Enter (e.g. line 10, or l. 10, or chap. "test chapter")
- Added a new preference to select if the citation dialog
should always open in list mode, library mode or in the last
mode that was used
- bubbles whose items are selected in library or list mode
are highlighted
- arrow up/down from a bubble will focus the bubble
above/below it for easier navigation across bubble-input
- multi-select is supported on items in list mode or item cards in
library mode via Shift-arrow or Cmd+click to select multiple items
- Cmd/Ctrl + Enter will always accept the dialog no matter what
is focused
- when there are no bubbles, accept button is disabled
- after an item is added, bubble-input is always refocused
- added suppressed property to itemTreeMenubar to be able to
hide if in list mode, where it is not relevant. Fixed menubar
getting stuck or re-appearing on Alt keypress on Linux by setting
height: 0 vs hiding it via hidden.
- added initialFolder and onActivate prop to collectionTree to set which collection
should be reopened when dialog opens and to be able to set a custom
onActivate handler.
- added getExtraField prop to itemTree to get data on if
an item is in a citation or not

Implementation details:
- citationDialog.js is the main file. It relies on a number of
helper files in citationDialog/* directory to keep the main
file less cluttered. popupHandler.js contains the logic of
opening/closing the item details popup to add locator/prefix/suffix/etc.
keyboardHandler.js is responsible for overall keyboard navigation
throughout the dialog. searchHandler.js contains the logic
for running the search based on user's query. Finally, Helpers.js
has general helper functions that don't handle any actual logic.
- SearchHandler is set to run search in two ways: for cited/selected/open
items (which are cached and do not involve any actual SQL query) and
general search for items across all libraries. When layout.search
runs, firstly cited/selected/open items are updated after which the
SQL search runs.
- bubbleInput.js is a customElement responsible for bubbles interface.
bubbleInput.refresh takes a list of items and handles adding/removing/reordering
of bubbles as needed. It always has two inputs on each side of
a bubble, as opposed to having inputs inserted dynamically. It
allows keyboardHandler.js to handle navigation with arrows within
bubbleInput.
- when user interacts with bubbleInput, it emits custom events that are
handled by IOManager singleton in citationDialog.js, which
may update the items information and pass them back to bubbleInput.refresh
to have the list of bubbles updated
- CitationDataManager singleton is responsible for storing
items added into the citation in CitationDataManager.items
in an object with both Zotero.Item and the actual citation item.
It is easier to pass both items to other components
and helpers, as opposed to sharing functions to convert
items back and forth.
2025-03-10 22:40:43 -04:00
Abe Jellinek
679de040ec Add tests for renderItemTitle() 2025-03-06 11:00:33 -05:00
Abe Jellinek
8082516bf6 renderItemTitle(): Create <span> when inverting style
Creating an <i> with a style attribute that *removes* italics is just
too confusing.
2025-03-06 11:00:32 -05:00
Dan Stillman
8021ca0a0b Fix /connector/saveSnapshot test for Zotero.HTTP.download() 2025-03-05 07:18:12 -05:00
Dan Stillman
a464fe0408 Update "Find Full Text" tests for Zotero.HTTP.download()
Downloads are now included in request() call counts
2025-03-05 06:34:25 -05:00
Dan Stillman
1f401f0897 Replace Zotero.Utilities.Internal.saveURI() with Zotero.HTTP.download()
Adds a new function, Zotero.HTTP.download(), that uses
Zotero.HTTP.request(). This fixes downloads via authenticated proxies in
Zotero 7 and gives us other request() functionality (e.g., 5xx retrying)
for free.

The downside is that this is probably less efficient, potentially
loading large downloads in memory. We should create a replacement for
request() based on fetch() that supports getting the body as a
ReadableStream.

Fixes #5062
2025-03-05 04:46:51 -05:00
Abe Jellinek
3c8d50dd47 Remove loadBrowserWindow() test support function (#5050)
A browser window was no longer actually needed for charset detection
(on macOS, at least, and hopefully elsewhere) because we switched to a
HiddenFrame-based hidden browser. Remaining uses now call
`loadZoteroWindow()`.
2025-02-26 03:00:04 -05:00
Adomas Ven
2e9b9d4070
Close citation dialog if user interacts with the integration plugin (#4859)
Asks the user if they want to discard the changes in their existing dialog if
they have made changes.

If there is no citation dialog, but a command is running (like updating the document)
an alert is displayed.

Closes #4855
2025-02-18 05:52:23 -05:00
Dan Stillman
fc3b7e0f83 Local API: Fix handling of style ids without standard prefix
Follow-up to #5032
2025-02-17 03:16:22 -05:00
abaevbog
506f3b14e3
Allow dragging items, collections, and searches into trash (#5033)
Fixes: #1943
2025-02-13 02:58:25 -05:00
Abe Jellinek
5978353d57
Fix faulty siblings-of-type check in setAutoAttachmentTitle() (#5045) 2025-02-12 22:29:49 -05:00
Dan Stillman
d358915707 Update sample data for podcast/date mapping 2025-02-05 03:08:32 -05:00
Abe Jellinek
a2a99c12f5 Local API: Fix test 2025-01-28 10:44:37 -05:00
Abe Jellinek
2a7f4fb2a5 Local API: Return everything when since=0
Addresses #5011 (option A)
2025-01-28 10:39:43 -05:00
Dan Stillman
d1e67987bd Fix broken test after #5004
Reverts a change I made to the PR. Only `since=0` would be valid in the
web API, but local items don't have a version by default, so it has to
be `-1` to match those. This probably isn't a great solution, since tools
targeting the web API would use `0`, but this will fix the test for now.
2025-01-28 01:25:08 -05:00
Abe Jellinek
a7fff8cada
Local API: Add /fulltext endpoints (#5004) 2025-01-28 00:58:12 -05:00
Abe Jellinek
6cdae37e5b
Local API: Fix 500 error when attachment has unparseable path (#5010) 2025-01-28 00:54:29 -05:00
Abe Jellinek
48b50064e9
Item box: Fix missing Copy/Paste menuitems on URL fields (#5001) 2025-01-28 00:48:41 -05:00
Dan Stillman
7a467b8bfa Fix selectItems() not selecting non-top-level item in trash
https://forums.zotero.org/discussion/comment/484380/#Comment_484380

Adds `Zotero.Item#isInTrash()` that returns true if the item or any of
its ancestors is in the trash (i.e., `.deleted == true`)
2025-01-27 04:02:10 -05:00
Dan Stillman
ed045e640a Tests for Item#fromJSON() changes (#3422) 2025-01-22 03:23:06 -05:00
Dan Stillman
b86305f40e Fix json[c.field] is undefined sync error
Fix error if local note or attachment is added to a parent item while
the remote version was added to a collection. Now, the new local parent
item will be added to any collections the remote child item was added
to.

Fixes #2934
2025-01-09 03:11:01 -05:00
Dan Stillman
0b44461a66 Fix Zotero.locked getting stuck on in data directory tests
This caused later DB tests to fail due to backups not running.
2025-01-02 07:41:16 -05:00
Dan Stillman
6ee556500d fx128: Implement non-incremental backup option
A new function, `Zotero.DB.backUpDatabase()`, by default makes offline
backups, by closing the database, doing a regular file copy, and
reopening the database. It takes an options object with an `online`
flag to make online, incremental backups that can take multiple minutes
to complete, though for now we're still running them on idle.

The old function, `Zotero.DB.backupDatabase(suffix, force)`, is
deprecated and proxies to the new function, making offline backups.

Fixes #4935
2025-01-02 02:56:41 -05:00