Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/cybersemics/em into joe/fix…
Browse files Browse the repository at this point in the history
…-986
  • Loading branch information
jbrundige committed Aug 13, 2024
2 parents c673719 + 867af01 commit 23a374e
Show file tree
Hide file tree
Showing 212 changed files with 1,875 additions and 1,761 deletions.
2 changes: 1 addition & 1 deletion .hooks/pre-push
Original file line number Diff line number Diff line change
@@ -1 +1 @@
npm run lint:src
npm run lint
3 changes: 1 addition & 2 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@
{ "source": "**/.woff2", "headers": [{ "key": "Cache-Control", "value": "31536000" }] },
{ "source": "/", "headers": [{ "key": "Cache-Control", "value": "no-cache" }] },
{ "source": "/index.html", "headers": [{ "key": "Cache-Control", "value": "no-cache" }] },
{ "source": "/service-worker.js", "headers": [{ "key": "Cache-Control", "value": "no-cache" }] },
{ "source": "/scripts/firebase-v*", "headers": [{ "key": "Cache-Control", "value": "31536000" }] }
{ "source": "/service-worker.js", "headers": [{ "key": "Cache-Control", "value": "no-cache" }] }
],
"public": "build",
"ignore": ["firebase.json", "**/.*", "**/node_modules/**"],
Expand Down
12 changes: 11 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!DOCTYPE html>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
Expand Down Expand Up @@ -36,6 +36,16 @@
<div id="debug"></div>

<script>
// Prevent the React DevTools console message in Puppeteer tests.
// https://github.com/cybersemics/em/issues/2251
if (navigator.webdriver) {
const info = console.info.bind(console)
console.info = (...args) => {
if (typeof args[0] === 'string' && args[0].startsWith('%cDownload the React DevTools')) return
info(...args)
}
}

// Note: theme needs to be loaded here before react loads, otherwise it causes a white flash.
const theme = localStorage.getItem('storageCache/theme')?.toLowerCase() || 'dark'
document.body.classList.add(theme)
Expand Down
25 changes: 14 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "em",
"version": "300.30.10",
"version": "300.30.11",
"author": "Raine Revere <raine@cybersemics.org>",
"description": "A beautiful, minimalistic note-taking app for personal sensemaking.",
"license": "NoHarm-draft",
Expand Down Expand Up @@ -28,7 +28,7 @@
"cap:sync:prod": "npm run build && NODE_ENV=production cap sync",
"start": "vite --host --port 3000",
"build": "vite build",
"clean": "rm -rf ./node_modules/.cache && rm -rf .eslintcache",
"clean": "rm -rf ./node_modules/.cache && rm -rf ./node_modules/.vite && rm -rf .eslintcache",
"deploy:major": "npm run lint && npm version major && npm run build && firebase deploy --only hosting",
"deploy:minor": "npm run lint && npm version minor && npm run build && firebase deploy --only hosting",
"deploy:patch": "npm run lint && npm version patch && npm run build && firebase deploy --only hosting",
Expand All @@ -39,6 +39,7 @@
"lint:src": "FORCE_COLOR=1 eslint . --cache --rule 'no-console: [2, { allow: [error, info, warn] }]'",
"lint:lockfile": "npx lockfile-lint",
"lint:no-npm": "node ./scripts/no-files.js package-lock.json",
"lint:tsc": "tsc",
"postinstall": "scripts/install-hooks.sh",
"servebuild": "npx serve -s build -l 3000",
"test": "vitest --project unit",
Expand Down Expand Up @@ -93,24 +94,24 @@
"immer": "^10.1.1",
"ipfs-http-client": "^43.0.1",
"lodash": "^4.17.21",
"marked": "^13.0.2",
"marked": "^13.0.3",
"moize": "^6.1.6",
"murmurhash3js": "^3.0.1",
"nanoid": "^5.0.7",
"openai": "^4.52.3",
"openai": "^4.54.0",
"page-lifecycle": "git+https://git@github.com/magic-akari/page-lifecycle#feat/add-types",
"pluralize": "^8.0.0",
"qrcode.react": "^3.1.0",
"react": "18.3.1",
"react-contenteditable": "^3.3.7",
"react-dnd": "^11.1.3",
"react-dnd-html5-backend": "^11.1.3",
"react-dnd-multi-backend": "^6.0.2",
"react-dnd-touch-backend": "^11.1.3",
"react-dnd": "14.0.0",
"react-dnd-html5-backend": "14.0.0",
"react-dnd-multi-backend": "8.0.3",
"react-dnd-touch-backend": "14.0.0",
"react-dom": "18.3.1",
"react-error-boundary": "^4.0.13",
"react-gravatar": "^2.6.3",
"react-native-gesture-handler": "^2.17.1",
"react-native-gesture-handler": "^2.18.1",
"react-native-web": "^0.19.12",
"react-redux": "^9.1.2",
"react-signature-pad-wrapper": "^3.4.0",
Expand Down Expand Up @@ -145,6 +146,7 @@
"@testing-library/jest-dom": "^6.4.8",
"@testing-library/react": "^12.1.5",
"@testing-library/user-event": "^13.5.0",
"@total-typescript/ts-reset": "^0.5.1",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/classnames": "^2.3.1",
"@types/clipboard": "^2.0.7",
Expand All @@ -154,7 +156,7 @@
"@types/jest-image-snapshot": "^6.4.0",
"@types/lodash": "^4.17.5",
"@types/murmurhash3js": "^3.0.7",
"@types/node": "^20.14.2",
"@types/node": "^22.1.0",
"@types/pluralize": "0.0.33",
"@types/react": "^18.3.3",
"@types/react-dnd-multi-backend": "^6.0.6",
Expand Down Expand Up @@ -205,7 +207,8 @@
"redux-mock-store": "^1.5.4",
"tcp-port-used": "^1.0.2",
"typescript": "5.4.5",
"vite": "^5.3.4",
"vite": "^5.4.0",
"vite-plugin-checker": "^0.7.2",
"vite-plugin-pwa": "^0.20.0",
"vitest": "^1.6.0",
"webdriverio": "^7.36.0"
Expand Down
50 changes: 0 additions & 50 deletions public/scripts/firebase-v4.12.1.js

