Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
19c3d80
Hide tauri app title
cguedes May 16, 2023
4a5f5f8
Create 3 panel layout with References, Editor and AI (mock editor)
cguedes May 16, 2023
fd75d1a
Adds Lexical with plain text editor
cguedes May 16, 2023
3f6236b
Add RichTextEditorPanel with toolbar
cguedes May 16, 2023
2eaaba8
Set default Tauri window size 1280x800
cguedes May 16, 2023
2884126
Make tauri resizable
cguedes May 16, 2023
f3fbfd5
Externalize ReferencesPanel
cguedes May 16, 2023
dc296b1
Add button that injects text in the editor
cguedes May 16, 2023
975c61c
Handle references click via left sidebar
cguedes May 16, 2023
f3150b6
Add TreeViewPlugin + toggle
cguedes May 17, 2023
93742d2
Update copy
cguedes May 17, 2023
c0433f8
Code reorganization with Panels and View components
cguedes May 17, 2023
29ca60d
Adds Tailwind (+Prettier) support and classnames
cguedes May 17, 2023
da57866
Move view to views folder and add styles and dummy content
cguedes May 17, 2023
b115931
Create simple AI interaction using rust (len+uppercase)
cguedes May 17, 2023
5b8406c
Added a new Node type (text) for references
cguedes May 17, 2023
719c4ea
WIP using a DecoratorNode
cguedes May 17, 2023
fab3170
Add CollapsiblePlugin and CollapsibleNodes
cguedes May 17, 2023
f29e1af
Add .debug plugin helpers to tailwindcss
cguedes May 17, 2023
e511d2c
Remove CSS styles from editor and improve styles
cguedes May 17, 2023
b54f21f
Bring back ReferenceNode (text) and create WIP decorator node version
cguedes May 17, 2023
27e2c34
Adds AutoLinkPlugin from playground examples
cguedes May 18, 2023
6df2bad
Update prettier to 120 width (package.json) and format code
cguedes May 18, 2023
8a5c26a
Improve Folders view UI and content
cguedes May 18, 2023
a0d7f29
Add Toggle for Markdown view
cguedes May 18, 2023
eb97bff
Use $createLinkNode in the default text
cguedes May 18, 2023
fb53948
Adds styles for ul and li HTML
cguedes May 18, 2023
c22be53
Use $createHorizontalRuleNode in the default content
cguedes May 18, 2023
13adbf6
Fix styles for the app
cguedes May 18, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,16 @@
"tauri": "tauri"
},
"dependencies": {
"@lexical/react": "^0.10.0",
"@tauri-apps/api": "^1.2.0",
"autoprefixer": "^10.4.14",
"classnames": "^2.3.2",
"lexical": "^0.10.0",
"postcss": "^8.4.23",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-resizable-panels": "^0.0.42"
"react-resizable-panels": "^0.0.42",
"tailwindcss": "^3.3.2"
},
"devDependencies": {
"@tauri-apps/cli": "^1.2.3",
Expand All @@ -24,7 +30,8 @@
"@vitejs/plugin-react": "^3.0.0",
"husky": "^8.0.3",
"lint-staged": "^13.2.0",
"prettier": "^2.8.7",
"prettier": "^2.8.8",
"prettier-plugin-tailwindcss": "^0.3.0",
"typescript": "^4.9.5",
"vite": "^4.2.1"
},
Expand All @@ -47,7 +54,7 @@
},
"prettier": {
"bracketSpacing": true,
"printWidth": 80,
"printWidth": 120,
"semi": true,
"singleQuote": true,
"tabWidth": 2,
Expand Down
6 changes: 6 additions & 0 deletions postcss.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default {
plugins: {
tailwindcss: {},
autoprefixer: {},
},
}
5 changes: 5 additions & 0 deletions public/images/icons/LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Bootstrap Icons
https://icons.getbootstrap.com

Licensed under MIT license
https://github.com/twbs/icons/blob/main/LICENSE.md
4 changes: 4 additions & 0 deletions public/images/icons/arrow-clockwise.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/images/icons/arrow-counterclockwise.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/images/icons/chat-square-quote.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/icons/chevron-down.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/icons/code.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions public/images/icons/journal-code.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions public/images/icons/journal-text.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/icons/justify.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/images/icons/link.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions public/images/icons/list-ol.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/icons/list-ul.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/icons/pencil-fill.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/icons/text-center.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/icons/text-left.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/icons/text-paragraph.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/icons/text-right.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/icons/type-bold.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/icons/type-h1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/icons/type-h2.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/icons/type-h3.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/icons/type-italic.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/icons/type-strikethrough.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions public/images/icons/type-underline.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 6 additions & 0 deletions src-tauri/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@ fn greet(name: &str) -> String {
format!("Hello, {}! You've been greeted from Rust!", name)
}

#[tauri::command]
fn interact_with_ai(selection: &str) -> String {
format!("{}: {}", selection.len(), selection.to_uppercase())
}

fn main() {
tauri::Builder::default()
.invoke_handler(tauri::generate_handler![greet])
.invoke_handler(tauri::generate_handler!(interact_with_ai))
.run(tauri::generate_context!())
.expect("error while running tauri application");
}
4 changes: 2 additions & 2 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@
"fullscreen": false,
"resizable": true,
"title": "refstudio",
"width": 800,
"height": 600
"width": 1280,
"height": 800
}
]
}
Expand Down
77 changes: 50 additions & 27 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,40 +1,63 @@
import { useState } from 'react';
import { Panel, PanelGroup } from 'react-resizable-panels';
import { invoke } from '@tauri-apps/api/tauri';
import { $getSelection, LexicalEditor } from 'lexical';
import { useRef, useState } from 'react';
import { Panel, PanelGroup, PanelResizeHandle } from 'react-resizable-panels';
import { $createReferenceNode } from './lexical-nodes/ReferenceNode';
import { ReferenceItem } from './types/ReferenceItem';
import { AIView } from './views/AIView';
import EditorView from './views/EditorView';
import { FoldersView } from './views/FoldersView';
import { ReferencesView } from './views/ReferencesView';

