Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663

This commit is contained in:
Greg Anderson 2015-10-08 11:40:12 -07:00
parent eb34d130a8
commit f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions

View file

@ -25,9 +25,9 @@
var $configurationForm = $(context).find('.ckeditor-toolbar-configuration').once('ckeditor-configuration');
if ($configurationForm.length) {
var $textarea = $configurationForm
// Hide the textarea that contains the serialized representation of
// the CKEditor configuration.
.find('.form-item-editor-settings-toolbar-button-groups')
// Hide the textarea that contains the serialized representation of the
// CKEditor configuration.
.find('.js-form-item-editor-settings-toolbar-button-groups')
.hide()
// Return the textarea child node from this expression.
.find('textarea');

View file

@ -36,12 +36,6 @@
var label = $('label[for=' + element.getAttribute('id') + ']').html();
format.editorSettings.title = Drupal.t("Rich Text Editor, !label field", {'!label': label});
// CKEditor initializes itself in a read-only state if the 'disabled'
// attribute is set. It does not respect the 'readonly' attribute,
// however, so we set the 'readOnly' configuration property manually in
// that case, for the CKEditor instance that's about to be created.
format.editorSettings.readOnly = element.hasAttribute('readonly');
return !!CKEDITOR.replace(element, format.editorSettings);
},
@ -221,9 +215,10 @@
// Add a consistent dialog class.
var classes = dialogSettings.dialogClass ? dialogSettings.dialogClass.split(' ') : [];
classes.push('editor-dialog');
classes.push('ui-dialog--narrow');
dialogSettings.dialogClass = classes.join(' ');
dialogSettings.autoResize = Drupal.checkWidthBreakpoint(600);
dialogSettings.autoResize = window.matchMedia('(min-width: 600px)').matches;
dialogSettings.width = 'auto';
// Add a "Loading…" message, hide it underneath the CKEditor toolbar,
// create a Drupal.Ajax instance to load the dialog and trigger it.
@ -254,7 +249,7 @@
// Moves the dialog to the top of the CKEDITOR stack.
$(window).on('dialogcreate', function (e, dialog, $element, settings) {
$('.editor-dialog').css("zIndex", CKEDITOR.config.baseFloatZIndex + 1);
$('.ui-dialog--narrow').css("zIndex", CKEDITOR.config.baseFloatZIndex + 1);
});
// Respond to new dialogs that are opened by CKEditor, closing the AJAX loader.

View file

@ -30,13 +30,38 @@
}
// Override requiredContent & allowedContent.
widgetDefinition.requiredContent = 'img[alt,src,width,height,data-entity-type,data-entity-uuid]';
widgetDefinition.allowedContent.img.attributes += ',!data-entity-type,!data-entity-uuid';
// We don't allow <figure>, <figcaption>, <div> or <p> in our downcast.
delete widgetDefinition.allowedContent.figure;
delete widgetDefinition.allowedContent.figcaption;
delete widgetDefinition.allowedContent.div;
delete widgetDefinition.allowedContent.p;
widgetDefinition.requiredContent = new CKEDITOR.style({
element: 'img',
attributes: {
'alt': '',
'src': '',
'width': '',
'height': '',
'data-entity-type': '',
'data-entity-uuid': ''
}
});
var allowedContentDefinition = {
element: 'img',
attributes: {
'!data-entity-type': '',
'!data-entity-uuid': ''
}
};
var imgAttributes = widgetDefinition.allowedContent.img.attributes.split(/\s*,\s*/);
for (var i = 0; i < imgAttributes.length; i++) {
allowedContentDefinition.attributes[imgAttributes[i]] = '';
}
if (widgetDefinition.allowedContent.img.classes) {
allowedContentDefinition.attributes['class'] = widgetDefinition.allowedContent.img.classes.split(/\s*,\s*/).join(' ');
}
if (widgetDefinition.allowedContent.img.styles) {
var imgStyles = widgetDefinition.allowedContent.img.styles.split(/\s*,\s*/);
for (var j = 0; j < imgStyles.length; j++) {
allowedContentDefinition.styles[imgStyles[j]] = '';
}
}
widgetDefinition.allowedContent = new CKEDITOR.style(allowedContentDefinition);
// Override the 'link' part, to completely disable image2's link
// support: http://dev.ckeditor.com/ticket/11341.

View file

