Jump to conversation
Unresolved conversations (11)
@laurent22 laurent22 Nov 4, 2024
I think noteId could be undefined? If there's no note in the notebook for example
...p-desktop/commands/openNoteInNewWindow.ts
personalizedrefrigerator laurent22
@personalizedrefrigerator personalizedrefrigerator Nov 1, 2024
`NoteTextViewer` was converted to a function component to allow getting the window ID with the `useContext(WindowIdContext)` hook. The window ID is used to ensure that when plugins call `response = await webviewApi.postMessage(...)`, the response is sent to the correct window.
Outdated
packages/app-desktop/gui/NoteTextViewer.tsx
@personalizedrefrigerator personalizedrefrigerator Nov 1, 2024
This allows the main window to be closed without quitting the app, even if "show tray icon" is disabled.
packages/app-desktop/ElectronAppWrapper.ts
@personalizedrefrigerator personalizedrefrigerator Nov 1, 2024
The note editor and note viewer can now be open in multiple windows at the same time. To allow this, the `PostMessageService` has been updated to associate a `windowId` with plugin messages. For example, if a note viewer content script in window A calls `webviewApi.postMessage`, the `windowId` is used to send the plugin's response to window A (and not some other window with a note viewer).
Outdated
packages/lib/services/PostMessageService.ts
@personalizedrefrigerator personalizedrefrigerator Nov 1, 2024
`useFormNote` was updated to allow changes from one window to update other windows viewing the same note. In particular, it now uses the `ItemChange` event to detect note changes. Previously, it refreshed the note on sync start/end, decryption, or external editor note updates. Unnecessary note refreshes can cause the cursor to jump and undo history to be lost. To avoid such refreshes, - When notes are saved from an editor, a `changeId` is passed to `Note.save`. - Each editor has a unique `changeId`. - This `changeId` is included with `ItemChange` events. - The `changeId` is used to avoid refreshing when a change event was triggered by the current editor. For example, if a note is changed in editor A and also open in editor B, 1. `Note.save` is called with `changeId: 'editorChange-editor-1'`. 2. This causes an `ItemChange` event to be dispatched. 3. Editor A receives this `ItemChange` event, but ignores it because its `changeId` is `editorChange-editor-1`. 4. Editor B receives this event and **does not ignore it** because its changeId is **not** `editorChange-editor-2`.
Outdated
...sktop/gui/NoteEditor/utils/useFormNote.ts
@personalizedrefrigerator personalizedrefrigerator Nov 1, 2024
This callback is used to update secondary windows' titlebars.
...app-desktop/gui/NoteEditor/utils/types.ts
@personalizedrefrigerator personalizedrefrigerator Nov 1, 2024
**Note**: `Navigator` was converted to a function component to allow the use of `useContext` (used to determine the current window ID).
Outdated
packages/app-desktop/gui/Navigator.tsx
@personalizedrefrigerator personalizedrefrigerator Nov 1, 2024
```suggestion export const loadScript = async (script: Script, targetDocument: Document) => { ``` I'm not sure whether it's better to shadow the global `document` variable or use a different name. Tradeoffs: - **Benefit**: Shadowing the global `document` prevents the function's code from accidentally using the wrong `document` object. - **Drawback**: Shadowing `document` may make it less clear that code in the function is not necessarily referencing the global `document`.
packages/app-desktop/gui/utils/loadScript.ts
@personalizedrefrigerator personalizedrefrigerator Oct 16, 2024
`NoteEditor.tsx` is a new file. The old `NoteEditor.tsx` was renamed to `NoteEditorContent.tsx`. - [x] To-do: Use a different name for the note editor wrapper so that it's marked as a rename by `git`?
Outdated
...app-desktop/gui/NoteEditor/NoteEditor.tsx
@personalizedrefrigerator personalizedrefrigerator Oct 10, 2024
This code uses `CacheProvider` from `@emotion/react` to cause `react-select` to insert its styles into the new window (see [comment](https://github.com/JedWatson/react-select/issues/3680#issuecomment-809518245)). `@emotion/react` is a dependency of `react-select` and, at present, is not a direct dependency of Joplin. Adding `@emotion/react` to `app-desktop/package.json` could be problematic if `react-select` is updated without also updating the `@emotion/react` version — having multiple versions of `@emotion/react` [may cause styling issues](https://github.com/emotion-js/emotion/issues/2383) (or perhaps break styling just in new windows). See [this unmerged upstream pull request](https://github.com/JedWatson/react-select/pull/5939) for a possible future solution that doesn't involve `import`ing transitive dependencies.
Outdated
...ktop/gui/NoteEditor/NoteEditorWrapper.tsx
@personalizedrefrigerator personalizedrefrigerator Oct 5, 2024
Related documentation/explanation: - [React Portals](https://react.dev/reference/react-dom/createPortal#rendering-react-components-into-non-react-dom-nodes) documentation. - [StackOverflow thread](https://stackoverflow.com/questions/68464980/render-a-react-component-in-a-new-window) with discussion on how to render React components to a new window. - [A blog post](https://david-gilbertson.medium.com/using-a-react-16-portal-to-do-something-cool-2a2d627b0202) about using `createPortal` with new windows.
Outdated
...ges/app-desktop/gui/NewWindowOrIFrame.tsx
Resolved conversations (2)
@personalizedrefrigerator personalizedrefrigerator Nov 5, 2024
Currently, these are hardcoded to match the CSS URLs in the main `index.html` document. I'm currently trying to update this so that `style.min.css` imports the other CSS files dynamically.
Outdated
...ges/app-desktop/gui/NewWindowOrIFrame.tsx
@personalizedrefrigerator personalizedrefrigerator Nov 1, 2024
`WindowCommandHandler` may not be the best name for this file — it handles dialogs in addition to window commands. `WindowDialogAndCommandHandler` might be a (long) alternative.
Outdated
...owCommandHandler/WindowCommandHandler.tsx
personalizedrefrigerator