|
|
@ -15,8 +15,7 @@ const _paq = window._paq = window._paq || [] //eslint-disable-line |
|
|
|
|
|
|
|
|
|
|
|
/* eslint-disable-next-line */ |
|
|
|
/* eslint-disable-next-line */ |
|
|
|
export interface RemixUiHomeTabProps { |
|
|
|
export interface RemixUiHomeTabProps { |
|
|
|
plugin: any, |
|
|
|
plugin: any |
|
|
|
registry: any |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const loadingInitialState = { |
|
|
|
const loadingInitialState = { |
|
|
@ -30,7 +29,9 @@ const loadingReducer = (state = loadingInitialState, action) => { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => { |
|
|
|
export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => { |
|
|
|
const { plugin, registry } = props |
|
|
|
const { plugin } = props |
|
|
|
|
|
|
|
let fileManager = plugin.fileManager |
|
|
|
|
|
|
|
|
|
|
|
const [state, setState] = useState<{ |
|
|
|
const [state, setState] = useState<{ |
|
|
|
themeQuality: { filter: string, name: string }, |
|
|
|
themeQuality: { filter: string, name: string }, |
|
|
|
showMediaPanel: 'none' | 'twitter' | 'medium', |
|
|
|
showMediaPanel: 'none' | 'twitter' | 'medium', |
|
|
@ -39,7 +40,7 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => { |
|
|
|
importSource: string, |
|
|
|
importSource: string, |
|
|
|
toasterMsg: string |
|
|
|
toasterMsg: string |
|
|
|
}>({ |
|
|
|
}>({ |
|
|
|
themeQuality: registry.get('themeModule').api.currentTheme().quality === 'dark' ? themes.dark : themes.light, |
|
|
|
themeQuality: themes.light, |
|
|
|
showMediaPanel: 'none', |
|
|
|
showMediaPanel: 'none', |
|
|
|
showModalDialog: false, |
|
|
|
showModalDialog: false, |
|
|
|
modalInfo: { title: '', loadItem: '', examples: [] }, |
|
|
|
modalInfo: { title: '', loadItem: '', examples: [] }, |
|
|
@ -49,7 +50,7 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => { |
|
|
|
|
|
|
|
|
|
|
|
const processLoading = () => { |
|
|
|
const processLoading = () => { |
|
|
|
const contentImport = plugin.contentImport |
|
|
|
const contentImport = plugin.contentImport |
|
|
|
const fileProviders = registry.get('fileproviders').api |
|
|
|
const workspace = fileManager.getProvider('workspace') |
|
|
|
contentImport.import( |
|
|
|
contentImport.import( |
|
|
|
state.importSource, |
|
|
|
state.importSource, |
|
|
|
(loadingMsg) => dispatch({ tooltip: loadingMsg }), |
|
|
|
(loadingMsg) => dispatch({ tooltip: loadingMsg }), |
|
|
@ -58,7 +59,7 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => { |
|
|
|
toast(error.message || error) |
|
|
|
toast(error.message || error) |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
try { |
|
|
|
try { |
|
|
|
fileProviders.workspace.addExternal(type + '/' + cleanUrl, content, url) |
|
|
|
workspace.addExternal(type + '/' + cleanUrl, content, url) |
|
|
|
plugin.call('menuicons', 'select', 'filePanel') |
|
|
|
plugin.call('menuicons', 'select', 'filePanel') |
|
|
|
} catch (e) { |
|
|
|
} catch (e) { |
|
|
|
toast(e.message) |
|
|
|
toast(e.message) |
|
|
@ -81,7 +82,13 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => { |
|
|
|
const inputValue = useRef(null) |
|
|
|
const inputValue = useRef(null) |
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
|
useEffect(() => { |
|
|
|
registry.get('themeModule').api.events.on('themeChanged', (theme) => { |
|
|
|
plugin.call('theme', 'currentTheme').then((theme) => { |
|
|
|
|
|
|
|
// update theme quality. To be used for for images
|
|
|
|
|
|
|
|
setState(prevState => { |
|
|
|
|
|
|
|
return { ...prevState, themeQuality: theme.quality === 'dark' ? themes.dark : themes.light } |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
plugin.on('theme', 'themeChanged', (theme) => { |
|
|
|
// update theme quality. To be used for for images
|
|
|
|
// update theme quality. To be used for for images
|
|
|
|
setState(prevState => { |
|
|
|
setState(prevState => { |
|
|
|
return { ...prevState, themeQuality: theme.quality === 'dark' ? themes.dark : themes.light } |
|
|
|
return { ...prevState, themeQuality: theme.quality === 'dark' ? themes.dark : themes.light } |
|
|
@ -129,7 +136,7 @@ export const RemixUiHomeTab = (props: RemixUiHomeTabProps) => { |
|
|
|
plugin.appManager.activatePlugin('remixd') |
|
|
|
plugin.appManager.activatePlugin('remixd') |
|
|
|
} |
|
|
|
} |
|
|
|
const importFromGist = () => { |
|
|
|
const importFromGist = () => { |
|
|
|
plugin.gistHandler.loadFromGist({ gist: '' }, registry.get('filemanager').api) |
|
|
|
plugin.gistHandler.loadFromGist({ gist: '' }, fileManager) |
|
|
|
plugin.verticalIcons.select('filePanel') |
|
|
|
plugin.verticalIcons.select('filePanel') |
|
|
|
} |
|
|
|
} |
|
|
|
const switchToPreviousVersion = () => { |
|
|
|
const switchToPreviousVersion = () => { |
|
|
|