0 votes
2.7k views
in Coach Views by (120 points)

Hi,

I am using IBM BAW, I want to use the Rich Text component, but when I click on the 'Image' item, the editor does not have the upload option enabled. I need to upload files from my PC.

I know that IBM BAW uses a third party library for this component  - https://www.tiny.cloud/

Is it possible to enable the upload function with javascript?

Thank you.

1 Answer

0 votes
by (30.6k points)

The OOB Rich Text control (CKEditor inside the UI Toolkit) has no upload plugin enabled - its image dialog only takes a URL, because the coach has no server end point for the upload. Three options, from simplest to most complete:

1. Paste / drag as data URL - enable the CKEditor image2 / uploadimage feature but let it produce an inline data:image/png;base64,... instead of a server upload. The picture then lives inside the rich text value (fine for small images, the variable grows with the picture):

// "load" event of the Rich Text control's parent coach view
var ed = CKEDITOR.instances[ me.context.element.querySelector("textarea").id ];
ed.on("fileUploadRequest", function (evt) {
  var file = evt.data.fileLoader.file, reader = new FileReader();
  reader.onload = function () { evt.data.fileLoader.responseData = { url: reader.result }; evt.data.fileLoader.fire("uploaded"); };
  reader.readAsDataURL(file); evt.stop();
});

2. Upload to the document store, insert the URL - put a UI Toolkit File Uploader (BPM document store or ECM) next to the editor; after the upload the control gives you the document id, build the download URL and insert it into the editor:

// after the File Uploader "on upload" event: docId of the new document
var url = "/rest/bpm/wle/v1/document/" + docId + "/content?snapshotId=" + tw.system.model.processApp.currentSnapshot.id;  // or the ECM /content URL
CKEDITOR.instances[editorId].insertHtml('<img src="' + url + '" />');

3. Custom coach view with a full editor (CKEditor 5 or TinyMCE as a managed web asset) whose upload adapter posts to your own service - the cleanest result but you own the editor.

Note for e-mails: an inline data URL image renders in most mail clients, a link to the BAW document store only works for logged-in users.

References

Related questions

0 votes
1 answer 1.6k views
+1 vote
1 answer 4.9k views
0 votes
1 answer 1.3k views
asked Feb 13, 2021 by Manana (190 points)
0 votes
1 answer 2.3k views
0 votes
1 answer 1.0k views
0 votes
2 answers 4.6k views
0 votes
3 answers 4.0k views
0 votes
1 answer 1.0k views
0 votes
1 answer 1.0k views
0 votes
1 answer 705 views
0 votes
2 answers 1.5k views
asked May 5, 2017 by Ramesh (260 points)

723 questions

807 answers

98 comments

4.9k users

Join BPM Community Discord Channel

Welcome to BPM Tips Q&A, Community wiki/forum where you can ask questions and receive answers from other IBM BPM experts and members of the community. Users with 2000 points will automatically be promoted to expert level.
Created by Dosvak LLC
Our Youtube Channel
...