feat: add code and text block types (#609)
This commit is contained in:
parent
3df0fd4c0f
commit
9778631d6f
27 changed files with 1754 additions and 290 deletions
|
|
@ -9,6 +9,7 @@ import { createRoot } from 'react-dom/client';
|
|||
|
||||
import { Suggestion as PreviewSuggestion } from '@/components/suggestion';
|
||||
import type { Suggestion } from '@/lib/db/schema';
|
||||
import { BlockKind } from '@/components/block';
|
||||
|
||||
export interface UISuggestion extends Suggestion {
|
||||
selectionStart: number;
|
||||
|
|
@ -69,6 +70,7 @@ export function projectWithPositions(
|
|||
export function createSuggestionWidget(
|
||||
suggestion: UISuggestion,
|
||||
view: EditorView,
|
||||
blockKind: BlockKind = 'text',
|
||||
): { dom: HTMLElement; destroy: () => void } {
|
||||
const dom = document.createElement('span');
|
||||
const root = createRoot(dom);
|
||||
|
|
@ -111,7 +113,13 @@ export function createSuggestionWidget(
|
|||
dispatch(textTransaction);
|
||||
};
|
||||
|
||||
root.render(<PreviewSuggestion suggestion={suggestion} onApply={onApply} />);
|
||||
root.render(
|
||||
<PreviewSuggestion
|
||||
suggestion={suggestion}
|
||||
onApply={onApply}
|
||||
blockKind={blockKind}
|
||||
/>,
|
||||
);
|
||||
|
||||
return {
|
||||
dom,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue