Skip to content

Commit

Permalink
Added browserlist, Tweaked md scrollToText ot use ES6
Browse files Browse the repository at this point in the history
  • Loading branch information
ssddanbrown committed Jul 14, 2018
1 parent f668bee commit b2cd363
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 24 deletions.
2 changes: 2 additions & 0 deletions .browserslistrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
>0.25%
not op_mini all
39 changes: 17 additions & 22 deletions resources/assets/js/components/markdown-editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -395,35 +395,30 @@ class MarkdownEditor {
}

// Scroll to a specified text
scrollToText(searchText) {;
scrollToText(searchText) {
if (!searchText) {
return;
}

const content = this.cm.getValue();
const lines = content.split(/\r?\n/);
let lineNumber = -1;
for (let i = 0; i !== lines.length; ++i) {
const line = lines[i];
if (!line) {
continue;
}
if (line.indexOf(searchText) !== -1) {
lineNumber = i;
break;
}
}
let lineNumber = lines.findIndex(line => {
return line && line.indexOf(searchText) !== -1;
});

if (lineNumber !== -1) {
this.cm.scrollIntoView({
line: lineNumber,
}, 200);
this.cm.focus();
// set the cursor location.
this.cm.setCursor({
line: lineNumber,
char: lines[lineNumber].length
})
if (lineNumber === -1) {
return;
}

this.cm.scrollIntoView({
line: lineNumber,
}, 200);
this.cm.focus();
// set the cursor location.
this.cm.setCursor({
line: lineNumber,
char: lines[lineNumber].length
})
}

}
Expand Down
1 change: 0 additions & 1 deletion resources/assets/js/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// Global Polyfills
import "@babel/polyfill"
import "./services/dom-polyfills"

// Url retrieval function
Expand Down
6 changes: 5 additions & 1 deletion webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ const config = {
use: {
loader: 'babel-loader',
options: {
presets: ['@babel/preset-env']
presets: [[
'@babel/preset-env', {
useBuiltIns: 'usage'
}
]]
}
}
},
Expand Down

0 comments on commit b2cd363

Please sign in to comment.