diff --git a/CHANGELOG.md b/CHANGELOG.md index c2a2560d7..422d4cee5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# WIP + +* merge PR to open links in rich text with a single click + # 4.4.0 ## Goals diff --git a/www/common/translations/messages.de.json b/www/common/translations/messages.de.json index d45897457..c7d28db09 100644 --- a/www/common/translations/messages.de.json +++ b/www/common/translations/messages.de.json @@ -417,6 +417,9 @@ "settings_padSpellcheckTitle": "Rechtschreibprüfung", "settings_padSpellcheckHint": "Mit dieser Option kann die Rechtschreibprüfung in Rich-Text-Pads aktiviert werden. Rechtschreibfehler werden rot unterstrichen. Halte die Strg- oder Meta-Taste gedrückt, um Verbesserungsvorschläge anzuzeigen.", "settings_padSpellcheckLabel": "Rechtschreibprüfung in Rich-Text-Pads aktivieren", + "settings_padOpenLinkTitle": "Links direkt öffnen", + "settings_padOpenLinkHint": "Mit dieser Optione werden externe Links direkt über Klick in einem neuem Fenster geöffnet.", + "settings_padOpenLinkLabel": "Aktiviert Links direkt über Klick zu öffnen", "settings_ownDriveTitle": "Account aktualisieren", "settings_ownDriveHint": "Aus technischen Gründen sind nicht alle neue Funktionen für ältere Konten verfügbar. Eine kostenlose Aktualisierung wird die neuen Funktionen aktivieren und dein CryptDrive für zukünftige Aktualisierungen vorbereiten.", "settings_ownDriveButton": "Upgrade deines Accounts", diff --git a/www/common/translations/messages.json b/www/common/translations/messages.json index bac8defb3..c0ecbb163 100644 --- a/www/common/translations/messages.json +++ b/www/common/translations/messages.json @@ -434,6 +434,9 @@ "settings_padSpellcheckTitle": "Spellcheck", "settings_padSpellcheckHint": "This option allows you to enable spellcheck in rich text pads. Spelling errors will be underlined in red and you'll have to hold your Ctrl or Meta key while right-clicking to see the correct options.", "settings_padSpellcheckLabel": "Enable spell check in rich text pads", + "settings_padOpenLinkTitle": "Open links on first click", + "settings_padOpenLinkHint": "With this option you can open embedded links on click without the preview popup", + "settings_padOpenLinkLabel": "Enable direct link opening rich text pads", "settings_ownDriveTitle": "Update Account", "settings_ownDriveHint": "Older accounts do not have access to the latest features, due to technical reasons. A free update will enable current features, and prepare your CryptDrive for future updates.", "settings_ownDriveButton": "Upgrade your account", diff --git a/www/pad/inner.js b/www/pad/inner.js index cb2cb9285..18d4c18a5 100644 --- a/www/pad/inner.js +++ b/www/pad/inner.js @@ -1445,7 +1445,9 @@ define([ editor.setKeystroke( CKEDITOR.CTRL + CKEDITOR.ALT + styleKeys[tag], tag); }); - Links.init(Ckeditor, editor); + var privateData = framework._.cpNfInner.metadataMgr.getPrivateData(); + var openLinkSetting = Util.find(privateData, ['settings', 'pad', 'openLink']); + Links.init(Ckeditor, editor, openLinkSetting); }).nThen(function() { // Move ckeditor parts to have a structure like the other apps var $contentContainer = $('#cke_1_contents'); diff --git a/www/pad/links.js b/www/pad/links.js index 779257dfb..68c59d5b3 100644 --- a/www/pad/links.js +++ b/www/pad/links.js @@ -5,7 +5,7 @@ define([ '/customize/messages.js' ], function ($, h, UIElements, Messages) { - var onLinkClicked = function (e, inner) { + var onLinkClicked = function (e, inner, openLinkSetting) { var $target = $(e.target); if (!$target.is('a')) { $target = $target.closest('a'); @@ -25,6 +25,13 @@ define([ return; } + var open = function () { + var bounceHref = window.location.origin + '/bounce/#' + encodeURIComponent(href); + window.open(bounceHref); + }; + + if (openLinkSetting) { return void open(); } + var $iframe = $('html').find('iframe').contents(); var rect = e.target.getBoundingClientRect(); @@ -48,8 +55,7 @@ define([ $(a).click(function (ee) { ee.preventDefault(); ee.stopPropagation(); - var bounceHref = window.location.origin + '/bounce/#' + encodeURIComponent(href); - window.open(bounceHref); + open(); $link.remove(); }); $link.on('mouseleave', function () { @@ -61,7 +67,7 @@ define([ }; return { - init : function (Ckeditor, editor) { + init : function (Ckeditor, editor, openLinkSetting) { if (!Ckeditor.plugins.link) { return; } var inner = editor.document.$.body; @@ -70,7 +76,7 @@ define([ $inner.click(function (e) { removeClickedLink($inner); if (e.target.nodeName.toUpperCase() === 'A' || $(e.target).closest('a').length) { - return void onLinkClicked(e, inner); + return void onLinkClicked(e, inner, openLinkSetting); } }); diff --git a/www/settings/inner.js b/www/settings/inner.js index 85aa27c10..75d7b05f1 100644 --- a/www/settings/inner.js +++ b/www/settings/inner.js @@ -84,6 +84,7 @@ define([ 'cp-settings-pad-width', 'cp-settings-pad-spellcheck', 'cp-settings-pad-notif', + 'cp-settings-pad-openlink', ], 'code': [ // Msg.settings_cat_code 'cp-settings-code-indent-unit', @@ -1359,6 +1360,43 @@ define([ cb($cbox); }, true); + create['pad-openlink'] = function() { + var $div = $('
', { + 'class': 'cp-settings-pad-openlink cp-sidebarlayout-element' + }); + $('