Hi everyone,
i am trying to use the mention function for the Oracle Apex Item Rich Text Editor and save the selected user(s) in a table.
To do this, I created a Rich Text Editor item and added the following JavaScript initialization code. getUser is a JS function thats invoke my application process Get_Users and lists the users displayed when you enter @. So far, this works great. My challenge now is how to access the USER_ID of the selected user and then save it in a table. Has anyone done something similar before?
I would be very grateful for any advice!
Oracle Apex Version: 24.2.12
Best Regards
Jegor
Rich Text Editior initialization Code:
function (options) {
options.editorOptions.extraPlugins.push(ckeditor5.Mention);
options.editorOptions.mention = {
feeds: [
{
marker: '@',
feed: getUser,
minimumCharacters: 1
}
]
};
return options;
}
getUser JS Function:
function getUser( queryText ) {
return new Promise( resolve => {
let ret = apex.server.process(
"Get_Users",
{
x01:queryText.toLowerCase()
}
);
ret.done( function( data ) {
let users = [];
if ( data.matchFound ) {
users = JSON.parse(data.users);
}
resolve(users);
} );
} );
}
My Application Process Get_Users to list Users:
Declare
l_users clob;
Begin
With users_tab as (
Select
1 as USER_ID,
'Max Mustermann 1' as USER_NAME
From Dual
union
Select
1 as USER_ID,
'Max Mustermann 2' as USER_NAME
From Dual
)
Select
json_arrayagg(
json_object(
key 'id' value '@' ||USER_NAME,
key 'text' value USER_NAME,
key 'userID' value USER_ID
)
returning clob) into l_users
From users_tab
Where lower(USER_NAME) like apex_application.g_x01 ||'%'
Or lower(USER_NAME) like apex_application.g_x01 ||'%' ;
apex_json.open_object;
apex_json.write('success', true);
apex_json.write('matchFound', (l_users is not null));
apex_json.write('users', l_users);
apex_json.close_object;
End;