Skip to content

Commit

Permalink
fix: use tiptap type
Browse files Browse the repository at this point in the history
  • Loading branch information
17Amir17 committed Dec 16, 2024
1 parent b310f62 commit 914b39c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
20 changes: 4 additions & 16 deletions src/bridges/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,10 @@ import { focusListener } from '../webEditorUtils/focusListener';
import Document from '@tiptap/extension-document';
import Paragraph from '@tiptap/extension-paragraph';
import Text from '@tiptap/extension-text';
import type { Content } from '@tiptap/react';

export type EditorContentType = 'html' | 'text' | 'json';

type JSONContent = {
type?: string;
attrs?: Record<string, any>;
content?: JSONContent[];
marks?: {
type: string;
attrs?: Record<string, any>;
[key: string]: any;
}[];
text?: string;
[key: string]: any;
};

type CoreEditorState = {
selection: { from: number; to: number };
isFocused: boolean;
Expand All @@ -34,7 +22,7 @@ type CoreEditorInstance = {
getHTML: () => Promise<string>;
getJSON: () => Promise<object>;
getText: () => Promise<string>;
setContent: (content: string | JSONContent) => void;
setContent: (content: Content) => void;
setSelection: (from: number, to: number) => void;
updateScrollThresholdAndMargin: (offset: number) => void;
focus: (pos: FocusArgs) => void;
Expand Down Expand Up @@ -115,7 +103,7 @@ export type CoreMessages =
| {
type: CoreEditorActionType.SetContent;
payload: {
content: string | JSONContent;
content: Content;
};
}
| {
Expand Down Expand Up @@ -283,7 +271,7 @@ export const CoreBridge = new BridgeExtension<
},
});
},
setContent: (content: string | JSONContent) => {
setContent: (content: Content) => {
sendBridgeMessage({
type: CoreEditorActionType.SetContent,
payload: {
Expand Down
4 changes: 2 additions & 2 deletions website/docs/api/EditorBridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ an async function that will return the content of the editor in json format <br

#### setContent

`(content: string | JSONContent) => void`<br />
a function that get's html as string and set set's it as the editors content <br /> extended by [CoreBridge](./BridgeExtensions#coreextension)
`(content: Content) => void`<br />
a function that get's html as string or document object and set set's it as the editors content <br /> extended by [CoreBridge](./BridgeExtensions#coreextension)

#### setEditable

Expand Down

0 comments on commit 914b39c

Please sign in to comment.