Comments (5)
Yes – this is being worked on as part of #29! The hard part is figuring out the AI editing UX – I wrote about it in the PR!
from novel.
I added additional command in slash. slah comment is trigget by selectItem so you can add whatever command you need.
- extract apis into different hooks
const {
complete: continueComplete,
completion,
isLoading: isLoadingContinue,
stop,
} = useContinueCommand(editor)
const { complete: breakSteps, isLoading: isLoadingBreakSteps } = useBreakIntoSteps({
editor,
project_title,
project_des,
task_title,
})
const selectItem = useCallback(
(index: number) => {
const item = items[index]
if (item) {
if (item.title === 'Continue writing') {
const text = editor.getText()
continueComplete(text)
}
if (item.title === 'Break into steps') {
const text = editor.getText()
breakSteps(text)
} else {
command(item)
}
}
},
[continueComplete, breakSteps, command, editor, items]
)
- add to array
const getSuggestionItems = ({ query }: { query: string }) => {
return [
{
title: 'Continue writing',
description: 'Use AI to expand your thoughts.',
icon: <Magic className="w-7 text-black" />,
},
{
title: 'Break into steps',
description: 'Use AI to break action into steps .',
icon: <Component className="w-7 text-black" />,
},
]
- add spinning indicator for new command (could use switch state for better readability)
{item.title === 'Continue writing' && isLoadingContinue ? (
<LoadingCircle />
) : item.title === 'Break into steps' && isLoadingBreakSteps ? (
<LoadingCircle />
) : (
item.icon
)}
from novel.
It would look like this. (I turned off the markdown)
from novel.
@jt6677 oooh very interesting – so you're basically streaming in responses without markdown, and then converting them to markdown once streaming is complete?
Is it possible to stream them in and directly format them as markdown?
from novel.
@jt6677 oooh very interesting – so you're basically streaming in responses without markdown, and then converting them to markdown once streaming is complete?
Is it possible to stream them in and directly format them as markdown?
For what I understand, tiptap does not play nice with markdown. Individual paragraph or each circled step is a tiptap node.
const taskItems = completion
.split(/\n(?=\d+\.)/) // Splits at the start of each numbered item
.filter((task) => task.trim().length > 0) // Filters out any empty strings
.map((task) => {
const taskText = task.trim().slice(3) // Removes the numbering and leading space from each task item
return {
type: 'taskItem',
attrs: {
checked: false,
},
content: [
{
type: 'paragraph',
content: [{ type: 'text', text: taskText }],
},
],
}
})
const taskList = {
type: 'taskList',
content: taskItems,
}
editor?.chain().deleteRange({ from, to }).insertContent(taskList).run()
Basically, I take the finial result (after streaming), split into array of text and parse each text as a special tiptap node(taskItem). There is a problem in current version of novel; streamed markdown would appear to be correctly formatted at first. But to Tiptap, it was just a SINGLE node with text. Any editing on the markdown text would cause the text to lose all format, and collapse into a single paragraph.
The solution I am using in my app is just parse individual text to tiptap nodes whether is a paragraph or a taskItem.
from novel.
Related Issues (20)
- AI not showing ++ or slash menu HOT 4
- Unable to use Editor as a JSX component HOT 4
- bug: Imports broken in v2 HOT 10
- feat: Track Changes with Red and Green Highlights HOT 1
- feat: Youtube Support HOT 1
- bug: Runtime Error with Invalid Element Type in Next.js 14 Project Using Novel.sh HOT 2
- bug: slash command tunnel is shared between editor instances
- feat: Unhandled Runtime Error Error: Unsupported Server Component type: undefined HOT 2
- bug: Uncaught RangeError: Schema is missing its top node type ('doc') HOT 9
- bug: Image can't be resized HOT 2
- bug: Missing CSS variables
- bug: 'EditorContent' cannot be used as a JSX component.
- Selectors show on left top in Safari
- bug: Ask AI text gets hidden behind button, makes it hard to see your prompt
- bug: closing tags in code editor trigger slash command
- bug: Module '"novel"' declares 'Editor' locally, but it is not exported. HOT 11
- feat: Notion Styled Toggle List
- bug: Error with Ask AI features e.g Improve Writing, Fix Grammar in the latest main branch HOT 1
- Text to Image
- feat: Convert the content in an Editor to a Notion Page HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from novel.