docs/assets/javascript/editor.js
function update (e) {
		// tab indent
		if (e.keyCode === 9) {
			e.preventDefault();

         var selection = window.getSelection();
         var range = selection.getRangeAt(0);
         var text = document.createTextNode('\t');

         range.deleteContents();
         range.insertNode(text);
         range.setStartAfter(text);
         selection.removeAllRanges();
         selection.addRange(range);

         return;
		}

		var namespace = '.scope';
		var raw = editor.textContent;
		var pragma = /\/\* @scope (.*?) \*\//g.exec(raw);

		if (pragma != null) {
			namespace = pragma[1].trim();
		}

		var processed = stylis(namespace, raw);

		// apply formatting
		processed = processed.replace(/(;|\})/g, format.newlines);
		processed = processed.replace(/(.*?)\{/g, format.selector);
		processed = processed.replace(/:(.*);/g, format.value);
		processed = processed.replace(/^.*;$/gm, format.tabs);
		processed = processed.replace(/\}\n\n\}/g, '}\n}');
		processed = processed.replace(/(.*@.*\{)([^\0]+\})(\n\})/g, format.block);
		processed = processed.replace(/['"`].*?['"`]/g, format.string);

		output.innerHTML = processed;
	}
function update (e) {
		// tab indent
		if (e.keyCode === 9) {
			e.preventDefault();

         var selection = window.getSelection();
         var range = selection.getRangeAt(0);
         var text = document.createTextNode('\t');

         range.deleteContents();
         range.insertNode(text);
         range.setStartAfter(text);
         selection.removeAllRanges();
         selection.addRange(range);

         return;
		}

		var namespace = '.scope';
		var raw = editor.textContent;
		var pragma = /\/\* @scope (.*?) \*\//g.exec(raw);

		if (pragma != null) {
			namespace = pragma[1].trim();
		}

		var processed = stylis(namespace, raw);

		// apply formatting
		processed = processed.replace(/(;|\})/g, format.newlines);
		processed = processed.replace(/(.*?)\{/g, format.selector);
		processed = processed.replace(/:(.*);/g, format.value);
		processed = processed.replace(/^.*;$/gm, format.tabs);
		processed = processed.replace(/\}\n\n\}/g, '}\n}');
		processed = processed.replace(/(.*@.*\{)([^\0]+\})(\n\})/g, format.block);
		processed = processed.replace(/['"`].*?['"`]/g, format.string);

		output.innerHTML = processed;
	}
function update ( e ) { // tab indent if ( e . keyCode === 9 ) { e . preventDefault ( ) ; var selection = window . getSelection ( ) ; var range = selection . getRangeAt ( 0 ) ; var text = document . createTextNode ( '\t' ) ; range . deleteContents ( ) ; range . insertNode ( text ) ; range . setStartAfter ( text ) ; selection . removeAllRanges ( ) ; selection . addRange ( range ) ; return ; } var namespace = '.scope' ; var raw = editor . textContent ; var pragma = / \/\* @scope (.*?) \*\/ / g . exec ( raw ) ; if ( pragma != null ) { namespace = pragma [ 1 ] . trim ( ) ; } var processed = stylis ( namespace , raw ) ; // apply formatting processed = processed . replace ( / (;|\}) / g , format . newlines ) ; processed = processed . replace ( / (.*?)\{ / g , format . selector ) ; processed = processed . replace ( / :(.*); / g , format . value ) ; processed = processed . replace ( / ^.*;$ / gm , format . tabs ) ; processed = processed . replace ( / \}\n\n\} / g , '}\n}' ) ; processed = processed . replace ( / (.*@.*\{)([^\0]+\})(\n\}) / g , format . block ) ; processed = processed . replace ( / ['"`].*?['"`] / g , format . string ) ; output . innerHTML = processed ; }
update output preview
update output preview