From 8e9d3065109ebf4e0d71bff19c068d10ef220b9c Mon Sep 17 00:00:00 2001 From: Ed Sanders Date: Tue, 21 Apr 2020 15:28:40 +0100 Subject: [PATCH] Create a toolbarReady hook for attaching toolbar tools Using an event introduces a race condition where the extension adding the listener has to do so before WikiEditor finishes loading. Change-Id: I5a8dc6f8fd1b1939b5d98307b20ef1fd355cee99 --- extension.json | 2 +- modules/jquery.wikiEditor.toolbar.js | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/extension.json b/extension.json index 25783db4..62ccab9b 100644 --- a/extension.json +++ b/extension.json @@ -1,6 +1,6 @@ { "name": "WikiEditor", - "version": "0.5.2", + "version": "0.5.3", "author": [ "Derk-Jan Hartman", "Trevor Parscal", diff --git a/modules/jquery.wikiEditor.toolbar.js b/modules/jquery.wikiEditor.toolbar.js index 8392648d..9e0107fa 100644 --- a/modules/jquery.wikiEditor.toolbar.js +++ b/modules/jquery.wikiEditor.toolbar.js @@ -768,6 +768,8 @@ } setTimeout( function () { context.$textarea.trigger( 'wikiEditor-toolbar-doneInitialSections' ); + // Use hook for attaching new toolbar tools to avoid race conditions + mw.hook( 'wikiEditor.toolbarReady' ).fire( context.$textarea ); } ); } }