Skip to content

Commit 92564fb

Browse files
committed
feat(map): Inline embedding of map added
1 parent b3a9ec3 commit 92564fb

4 files changed

Lines changed: 65 additions & 40 deletions

File tree

dist/embed.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/embed.js

Lines changed: 46 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/embed.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/js/modules/map/map.es6

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ class Gmap {
66
this.output = output;
77
this.options = options;
88
this.embeds = embeds;
9+
this.service = 'map'
910
this.regex = /@\((.+)\)/gi;
1011
}
1112

@@ -38,17 +39,24 @@ class Gmap {
3839

3940
async process() {
4041
let match;
41-
while ((match = utils.matches(this.regex, this.input)) !== null) {
42+
while ((match = utils.matches(this.regex, this.output)) !== null) {
4243
let [latitude, longitude] = this.options.mapOptions.mode !== 'place' ? await this.getCoordinate(match[0]) : [null, null];
4344
let text = this.template(match[0], latitude, longitude);
44-
this.embeds.push({
45-
text: text,
46-
index: match.index
47-
})
45+
if (!utils.ifInline(this.options, this.service)) {
46+
this.output = this.output.replace(this.regex, (match) => {
47+
return '<span class="ejs-location">' + match.split('(')[1].split(')')[0] + '</span>' + text
48+
})
49+
} else {
50+
this.embeds.push({
51+
text: text,
52+
index: match.index
53+
})
54+
this.output = this.output.replace(this.regex, function(match) {
55+
return '<span class="ejs-location">' + match.split('(')[1].split(')')[0] + '</span>';
56+
});
57+
}
4858
}
49-
this.output = this.output.replace(this.regex, function(match) {
50-
return '<span class="ejs-location">' + match.split('(')[1].split(')')[0] + '</span>';
51-
});
59+
5260
return [this.output, this.embeds];
5361
}
5462
}

0 commit comments

Comments
 (0)