@ -51,8 +51,14 @@
}, true);
// Override requiredContent & allowedContent.
widgetDefinition.requiredContent = 'img[alt,src,width,height,data-entity-type,data-entity-uuid,data-align,data-caption]';
widgetDefinition.allowedContent.img.attributes += ',!data-align,!data-caption';
var requiredContent = widgetDefinition.requiredContent.getDefinition();
requiredContent.attributes['data-align'] = '';
requiredContent.attributes['data-caption'] = '';
widgetDefinition.requiredContent = new CKEDITOR.style(requiredContent);
var allowedContent = widgetDefinition.allowedContent.getDefinition();
allowedContent.attributes['!data-align'] = '';
allowedContent.attributes['!data-caption'] = '';
widgetDefinition.allowedContent = new CKEDITOR.style(allowedContent);
// Override allowedContent setting for the 'caption' nested editable.
// This must match what caption_filter enforces.
@ -63,9 +69,12 @@
// Override downcast(): ensure we *only* output <img>, but also ensure
// we include the data-entity-type, data-entity-uuid, data-align and
// data-caption attributes.
var originalDowncast = widgetDefinition.downcast;
widgetDefinition.downcast = function (element) {
// Find an image element in the one being downcasted (can be itself).
var img = findElementByName(element, 'img');
var img = originalDowncast.call(this, element);
if (!img) {
img = findElementByName(element, 'img');
}
var caption = this.editables.caption;
var captionHtml = caption && caption.getData();
var attrs = img.attributes;
@ -94,6 +103,7 @@
// - <img> tag in a paragraph (non-captioned, centered image),
// - <figure> tag (captioned image).
// We take the same attributes into account as downcast() does.
var originalUpcast = widgetDefinition.upcast;
widgetDefinition.upcast = function (element, data) {
if (element.name !== 'img' || !element.attributes['data-entity-type'] || !element.attributes['data-entity-uuid']) {
return;
@ -103,6 +113,7 @@
return;
}
element = originalUpcast.call(this, element, data);
var attrs = element.attributes;
var retElement = element;
var caption;
@ -210,6 +221,15 @@
// upcasting existing elements (see widgetDefinition.upcast).
if (dialogReturnValues.attributes.hasCaption) {
actualWidget.editables.caption.setAttribute('data-placeholder', placeholderText);
// Some browsers will add a <br> tag to a newly created DOM
// element with no content. Remove this <br> if it is the only
// thing in the caption. Our placeholder support requires the
// element be entirely empty. See filter-caption.css.
var captionElement = actualWidget.editables.caption.$;
if (captionElement.childNodes.length === 1 && captionElement.childNodes.item(0).nodeName === 'BR') {
captionElement.removeChild(captionElement.childNodes.item(0));
}
}
};
};

View file

@ -13,8 +13,19 @@
init: function (editor) {
// Add the commands for link and unlink.
editor.addCommand('drupallink', {
allowedContent: 'a[!href,target]',
requiredContent: 'a[href]',
allowedContent: new CKEDITOR.style({
element: 'a',
attributes: {
'!href': '',
'target': ''
}
}),
requiredContent: new CKEDITOR.style({
element: 'a',
attributes: {
href: ''
}
}),
modes: {wysiwyg: 1},
canUndo: true,
exec: function (editor) {
@ -111,8 +122,19 @@
editor.addCommand('drupalunlink', {
contextSensitive: 1,
startDisabled: 1,
allowedContent: 'a[!href]',
requiredContent: 'a[href]',
allowedContent: new CKEDITOR.style({
element: 'a',
attributes: {
'!href': '',
'target': ''
}
}),
requiredContent: new CKEDITOR.style({
element: 'a',
attributes: {
href: ''
}
}),
exec: function (editor) {
var style = new CKEDITOR.style({element: 'a', type: CKEDITOR.STYLE_INLINE, alwaysRemoveElement: 1});
editor.removeStyle(style);

View file

@ -221,6 +221,11 @@
// the feature that was just added or removed. Not every feature has
// such metadata.
var featureName = this.model.get('buttonsToFeatures')[button.toLowerCase()];
// Features without an associated command do not have a 'feature name' by
// default, so we use the lowercased button name instead.
if (!featureName) {
featureName = button.toLowerCase();
}
var featuresMetadata = this.model.get('featuresMetadata');
if (!featuresMetadata[featureName]) {
featuresMetadata[featureName] = new Drupal.EditorFeature(featureName);
@ -301,7 +306,6 @@
broadcastConfigurationChanges: function ($ckeditorToolbar) {
var view = this;
var hiddenEditorConfig = this.model.get('hiddenEditorConfig');
var featuresMetadata = this.model.get('featuresMetadata');
var getFeatureForButton = this.getFeatureForButton.bind(this);
var getCKEditorFeatures = this.getCKEditorFeatures.bind(this);
$ckeditorToolbar
@ -335,6 +339,7 @@
getCKEditorFeatures(hiddenEditorConfig, function (features) {
// Trigger a standardized text editor configuration event for each
// feature that was modified by the configuration changes.
var featuresMetadata = view.model.get('featuresMetadata');
for (var name in features) {
if (features.hasOwnProperty(name)) {
var feature = features[name];