This repository has been archived by the owner on May 26, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(editor): editor initialization fixed
related to #351 related to #352 Signed-off-by: ggalkin gleb.galkin@zalando.de Signed-off-by: ggalkin <gleb.galkin@zalando.de>
- Loading branch information
ggalkin
committed
Jul 16, 2019
1 parent
43bd86b
commit b67c15a
Showing
5 changed files
with
100 additions
and
109 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
export const aceThemePath = 'ace/theme/'; | ||
|
||
export const themes = { | ||
Default: aceThemePath + 'github', | ||
Monokai: aceThemePath + 'monokai', | ||
Ambiance: aceThemePath + 'ambiance', | ||
Chaos: aceThemePath + 'chaos', | ||
Chrome: aceThemePath + 'chrome', | ||
Clouds: aceThemePath + 'clouds', | ||
Clouds_midnight: aceThemePath + 'clouds_midnight', | ||
Cobalt: aceThemePath + 'cobalt', | ||
Crimson_editor: aceThemePath + 'crimson_editor', | ||
Dawn: aceThemePath + 'dawn', | ||
Dracula: aceThemePath + 'dracula', | ||
Dreamweaver: aceThemePath + 'dreamweaver', | ||
Eclipse: aceThemePath + 'eclipse', | ||
Github: aceThemePath + 'github', | ||
Gob: aceThemePath + 'gob', | ||
Gruvbox: aceThemePath + 'gruvbox', | ||
Idle_fingers: aceThemePath + 'idle_fingers', | ||
Iplastic: aceThemePath + 'iplastic', | ||
Katzenmilch: aceThemePath + 'katzenmilch', | ||
Kr_theme: aceThemePath + 'kr_theme', | ||
Kuroir: aceThemePath + 'kuroir', | ||
Merbivore: aceThemePath + 'merbivore', | ||
Merbivore_soft: aceThemePath + 'merbivore_soft', | ||
Mono_industrial: aceThemePath + 'mono_industrial', | ||
Pastel_on_dark: aceThemePath + 'pastel_on_dark', | ||
Solarized_dark: aceThemePath + 'solarized_dark', | ||
Solarized_light: aceThemePath + 'solarized_light', | ||
Sqlserver: aceThemePath + 'sqlserver', | ||
Terminal: aceThemePath + 'terminal', | ||
Textmate: aceThemePath + 'textmate', | ||
Tomorrow: aceThemePath + 'tomorrow', | ||
Tomorrow_night: aceThemePath + 'tomorrow_night', | ||
Tomorrow_night_blue: aceThemePath + 'tomorrow_night_blue', | ||
Tomorrow_night_bright: aceThemePath + 'tomorrow_night_bright', | ||
Tomorrow_night_eighties: aceThemePath + 'tomorrow_night_eighties', | ||
Twilight: aceThemePath + 'twilight', | ||
Vibrant_ink: aceThemePath + 'vibrant_ink', | ||
Xcode: aceThemePath + 'xcode' | ||
}; | ||
|
||
export const defaultCustomOptions = { | ||
liveUrlQuery: true, | ||
hideUnfilteredJsonByDefault: false | ||
}; | ||
|
||
export const defaultEditorOptions = { | ||
highlightActiveLine: true, | ||
highlightSelectedWord: true, | ||
readOnly: true, | ||
autoScrollEditorIntoView: false, | ||
showLineNumbers: true, | ||
showGutter: true, | ||
displayIndentGuides: true, | ||
fixedWidthGutter: false, | ||
theme: themes.Default, | ||
fontSize: '14px', | ||
fontFamily: | ||
'Monaco, Menlo, "Ubuntu Mono", Consolas, source-code-pro, monospace', | ||
dragEnabled: true | ||
}; |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,48 +1,56 @@ | ||
const domain = new URL(location.href).hostname; | ||
|
||
type SavedFilter = { | ||
domain: string, | ||
filter: string, | ||
domain: string; | ||
filter: string; | ||
}; | ||
|
||
export function checkStorageOptions(defaultOptions) { | ||
chrome.storage.sync.get(['options'], result => { | ||
if (result.options === undefined) { | ||
saveStorage(JSON.stringify(defaultOptions)); | ||
} | ||
}); | ||
} | ||
|
||
export function saveStorage(value) { | ||
chrome.storage.sync.set({ options: value }, function () { | ||
}); | ||
chrome.storage.sync.set({ options: value }, function() {}); | ||
} | ||
|
||
export function addFilter(filter: string, done?: () => void) { | ||
chrome.storage.sync.get(['storedFilters'], (result) => { | ||
const storedFilters = result.storedFilters as string[] || []; | ||
chrome.storage.sync.get(['storedFilters'], result => { | ||
const storedFilters = (result.storedFilters as string[]) || []; | ||
const filterObj = { | ||
filter, | ||
domain | ||
} | ||
}; | ||
let filterSet = new Set(storedFilters); | ||
filterSet.add(JSON.stringify(filterObj)); | ||
chrome.storage.sync.set({ storedFilters: Array.from(filterSet) }, done) | ||
chrome.storage.sync.set({ storedFilters: Array.from(filterSet) }, done); | ||
}); | ||
} | ||
|
||
export function removeFilter(filter: string, done?: () => void) { | ||
chrome.storage.sync.get(['storedFilters'], (result) => { | ||
const storedFilters = result.storedFilters as string[] || []; | ||
chrome.storage.sync.get(['storedFilters'], result => { | ||
const storedFilters = (result.storedFilters as string[]) || []; | ||
let filterSet = new Set(storedFilters); | ||
const filterObj = { | ||
filter, | ||
domain | ||
} | ||
}; | ||
filterSet.delete(JSON.stringify(filterObj)); | ||
chrome.storage.sync.set({ storedFilters: Array.from(filterSet) }, done); | ||
}); | ||
} | ||
|
||
export function getFilters(callback: (filterlist: string[]) => void) { | ||
chrome.storage.sync.get(['storedFilters'], (result) => { | ||
const filtersForDomain = (result.storedFilters as string[] || []) | ||
.map(s => JSON.parse(s) as SavedFilter) | ||
chrome.storage.sync.get(['storedFilters'], result => { | ||
const filtersForDomain = ((result.storedFilters as string[]) || []).map( | ||
s => JSON.parse(s) as SavedFilter | ||
); | ||
// .filter(f => f.domain === domain) | ||
// In the future this will make filters linked to the domain they were created in. | ||
const filterStrings = filtersForDomain.map(({ filter }) => filter) | ||
const filterStrings = filtersForDomain.map(({ filter }) => filter); | ||
callback(filterStrings); | ||
}); | ||
} |