Skip to content

Commit a58c4af

Browse files
committed
added support for Confluence (Atlassian)
1 parent 724ee4d commit a58c4af

File tree

1 file changed

+36
-3
lines changed

1 file changed

+36
-3
lines changed

js/expander.js

+36-3
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ jQuery.noConflict();
2626
, GTT_DOMAIN_REGEX = /translate.google.com/
2727
, OUTLOOK_DOMAIN_REGEX = /mail.live.com/
2828
, MAILCHIMP_DOMAIN_REGEX = /admin.mailchimp.com/
29+
, ATLASSIAN_DOMAIN_REGEX = /atlassian.net/
2930

3031
, EVENT_NAME_KEYPRESS = 'keypress.auto-expander'
3132
, EVENT_NAME_KEYUP = 'keyup.auto-expander'
@@ -43,6 +44,7 @@ jQuery.noConflict();
4344
, SELECTOR_OUTLOOK_EDIT = '#ComposeRteEditor_surface' // Outlook web editor
4445
, SELECTOR_EVERNOTE_EDIT = 'gwt-debug-noteEditor' // Evernote web note editor
4546
, SELECTOR_BASECAMP_EDIT = 'iframe.wysihtml5-sandbox' // Basecamp message editor
47+
, SELECTOR_ATLASSIAN_EDIT = 'iframe#wysiwygTextarea_ifr' // Confluence editor
4648
;
4749

4850
var typingBuffer = []; // Keep track of what's been typed before timeout
@@ -220,7 +222,9 @@ jQuery.noConflict();
220222
} else if (MAILCHIMP_DOMAIN_REGEX.test(domain)) {
221223
replaceTextMailchimp(shortcut, autotext);
222224
} else if (GTT_DOMAIN_REGEX.test(domain)) {
223-
replaceTextTranslate(shortcut, autotext);
225+
replaceTextGTT(shortcut, autotext);
226+
} else if (ATLASSIAN_DOMAIN_REGEX.test(domain)) {
227+
replaceTextAtlassian(shortcut, autotext);
224228
} else if (BASECAMP_DOMAIN_REGEX.test(domain)) {
225229
replaceTextBasecamp(shortcut, autotext);
226230
} else {
@@ -370,8 +374,8 @@ jQuery.noConflict();
370374
replaceTextContentEditable(shortcut, autotext, node, iframeWindow);
371375
}
372376

373-
// Specific handler for Google Translate iframe replacements
374-
function replaceTextTranslate(shortcut, autotext)
377+
// Specific handler for Google Translate iframe text replacements
378+
function replaceTextGTT(shortcut, autotext)
375379
{
376380
debugLog("Domain: Google Translate");
377381

@@ -385,6 +389,20 @@ jQuery.noConflict();
385389
replaceTextContentEditable(shortcut, autotext, node, iframeWindow);
386390
}
387391

392+
// Specific handler for Atlassian frame editor text replacements
393+
function replaceTextAtlassian(shortcut, autotext)
394+
{
395+
debugLog("Domain: Atlassian");
396+
397+
// Get the focused / selected text node
398+
var iframeWindow = document.querySelector(SELECTOR_ATLASSIAN_EDIT).contentWindow;
399+
var node = findFocusedNode(iframeWindow);
400+
debugLog("node:", node);
401+
402+
// Pass onto editable iframe text handler
403+
replaceTextContentEditable(shortcut, autotext, node, iframeWindow);
404+
}
405+
388406
// Reusable handler for editable iframe text replacements
389407
function replaceTextContentEditable(shortcut, autotext, node, win)
390408
{
@@ -895,6 +913,21 @@ jQuery.noConflict();
895913
}, TIME_EDITOR_CHECK);
896914
}
897915

916+
// Special case for Atlassian
917+
if (ATLASSIAN_DOMAIN_REGEX.test(domain))
918+
{
919+
debugLog("Domain: Atlassian");
920+
921+
// SUPER annoying, need to continually check for existence of editor iframe
922+
// because the iframe gets recreated each time and starts with cross-origin
923+
var editorCheck = setInterval(function() {
924+
var $target = $(SELECTOR_ATLASSIAN_EDIT);
925+
if ($target.length) {
926+
addListenersToIframe($target);
927+
}
928+
}, TIME_EDITOR_CHECK);
929+
}
930+
898931
// Special case for Mailchimp
899932
if (MAILCHIMP_DOMAIN_REGEX.test(domain))
900933
{

0 commit comments

Comments
 (0)