Files
drupal-quartiersdedemain/patches/2671162-151-prodonly.patch
T
bachir f0746c101a maj Drupal 10.5.4 -> 10.6.22 + modules contrib (cibles max D10/PHP8.1, sauts majeurs inclus)
- 154 packages drupal/* mis a jour (scan catalogue p2, filtre core 10.x + PHP 8.1)
- patches: 3 obsoletes retires (image_field_caption rewrite upstream, video_embed_field live, page_manager devel_load), core 2671162 re-rolle en local (prod-only), 2645922 garde
- +2 patches locaux image_field_caption: table optionnelle (updb) + lecture caption depuis le stockage champ
- pin-back drupal/jquery_ui_datepicker:2.1.1 + drupal/jquery_ui_slider:2.1.0 (modules enabled, orphelins apres BEF 7.x) -> pm:uninstall sur prod puis composer remove en commit separe
- sous-module starterkit: contraintes maj + retrait content_lock_timeout (fusionne dans content_lock 3.x, branche gogs q2d-maj-20261122)
- updb OK (23 updates), cex 28 fichiers, tests front 10 pages 200 + baseline avant/apres (ai-docs/front-baseline)

Generated by Mistral Vibe.
Co-Authored-By: Mistral Vibe <vibe@mistral.ai>
2026-11-22 16:25:20 +01:00

257 lines
9.1 KiB
Diff

diff --git a/core/modules/editor/js/editor.js b/core/modules/editor/js/editor.js
index da98baef34..ab7a21c3cf 100644
--- a/core/modules/editor/js/editor.js
+++ b/core/modules/editor/js/editor.js
@@ -15,9 +15,13 @@
*/
function findFieldForFormatSelector($formatSelector) {
const fieldId = $formatSelector.attr('data-editor-for');
+ const fieldIds = fieldId.split(/\s*,\s*/);
+ fieldIds.forEach((part, index) => {
+ fieldIds[index] = `#${part}`;
+ }, fieldIds);
// This selector will only find text areas in the top-level document. We do
// not support attaching editors on text areas within iframes.
- return $(`#${fieldId}`).get(0);
+ return $(fieldIds.join());
}
/**
@@ -102,6 +106,22 @@
field.setAttribute('data-editor-active-text-format', newFormatID);
}
+ /**
+ * Changes the text editor on a multiple text area.
+ *
+ * @param {HTMLElement} field
+ * The text area DOM element.
+ * @param {string} newFormatID
+ * The text format we're changing to; the text editor for the currently
+ * active text format will be detached, and the text editor for the new text
+ * format will be attached.
+ */
+ function changeTextEditorMultiple(field, newFormatID) {
+ field.each(function () {
+ changeTextEditor(this, newFormatID);
+ });
+ }
+
/**
* Handles changes in text format.
*
@@ -111,24 +131,33 @@
function onTextFormatChange(event) {
const select = event.target;
const field = event.data.field;
- const activeFormatID = field.getAttribute('data-editor-active-text-format');
+ let activeFormatID;
const newFormatID = select.value;
+ let checkContent = false;
+ field.each(function () {
+ activeFormatID = this.getAttribute('data-editor-active-text-format');
- // Prevent double-attaching if the change event is triggered manually.
- if (newFormatID === activeFormatID) {
- return;
- }
+ // Prevent double-attaching if the change event is triggered manually.
+ if (newFormatID === activeFormatID) {
+ return;
+ }
- // When changing to a text format that has a text editor associated
- // with it that supports content filtering, then first ask for
- // confirmation, because switching text formats might cause certain
- // markup to be stripped away.
- const supportContentFiltering =
- drupalSettings.editor.formats[newFormatID] &&
- drupalSettings.editor.formats[newFormatID].editorSupportsContentFiltering;
- // If there is no content yet, it's always safe to change the text format.
- const hasContent = field.value !== '';
- if (hasContent && supportContentFiltering) {
+ // When changing to a text format that has a text editor associated
+ // with it that supports content filtering, then first ask for
+ // confirmation, because switching text formats might cause certain
+ // markup to be stripped away.
+ const supportContentFiltering =
+ drupalSettings.editor.formats[newFormatID] &&
+ drupalSettings.editor.formats[newFormatID].editorSupportsContentFiltering;
+ // If there is no content yet, it's always safe to change the text format.
+ const hasContent = field.value !== '';
+ if (hasContent && supportContentFiltering) {
+ checkContent = true;
+ } else {
+ changeTextEditor(this, newFormatID);
+ }
+ });
+ if (checkContent) {
const message = Drupal.t(
'Changing the text format to %text_format will permanently remove content that is not allowed in that text format.<br><br>Save your changes before switching the text format to avoid losing data.',
{
@@ -146,7 +175,7 @@
text: Drupal.t('Continue'),
class: 'button button--primary',
click() {
- changeTextEditor(field, newFormatID);
+ changeTextEditorMultiple(field, newFormatID);
confirmationDialog.close();
},
},
@@ -179,8 +208,6 @@
});
confirmationDialog.showModal();
- } else {
- changeTextEditor(field, newFormatID);
}
}
@@ -219,26 +246,40 @@
// Store the current active format.
const activeFormatID = editor.value;
- field.setAttribute('data-editor-active-text-format', activeFormatID);
+ field.each(function () {
+ this.setAttribute('data-editor-active-text-format', activeFormatID);
+ });
// Directly attach this text editor, if the text format is enabled.
if (settings.editor.formats[activeFormatID]) {
// XSS protection for the current text format/editor is performed on
// the server side, so we don't need to do anything special here.
- Drupal.editorAttach(field, settings.editor.formats[activeFormatID]);
+ Drupal.editorAttachMultiple(
+ field,
+ settings.editor.formats[activeFormatID],
+ );
}
// When there is no text editor for this text format, still track
// changes, because the user has the ability to switch to some text
// editor, otherwise this code would not be executed.
$(field).on('change.editor keypress.editor', () => {
- field.setAttribute('data-editor-value-is-changed', 'true');
+ field.each(function() {
+ this.setAttribute('data-editor-value-is-changed', 'true');
+ });
+ // Or, using jQuery's .attr() for a more jQuery-centric approach:
+ // $(field).attr('data-editor-value-is-changed', 'true');
+
// Just knowing that the value was changed is enough, stop tracking.
$(field).off('.editor');
});
// Attach onChange handler to text format selector element.
if (editor.tagName === 'SELECT') {
- $this.on('change.editorAttach', { field }, onTextFormatChange);
+ $this.on(
+ 'change.editorAttachMultiple',
+ { field },
+ onTextFormatChange,
+ );
}
// Detach any editor when the containing form is submitted.
$(field.form).on('submit', (event) => {
@@ -248,11 +289,13 @@
}
// Detach the current editor (if any).
if (settings.editor.formats[activeFormatID]) {
- Drupal.editorDetach(
- field,
- settings.editor.formats[activeFormatID],
- 'serialize',
- );
+ field.each(function () {
+ Drupal.editorDetach(
+ this,
+ settings.editor.formats[activeFormatID],
+ 'serialize',
+ );
+ });
}
});
});
@@ -275,11 +318,13 @@
const activeFormatID = editor.value;
const field = findFieldForFormatSelector($this);
if (field && activeFormatID in settings.editor.formats) {
- Drupal.editorDetach(
- field,
- settings.editor.formats[activeFormatID],
- trigger,
- );
+ field.each(function () {
+ Drupal.editorDetach(
+ this,
+ settings.editor.formats[activeFormatID],
+ trigger,
+ );
+ });
}
});
},
@@ -315,6 +360,27 @@
}
};
+ /**
+ * Attaches editor behaviors to the field.
+ *
+ * @param {HTMLElement} field
+ * The textarea DOM element.
+ * @param {object} format
+ * The text format that's being activated, from
+ * drupalSettings.editor.formats.
+ *
+ * @listens event:change
+ *
+ * @fires event:formUpdated
+ */
+ Drupal.editorAttachMultiple = function (field, format) {
+ if (format.editor) {
+ field.each(function () {
+ Drupal.editorAttach(this, format);
+ });
+ }
+ };
+
/**
* Detaches editor behaviors from the field.
*
diff --git a/core/modules/editor/src/Element.php b/core/modules/editor/src/Element.php
index 91739d74a6..16be9686a4 100644
--- a/core/modules/editor/src/Element.php
+++ b/core/modules/editor/src/Element.php
@@ -67,8 +67,13 @@ public function preRenderTextFormat(array $element) {
return $element;
}
+ $field_ids = [$element['value']['#id']];
+
+ if (isset($element['summary'])) {
+ $field_ids[] = $element['summary']['#id'];
+ }
+
// Use a hidden element for a single text format.
- $field_id = $element['value']['#id'];
if (!$element['format']['format']['#access']) {
// Use the first (and only) available text format.
$format_id = $format_ids[0];
@@ -77,14 +82,14 @@ public function preRenderTextFormat(array $element) {
'#name' => $element['format']['format']['#name'],
'#value' => $format_id,
'#attributes' => [
- 'data-editor-for' => $field_id,
+ 'data-editor-for' => implode(',', $field_ids),
],
];
}
// Otherwise, attach to text format selector.
else {
$element['format']['format']['#attributes']['class'][] = 'editor';
- $element['format']['format']['#attributes']['data-editor-for'] = $field_id;
+ $element['format']['format']['#attributes']['data-editor-for'] = implode(',', $field_ids);
}
// Hide the text format's filters' guidelines of those text formats that have