Alexander O'Neill 6 years ago
parent
commit
c8bf170a5b
  1. 3
      bibcite_footnotes.module
  2. 18
      js/replace_citations.js

3
bibcite_footnotes.module

@ -250,8 +250,9 @@ function bibcite_footnotes_form_node_form_alter(&$form, FormStateInterface &$for
$triggering_element = $form_state->getTriggeringElement(); $triggering_element = $form_state->getTriggeringElement();
if (!$triggering_element) { if (!$triggering_element) {
$form[]['#attached']['library'][] = 'bibcite_footnotes/reference_footnote'; $form['#attached']['library'][] = 'bibcite_footnotes/replace_citations';
$form['#attached']['drupalSettings']['bibcite_footnotes']['references'] = $bibcite_references; $form['#attached']['drupalSettings']['bibcite_footnotes']['references'] = $bibcite_references;
// $form['#attached']['drupalSettings']['']
} }
else { else {
$form[$triggering_element['#parents'][0]]['widget']['#attached']['library'][] = 'bibcite_footnotes/replace_citations'; $form[$triggering_element['#parents'][0]]['widget']['#attached']['library'][] = 'bibcite_footnotes/replace_citations';

18
js/replace_citations.js

@ -12,16 +12,18 @@
Drupal.behaviors.bibciteFootnotesReplaceCitations = { Drupal.behaviors.bibciteFootnotesReplaceCitations = {
attach: function attach(context, settings) { attach: function attach(context, settings) {
alert('got here');
var formats = drupalSettings.editor.formats; if (CKEDITOR.instances) {
if (formats) { for (var instance in CKEDITOR.instances) {
for (var key in formats) { var editor = CKEDITOR.instances[instance];
var format = drupalSettings.editor.formats[key]; var config = editor.config;
if (format.editor == "ckeditor") { if (config.hasOwnProperty('referenceFootnotes_list')) {
format.editorSettings.referenceFootnotes_list = drupalSettings.bibcite_footnotes.references; config.referenceFootnotes_list = drupalSettings.bibcite_footnotes.references;
var name = editor.name;
editor.destroy();
CKEDITOR.replace(name, config);
} }
} }
} }
} }
} }

Loading…
Cancel
Save