Skip to content

Commit

Permalink
#1111 Placeholder text now works where text is in CDATA
Browse files Browse the repository at this point in the history
  • Loading branch information
FayCross committed Mar 14, 2024
1 parent 764ccd5 commit 1a9a452
Show file tree
Hide file tree
Showing 23 changed files with 82 additions and 82 deletions.
40 changes: 20 additions & 20 deletions editor/js/toolbox.js
Expand Up @@ -328,7 +328,6 @@ var EDITOR = (function ($, parent) {

// Recursive function to traverse the xml and build
build_lo_data = function (xmlData, parent_id) {

// First lets generate a unique key
var key = parent.tree.generate_lo_key();
if (parent_id == null)
Expand Down Expand Up @@ -375,10 +374,11 @@ var EDITOR = (function ($, parent) {
attributes[key] = makeAbsolute(attributes[key]);
}
});

// cdata-section
lo_data[key] = {};
lo_data[key]['attributes'] = attributes;
if (xmlData[0].firstChild && xmlData[0].firstChild.nodeType == 4) // cdata-section
{
if (xmlData[0].firstChild && xmlData[0].firstChild.nodeType == 4) {
lo_data[key]['data'] = makeAbsolute(xmlData[0].firstChild.data);

if (!alreadyUpgraded)
Expand Down Expand Up @@ -3816,30 +3816,30 @@ var EDITOR = (function ($, parent) {
case 'script':
case 'html':
case 'textarea':
var id = "textarea_" + form_id_offset;
var textvalue = "";

form_id_offset++;
var id = "textarea_" + form_id_offset;
var textvalue = "";
form_id_offset++;

// Set the value after initialisation of ckeditor in case of use of textarea, pre and code tags
const lcvalue=value.toLowerCase();
if (lcvalue.indexOf('<textarea') == -1
// Set the value after initialisation of ckeditor in case of use of textarea, pre and code tags
// if value is in cdata and placeholder is used, the empty value will be undefined - change this to empty string
const lcvalue = value == undefined && options.placeholder != undefined ? '' : value.toLowerCase();
if (lcvalue.indexOf('<textarea') == -1
&& lcvalue.indexOf('<pre>') == -1
&& lcvalue.indexOf('<code>') == -1)
textvalue = value;
textvalue = value == undefined && options.placeholder != undefined ? '' : value;

var textarea = "<textarea id=\"" + id + "\" class=\"ckeditor\" style=\"";
if (options.height) textarea += "height:" + options.height + "px";
textarea += "\">" + textvalue + "</textarea>";
$textarea = $(textarea);
var textarea = "<textarea id=\"" + id + "\" class=\"ckeditor\" style=\"";
if (options.height) textarea += "height:" + options.height + "px";
textarea += "\">" + textvalue + "</textarea>";
$textarea = $(textarea);

if (textvalue.length == 0) $textarea.data('afterckeditor', value);
if (textvalue.length == 0) $textarea.data('afterckeditor', value);

html = $('<div>')
.attr('style', 'width:100%')
.append($textarea);
html = $('<div>')
.attr('style', 'width:100%')
.append($textarea);

textareas_options.push({id: id, key: key, name: name, options: options});
textareas_options.push({id: id, key: key, name: name, options: options});
break;
case 'numericstepper':
var min = Number(options.min);
Expand Down
Expand Up @@ -83,7 +83,7 @@
$("#textHolder").remove();
$("#imgHolder").addClass("centerAlign");
} else {
$("#textHolder").html(x_addLineBreaks(x_currentPageXML.childNodes[0].nodeValue));
$("#textHolder").html(x_currentPageXML.childNodes[0] == undefined ? '' : x_addLineBreaks(x_currentPageXML.childNodes[0].nodeValue));
if (x_currentPageXML.getAttribute("align") == "Right") {
$("#pageContents .panel").addClass("x_floatLeft");
} else {
Expand Down
Expand Up @@ -142,8 +142,8 @@
if (x_currentPageXML.getAttribute("size") != undefined) {
$textHolder.css("font-size", Number(x_currentPageXML.getAttribute("size")) + "pt");
}
$textHolder.html(x_addLineBreaks(x_currentPageXML.childNodes[0].nodeValue));

$textHolder.html(x_currentPageXML.childNodes[0] == undefined ? '' : x_addLineBreaks(x_currentPageXML.childNodes[0].nodeValue));

var maxWH = this.getMaxDimensions();

Expand Down
Expand Up @@ -66,7 +66,7 @@
* in the HTML editor enclosed in <p></p>
*/

var text = x_addLineBreaks(x_currentPageXML.childNodes[0].nodeValue),
var text = x_currentPageXML.childNodes[0] == undefined ? '' : x_addLineBreaks(x_currentPageXML.childNodes[0].nodeValue),
bulletArray,
contentsStr = "",
startTag = '<p class="bullet">',
Expand Down
Expand Up @@ -135,7 +135,7 @@

// set up page
$("#mainText").html(x_addLineBreaks(x_currentPageXML.getAttribute("text")));

if (labelPos == "text") {
$("#mainText")
.after($("#labelHolder"))
Expand Down
Expand Up @@ -110,9 +110,8 @@
} else {
$panel.addClass("x_floatRight");
}

$textHolder.html(x_addLineBreaks(x_currentPageXML.childNodes[0].nodeValue));


$textHolder.html(x_currentPageXML.childNodes[0] == undefined ? '' : x_addLineBreaks(x_currentPageXML.childNodes[0].nodeValue));

// set up control panel & buttons
$controlPanel.draggable({containment: "parent"});
Expand Down
Expand Up @@ -53,8 +53,9 @@
if (copyTxt == undefined) {
copyTxt = "Note: Click the 'Select Text' button to highlight the text on the right and then Ctrl + C to copy this text to the clipboard. You can then paste (Ctrl + V) into another application such as Open Office, Word or an email to save for future reference.";
}

$("#textHolder").html(x_addLineBreaks(x_currentPageXML.childNodes[0].nodeValue) + '<hr/><div id="copyTxt"><p>' + copyTxt + '</p></div><button id="copyBtn">' + copyBtnLabel + '</button>');

var cdata = x_currentPageXML.childNodes[0] == undefined ? '' : x_addLineBreaks(x_currentPageXML.childNodes[0].nodeValue);
$("#textHolder").html(cdata + '<hr/><div id="copyTxt"><p>' + copyTxt + '</p></div><button id="copyBtn">' + copyBtnLabel + '</button>');

$("#copyBtn")
.button({
Expand Down
Expand Up @@ -36,7 +36,7 @@

this.init = function() {
var $pageContents = $("#pageContents");
$pageContents.html(x_addLineBreaks(x_currentPageXML.childNodes[0].nodeValue));
$pageContents.html(x_currentPageXML.childNodes[0] == undefined ? '' : x_addLineBreaks(x_currentPageXML.childNodes[0].nodeValue));
// ignores superscript support data in xml as it will do it automatically with <sub> <sup> tags

if (x_currentPageXML.getAttribute("textWidth") == "300") {
Expand Down

0 comments on commit 1a9a452

Please sign in to comment.