This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function slugify(text) { | |
return angular.lowercase((text || '')) | |
.replace(/\s+/g, '-') | |
.replace(/[^\w\-]+/g, '') | |
.replace(/\-\-+/g, '-') | |
.replace(/^-+/, '') | |
.replace(/-+$/, ''); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://stackoverflow.com/a/55605049 | |
export function getLineBreaks(node: Node): string[] { | |
// we only deal with TextNodes | |
if (!node || !node.parentNode || node.nodeType !== 3 || !node.textContent) return []; | |
// our Range object form which we'll get the characters positions | |
const range = document.createRange(); | |
// here we'll store all our lines | |
const lines = []; | |
// begin at the first char | |
range.setStart(node, 0); |