This file was deleted.

1 change: 0 additions & 1 deletion public/scripts/firebase-v4.12.1.js.map

This file was deleted.

6 changes: 6 additions & 0 deletions src/@types/CommandState.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import FormattingCommand from './FormattingCommand'

/** The set of commands applied to text (bold, italic, underline, strikethrough). */
type CommandState = Record<FormattingCommand, boolean>

export default CommandState
2 changes: 0 additions & 2 deletions src/@types/DragThoughtItem.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import DragAndDropType from './DragAndDropType'
import DragThoughtZone from './DragThoughtZone'
import Path from './Path'
import SimplePath from './SimplePath'
Expand All @@ -8,7 +7,6 @@ interface DragThoughtItem {
path: Path
simplePath: SimplePath
zone: DragThoughtZone
type: DragAndDropType
}

export default DragThoughtItem
8 changes: 8 additions & 0 deletions src/@types/FormattingCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
enum FormattingCommand {
bold = 'bold',
italic = 'italic',
underline = 'underline',
strikethrough = 'strikethrough',
}

export default FormattingCommand
7 changes: 7 additions & 0 deletions src/@types/react-contenteditable.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import 'react-contenteditable'

declare module 'react-contenteditable' {
export interface Props {
placeholder?: string
}
}
5 changes: 5 additions & 0 deletions src/@types/react-dnd.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { DndProviderProps } from 'react-dnd'

declare module 'react-dnd' {
export declare const DndProvider: React.FC<DndProviderProps<any, any> & { children?: React.ReactNode }>
}
11 changes: 11 additions & 0 deletions src/@types/react-split-pane.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { SplitPaneProps, SplitPaneState } from 'react-split-pane'

