@wordpress/editor
Version:
Enhanced block editor for WordPress posts.
8 lines (7 loc) • 2.89 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../../src/components/post-text-editor/index.js"],
"sourcesContent": ["/**\n * External dependencies\n */\nimport Textarea from 'react-autosize-textarea';\n\n/**\n * WordPress dependencies\n */\nimport { __ } from '@wordpress/i18n';\nimport { store as coreStore } from '@wordpress/core-data';\nimport { useDispatch, useSelect } from '@wordpress/data';\nimport { useInstanceId } from '@wordpress/compose';\nimport { VisuallyHidden } from '@wordpress/components';\n\n/**\n * Internal dependencies\n */\nimport { store as editorStore } from '../../store';\n\n/**\n * Displays the Post Text Editor along with content in Visual and Text mode.\n *\n * @return {React.ReactNode} The rendered PostTextEditor component.\n */\nexport default function PostTextEditor() {\n\tconst instanceId = useInstanceId( PostTextEditor );\n\tconst { value, type, id } = useSelect( ( select ) => {\n\t\tconst { getCurrentPostType, getCurrentPostId, getEditedPostContent } =\n\t\t\tselect( editorStore );\n\t\treturn {\n\t\t\tvalue: getEditedPostContent(),\n\t\t\ttype: getCurrentPostType(),\n\t\t\tid: getCurrentPostId(),\n\t\t};\n\t}, [] );\n\tconst { editEntityRecord } = useDispatch( coreStore );\n\n\treturn (\n\t\t<>\n\t\t\t<VisuallyHidden\n\t\t\t\tas=\"label\"\n\t\t\t\thtmlFor={ `post-content-${ instanceId }` }\n\t\t\t>\n\t\t\t\t{ __( 'Type text or HTML' ) }\n\t\t\t</VisuallyHidden>\n\t\t\t<Textarea\n\t\t\t\tautoComplete=\"off\"\n\t\t\t\tdir=\"auto\"\n\t\t\t\tvalue={ value }\n\t\t\t\tonChange={ ( event ) => {\n\t\t\t\t\teditEntityRecord( 'postType', type, id, {\n\t\t\t\t\t\tcontent: event.target.value,\n\t\t\t\t\t\tblocks: undefined,\n\t\t\t\t\t\tselection: undefined,\n\t\t\t\t\t} );\n\t\t\t\t} }\n\t\t\t\tclassName=\"editor-post-text-editor\"\n\t\t\t\tid={ `post-content-${ instanceId }` }\n\t\t\t\tplaceholder={ __( 'Start writing with text or HTML' ) }\n\t\t\t/>\n\t\t</>\n\t);\n}\n"],
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,qCAAqB;AAKrB,kBAAmB;AACnB,uBAAmC;AACnC,kBAAuC;AACvC,qBAA8B;AAC9B,wBAA+B;AAK/B,mBAAqC;AAqBnC;AAda,SAAR,iBAAkC;AACxC,QAAM,iBAAa,8BAAe,cAAe;AACjD,QAAM,EAAE,OAAO,MAAM,GAAG,QAAI,uBAAW,CAAE,WAAY;AACpD,UAAM,EAAE,oBAAoB,kBAAkB,qBAAqB,IAClE,OAAQ,aAAAA,KAAY;AACrB,WAAO;AAAA,MACN,OAAO,qBAAqB;AAAA,MAC5B,MAAM,mBAAmB;AAAA,MACzB,IAAI,iBAAiB;AAAA,IACtB;AAAA,EACD,GAAG,CAAC,CAAE;AACN,QAAM,EAAE,iBAAiB,QAAI,yBAAa,iBAAAC,KAAU;AAEpD,SACC,4EACC;AAAA;AAAA,MAAC;AAAA;AAAA,QACA,IAAG;AAAA,QACH,SAAU,gBAAiB,UAAW;AAAA,QAEpC,8BAAI,mBAAoB;AAAA;AAAA,IAC3B;AAAA,IACA;AAAA,MAAC,+BAAAC;AAAA,MAAA;AAAA,QACA,cAAa;AAAA,QACb,KAAI;AAAA,QACJ;AAAA,QACA,UAAW,CAAE,UAAW;AACvB,2BAAkB,YAAY,MAAM,IAAI;AAAA,YACvC,SAAS,MAAM,OAAO;AAAA,YACtB,QAAQ;AAAA,YACR,WAAW;AAAA,UACZ,CAAE;AAAA,QACH;AAAA,QACA,WAAU;AAAA,QACV,IAAK,gBAAiB,UAAW;AAAA,QACjC,iBAAc,gBAAI,iCAAkC;AAAA;AAAA,IACrD;AAAA,KACD;AAEF;",
"names": ["editorStore", "coreStore", "Textarea"]
}