Navigation
-
+
diff --git a/js/creator-23.js b/js/creator-23.js
index 4c527f60..688df1de 100644
--- a/js/creator-23.js
+++ b/js/creator-23.js
@@ -3907,6 +3907,36 @@ function fetchScryfallData(cardName, callback = console.log, searchUniqueArt = '
console.log('Scryfall API search failed.')
}
}
+
+function toggleTextTag(tag) {
+ var element = document.getElementById('text-editor');
+
+ var text = element.value;
+
+ var start = element.selectionStart;
+ var end = element.selectionEnd;
+ var selection = text.substring(start, end);
+
+ var openTag = '{' + tag + '}';
+ var closeTag = '{/' + tag + '}';
+
+ var prefix = text.substring(0, start);
+ var suffix = text.substring(end);
+
+ if (prefix.endsWith(openTag) && suffix.startsWith(closeTag)) {
+ prefix = prefix.substring(0, prefix.length-openTag.length);
+ suffix = suffix.substring(closeTag.length);
+ } else if (selection.startsWith(openTag) && selection.endsWith(closeTag)) {
+ selection = selection.substring(openTag.length, selection.length-closeTag.length);
+ } else {
+ selection = openTag + selection + closeTag;
+ }
+
+ element.value = prefix + selection + suffix;
+
+ textEdited();
+}
+
// INITIALIZATION
// auto load frame version (user defaults)
diff --git a/js/main-1.js b/js/main-1.js
index 34505eb5..8cd5f8f7 100644
--- a/js/main-1.js
+++ b/js/main-1.js
@@ -123,3 +123,12 @@ document.addEventListener('DOMContentLoaded', function() {
document.body.dispatchEvent(new Event('doCreate'));
})
+document.onkeyup = function(e) {
+ if (document.activeElement === document.getElementById('text-editor')) {
+ if (e.ctrlKey && e.which == 73) {
+ toggleTextTag('i');
+
+ e.preventDefault();
+ }
+ }
+}
\ No newline at end of file