-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds handling for suggested changes in a Google Doc. Before, if there were suggestions in the text, we'd show them in a totally undifferentiated way right next to the original text, which could make things appear totally garbled. This also adds a settings UI for choosing how to convert the suggestions: you can show them marked up as insertions and deletions in the markdown, accept them and render them as normal text, or reject them and render the markdown as if they weren’t there (the default). Settings are saved in localStorage so it’s consistent across uses and page loads. I've been meaning to add settings like this for a while, and a followup change will add the ability to choose how heading IDs are handled. This also has infrastructure we can re-use in the future for linking to bookmarks in the text. Fixes #194.
- Loading branch information
Showing
17 changed files
with
2,030 additions
and
43 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
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,46 @@ | ||
export const settings = { | ||
get(key) { | ||
return this._data[key]; | ||
}, | ||
|
||
getAll() { | ||
return Object.assign({}, this._data); | ||
}, | ||
|
||
set(key, value) { | ||
this._data[key] = value; | ||
this.save(); | ||
}, | ||
|
||
setAll(newData, { save = true } = {}) { | ||
Object.assign(this._data, newData); | ||
if (save) { | ||
this.save(); | ||
} | ||
}, | ||
|
||
toJSON() { | ||
return this.getAll(); | ||
}, | ||
|
||
save() { | ||
const serialized = JSON.stringify(this); | ||
try { | ||
window.localStorage.setItem(this._storageKey, serialized); | ||
} catch (error) { | ||
console.error('Error saving settings:', error); | ||
} | ||
}, | ||
|
||
load() { | ||
try { | ||
const serialized = window.localStorage.getItem(this._storageKey); | ||
this.setAll(JSON.parse(serialized), { save: false }); | ||
} catch (_error) { | ||
// OK: there might be nothing saved. | ||
} | ||
}, | ||
|
||
_storageKey: 'gdoc2md.options', | ||
_data: {}, | ||
}; |
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
Oops, something went wrong.