22import type React from 'react'
33
44import Color from '@tiptap/extension-color'
5- import Link from '@tiptap/extension-link'
65import TextAlign from '@tiptap/extension-text-align'
76import TextStyle from '@tiptap/extension-text-style'
87import Underline from '@tiptap/extension-underline'
98import StarterKit from '@tiptap/starter-kit'
109
1110import {
11+ CustomImageExtension ,
12+ ImageUploadNodeExtension ,
13+ ToolbarGroup ,
14+ ToolbarSeparator ,
15+ } from '@genseki/react'
16+ import {
17+ BackColorExtension ,
18+ CustomLinkExtension ,
1219 EditorBar ,
20+ EditorBgColorPicker ,
1321 EditorTextColorPicker ,
1422 MarkButton ,
1523 RedoButton ,
24+ SelectionExtension ,
1625 SelectTextStyle ,
1726 TextAlignButton ,
1827 TextAlignButtonsGroup ,
19- ToolbarGroup ,
20- ToolbarSeparator ,
2128 UndoButton ,
2229 UploadImageButton ,
23- } from '@genseki/react'
24- import {
25- BackColorExtension ,
26- CustomImageExtension ,
27- ImageUploadNodeExtension ,
28- SelectionExtension ,
29- } from '@genseki/react'
30+ } from '@genseki/react/v2'
3031
3132export const EditorSlotBefore = ( ) => {
3233 return (
@@ -40,6 +41,7 @@ export const EditorSlotBefore = () => {
4041 </ ToolbarGroup >
4142 < ToolbarSeparator className = "h-auto" />
4243 < EditorTextColorPicker />
44+ < EditorBgColorPicker />
4345 < ToolbarSeparator className = "h-auto" />
4446 < ToolbarGroup className = "items-center" >
4547 < TextAlignButtonsGroup >
@@ -108,66 +110,6 @@ export const editorProviderProps = {
108110 limit : 3 ,
109111 pathName : 'posts/rich-text' ,
110112 } ) ,
111- Link . configure ( {
112- openOnClick : false ,
113- autolink : true ,
114- defaultProtocol : 'https' ,
115- protocols : [ 'http' , 'https' ] ,
116- isAllowedUri : ( url , ctx ) => {
117- try {
118- // construct URL
119- const parsedUrl = url . includes ( ':' )
120- ? new URL ( url )
121- : new URL ( `${ ctx . defaultProtocol } ://${ url } ` )
122-
123- // use default validation
124- if ( ! ctx . defaultValidate ( parsedUrl . href ) ) {
125- return false
126- }
127-
128- // disallowed protocols
129- const disallowedProtocols = [ 'ftp' , 'file' , 'mailto' ]
130- const protocol = parsedUrl . protocol . replace ( ':' , '' )
131-
132- if ( disallowedProtocols . includes ( protocol ) ) {
133- return false
134- }
135-
136- // only allow protocols specified in ctx.protocols
137- const allowedProtocols = ctx . protocols . map ( ( p ) => ( typeof p === 'string' ? p : p . scheme ) )
138-
139- if ( ! allowedProtocols . includes ( protocol ) ) {
140- return false
141- }
142-
143- // disallowed domains
144- const disallowedDomains = [ 'example-phishing.com' , 'malicious-site.net' ]
145- const domain = parsedUrl . hostname
146-
147- if ( disallowedDomains . includes ( domain ) ) {
148- return false
149- }
150-
151- // all checks have passed
152- return true
153- } catch {
154- return false
155- }
156- } ,
157- shouldAutoLink : ( url ) => {
158- try {
159- // construct URL
160- const parsedUrl = url . includes ( ':' ) ? new URL ( url ) : new URL ( `https://${ url } ` )
161-
162- // only auto-link if the domain is not in the disallowed list
163- const disallowedDomains = [ 'example-no-autolink.com' , 'another-no-autolink.com' ]
164- const domain = parsedUrl . hostname
165-
166- return ! disallowedDomains . includes ( domain )
167- } catch {
168- return false
169- }
170- } ,
171- } ) ,
113+ CustomLinkExtension ,
172114 ] ,
173115}
0 commit comments