Skip to content

Commit

Permalink
DEV: add useBlockMode option for toolbar button text selection
Browse files Browse the repository at this point in the history
Allows buttons to switch selection to block mode if needed.
  • Loading branch information
pmusaraj committed Jul 2, 2019
1 parent c422520 commit 6e3e068
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion app/assets/javascripts/discourse/components/d-editor.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,13 @@ export default Ember.Component.extend({
this.set("value", `${pre}${hval}${example}${tail}${post}`);
this._selectText(pre.length + hlen, example.length);
} else if (opts && !opts.multiline) {
const [hval, hlen] = getHead(head);
let [hval, hlen] = getHead(head);

if (opts.useBlockMode && sel.value.split("\n").length > 1) {
hval += "\n";
hlen += 1;
tail = `\n${tail}`;
}

if (pre.slice(-hlen) === hval && post.slice(0, tail.length) === tail) {
this.set(
Expand Down

0 comments on commit 6e3e068

Please sign in to comment.