function App() {
const [greetMsg, setGreetMsg] = useState('');
const [name, setName] = useState('');
const [selection, setSelection] = useState('');

async function greet() {
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
setGreetMsg(await invoke('greet', { name }));
const editorRef = useRef({
main: null as LexicalEditor | null,
});

function handleRefClicked(reference: ReferenceItem) {
if (!editorRef.current.main) return;
editorRef.current.main.update(() => {
$getSelection()?.insertNodes([
$createReferenceNode(reference),
// .setFormat('bold'),
// $createTextNode(`[${referenceId}]`).setFormat('bold'),
]);
});
}

return (
<PanelGroup autoSaveId="example" direction="horizontal">
<Panel />
<PanelGroup autoSaveId="ref-studio" direction="horizontal" className="min-h-screen">
<Panel defaultSize={20} className="p-3">
<FoldersView />
</Panel>
<VerticalResizeHandle />

<Panel defaultSize={60} className="p-3">
<EditorView onChange={(editor) => (editorRef.current.main = editor)} onSelection={setSelection} />
</Panel>

<VerticalResizeHandle />
<Panel>
<div>
<form
onSubmit={(e) => {
e.preventDefault();
greet();
}}
>
<input
id="greet-input"
onChange={(e) => setName(e.currentTarget.value)}
placeholder="Enter a name..."
/>
<button type="submit">Greet</button>
</form>
<p>{greetMsg}</p>
</div>
<PanelGroup direction="vertical">
<Panel className="p-3">
<ReferencesView onRefClicked={handleRefClicked} />
</Panel>
<HorizontalResizeHandle />
<Panel className="p-3">
<AIView selection={selection} />
</Panel>
</PanelGroup>
</Panel>
<Panel />
</PanelGroup>
);
}

function VerticalResizeHandle() {
return <PanelResizeHandle className="flex w-1 items-center bg-gray-200 hover:bg-blue-100" />;
}

function HorizontalResizeHandle() {
return <PanelResizeHandle className="flex h-1 items-center bg-gray-200 hover:bg-blue-100" />;
}
export default App;
6 changes: 6 additions & 0 deletions src/Reference.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { ReferenceItem } from './types/ReferenceItem';

export function Reference({ ref }: { ref?: ReferenceItem }) {
if (!ref) return <span>-</span>;
return <span>[{ref.id}]</span>;
}
3 changes: 3 additions & 0 deletions src/cx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import classNames from 'classnames';

export const cx = classNames;
12 changes: 12 additions & 0 deletions src/hooks/useDebounce.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import * as React from 'react';

export default <T extends any[]>(callback: (...args: T) => any, ms: number) => {
const timeout = React.useRef<NodeJS.Timeout>();

return (...args: T) => {
if (timeout.current) {
clearTimeout(timeout.current);
}
timeout.current = setTimeout(() => callback(...args), ms);
};
};
39 changes: 39 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
@tailwind base;
@tailwind components;
@tailwind utilities;

h1, h2, h3, h4, h5, h6 {
@apply font-bold;
@apply mb-4;
}

h1 {
@apply text-3xl;
}

h2 {
@apply text-2xl;
}

h3 {
@apply text-xl;
}

h4 {
@apply text-lg;
}

a {
@apply text-blue-500 underline cursor-pointer hover:no-underline;
}

p {
@apply my-4;
}

ul {
@apply mb-4;
}
ul li {
@apply ml-4 list-disc;
}
Loading