UX: only apply link formats on paste to selections that do not contain bbcode-like tags (#15204)
This commit is contained in:
parent
e0ea16f05d
commit
c8af3e7bc1
|
@ -286,7 +286,10 @@ export default Mixin.create({
|
|||
plainText &&
|
||||
!handled &&
|
||||
selected.end > selected.start &&
|
||||
!this._cachedLinkify.test(selectedValue)
|
||||
// text selection does not contain url
|
||||
!this._cachedLinkify.test(selectedValue) &&
|
||||
// text selection does not contain a bbcode-like tag
|
||||
!selectedValue.match(/\[\/?[a-z =]+?\]/g)
|
||||
) {
|
||||
if (this._cachedLinkify.test(plainText)) {
|
||||
const match = this._cachedLinkify.match(plainText)[0];
|
||||
|
|
|
@ -846,6 +846,19 @@ third line`
|
|||
}
|
||||
);
|
||||
|
||||
testCase(
|
||||
`pasting a url onto a selection that contains bbcode-like tags will use default paste behavior`,
|
||||
async function (assert, textarea) {
|
||||
this.set("value", "hello [url=foobar]foobar[/url]");
|
||||
setTextareaSelection(textarea, 0, 30);
|
||||
const element = query(".d-editor");
|
||||
const event = await paste(element, "https://www.discourse.com/");
|
||||
// Synthetic paste events do not manipulate document content.
|
||||
assert.strictEqual(this.value, "hello [url=foobar]foobar[/url]");
|
||||
assert.strictEqual(event.defaultPrevented, false);
|
||||
}
|
||||
);
|
||||
|
||||
(() => {
|
||||
// Tests to check cursor/selection after replace-text event.
|
||||
const BEFORE = "red green blue";
|
||||
|
|
Loading…
Reference in New Issue