declare module 'react-split-pane' {
// eslint-disable-next-line jsdoc/require-jsdoc
export class SplitPane extends React.Component<SplitPaneProps & { children: React.ReactNode }, SplitPaneState> {
// eslint-disable-next-line jsdoc/require-jsdoc
render(): React.ReactNode
}

export default SplitPane
}
4 changes: 2 additions & 2 deletions src/actions/deleteThought.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ const deleteThought = (state: State, { local = true, pathParent, thoughtId, orph

// The new Lexeme is typically the old Lexeme less the deleted context.
// However, during deallocation we should not remove a single context, which would create an invalid Lexeme. Instead, we keep the Lexeme intact with all contexts, only deallocating it when all of its context thoughts have been deallocated.
const lexemeWithoutContext = lexeme ? removeContext(state, lexeme, thoughtId) : null
const lexemeWithoutContext = lexeme ? removeContext(lexeme, thoughtId) : null

const lexemeNew = persist
? lexemeWithoutContext?.contexts.length
Expand Down Expand Up @@ -131,7 +131,7 @@ const deleteThought = (state: State, { local = true, pathParent, thoughtId, orph

// The new Lexeme is typically the old Lexeme less the deleted context.
// However, during deallocation we should not remove a single context, which would create an invalid context superscript. Instead, we keep the Lexeme intact with all contexts, only deallocating it when all of its context thoughts have been deallocated.
const lexemeChildWithoutContext = lexemeChild ? removeContext(state, lexemeChild, child.id) : null
const lexemeChildWithoutContext = lexemeChild ? removeContext(lexemeChild, child.id) : null
const lexemeChildNew = persist
? lexemeChildWithoutContext?.contexts.length
? lexemeChildWithoutContext
Expand Down
2 changes: 1 addition & 1 deletion src/actions/editThought.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const editThought = (state: State, { force, oldValue, newValue, path, rankInCont
}

// the old thought less the context
const newOldLexeme = lexemeOld && !isThoughtOldOrphan() ? removeContext(state, lexemeOld, editedThoughtId) : null
const newOldLexeme = lexemeOld && !isThoughtOldOrphan() ? removeContext(lexemeOld, editedThoughtId) : null

const lexemeNew = addContext(lexemeNewWithoutContext, { id: editedThoughtId, archived: editedThought.archived })

Expand Down
6 changes: 4 additions & 2 deletions src/actions/freeThoughts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,16 @@ const freeThoughts = (state: State) => {
...getAllChildren(state, head(path)),
// preserve context view (including context ancestors)
...(showContexts
? getContexts(state, getThoughtById(state, head(path)).value).flatMap(cxid => thoughtToPath(state, cxid))
? (getContexts(state, getThoughtById(state, head(path)).value).flatMap(cxid =>
thoughtToPath(state, cxid),
) as ThoughtId[])
: []),
]
}),
// preserve EM context
...getDescendantThoughtIds(state, EM_TOKEN),
// preserve favorites contexts and their ancestors
...(getLexeme(state, '=favorite')?.contexts || []).flatMap(cxid => thoughtToPath(state, cxid)),
...((getLexeme(state, '=favorite')?.contexts || []).flatMap(cxid => thoughtToPath(state, cxid)) as ThoughtId[]),
])

// iterate over the entire thoughtIndex, deleting thoughts that are no longer visible
Expand Down
7 changes: 4 additions & 3 deletions src/actions/importText.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import _ from 'lodash'
import Path from '../@types/Path'
import SimplePath from '../@types/SimplePath'
import State from '../@types/State'
import ThoughtIndices from '../@types/ThoughtIndices'
import Thunk from '../@types/Thunk'
import Timestamp from '../@types/Timestamp'
import editThought from '../actions/editThought'
Expand All @@ -25,7 +26,7 @@ import isRoot from '../util/isRoot'
import { markdownToText } from '../util/markdownToText'
import parentOf from '../util/parentOf'
import reducerFlow from '../util/reducerFlow'
import roamJsonToBlocks from '../util/roamJsonToBlocks'
import roamJsonToBlocks, { RoamPage } from '../util/roamJsonToBlocks'
import strip from '../util/strip'
import textToHtml from '../util/textToHtml'
import unroot from '../util/unroot'
Expand Down Expand Up @@ -111,7 +112,7 @@ const importText = (
"thoughtIndex": {
"__ROOT__": {`)
) {
const thoughts = JSON.parse(text)
const thoughts = JSON.parse(text) as ThoughtIndices
const stateNew = initialState()
return {
...stateNew,
Expand Down Expand Up @@ -155,7 +156,7 @@ const importText = (
: null,
])(state)
} else {
const json = isRoam ? roamJsonToBlocks(JSON.parse(convertedText)) : htmlToJson(convertedText)
const json = isRoam ? roamJsonToBlocks(JSON.parse(convertedText) as RoamPage[]) : htmlToJson(convertedText)

const destIsLeaf = !anyChild(state, head(simplePath))

Expand Down
2 changes: 1 addition & 1 deletion src/actions/mergeThoughts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const mergeThoughts = (
// update Lexeme
lexemeIndexUpdates: lexeme
? {
[key]: removeContext(state, lexeme, sourceThought.id),
[key]: removeContext(lexeme, sourceThought.id),
}
: {},
}),
Expand Down
4 changes: 2 additions & 2 deletions src/actions/repairThought.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export const repairThoughtActionCreator =
updateThoughts({
thoughtIndexUpdates: {},
lexemeIndexUpdates: {
[hashThought(cursorValue!)]: removeContext(state, cursorLexeme, id),
[hashThought(cursorValue!)]: removeContext(cursorLexeme, id),
},
}),
)
Expand All @@ -55,7 +55,7 @@ export const repairThoughtActionCreator =
updateThoughts({
thoughtIndexUpdates: {},
lexemeIndexUpdates: {
[hashThought(cursorValue!)]: removeContext(getState(), cursorLexeme, id),
[hashThought(cursorValue!)]: removeContext(cursorLexeme, id),
},
}),
// add the missing thought to its parent
Expand Down
2 changes: 1 addition & 1 deletion src/components/AppComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ const StyleInjector = ({
const GlobalStyles = React.memo(({ styles }: { styles: [string, React.CSSProperties][] }) => {
const [globalStyle, setGlobalStyle] = useState<Index<string>>({})
const appendGlobalStyle = useCallback(
i => (css: string) => setGlobalStyle(globalStyle => ({ ...globalStyle, [i]: css })),
(i: number) => (css: string) => setGlobalStyle(globalStyle => ({ ...globalStyle, [i]: css })),
[],
)
return (
Expand Down
17 changes: 10 additions & 7 deletions src/components/CommandPalette.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const CommandSearch: FC<{

/** Handle command palette shortuts. */
const onKeyDown = useCallback(
e => {
(e: KeyboardEvent) => {
if (
e.key === 'Escape' ||
// manually check if the commandPalette shortcut is entered since global shortcuts are disabled while the command palette is open
Expand Down Expand Up @@ -446,10 +446,13 @@ const CommandPalette: FC = () => {
)

/** Execute the selected shortcut. */
const onExecuteSelected = useCallback(e => onExecute(e, selectedShortcut), [onExecute, selectedShortcut])
const onExecuteSelected = useCallback(
(e: KeyboardEvent) => onExecute(e, selectedShortcut),
[onExecute, selectedShortcut],
)

/** Select shortcuts on hover. */
const onHover = useCallback((e, shortcut) => setSelectedShortcut(shortcut), [])
const onHover = useCallback((e: MouseEvent, shortcut: Shortcut) => setSelectedShortcut(shortcut), [])

// Select the first shortcut when the input changes.
useEffect(() => {
Expand All @@ -467,7 +470,7 @@ const CommandPalette: FC = () => {

/** Select the previous shortcut in the list. */
const onSelectUp = useCallback(
e => {
(e: KeyboardEvent) => {
e.preventDefault()
e.stopPropagation()
if (selectedShortcut !== possibleShortcutsSorted[0]) {
Expand All @@ -480,7 +483,7 @@ const CommandPalette: FC = () => {

/** Select the next shortcut in the list. */
const onSelectDown = useCallback(
e => {
(e: KeyboardEvent) => {
e.preventDefault()
e.stopPropagation()
if (selectedShortcut !== possibleShortcutsSorted[possibleShortcutsSorted.length - 1]) {
Expand All @@ -493,7 +496,7 @@ const CommandPalette: FC = () => {

/** Select the first shortcut in the list. */
const onSelectTop = useCallback(
e => {
(e: KeyboardEvent) => {
e.preventDefault()
e.stopPropagation()
setSelectedShortcut(possibleShortcutsSorted[0])
Expand All @@ -503,7 +506,7 @@ const CommandPalette: FC = () => {

/* Select the last shortcut in the list. */
const onSelectBottom = useCallback(
e => {
(e: KeyboardEvent) => {
e.preventDefault()
e.stopPropagation()
setSelectedShortcut(possibleShortcutsSorted[possibleShortcutsSorted.length - 1])
Expand Down
7 changes: 5 additions & 2 deletions src/components/DragAndDropContext.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import React, { FC, PropsWithChildren } from 'react'
import { FC, PropsWithChildren } from 'react'
import { DndProvider } from 'react-dnd'
import { HTML5Backend } from 'react-dnd-html5-backend'
import MultiBackend, { TouchTransition } from 'react-dnd-multi-backend'
import { MouseTransition, MultiBackend, TouchTransition } from 'react-dnd-multi-backend'
import { TouchBackend } from 'react-dnd-touch-backend'
import { TIMEOUT_LONG_PRESS_THOUGHT } from '../constants'

const options = {
backends: [
{
id: 'html5',
backend: HTML5Backend,
transition: MouseTransition,
},
{
id: 'touch',
backend: TouchBackend,
options: { delayTouchStart: TIMEOUT_LONG_PRESS_THOUGHT },
preview: true,
Expand Down
Loading

0 comments on commit 23a374e

Please sign in to comment.