Merge pull request #610 from fhemberger/patch-1

fix(shortcuts-settings): `settingsJSON` must be defined if note doesn't exist
This commit is contained in:
Chee Aun 2024-08-04 10:11:42 +08:00 committed by GitHub
commit 4937c5f77e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1055,16 +1055,16 @@ function ImportExport({ shortcuts, onClose }) {
const { note = '' } = relationship; const { note = '' } = relationship;
// const newNote = `${note}\n\n\n$<phanpy-shortcuts-settings>{shortcutsStr}</phanpy-shortcuts-settings>`; // const newNote = `${note}\n\n\n$<phanpy-shortcuts-settings>{shortcutsStr}</phanpy-shortcuts-settings>`;
let newNote = ''; let newNote = '';
if (
/<phanpy-shortcuts-settings>(.*)<\/phanpy-shortcuts-settings>/.test(
note,
)
) {
const settingsJSON = JSON.stringify({ const settingsJSON = JSON.stringify({
v: '1', // version v: '1', // version
dt: Date.now(), // datetime stamp dt: Date.now(), // datetime stamp
data: shortcutsStr, // shortcuts settings string data: shortcutsStr, // shortcuts settings string
}); });
if (
/<phanpy-shortcuts-settings>(.*)<\/phanpy-shortcuts-settings>/.test(
note,
)
) {
newNote = note.replace( newNote = note.replace(
/<phanpy-shortcuts-settings>(.*)<\/phanpy-shortcuts-settings>/, /<phanpy-shortcuts-settings>(.*)<\/phanpy-shortcuts-settings>/,
`<phanpy-shortcuts-settings>${settingsJSON}</phanpy-shortcuts-settings>`, `<phanpy-shortcuts-settings>${settingsJSON}</phanpy-shortcuts-settings>`,