Skip to content

fix(rte): insert image selected from Assets folder (#11) - #13

Merged
natechadwick merged 1 commit into
mainfrom
bugfix/11-rte-image-not-inserted-from-assets
Aug 12, 2026
Merged

natechadwick merged 1 commit into
mainfrom
bugfix/11-rte-image-not-inserted-from-assets

Conversation

@vijaya-boddipudi

Copy link
Copy Markdown
Collaborator

Fixes #11.

Bug
When editing a Rich Text widget in the CMS UI, clicking Insert/Edit Image, browsing the Assets folder, and selecting an image produces no visible change in the editor. After clicking Save, the server throws:

PSInlineLinkField: Missing required inline link parameter: sys_dependentvariantid
PSItemSummaryService: Failed to load: -1-101-undefined
java.lang.NumberFormatException: For input string: "undefined"

In the browser console:

Uncaught TypeError: pathItem.PathItem.folderPaths.replace is not a function
    at plugin.js:336:73

Root cause
modules/perc-tinymce/.../plugins/percadvimage/plugin.js invoked pathItem.PathItem.folderPaths.replace('/Folders/$System$/','') inside getImageData. PercPathService.getPathItemById now returns folderPaths as an array, so .replace is undefined on the returned value. The thrown TypeError aborted the rest of getImageData, leaving cm1LinkData.fullUrl, fullVarId, and jcrpath unset. The resulting <img> element was therefore inserted without sys_dependentvariantid / sys_dependentid, which causes the server-side failure during inline-link processing and a malformed asset-widget relationship creation downstream.

Fix
Normalize folderPaths to a string before calling .replace, handling both the legacy string format and the new array format (same pattern already used by PercSiteTemplatesWidget.js and PercTemplateView.js). Also remove the stray console.log("Hello") debug line in the updateFileSelection command handler.

Files

  • modules/perc-tinymce/src/main/resources/META-INF/resources/sys_resources/tinymce/plugins/percadvimage/plugin.js — handle array folderPaths, drop debug log
  • CHANGELOG.md — ### Fixed entry under the [8.1.7 Build GH_POST_PR_COMMIT_RUN_ID] section per AGENTS.md

The percadvimage TinyMCE plugin assumed pathItem.PathItem.folderPaths
returned by PercPathService.getPathItemById was a string and called
String.prototype.replace on it. The REST service now returns an array,
so the call threw 'pathItem.PathItem.folderPaths.replace is not a
function' and aborted getImageData before the inline image element was
populated with sys_dependentvariantid / sys_dependentid. The resulting
<IMG> was missing those attributes, causing the server-side
PSInlineLinkField to throw 'Missing required inline link parameter:
sys_dependentvariantid' on save, and a subsequent
createAssetWidgetRelationship call was made with the unresolved id
'-1-101-undefined' (java.lang.NumberFormatException).

Normalize folderPaths to a string (handling both string and array
responses, matching the pattern already used by PercSiteTemplatesWidget
and PercTemplateView) so the inline link element is written correctly
and the image is inserted into the Rich Text widget. Also remove the
stray console.log('Hello') debug line in the updateFileSelection
command handler.
@natechadwick
natechadwick merged commit 1b49ed3 into main Aug 12, 2026
6 of 9 checks passed
@natechadwick
natechadwick deleted the bugfix/11-rte-image-not-inserted-from-assets branch August 12, 2026 04:50
natechadwick-intsof added a commit that referenced this pull request Aug 12, 2026
Resolve conflicts after Task 0/1 (#8/#9) and RTE fix (#13) landed on main:
- CHANGELOG: keep main history and add Task 6 path-injection section
- docs/ai-generated/tasks/8.1.x-codeql-baseline/*: take main (canonical Task 0)

Co-Authored by Grok using grok-4.5 with agent coding.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8.1.7: Image selected from Assets is not inserted into Rich Text widget

2 participants