Topic on Extension talk:WYSIWYG

Open reference dialog by doubleclick on the footnote

2
Varlin (talkcontribs)

Hi, I was able to add this feature to my wiki (after I asked for help). You can check here how it works : https://wikirouge.net/Journ%C3%A9es_de_juillet_1917

The changes have been made in these two files :

  • WYSIWYG/ckeditor/plugins/mediawiki/dialogs/ref.js
  • WYSIWYG/ckeditor/plugins/mediawiki/plugin.js

Here are the changes, in github format (It should be possible to "import" these instructions onto github, right ?) :

diff --git a/extensions/WYSIWYG/ckeditor/plugins/mediawiki/dialogs/ref.js b/extensions/WYSIWYG/ckeditor/plugins/mediawiki/dialogs/ref.js index c116dd8..ec614d6 100644 --- a/extensions/WYSIWYG/ckeditor/plugins/mediawiki/dialogs/ref.js +++ b/extensions/WYSIWYG/ckeditor/plugins/mediawiki/dialogs/ref.js @@ -148,6 +148,12 @@ CKEDITOR.dialog.add( 'MWRefmarker', function( editor ) { if ( span1.getName() == 'span' && span1.hasClass('fck_mw_ref') && span1.getAttribute('data-widget') == 'mwrefmarker' && sup1.getName() == 'sup' && ref1.getName() == 'ref' ) { element = ref1; + } else if (span1 != null && sup1 != null && sup1.getName() == "references") { + var ref = CKEDITOR.plugins.mwreferencesmarkerref; + if (ref != null) { + element = editor.document.find('#cite_ref-' + ref).getItem(0); + CKEDITOR.plugins.mwreferencesmarkerref = null; + } } } } diff --git a/extensions/WYSIWYG/ckeditor/plugins/mediawiki/plugin.js b/extensions/WYSIWYG/ckeditor/plugins/mediawiki/plugin.js index 4042546..cc9c312 100644 --- a/extensions/WYSIWYG/ckeditor/plugins/mediawiki/plugin.js +++ b/extensions/WYSIWYG/ckeditor/plugins/mediawiki/plugin.js @@ -1,4 +1,4 @@ -/** +/** * @license Copyright (c) 2003-2016, CKSource - Frederico Knabben. All rights reserved. * For licensing, see LICENSE.md or http://ckeditor.com/license */ @@ -1159,10 +1159,17 @@ if (!editor.document) return; editor.on( 'doubleclick', function( evt ) { + CKEDITOR.plugins.mwreferencesmarkerref = null; var element = CKEDITOR.plugins.link.getSelectedLink( editor ) || evt.data.element; if ( element == null ) { element = selection.getStartElement(); //For <ref> as text based element, img element is not used } + if (element.hasClass("ref-string-o-row")) { + var className = element.getAttribute('class'), match; + if (match = className.match(/ref-string-o-(\d+)/)) { + CKEDITOR.plugins.mwreferencesmarkerref = match[1]; + } + } /**** if ( element.hasAscendant( 'ref', true ) == true ) { //For <ref> as text based element, img element is not used @@ -1193,6 +1200,9 @@ if (!editor.document) return; element.getAttribute( 'class' ) == 'FCK__MWTemplate' ) { evt.data.dialog = 'MWTemplate'; } //03.02.14 RL<- + else if (element.is("span") && element.hasClass("ref-string-o-row")) { + evt.data.dialog = 'MWRefmarker'; + } else {

Riparap (talkcontribs)

Great, this is cool function. It has been included in Version 1.5.6_0 [B551-01.07.2018] (#6 bundle) together with button to format selected text with "italic + angle quotes".

Reply to "Open reference dialog by doubleclick on the footnote"