DEV: Make image resize controls more resilient (#8867)

Commit aa24be1 made it possible to build data attributes from image's
Markdown and this changes ensure that the resize controls still work
when data attributes are present.
This commit is contained in:
Dan Ungureanu
2020-02-06 17:19:24 +02:00
committed by GitHub
parent 1183f8df52
commit 2a884e25be
3 changed files with 26 additions and 13 deletions

View File

@@ -15,10 +15,15 @@ function buildToken(state, type, tag, klass, nesting) {
function wrapImage(tokens, index, state, imgNumber) {
const imgToken = tokens[index];
let selectedScale = imgToken.content
.split(",")
.pop()
.trim();
const sizePart = imgToken.content
.split("|")
.find(x => x.match(/\d{1,4}x\d{1,4}(,\s*\d{1,3}%)?/));
let selectedScale =
sizePart &&
sizePart
.split(",")
.pop()
.trim();
tokens.splice(
index,
0,