DocumentHandler: fix several admin/client media and link bugs#1869
Draft
matself wants to merge 8 commits into
Draft
DocumentHandler: fix several admin/client media and link bugs#1869matself wants to merge 8 commits into
matself wants to merge 8 commits into
Conversation
added 8 commits
July 6, 2026 10:35
Resolving "../Upload/..." paths concatenated baseUrl directly without a separating slash, breaking the URL whenever baseUrl (e.g. mapservice base) had no trailing slash. Also fixes the Audio component ignoring its own corrected URL in favor of the raw src attribute. See discussion hajkmap#1759.
Previously nothing exposed this folder over HTTP at all, relying entirely on a reverse proxy (e.g. nginx) in production. Now a plain `npm run dev`/`node index.js` instance serves uploaded document media out of the box, at both /Upload (matching a typical proxy alias) and /api/vN/Upload (matching DocumentHandler's default relative "../Upload/..." resolution). Respects INFORMATIVE_CUSTOM_UPLOAD_DIR_ABSOLUTE_PATH if set, same as the existing file-listing logic in informative.service.js.
_promptForLink/_promptForHover always opened the link dialog with whatever urlValue was last left in state (reset to "" after every confirm/close), never checking whether the current selection already sits on a saved LINK entity. Editing an existing map/document/web link therefore looked like it had been erased, forcing users to retype it from scratch every time. Verified via discussion hajkmap#1755: inserted a maplink, saved (href and data-maplink persisted correctly to the chapter HTML), then re-selected it and reopened the map-link tool - urlValue is now pre-filled from the entity's saved data instead of opening blank.
The link/maplink/document-link input used a bare default input width (~20 chars), far too short for the long URLs DocumentHandler map links typically are. Set an explicit 600px width, roughly triple the previous rendered width.
Bug 2 from discussion hajkmap#1755: map links pasted from Anchor's share dialog typically have an empty or incomplete p= (visible plugins) parameter, since the document viewer usually isn't open at the moment the admin generates the share link from the running client. Clicking such a link then just recenters the map instead of reopening the document. Rather than changing Anchor's generic share dialog (which has no concept of "this link is for a document" and shouldn't need one), enforce this where the intent is actually known: when a map link is confirmed here, ensure its p param includes documentviewer, appending to any existing plugin list rather than overwriting it. Non-Hajk URLs (no hash fragment) are left untouched.
Bug 1 from discussion hajkmap#1755: MenuConnectionSelector.updateSelection always wrote folder: folder into the menu item unconditionally, where folder is the admin's own currently-browsed document-folder filter (component-level UI state), not the menu item's own folder property. Since a separate MenuConnectionSelector instance exists per connection type (DOCUMENT, LINK, MAP_LINK), confirming a maplink or weblink on an item silently wiped its folder to "" - breaking the linked document, since folder+document together locate the file. Gate the folder write the same way document/link/maplink already are: only touch it when the DOCUMENT connection itself is being confirmed. Verified: a menu item with a pre-set folder now keeps it after confirming a maplink via the admin UI.
DocumentTextEditor's _handleReturn calls insertNewLine() whenever Enter is pressed while an image (atomic) block is selected, to add an empty line for continued typing. insertNewLine's fragment included the current block alongside the new empty block, and Modifier.replaceWithFragment inserts everything in that fragment - so the current block (the image) got duplicated into a second, malformed copy (rendered as a bare <img> instead of a proper <figure>) every time this path fired. Reproduced via the exact chapter content from a live test instance: insert an image, click it to select it, press Enter - before this fix, getHtml() showed the image twice; after, exactly once, with a new empty paragraph following it as intended.
…p#1755) Documents the media-path/Upload-serving fixes from discussion hajkmap#1759 and the four admin DocumentHandler fixes from discussion hajkmap#1755 (folder-clearing, link pre-fill, missing p=documentviewer, image duplication on Enter).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes a cluster of DocumentHandler bugs reported in Discussion #1759 and Discussion #1755.
A live demo instance with these fixes applied is available at https://test.webkarta.se/?m=demo.
From #1759 (relative media paths):
Img/Video/Audiorenderers resolved../Upload/...paths incorrectly whenevermapserviceBasehad no trailing slash (e.g./api/v2Upload/...instead of/api/v2/Upload/...). Also fixed theAudiocomponent ignoring its own corrected URL in favor of the rawsrcattribute.App_Data/Uploadis now served directly by the Node backend (at both/Uploadand/api/vN/Upload), so uploaded document media works out of the box on a plainnpm run dev/node index.jsinstance instead of requiring a reverse proxy in front.From #1755 (admin DocumentHandler tooling):
folderwhenever a link or map link was confirmed on it, breaking the linked document.p=documentviewerin their URL, so clicking them reliably reopens the document instead of just recentering the map.<img>) whenever Enter was pressed while the image was selected.Each fix is its own commit; see individual commit messages for root-cause detail.
Test plan
../Upload/...path resolution against a local backend with both correct (/api/v2/Upload) and previously-broken (/api/v2Upload) request paths.App_Data/Uploadis served at both/Uploadand/api/v2/Uploadon a plainnpm run devbackend instance.foldersurvives confirming a map link via the admin UI.pparameter getsdocumentviewerappended (not overwritten).