File tree Expand file tree Collapse file tree
resources/js/form/components/fields/editor Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212 import { Iframe } from " @/form/components/fields/editor/extensions/iframe/Iframe" ;
1313 import { useParentForm } from " @/form/useParentForm" ;
1414 import { trimHTML } from " @/form/components/fields/editor/utils/html" ;
15- import { getExtensionsForEditor } from " @/form/components/fields/editor/extensions" ;
15+ import { getExtensions } from " @/form/components/fields/editor/extensions" ;
1616 import { ContentEmbedManager } from " @/content/ContentEmbedManager" ;
1717 import { ContentUploadManager } from " @/content/ContentUploadManager" ;
1818 import { FormFieldEmits , FormFieldProps } from " @/form/types" ;
7474 (locale ) => {
7575 const { field } = props ;
7676 const extensions = [
77- ... getExtensionsForEditor (field ),
77+ ... getExtensions (field ),
7878 field .markdown && Markdown .configure ({
7979 breaks: config (' sharp.markdown_editor.nl2br' ),
8080 }),
Original file line number Diff line number Diff line change 11import { Command , Extension } from "@tiptap/core" ;
22import { Plugin } from '@tiptap/pm/state' ;
3- import { DOMParser , Schema } from '@tiptap/pm/model' ;
3+ import { DOMParser } from '@tiptap/pm/model' ;
44import { __ } from "@/utils/i18n" ;
55
66export const Clipboard = Extension . create ( {
77 name : 'clipboard' ,
88 addOptions ( ) {
99 return {
10- schema : null ,
1110 inline : false ,
1211 }
1312 } ,
1413 addProseMirrorPlugins ( ) {
15- const schema = getNormalizedSchema (
16- this . options . schema ,
17- this . editor . schema
18- ) ;
19- const parser = DOMParser . fromSchema ( schema ) ;
14+ const parser = DOMParser . fromSchema ( this . editor . schema ) ;
2015 return [
2116 new Plugin ( {
2217 props : {
@@ -83,17 +78,3 @@ declare module '@tiptap/core' {
8378 }
8479 }
8580}
86-
87- // needed to keep same references of node/mark types
88- function getNormalizedSchema ( target , source ) {
89- const schema = new Schema ( target . spec ) ;
90- // @ts -ignore
91- schema . nodes = Object . fromEntries (
92- Object . entries ( source . nodes ) . filter ( ( [ key ] ) => ! ! target . nodes [ key ] )
93- ) ;
94- // @ts -ignore
95- schema . marks = Object . fromEntries (
96- Object . entries ( source . marks ) . filter ( ( [ key ] ) => ! ! target . marks [ key ] )
97- ) ;
98- return schema ;
99- }
Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ export type EmbedOptions = {
1818export const Embed : WithRequiredOptions < Node < EmbedOptions > > = Node . create < EmbedOptions > ( {
1919 name : 'embed' ,
2020
21- group : 'block ' ,
21+ group : 'embed ' ,
2222
2323 atom : true ,
2424
Original file line number Diff line number Diff line change @@ -35,7 +35,7 @@ import { CharacterCount } from '@tiptap/extension-character-count';
3535import { FormEditorFieldData , FormEditorToolbarButton } from "@/types" ;
3636
3737
38- function getExtensions ( field : FormEditorFieldData ) {
38+ export function getExtensions ( field : FormEditorFieldData ) {
3939 const toolbarHas = ( buttonName : FormEditorToolbarButton | FormEditorToolbarButton [ ] ) =>
4040 ! field . toolbar || field . toolbar . some ( button =>
4141 Array . isArray ( buttonName )
@@ -54,9 +54,16 @@ function getExtensions(field: FormEditorFieldData) {
5454 ]
5555 }
5656 } ) ,
57+ Clipboard . configure ( {
58+ inline : field . inline ,
59+ } ) ,
5760 toolbarHas ( 'code' ) && Code ,
5861 toolbarHas ( 'code-block' ) && CodeBlock ,
59- Document ,
62+ Document . extend ( {
63+ content : field . uploads || Object . keys ( field . embeds ?? { } ) . length
64+ ? '(block | embed)+'
65+ : 'block+' ,
66+ } ) ,
6067 Dropcursor ,
6168 Gapcursor ,
6269 HardBreak . extend ( {
@@ -116,16 +123,3 @@ function getExtensions(field: FormEditorFieldData) {
116123 . flat ( )
117124 . filter ( extension => ! ! extension ) ;
118125}
119-
120- export function getExtensionsForEditor ( field : FormEditorFieldData ) {
121- return [
122- ...getExtensions ( field ) ,
123- Clipboard . configure ( {
124- schema : getSchema ( getExtensions ( {
125- ...field ,
126- toolbar : field . toolbar ?? [ ] , // if no toolbar, prevent pasting formatted HTML
127- } ) ) ,
128- inline : field . inline ,
129- } ) ,
130- ] ;
131- }
Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ export type UploadOptions = {
2121export const Upload : WithRequiredOptions < Node < UploadOptions > > = Node . create < UploadOptions > ( {
2222 name : 'upload' ,
2323
24- group : 'block ' ,
24+ group : 'embed ' ,
2525
2626 atom : true ,
2727
You can’t perform that action at this time.
0 commit comments