Skip to content
Open
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
3 changes: 2 additions & 1 deletion ressources/components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ export default class App extends React.Component {
}

componentDidMount() {
window.SetSettings = json => {
window.SetSettings = base64json => {
const json = decodeURIComponent(window.atob(base64json))
this.setState(JSON.parse(json))
this.findIntput.focus()
this.setState({
Expand Down
6 changes: 3 additions & 3 deletions ressources/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ let dark = true

window.settings = {}

window.updateData = function(json) {
window.updateData = function(base64json) {
if (typeof window.SetSettings == 'function') {
window.SetSettings(json)
window.SetSettings(base64json)
} else {
setTimeout(() => window.updateData(json), 100)
setTimeout(() => window.updateData(base64json), 100)
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/Find-and-replace.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,10 @@ export default function() {
state = Object.assign({}, state, { init })
}
if (isWebviewPresent(windowOptions.identifier)) {
let base64EncodedState = Buffer.from(encodeURIComponent(JSON.stringify(state))).toString("base64")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I couldn't figure out how to use window.btoa() in this context so Buffer.toString("base64") to the rescue.

sendToWebview(
windowOptions.identifier,
`updateData('${JSON.stringify(state)}')`
`updateData('${base64EncodedState}')`
)
}
state = Object.assign({}, state, { init: false })
Expand Down