-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4c8b06
commit cb95f6f
Showing
15 changed files
with
205 additions
and
146 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { TenTapBridge } from 'tentap'; | ||
import CharacterCount from '@tiptap/extension-character-count'; | ||
|
||
type CounterEditorState = { | ||
wordCount: number; | ||
characterCount: number; | ||
}; | ||
|
||
type CounterEditorInstance = {}; | ||
|
||
declare module 'tentap' { | ||
interface EditorNativeState extends CounterEditorState {} | ||
interface EditorInstance extends CounterEditorInstance {} | ||
} | ||
|
||
export const CounterBridge = new TenTapBridge< | ||
CounterEditorState, | ||
CounterEditorInstance, | ||
unknown | ||
>({ | ||
tiptapExtension: CharacterCount.configure({ | ||
limit: 240, | ||
}), | ||
extendEditorState: (editor) => { | ||
return { | ||
wordCount: editor.storage.characterCount.characters(), | ||
characterCount: editor.storage.characterCount.words(), | ||
}; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,17 @@ | ||
import React from 'react'; | ||
import { BubbleMenu, EditorContent } from '@tiptap/react'; | ||
import { sendMessage, useTenTap } from 'tentap'; | ||
import { EditorContent } from '@tiptap/react'; | ||
import { useTenTap } from 'tentap'; | ||
import Document from '@tiptap/extension-document'; | ||
import Paragraph from '@tiptap/extension-paragraph'; | ||
import Text from '@tiptap/extension-text'; | ||
import { CounterBridge } from '../CounterBridge'; | ||
|
||
export const AdvancedEditor = () => { | ||
const editor = useTenTap(); | ||
// alert('ssss') | ||
return ( | ||
<> | ||
{editor && ( | ||
<BubbleMenu editor={editor || undefined}> | ||
<button | ||
onClick={() => | ||
window.ReactNativeWebView?.postMessage( | ||
JSON.stringify({ | ||
type: 'new-comment', | ||
}) | ||
) | ||
} | ||
> | ||
Add comment | ||
</button> | ||
</BubbleMenu> | ||
)} | ||
<EditorContent editor={editor} /> | ||
</> | ||
); | ||
const editor = useTenTap({ | ||
bridges: [CounterBridge], | ||
tiptapOptions: { | ||
extensions: [Document, Paragraph, Text], | ||
}, | ||
}); | ||
return <EditorContent editor={editor} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,29 @@ | ||
import { EditorContent } from '@tiptap/react'; | ||
import { useTenTap } from './useTenTap'; | ||
import { useTenTap } from '../webEditorUtils'; | ||
import { TenTapStartKit } from '../bridges/StarterKit'; | ||
import { UnderlineBridge } from '../bridges/underline'; | ||
import { TaskListBridge } from '../bridges/tasklist'; | ||
import { LinkBridge } from '../bridges/link'; | ||
import { ColorBridge } from '../bridges/color'; | ||
import { HighlightBridge } from '../bridges/highlight'; | ||
import { CoreBridge } from '../bridges/core'; | ||
import { ImageBridge } from '../bridges/image'; | ||
|
||
let tenTapExtensions = [ | ||
TenTapStartKit, | ||
UnderlineBridge, | ||
ImageBridge, | ||
TaskListBridge, | ||
LinkBridge, | ||
ColorBridge, | ||
HighlightBridge, | ||
CoreBridge, | ||
].filter( | ||
(e) => !window.whiteListPlugins || window.whiteListPlugins.includes(e.name) | ||
); | ||
|
||
export default function Tiptap() { | ||
const editor = useTenTap(); | ||
const editor = useTenTap({ bridges: tenTapExtensions }); | ||
|
||
return <EditorContent editor={editor} />; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from './useTenTap'; | ||
export * from './useTenTap'; | ||
export { default as TenTapBridge } from '../bridges/base'; |
Oops, something went wrong.