UNPKG

7.2 kBSource Map (JSON)View Raw
1{"version":3,"sources":["@wordpress/block-library/src/paragraph/edit.native.js"],"names":["View","__","Component","createBlock","RichText","styles","name","ParagraphEdit","props","splitBlock","bind","onReplace","state","aztecHeight","before","after","attributes","insertBlocksAfter","setAttributes","blocks","newBlock","content","push","length","map","block","index","mergeBlocks","style","placeholder","minHeight","blockText","isSelected","onFocus","onBlur","onCaretVerticalPositionChange","Math","max","nextContent","event","setState"],"mappings":";;;;;;;;;AAAA;;;AAGA,SAASA,IAAT,QAAqB,cAArB;AAEA;;;;AAGA,SAASC,EAAT,QAAmB,iBAAnB;AACA,SAASC,SAAT,QAA0B,oBAA1B;AACA,SAASC,WAAT,QAA4B,mBAA5B;AACA,SAASC,QAAT,QAAyB,yBAAzB;AAEA;;;;AAGA,OAAOC,MAAP,MAAmB,cAAnB;AAEA,IAAMC,IAAI,GAAG,gBAAb;;IAEMC,a;;;;;AACL,yBAAaC,KAAb,EAAqB;AAAA;;AAAA;;AACpB,uFAAOA,KAAP;AACA,UAAKC,UAAL,GAAkB,MAAKA,UAAL,CAAgBC,IAAhB,uDAAlB;AACA,UAAKC,SAAL,GAAiB,MAAKA,SAAL,CAAeD,IAAf,uDAAjB;AAEA,UAAKE,KAAL,GAAa;AACZC,MAAAA,WAAW,EAAE;AADD,KAAb;AALoB;AAQpB;AAED;;;;;;;;;;;;;;;;;+BAaYC,M,EAAQC,K,EAAmB;AAAA,wBAMlC,KAAKP,KAN6B;AAAA,UAErCQ,UAFqC,eAErCA,UAFqC;AAAA,UAGrCC,iBAHqC,eAGrCA,iBAHqC;AAAA,UAIrCC,aAJqC,eAIrCA,aAJqC;AAAA,UAKrCP,SALqC,eAKrCA,SALqC;;AAAA,wCAATQ,MAAS;AAATA,QAAAA,MAAS;AAAA;;AAQtC,UAAKJ,KAAK,KAAK,IAAf,EAAsB;AACrB;AACA;AACA,YAAMK,QAAQ,GAAGjB,WAAW,CAAEG,IAAF,EAAQ;AAAEe,UAAAA,OAA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AAO,EAAC,GADT;AAEC,QAAA,KAAK,EAAGT,OAFT;AAGC,QAAA,UAAU,EAAG,KAAKb,KAAL,CAAWwB,UAHzB;AAIC,QAAA,OAAO,EAAG,KAAKxB,KAAL,CAAWyB,OAJtB,CAIgC;AAJhC;AAKC,QAAA,MAAM,EAAG,KAAKzB,KAAL,CAAW0B,MALrB,CAK8B;AAL9B;AAMC,QAAA,6BAA6B,EAAG,KAAK1B,KAAL,CAAW2B,6BAN5C;AAOC,QAAA,KAAK,oBACDP,KADC;AAEJE,UAAAA,SAAS,EAAEM,IAAI,CAACC,GAAL,CAAUP,SAAV,EAAqB,KAAKlB,KAAL,CAAWC,WAAhC;AAFP,UAPN;AAWC,QAAA,QAAQ,EAAG,kBAAEyB,WAAF,EAAmB;AAC7BpB,UAAAA,aAAa,CAAE;AACdG,YAAAA,OAAO,EAAEiB;AADK,WAAF,CAAb;AAGA,SAfF;AAgBC,QAAA,OAAO,EAAG,KAAK7B,UAhBhB;AAiBC,QAAA,OAAO,EAAGkB,WAjBX;AAkBC,QAAA,SAAS,EAAG,KAAKhB,SAlBlB;AAmBC,QAAA,mBAAmB,EAAG,6BAAE4B,KAAF,EAAa;AAClC,UAAA,MAAI,CAACC,QAAL,CAAe;AAAE3B,YAAAA,WAAW,EAAE0B,KAAK,CAAC1B;AAArB,WAAf;AACA,SArBF;AAsBC,QAAA,WAAW,EAAGgB,WAAW,IAAI5B,EAAE,CAAE,gBAAF;AAtBhC,QADD,CADD;AA4BA;;;;EA/G0BC,S;;AAkH5B,eAAeK,aAAf","sourcesContent":["/**\n * External dependencies\n */\nimport { View } from 'react-native';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { Component } from '@wordpress/element';\nimport { createBlock } from '@wordpress/blocks';\nimport { RichText } from '@wordpress/block-editor';\n\n/**\n * Internal dependencies\n */\nimport styles from './style.scss';\n\nconst name = 'core/paragraph';\n\nclass ParagraphEdit extends Component {\n\tconstructor( props ) {\n\t\tsuper( props );\n\t\tthis.splitBlock = this.splitBlock.bind( this );\n\t\tthis.onReplace = this.onReplace.bind( this );\n\n\t\tthis.state = {\n\t\t\taztecHeight: 0,\n\t\t};\n\t}\n\n\t/**\n\t * Split handler for RichText value, namely when content is pasted or the\n\t * user presses the Enter key.\n\t *\n\t * @param {?Array} before Optional before value, to be used as content\n\t * in place of what exists currently for the\n\t * block. If undefined, the block is deleted.\n\t * @param {?Array} after Optional after value, to be appended in a new\n\t * paragraph block to the set of blocks passed\n\t * as spread.\n\t * @param {...WPBlock} blocks Optional blocks inserted between the before\n\t * and after value blocks.\n\t */\n\tsplitBlock( before, after, ...blocks ) {\n\t\tconst {\n\t\t\tattributes,\n\t\t\tinsertBlocksAfter,\n\t\t\tsetAttributes,\n\t\t\tonReplace,\n\t\t} = this.props;\n\n\t\tif ( after !== null ) {\n\t\t\t// Append \"After\" content as a new paragraph block to the end of\n\t\t\t// any other blocks being inserted after the current paragraph.\n\t\t\tconst newBlock = createBlock( name, { content: after } );\n\t\t\tblocks.push( newBlock );\n\t\t}\n\n\t\tif ( blocks.length && insertBlocksAfter ) {\n\t\t\tinsertBlocksAfter( blocks );\n\t\t}\n\n\t\tconst { content } = attributes;\n\t\tif ( before === null ) {\n\t\t\tonReplace( [] );\n\t\t} else if ( content !== before ) {\n\t\t\t// Only update content if it has in-fact changed. In case that user\n\t\t\t// has created a new paragraph at end of an existing one, the value\n\t\t\t// of before will be strictly equal to the current content.\n\t\t\tsetAttributes( { content: before } );\n\t\t}\n\t}\n\n\tonReplace( blocks ) {\n\t\tconst { attributes, onReplace } = this.props;\n\t\tonReplace( blocks.map( ( block, index ) => (\n\t\t\tindex === 0 && block.name === name ?\n\t\t\t\t{ ...block,\n\t\t\t\t\tattributes: {\n\t\t\t\t\t\t...attributes,\n\t\t\t\t\t\t...block.attributes,\n\t\t\t\t\t},\n\t\t\t\t} :\n\t\t\t\tblock\n\t\t) ) );\n\t}\n\n\trender() {\n\t\tconst {\n\t\t\tattributes,\n\t\t\tsetAttributes,\n\t\t\tmergeBlocks,\n\t\t\tstyle,\n\t\t} = this.props;\n\n\t\tconst {\n\t\t\tplaceholder,\n\t\t\tcontent,\n\t\t} = attributes;\n\n\t\tconst minHeight = styles.blockText.minHeight;\n\n\t\treturn (\n\t\t\t<View>\n\t\t\t\t<RichText\n\t\t\t\t\ttagName=\"p\"\n\t\t\t\t\tvalue={ content }\n\t\t\t\t\tisSelected={ this.props.isSelected }\n\t\t\t\t\tonFocus={ this.props.onFocus } // always assign onFocus as a props\n\t\t\t\t\tonBlur={ this.props.onBlur } // always assign onBlur as a props\n\t\t\t\t\tonCaretVerticalPositionChange={ this.props.onCaretVerticalPositionChange }\n\t\t\t\t\tstyle={ {\n\t\t\t\t\t\t...style,\n\t\t\t\t\t\tminHeight: Math.max( minHeight, this.state.aztecHeight ),\n\t\t\t\t\t} }\n\t\t\t\t\tonChange={ ( nextContent ) => {\n\t\t\t\t\t\tsetAttributes( {\n\t\t\t\t\t\t\tcontent: nextContent,\n\t\t\t\t\t\t} );\n\t\t\t\t\t} }\n\t\t\t\t\tonSplit={ this.splitBlock }\n\t\t\t\t\tonMerge={ mergeBlocks }\n\t\t\t\t\tonReplace={ this.onReplace }\n\t\t\t\t\tonContentSizeChange={ ( event ) => {\n\t\t\t\t\t\tthis.setState( { aztecHeight: event.aztecHeight } );\n\t\t\t\t\t} }\n\t\t\t\t\tplaceholder={ placeholder || __( 'Start writing…' ) }\n\t\t\t\t/>\n\t\t\t</View>\n\t\t);\n\t}\n}\n\nexport default ParagraphEdit;\n"]}
\No newline at end of file