i am using the CKEditor to enable writing on a page in my project. In this area where the CKEditor writes, there should also be the possibilty to insert a textfield, im using the standard textfield-dialog plugin (the 4th button in the 2nd row) with only the value field. By using the config.js:
var infoTab = dialogDefinition.getContents( 'info' );
// remove unwanted input fields
infoTab.remove( '_cke_saved_name' );
infoTab.remove( 'size' );
infoTab.remove( 'maxLength' );
infoTab.remove( 'type' );
And i wanted to modify the onOk-function of the used value-field by inserting a nested element containing the textfield.
Original:
onOk: function() {
var a = this.getParentEditor(),
c = this.textField,
b = !c;
b && (c = a.document.createElement("input"), c.setAttribute("type", "text"));
c = {
element: c
};
b && a.insertElement(c.element);
this.commitContent(c);
b || a.getSelection().selectElement(c.element)
}
Modified:
onOk: function() {
var a = this.getParentEditor(),
c = this.textField,
b = !c,
additionalElement = a.document.createElement("button");
additionalElement.setAttribute("onclick", $(this).parent().remove());
b && (c = a.document.createElement("input"), c.setAttribute("type", "text"));
c = {
element: c,
element2: additionalElement
};
b && a.insertHtml("<span>");
b && a.insertElement(c.element);
b && a.insertElement(c.element2);
b && a.insertHtml("</span>");
this.commitContent(c);
b || a.getSelection().selectElement(c.element)
}
I tried this approach, but the span-element does not appear in the source code of the page, when using it. I also tried using the div-element which breaks the p-element containing the whole input. (the p end at the div and a new starts after. 'div style="display: inline"' does not work either.) The at the moment most successfull approach, still not doing what i want, is using a 'a style="color: black; text-decoration: none"', which works as long as i dont double-click the textfield, if i double-click it, the link-dialog opens instead of the textfield-dialog. I also tried adding an additional element:
var wrapper = a.document.createElement("span");
wrapper.append(c);
wrapper.append(additionalElement);
But i could not get the CKEditor to output it.
All help is appreciated, hopefully before i turn insane ;)
Text before textfield
` – IIOIOOO Oct 05 '16 at 08:21