Skip to main content

United Codes Rich Text Editor Pro (Process)

Overview

The supporting process plug-in enables a developer to handle the plug-in session state and to pernamently delete images uplaoded using RESTful service and removed from the current rich text HTML.

The plug-in exposes the following actions:

  • Clear CLOB
  • Load CLOB
  • Update CLOB
  • Delete Removed Images

Clear CLOB

The action clears the item plug-in collection data and sets item's session state to NULL. Additionally, other page items can be specified to be cleared using APEX PL/SQL API APEX_UTIL.SET_SESSION_STATE.

A developer has to specify:

AttributeTypeRequiredDescription
ItemPage itemYesAn item implementing the plug-in.
Other Page Item(s)Page item(s)NoOther page items to be cleared using Oracle APEX API.

The action can be used both on pre-rendering (Before Header, After Header, and Before Regions) and after page submission (Processing and After Processing).


Load CLOB (SQL Query)

The action loads CLOB content into the plug-in session state based on the given SQL Query returning CLOB value.

A developer has to specify:

AttributeTypeRequiredDescription
ItemPage itemYesAn item implementing the plug-in.
SQL QuerySQL QueryYesValid SQL Query returning CLOB content.

See an example SQL query returning CLOB below.

select CLOB_COLUMN from UC_RTE_CLOBS where id = :P4_ID;

Load CLOB (Function Body Returning CLOB)

The action loads CLOB content into the plug-in session state based on the given PL/SQL Code.

A developer has to specify:

AttributeTypeRequiredDescription
ItemPage itemYesItem implementing the plug-in
Function Body returning CLOBPL/SQL CodeYesValid anonymous PL/SQL code with return statement.

See an example function returning CLOB below.

declare
v_clob clob;
v_result clob;
v_test number;
begin
if :P4_ID is null then
v_result := to_clob(null);
else
select
CLOB_CONTENT
into
v_result
from
UC_RTE_CLOBS
where
id = :P4_ID
;
end if;

return v_result;
end;

Load CLOB (Table)

The action loads CLOB contents into the plug-in session state based on the given table specification.

A developer has to specify:

AttributeTypeRequiredDescription
ItemPage itemYesItem name implementing the plug-in
SchemaTextYesSchema that owns the table
Table NameTextYesThe case-sensitive table or view name.
CLOB Column NameTextYesThe column name which stores the CLOB content
PK(s) Column(s) Name(s)TextYesComma separated list of primary key columns needed to fetch the CLOB
Item(s) Containing PK(s) Value(s)Page Item(s)YesComma separated list of APEX page items containing primary keys values

The screenshot below shows an example implementation.

image-20230303184538025


Update CLOB (PL/SQL Code)

The action updates the plug-in CLOB value in the database based on a developer custom PL/SQL code. The provided code can reference bind variable :CONTENT referencing the current rich text HTML CLOB value after submitting a page.

A developer has to specify:

AttributeTypeRequiredDescription
ItemPage itemYesAn item implementing the plug-in
PL/SQL CodePL/SQL CodeYesA valid anonymous PL/SQL code with return statement.

See an example PL/SQL code below.

begin
update
#OWNER#.UC_RTE_CLOBS
set
CLOB_CONTENT = :CONTENT
where
ID = :P4_ID
;
end;

Update CLOB (Table)

The action updates the plug-in CLOB value in the database based on given table specification.

A developer has to specify:

AttributeTypeRequiredDescription
ItemPage itemYesItem name implementing the plug-in
SchemaTextYesSchema that owns the table
Table NameTextYesThe case-sensitive table or view name.
CLOB Column NameTextYesThe column name which stores the CLOB content
PK(s) Column(s) Name(s)TextYesComma separated list of primary key columns needed to fetch the CLOB
Item(s) Containing PK(s) Value(s)Page Item(s)YesComma separated list of APEX page items containing primary keys values

The screenshot below shows an example implementation.

image-20230303184637339


Delete Removed Images

The action allows a developer to define custom PL/SQL code executed in the loop over removed images from rich text HTML. Images included in the loop are the images uploaded using the RESTful service. The provided PL/SQL code can reference an image meta-data stored in the plug-in collection using the plug-in package variables listed below.

VariableTypeDescription
UC_FROALA_RTE.g_froala_image_idVARCHAR2(4000)an image ID assigned after a successful image upload
UC_FROALA_RTE.g_froala_image_get_urlVARCHAR2(4000)an image URL
UC_FROALA_RTE.g_froala_image_safe_to_deleteVARCHAR2(1)an image flag Y/N indicating if the image can be safely removed

A developer has to specify:

AttributeTypeRequiredDescription
ItemPage itemYesItem name implementing the plug-in
PL/SQL CodePL/SQL CodeYesThe PL/SQL code deleting removed images

See an example PL/SQL code below.

declare
v_removed_img_id number := UC_FROALA_RTE.g_froala_image_id;
begin
delete from UC_FROALA_SAMPLE_BLOBS where id = v_removed_img_id;
end;

Learn more about when images are safe to delete in Integration with APEX \ About the APEX Session State \ The plug-in collection \ Images.

An Example implementation

The screenshot below presents the process implementing the supporting plug-in in the sample application home page. The presented PL/SQL code deletes images uploaded using RESTful service that are safe to remove.

image-20230303183628061

The plug-in action implementation can be tested in the sample application. Use the settings popup to show the plug-in session state for images added to rich text HTML.

image-20230303184230514

*Learn more about images in the plug-in collection in the Integration with APEX \ About the APEX Session State \ The plug-in collection.

Process Uploaded Images

The action allows a developer to define custom PL/SQL code executed in the loop over recently uploaded images using the plug-in RESTful service. The provided PL/SQL code can reference an image meta-data stored in the plug-in collection using the plug-in package variables listed below.

VariableTypeDescription
UC_FROALA_RTE.g_froala_image_idVARCHAR2(4000)an image ID assigned after a successful image upload
UC_FROALA_RTE.g_froala_image_get_urlVARCHAR2(4000)an image URL
UC_FROALA_RTE.g_froala_image_onloadVARCHAR2(1)an image flag Y/N indicating if the image was available before the plug-in was initialized.

A developer has to specify:

AttributeTypeRequiredDescription
ItemPage itemYesItem name implementing the plug-in
PL/SQL CodePL/SQL CodeYesThe PL/SQL code processing uploaded images

See an example PL/SQL code below.

declare
v_clob_id constant number := :P1432_ID;
v_img_exists number;
v_img_id number;
v_img_url varchar2(4000);
begin

v_img_id := UC_FROALA_RTE.g_froala_image_id;
v_img_url := UC_FROALA_RTE.g_froala_image_get_url;

select
count(1)
into
v_img_exists
from
UC_FROALA_SAMPLE_CLOB_BLOBS
where
CLOB_ID = v_clob_id
and BLOB_ID = v_img_id
;

if v_img_exists = 0 then

insert into
UC_FROALA_SAMPLE_CLOB_BLOBS(
CLOB_ID,
BLOB_ID,
IMAGE_URL
) values(
v_clob_id,
v_img_id,
v_img_url
);

end if;

end;