-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* v1.0.3 * 色の調整 * refactor * jest-chrome uninstall * css分割 * icon導入 * refactor * fix * wasm import * fix test * npm i --force削除 * update gif --------- Co-authored-by: nusuke <[email protected]>
- Loading branch information
Showing
19 changed files
with
2,670 additions
and
361 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 +1,5 @@ | ||
Object.assign(global, require("jest-chrome")); | ||
Object.assign(global, { | ||
chrome: { | ||
runtime: { sendMessage: () => {}, onMessage: { addListener: () => {} } }, | ||
}, | ||
}); |
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
Large diffs are not rendered by default.
Oops, something went wrong.
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,58 @@ | ||
import { useCallback, useEffect, useState } from "react"; | ||
import { | ||
getHistory, | ||
remoevHistoryAll, | ||
removeHistory, | ||
} from "../../../lib/queryHistoryFromLocalStrage"; | ||
|
||
export const useQueryHistory = (setJqQuery: any) => { | ||
const [jqQueryHistories, setJqQueryHistory] = useState<string[]>([]); | ||
const [historyKeyIndex, setHistoryKeyIndex] = useState(-1); | ||
const [suggestMode, setSuggestMode] = useState(false); | ||
const [selectedHistoryQuery, setSelectedHisotoryQuery] = useState< | ||
string | null | ||
>(null); | ||
|
||
// ↑↓で履歴をinput要素にセットする | ||
useEffect(() => { | ||
if (historyKeyIndex >= 0 && jqQueryHistories.length > historyKeyIndex) { | ||
setSelectedHisotoryQuery(jqQueryHistories[historyKeyIndex]); | ||
} | ||
}, [historyKeyIndex]); | ||
|
||
const updateHistoryFromLocalStrage = useCallback(async () => { | ||
const res = await getHistory(); | ||
setJqQueryHistory(res ?? []); | ||
}, []); | ||
|
||
// 履歴を全て消す | ||
const allRemoveHisotryHandler = useCallback(async () => { | ||
if (confirm(`Delete all`)) { | ||
await remoevHistoryAll(); | ||
window.location.reload(); | ||
} | ||
}, []); | ||
|
||
const removeHisotryHandler = (queryHistory: string) => { | ||
if (confirm(`Can I delete the query "${queryHistory}"?`)) { | ||
removeHistory(queryHistory, jqQueryHistories); | ||
window.location.reload(); | ||
} | ||
}; | ||
|
||
const execQueryHistory = (query?: string) => { | ||
setJqQuery(query ?? selectedHistoryQuery); | ||
}; | ||
|
||
return { | ||
updateHistoryFromLocalStrage, | ||
setSuggestMode, | ||
setHistoryKeyIndex, | ||
suggestMode, | ||
jqQueryHistories, | ||
allRemoveHisotryHandler, | ||
removeHisotryHandler, | ||
execQueryHistory, | ||
selectedHistoryQuery, | ||
}; | ||
}; |
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,20 +1,23 @@ | ||
import { useEffect } from "react"; | ||
import { convertJSONToHTML } from "./convertJSONToHTML"; | ||
import { getSurroundCharactor, surroundParentheses } from "./parentheses"; | ||
import { messageType } from "../../../background"; | ||
|
||
type P = { targetJson: JSON }; | ||
export const JsonPreview: React.FC<P> = (props: P) => { | ||
useEffect(() => { | ||
chrome.runtime.sendMessage({ | ||
type: "road", | ||
type: messageType.load, | ||
text: JSON.stringify(props.targetJson), | ||
}); | ||
}, []); | ||
const surruondChar = getSurroundCharactor(props.targetJson); | ||
|
||
return ( | ||
<div className="jsonPreview"> | ||
{surroundParentheses(convertJSONToHTML(props.targetJson), surruondChar)} | ||
{surroundParentheses( | ||
convertJSONToHTML(props.targetJson), | ||
getSurroundCharactor(props.targetJson) | ||
)} | ||
</div> | ||
); | ||
}; |
Oops, something went wrong.