Skip to content

add TipTap as an editor#16

Merged
sergioramos merged 29 commits into
mainfrom
poc-editor-tiptap
May 19, 2023
Merged

add TipTap as an editor#16
sergioramos merged 29 commits into
mainfrom
poc-editor-tiptap

Conversation

@sehyod

@sehyod sehyod commented May 18, 2023

Copy link
Copy Markdown
Collaborator

This PR is the PoC for using TipTap within the evaluation of text editors being discussed in #4

image

POC with 3 panels:

Left Panel: List of project's documents
Center Panel: TipTap editor
Right Panel : references and AI interactions

  • Selecting text in the editor sends it to the backend and shows the result in the AI interactions panel (currently only returning the length of the selected text followed by the uppercased selection)
  • Clicking on a reference adds it to the editor as a special, uneditable node

The editor supports basic text formatting and draggable collapsible blocks.

Due to tauri's limitation (see this issue), HTML drag events don't work properly with the fileDropEnabled config

@sehyod sehyod marked this pull request as draft May 18, 2023 13:20
@sehyod sehyod changed the title Poc editor tiptap PoC using TipTap May 18, 2023
@hammer

hammer commented May 18, 2023

Copy link
Copy Markdown
Contributor

Nice! A lot of the comments from #13 (comment) also apply here.

A few additional thoughts

  • It's nice to see blocks with handles that can be relocated here.
  • Text selections showing up in the AI interactions component already! I didn't notice this on the Lexical demo, I think it's working there too.
  • Toggling block collapse with Cmd-Enter does not work as expected.
  • File browser +/- not yet working it seems
  • Vertical scroll within a component not working yet

@hammer

hammer commented May 18, 2023

Copy link
Copy Markdown
Contributor

@sergioramos @danvk @cguedes could y'all review this PR and get it ready for the merge to main?

@danvk danvk left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice to see this come together!

A few high level comments on the code:

  • Did the CollapsibleBlock code come from somewhere or is that custom?
  • Please run prettier on all files.
  • We should set up eslint, but I have no preference about whether that happens before or after this PR is merged to main.

Comment thread src/hooks/useDebounce.ts Outdated
@@ -0,0 +1,17 @@
import * as React from 'react';

export default <T>(value: T, ms: number) => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using a version of this from an external library since debouncing can have lots of subtleties. It's interesting how different this implementation is than https://github.com/refstudio/refstudio/pull/13/files#diff-cda4ca785473197ac020d50f1efbbecd157cb01dc09e86d93bac11be09bf54fa

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually implemented both versions, and the second time I figured it made more sense for the hook to debounce a value rather than a callback's result.
As per your suggestion I have now installed usehooks instead of having our own implementation.

Comment thread src/Reference/suggestion.ts Outdated
Comment thread src/App.tsx Outdated
Comment thread src/App.tsx Outdated
Comment thread src/App.tsx Outdated
Comment thread src/views/AIView.tsx Outdated

{selection && (
<div style={{ display: 'flex', flexDirection: "column", gap: "1rem" }}>
<div style={{ borderWidth: "1px", borderColor: "rgb(254 249 195)", backgroundColor: "rgb(254 252 232)", padding: "1rem" }}>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/views/AIView.tsx Outdated
Comment thread src/views/AIView.tsx Outdated

{selection && (
<div style={{ display: 'flex', flexDirection: "column", gap: "1rem" }}>
<div style={{ borderWidth: "1px", borderColor: "rgb(254 249 195)", backgroundColor: "rgb(254 252 232)", padding: "1rem" }}>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should discuss everyone's preferences around inline styles. I find that all the inline styles in this component make it a bit difficult to follow the logic.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We will be using tailwind for style from now on. I only used inline style for the PoC and this will be removed before we merge the PR

Comment thread src/views/EditorView.tsx Outdated
Comment thread src/views/ReferencesView.tsx Outdated
Comment thread src/views/EditorView.tsx Outdated
@sehyod sehyod marked this pull request as ready for review May 19, 2023 15:40
@cguedes

cguedes commented May 19, 2023

Copy link
Copy Markdown
Collaborator

@sergioramos this is ready for review

@cguedes cguedes requested a review from sergioramos May 19, 2023 15:41
@sergioramos sergioramos changed the title PoC using TipTap add TipTap as an editor May 19, 2023
@sergioramos sergioramos merged commit bebef76 into main May 19, 2023
@sergioramos sergioramos deleted the poc-editor-tiptap branch May 19, 2023 16:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants