File tree Expand file tree Collapse file tree 8 files changed +33
-29
lines changed
react-prosemirror-config-default/src Expand file tree Collapse file tree 8 files changed +33
-29
lines changed Original file line number Diff line number Diff line change 77 "main" : " dist" ,
88 "files" : [
99 " dist" ,
10- " src"
10+ " src" ,
11+ " style"
1112 ],
1213 "publishConfig" : {
1314 "access" : " public"
Original file line number Diff line number Diff line change 11import { Plugin } from 'prosemirror-state'
22import FootnoteView from './FootnoteView'
33
4- import './footnotes.css'
5-
64export default options => {
75 return new Plugin ( {
86 props : {
File renamed without changes.
Original file line number Diff line number Diff line change 77 "main" : " dist" ,
88 "files" : [
99 " dist" ,
10- " src"
10+ " src" ,
11+ " style"
1112 ],
1213 "publishConfig" : {
1314 "access" : " public"
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11import { Plugin } from 'prosemirror-state'
2- import { DecorationSet , Decoration } from 'prosemirror-view'
2+ import { Decoration , DecorationSet } from 'prosemirror-view'
33
4- import './placeholder.css'
5-
6- const isEmpty = doc => (
7- doc . childCount === 1 &&
8- doc . firstChild . isTextblock &&
9- doc . firstChild . content . size === 0
10- )
11-
12- export default options => {
4+ export default ( ) => {
135 return new Plugin ( {
146 props : {
157 decorations : state => {
16- if ( ! isEmpty ( state . doc ) ) return null
8+ const decorations = [ ]
9+
10+ const decorate = ( node , pos ) => {
11+ if ( node . type . isBlock && node . childCount === 0 ) {
12+ decorations . push (
13+ Decoration . node ( pos , pos + node . nodeSize , {
14+ class : 'empty-node'
15+ } )
16+ )
17+ }
18+ }
1719
18- const node = document . createElement ( 'div' )
19- node . textContent = options . content
20- node . className = 'placeholder'
20+ state . doc . descendants ( decorate )
2121
22- return DecorationSet . create ( state . doc , [
23- Decoration . widget ( 1 , node )
24- ] )
22+ return DecorationSet . create ( state . doc , decorations )
2523 }
2624 }
2725 } )
Original file line number Diff line number Diff line change 1+ .ProseMirror .empty-node ::before {
2+ float : left;
3+ color : # aaa ;
4+ pointer-events : none;
5+ height : 0 ;
6+ font-style : italic;
7+ }
8+
9+ .ProseMirror p .empty-node : first-child ::before {
10+ content : 'Start typing…' ;
11+ }
Original file line number Diff line number Diff line change @@ -7,16 +7,16 @@ import { footnotes } from '@aeaton/prosemirror-footnotes'
77
88import 'prosemirror-tables/style/tables.css'
99import 'prosemirror-gapcursor/style/gapcursor.css'
10+ import '@aeaton/prosemirror-footnotes/style/footnotes.css'
11+ import '@aeaton/prosemirror-placeholder/style/placeholder.css'
1012
1113import keys from './keys'
1214import rules from './rules'
1315
1416export default [
1517 rules ,
1618 keys ,
17- placeholder ( {
18- content : 'Start typing…'
19- } ) ,
19+ placeholder ( ) ,
2020 footnotes ( ) ,
2121 dropCursor ( ) ,
2222 gapCursor ( ) ,
You can’t perform that action at this time.
0 commit comments