Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix handleTabs from @ecchochan fork and fix #67 #89

Merged
merged 11 commits into from
Dec 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build/codeflask.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion build/codeflask.module.js

Large diffs are not rendered by default.

468 changes: 283 additions & 185 deletions src/codeflask.js

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions src/styles/editor.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { BACKGROUND_COLOR, LINE_HEIGHT, FONT_SIZE } from './theme-default';
import { cssSupports } from '../utils/css-supports';
import { BACKGROUND_COLOR, LINE_HEIGHT, FONT_SIZE } from './theme-default'
import { cssSupports } from '../utils/css-supports'

const FONT_FAMILY = `"SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace`;
const COLOR = (cssSupports('caret-color', '#000')) ? BACKGROUND_COLOR : '#ccc';
const FONT_FAMILY = `"SFMono-Regular", Consolas, "Liberation Mono", Menlo, Courier, monospace`
const COLOR = (cssSupports('caret-color', '#000')) ? BACKGROUND_COLOR : '#ccc'
const LINE_NUMBER_WIDTH = '40px'


export const editor_css = `
export const editorCss = `
.codeflask {
position: absolute;
width: 100%;
Expand Down Expand Up @@ -110,4 +109,4 @@ export const editor_css = `
background: #eee;
z-index: 1;
}
`;
`
20 changes: 10 additions & 10 deletions src/styles/injector.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
export function inject_css(css, styleName, parent) {
const CSS_ID = styleName || 'codeflask-style';
const PARENT = parent || document.head;
export function injectCss (css, styleName, parent) {
const CSS_ID = styleName || 'codeflask-style'
const PARENT = parent || document.head

if (!css) {
return false;
return false
}

if (document.getElementById(CSS_ID)) {
return true;
return true
}

const style = document.createElement('style');
const style = document.createElement('style')

style.innerHTML = css;
style.id = CSS_ID;
PARENT.appendChild(style);
style.innerHTML = css
style.id = CSS_ID
PARENT.appendChild(style)

return true;
return true
}
10 changes: 5 additions & 5 deletions src/styles/theme-default.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const BACKGROUND_COLOR = '#fff';
export const LINE_HEIGHT = '20px';
export const FONT_SIZE = '13px';
export const BACKGROUND_COLOR = '#fff'
export const LINE_HEIGHT = '20px'
export const FONT_SIZE = '13px'

export const default_css_theme = `
export const defaultCssTheme = `
.codeflask {
background: ${BACKGROUND_COLOR};
color: #4f559c;
Expand Down Expand Up @@ -55,4 +55,4 @@ export const default_css_theme = `
.codeflask .token.attr-value {
color: #8500ff;
}
`;
`
12 changes: 6 additions & 6 deletions src/utils/css-supports.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
export function cssSupports(property, value) {
export function cssSupports (property, value) {
if (CSS) {
return CSS.supports(property, value);
return CSS.supports(property, value)
}

return toCamelCase(property) in document.body.style;
return toCamelCase(property) in document.body.style
}

export function toCamelCase(cssProperty) {
export function toCamelCase (cssProperty) {
cssProperty = cssProperty
.split('-')
.filter(word => !!word)
.map(word => word[0].toUpperCase() + word.substr(1))
.join('');
.join('')

return cssProperty[0].toLowerCase() + cssProperty.substr(1);
return cssProperty[0].toLowerCase() + cssProperty.substr(1)
}
10 changes: 5 additions & 5 deletions src/utils/html-escape.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ const entityMap = {
'/': '/',
'`': '`',
'=': '='
};
}

export function escape_html (string) {
return String(string).replace(/[&<>"'`=\/]/g, function (s) {
return entityMap[s];
});
export function escapeHtml (string) {
return String(string).replace(/[&<>"'`=/]/g, function (s) {
return entityMap[s]
})
}