1
0
Fork 0

Remove link functionality from editor

Dieser Commit ist enthalten in:
Angus McLeod 2019-10-11 08:49:20 +11:00
Ursprung a2b15024b9
Commit bdb1d936b9
3 geänderte Dateien mit 0 neuen und 47 gelöschten Zeilen

Datei anzeigen

@ -39,6 +39,5 @@
//= require discourse/templates/components/conditional-loading-spinner
//= require discourse/components/d-button
//= require discourse/templates/components/d-button
//= require discourse/components/d-editor-modal
//= require lodash.js
//= require mousetrap.js

Datei anzeigen

@ -68,8 +68,6 @@ class Toolbar {
perform: e => e.applySurround('_', '_', 'italic_text')
});
this.addButton({id: 'link', group: 'insertions', shortcut: 'K', action: 'showLinkModal'});
this.addButton({
id: 'quote',
group: 'insertions',
@ -175,9 +173,6 @@ class Toolbar {
export default Ember.Component.extend({
classNames: ['d-editor'],
ready: false,
insertLinkHidden: true,
linkUrl: '',
linkText: '',
lastSel: null,
_mouseTrap: null,
showPreview: false,
@ -631,16 +626,6 @@ export default Ember.Component.extend({
}
},
showLinkModal() {
this._lastSel = this._getSelected();
if (this._lastSel) {
this.set("linkText", this._lastSel.value.trim());
}
this.set('insertLinkHidden', false);
},
formatCode() {
const sel = this._getSelected('', { lineVal: true });
const selValue = sel.value;
@ -669,29 +654,6 @@ export default Ember.Component.extend({
return this._addText(sel, `${preNewline}\`\`\`\n${sel.value}\n\`\`\`${postNewline}`);
}
}
},
insertLink() {
const origLink = this.get('linkUrl');
const linkUrl = (origLink.indexOf('://') === -1) ? `http://${origLink}` : origLink;
const sel = this._lastSel;
if (Ember.isEmpty(linkUrl)) { return; }
const linkText = this.get('linkText') || '';
if (linkText.length) {
this._addText(sel, `[${linkText}](${linkUrl})`);
} else {
if (sel.value) {
this._addText(sel, `[${sel.value}](${linkUrl})`);
} else {
this._addText(sel, `[${origLink}](${linkUrl})`);
this._selectText(sel.start + 1, origLink.length);
}
}
this.set('linkUrl', '');
this.set('linkText', '');
}
}
});

Datei anzeigen

@ -1,13 +1,5 @@
<div class='d-editor-overlay hidden'></div>
<div class='d-editor-modals'>
{{#d-editor-modal class="insert-link" hidden=insertLinkHidden okAction="insertLink"}}
<h3>{{i18n "wizard_composer.link_dialog_title"}}</h3>
{{wizard-text-field value=linkUrl placeholderKey="wizard_composer.link_url_placeholder" class="link-url"}}
{{wizard-text-field value=linkText placeholderKey="wizard_composer.link_optional_text" class="link-text"}}
{{/d-editor-modal}}
</div>
<div class='d-editor-container'>
{{#if showPreview}}
<div class="d-editor-preview-wrapper {{if forcePreview 'force-preview'}}">