This file contains hidden or 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
| import type { Replicache } from "replicache"; | |
| import { useSubscribe } from "replicache-react"; | |
| import { getClientState, clientStatePrefix } from "./client-state"; | |
| import { getShape, shapePrefix } from "./shape"; | |
| import { getItem, itemPrefix } from "./item" | |
| import { getArrow, arrowPrefix } from './arrow' | |
| import type { M } from "./mutators"; | |
| export function getItems(rep: Replicache<M>) { | |
| return useSubscribe( |
This file contains hidden or 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
| import React from 'react' | |
| import { useItemByID } from '../datamodel/subscriptions' | |
| import TestEditor from './test-editor' | |
| import { htmlToText } from '../util/htmlToText' | |
| import styles from './test-editor-container.module.css' | |
| import TestEditorFootnotes from './test-editor-footnotes' | |
| import TestEditorSubItems from './test-editor-sub-items' | |
| import TestEditorForwardArrows from './test-editor-forward-arrows' | |
| import TestEditorBackArrows from './test-editor-back-arrows' | |
| import TestEditorComments from './test-editor-comments' |
This file contains hidden or 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
| import React, { useEffect, useRef, useState } from 'react' | |
| import { createParser, createSerializer } from './editor/config/utils' | |
| import { schema } from './editor/config/schema' | |
| import { EditorState, Transaction } from 'prosemirror-state' | |
| import type { EditorView } from 'prosemirror-view' | |
| import type { Schema } from 'prosemirror-model' | |
| import { exampleSetup } from './editor/plugins/index' | |
| import EditorEditor from './editor-editor' | |
| import type { Replicache } from 'replicache' | |
| import type { M } from '../datamodel/mutators' |
This file contains hidden or 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
| import ItemEditorContainer from './item-editor-container' | |
| function ActivityItem({item, rep}: any) { | |
| const [titleValue, setTitleValue] = useState<string>(item.title) | |
| const [contentValue, setContentValue] = useState<string>(item.content) | |
| const { id: itemID } = item | |
| useEffect(() => { | |
| titleValue !== item.title && rep.mutate.updateItemTitle({ id: itemID, title: titleValue }) |
This file contains hidden or 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
| import React, { | |
| createContext, | |
| useContext, | |
| ReactNode | |
| } from 'react' | |
| type WorkspaceContextType = { | |
| } |
This file contains hidden or 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
| import { nanoid } from 'nanoid' | |
| import { z } from 'zod' | |
| const LOCAL_STORAGE_KEY = 'trunk-mini.item-arrows' | |
| export const draftArrow = z.object({ | |
| type: z.literal(`arrow`), | |
| id: z.string(), | |
| created_at: z.string(), | |
| created_by: z.string(), |
This file contains hidden or 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 works on all devices/browsers, and uses IndexedDBShim as a final fallback | |
| var indexedDB = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB || window.shimIndexedDB; | |
| // Open (or create) the database | |
| var open = indexedDB.open("MyDatabase", 1); | |
| // Create the schema | |
| open.onupgradeneeded = function() { | |
| var db = open.result; | |
| var store = db.createObjectStore("MyObjectStore", {keyPath: "id"}); |
This file contains hidden or 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
| import { getDB } from '../../db' | |
| // eslint-disable-next-line import/no-anonymous-default-export | |
| export default async (req: any, res: any) => { | |
| const pull = req.body | |
| console.log(`Processing pull`, JSON.stringify(pull, null, '')) | |
| const t0 = Date.now() | |
| try { | |
| const db = await getDB() |
This file contains hidden or 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
| import { getDB } from '../../db.js' | |
| // eslint-disable-next-line import/no-anonymous-default-export | |
| export default async (req: any, res: any) => { | |
| const push = req.body | |
| console.log('Processing push', JSON.stringify(push, null, '')) | |
| const t0 = Date.now() | |
| try { |
This file contains hidden or 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
| use std::fs::File; | |
| use std::io::ErrorKind; | |
| fn main() { | |
| let _f = File::open("hello.txt").unwrap_or_else(|error| { | |
| if error.kind() == ErrorKind::NotFound { | |
| File::create("hello.txt").unwrap_or_else(|error| { | |
| panic!("Problem creating the file: {:?}", error); | |
| }) | |
| } else { |