Add isMac, isWindows, isLinux to a global window.platform object in the renderer

This commit is contained in:
Jonatan Heyman 2023-01-16 15:32:45 +01:00
parent d4078d50d4
commit fc63ad1651
3 changed files with 18 additions and 3 deletions

View File

@ -0,0 +1,6 @@
const os = require('os');
export const isMac = os.platform() === "darwin";
export const isWindows = os.platform() === "win32";
export const isLinux = os.platform() === "linux";

View File

@ -1,6 +1,11 @@
const { contextBridge } = require('electron') const { contextBridge } = require('electron')
import darkMode from "./theme-mode" import darkMode from "./theme-mode"
import { isMac, isWindows, isLinux } from "./detect-platform"
contextBridge.exposeInMainWorld("platform", {
isMac,
isWindows,
isLinux,
}) })
contextBridge.exposeInMainWorld('darkMode', darkMode) contextBridge.exposeInMainWorld('darkMode', darkMode)

View File

@ -3,13 +3,17 @@
import { HeynoteEditor } from '../editor/editor.js' import { HeynoteEditor } from '../editor/editor.js'
import testContent from "../editor/fixture.js" import testContent from "../editor/fixture.js"
const modChar = window.platform.isMac ? "⌘" : "Ctrl"
const initialContent = ` const initialContent = `
text-a text-a
Welcome to Heynote! Welcome to Heynote!
[ + Enter] Insert new note block [${modChar} + Enter] Insert new note block
[ + A] Select all text in a note block. Press again to select the whole scratchpad [${modChar} + Down] Goto next block
[ + + Up/Down]  Add additional cursor above/below [${modChar} + Up] Goto previous block
[${modChar} + A] Select all text in a note block. Press again to select the whole scratchpad
[${modChar} + + Up/Down]  Add additional cursor above/below
text-a text-a
` `