Hello everyone,
can someone please tell me if it is possible to hide certain elements of the rich text box. For example, I would like only bold, underline and italics to be possible:
Thank you very much
Hello everyone,
can someone please tell me if it is possible to hide certain elements of the rich text box. For example, I would like only bold, underline and italics to be possible:
Thank you very much
This is a good idea, but it is not something that we have a feature for in Leap today. Have you entered this idea in our Ideas portal?
Hi Christopher,
the idea is that a user can format a text nicely for my specific purpose. But sometimes it's not good to pass all these functions, because the formatting might become too much, or the user suddenly inserts links and that's not wanted. For this special case, I have created a way to emphasise a text a little. It's not particularly convenient, but it meets the user's requirements and mine too. The script converts the input of a text field and outputs it in an HTML field. I have chosen #b for bold, #_ for underlined and #r for red/bold. This should be enough to emphasise certain words or passages in a text. The result looks like this:
If I #bstart a formatting but do not finish it, it is automatically finished after the first word, otherwise it looks where the end of the formatting is so that #bseveral words can be included#b. There is #bbold, #_underlined and #rbold/red allowed. That's it #r:-)
becomes
![]()
The code is called up with :
myTextFromTextfield = BO.F_Paragraphtext.getValue();page.F_HTMLArea.setContent(app.getSharedData().makeHTML(myTextFromTextfield));
If anyone finds the script useful for their project, here it is:
app.getSharedData().makeHTML = function(input) { const tagDefs = { '#b': {open: '<strong>', close: '</strong>'}, '#_': {open: '<u>', close: '</u>'}, '#r': {open: '<strong style="color:red;">', close: '</strong>'} };
// Step 0: "Separate" dots or commas after closing tags input = input.replace(/(#b|#_|#r)(?=[.,])/g, '$1 '); // Step 1: Preliminary analysis & automatic completion of missing contracts const tokens = input.split(/(\s+)/);
const openTags = {'#b': null, '#_': null, '#r': null};
// Run through tokens and check openings and closures for (let i = 0; i < tokens.length; i++) { let token = tokens[i];
for (const tag in tagDefs) { const escTag = tag.replace(/[#_]/g, '\\$&');
const openRegex = new RegExp(`^${escTag}(\\S.*)$`); const closeRegex = new RegExp(`^(.*\\S)${escTag}$`);
if (openRegex.test(token)) { // If already open but no closer followed, add closure if (openTags[tag] !== null) { tokens[openTags[tag]] += tag; // Adds closer directly after word openTags[tag] = null; } openTags[tag] = i; // notice opening }
if (closeRegex.test(token) && openTags[tag] !== null) { openTags[tag] = null; // Closure found } } }
// Close open tags at the end of the text for (const tag in openTags) { if (openTags[tag] !== null) { tokens[openTags[tag]] += tag; // Attach closer openTags[tag] = null; } }
let result = tokens.join('');
// Step 2: Now replace all tags correctly with HTML tags for (const tag in tagDefs) { const escTag = tag.replace(/[#_]/g, '\\$&');
// Replace opening-Tag: #bword => <strong>word result = result.replace(new RegExp(`${escTag}(\\S)`, 'g'), tagDefs[tag].open + '$1');
// Replace close-Tag: word#b => word</strong> result = result.replace(new RegExp(`(\\S)${escTag}`, 'g'), '$1' + tagDefs[tag].close); } // Step 3: Remove one space before point or comma result = result.replace(/\s+([.,])/g, '$1'); // Set the font size from 12px result = '<span style="font-size:12px">'+result+'</span>'; return result;}
Christopher, where can I submit the idea that the rich edit field should be configurable in terms of controls?
Best regards
Vici