Add data-hallo-editor data attribute as integration point for Hallo plugins

This commit is contained in:
Thibaud Colas 2018-01-26 11:42:16 +02:00
parent 2e9b5e5569
commit 7d10279ed6
4 changed files with 6 additions and 6 deletions

View file

@ -54,7 +54,7 @@ CODE FOR SETTING UP SPECIFIC UI WIDGETS, SUCH AS DELETE BUTTONS OR MENUS, DOES N
// focus first suitable input found
var timeout = setTimeout(function() {
var $input = $('.input', self.container);
var $firstField = $('input, textarea, .halloeditor, [data-draftail-input]', $input).first();
var $firstField = $('input, textarea, [data-hallo-editor], [data-draftail-input]', $input).first();
if ($firstField.is('[data-draftail-input]')) {
$firstField.get(0).draftailEditor.focus();

View file

@ -2,7 +2,7 @@
function makeHalloRichTextEditable(id, plugins) {
var input = $('#' + id);
var editor = $('<div class="halloeditor"></div>').html(input.val());
var editor = $('<div class="halloeditor" data-hallo-editor></div>').html(input.val());
editor.insertBefore(input);
input.hide();
@ -78,7 +78,7 @@ function insertRichTextDeleteControl(elem) {
var a = $('<a class="icon icon-cross text-replace halloembed__delete">Delete</a>');
$(elem).addClass('halloembed').prepend(a);
a.on('click', function() {
var widget = $(elem).parent('.halloeditor').data('IKS-hallo');
var widget = $(elem).parent('[data-hallo-editor]').data('IKS-hallo');
$(elem).fadeOut(function() {
$(elem).remove();
if (widget != undefined && widget.options.editable) {
@ -89,7 +89,7 @@ function insertRichTextDeleteControl(elem) {
}
$(function() {
$('.halloeditor [contenteditable="false"]').each(function() {
$('[data-hallo-editor] [contenteditable="false"]').each(function() {
insertRichTextDeleteControl(this);
});
})

View file

@ -25,7 +25,7 @@
var insertionPoint, lastSelection;
lastSelection = widget.options.editable.getSelection();
insertionPoint = $(lastSelection.endContainer).parentsUntil('.halloeditor').last();
insertionPoint = $(lastSelection.endContainer).parentsUntil('[data-hallo-editor]').last();
return ModalWorkflow({
url: window.chooserUrls.embedsChooser,

View file

@ -23,7 +23,7 @@
var insertionPoint, lastSelection;
lastSelection = widget.options.editable.getSelection();
insertionPoint = $(lastSelection.endContainer).parentsUntil('.halloeditor').last();
insertionPoint = $(lastSelection.endContainer).parentsUntil('[data-hallo-editor]').last();
return ModalWorkflow({
url: window.chooserUrls.imageChooser + '?select_format=true',
responses: {