From c8bf170a5b4620f7dc57c53866e979a523c35ffa Mon Sep 17 00:00:00 2001 From: Alexander O'Neill Date: Thu, 22 Nov 2018 16:18:16 -0400 Subject: [PATCH] WIP --- bibcite_footnotes.module | 3 ++- js/replace_citations.js | 20 +++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/bibcite_footnotes.module b/bibcite_footnotes.module index b706d8f..9d890bc 100644 --- a/bibcite_footnotes.module +++ b/bibcite_footnotes.module @@ -250,8 +250,9 @@ function bibcite_footnotes_form_node_form_alter(&$form, FormStateInterface &$for $triggering_element = $form_state->getTriggeringElement(); 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'][''] } else { $form[$triggering_element['#parents'][0]]['widget']['#attached']['library'][] = 'bibcite_footnotes/replace_citations'; diff --git a/js/replace_citations.js b/js/replace_citations.js index ae69224..8c90a8d 100644 --- a/js/replace_citations.js +++ b/js/replace_citations.js @@ -12,16 +12,18 @@ Drupal.behaviors.bibciteFootnotesReplaceCitations = { attach: function attach(context, settings) { - - var formats = drupalSettings.editor.formats; - if (formats) { - for (var key in formats) { - var format = drupalSettings.editor.formats[key]; - if (format.editor == "ckeditor") { - format.editorSettings.referenceFootnotes_list = drupalSettings.bibcite_footnotes.references; - } + alert('got here'); + if (CKEDITOR.instances) { + for (var instance in CKEDITOR.instances) { + var editor = CKEDITOR.instances[instance]; + var config = editor.config; + if (config.hasOwnProperty('referenceFootnotes_list')) { + config.referenceFootnotes_list = drupalSettings.bibcite_footnotes.references; + var name = editor.name; + editor.destroy(); + CKEDITOR.replace(name, config); + } } - } } }