1 |
- {"version":3,"file":"index.js","sources":["../../src/components/Editor/CommonTool/ControlsToolBar.tsx","../../src/components/Editor/ImgTxtEditor/SimpleEditor.tsx"],"sourcesContent":["import React from \"react\";\nimport { EditorState } from \"braft-editor\";\nimport { render } from '@testing-library/react';\n\nexport interface ToolListItem {\n key: any;\n color: string;\n iconClass: string;\n iconTextClass: string;\n onClick: any;\n text?: string;\n render?: (i: ToolListItem, innerIcon: any, innerText: any, divWrapStyle: React.CSSProperties | undefined) => any;\n};\ninterface ControlsToolBarProps {\n editorState: EditorState;\n setEditorState: any;\n toolList: Array<ToolListItem>;\n injectIconWrapStyle?: any;\n injectIconStyle?: any;\n injectIconTextStyle?: any;\n}\n\nexport const ControlsToolBar = (props: ControlsToolBarProps) => {\n const {\n editorState,\n setEditorState,\n toolList = [],\n injectIconWrapStyle = {},\n injectIconStyle = {},\n injectIconTextStyle = {},\n } = props;\n const IconWrapStyle = {\n display: 'flex',\n alignItems: 'center',\n cursor: \"pointer\",\n textAlign: \"center\" as const,\n minWidth: \"42px\",\n ...injectIconWrapStyle,\n };\n const IconStyle = { fontSize: \"21px\", ...injectIconStyle };\n const IconTextStyle = { margin: \"0 4px\", ...injectIconTextStyle };\n\n if (toolList.length < 1) {\n return null;\n }\n\n return (\n <>\n {\n toolList.map(i => {\n const innerIcon = <i className={i.iconClass} style={IconStyle} />;\n const innerText = i.text ? <span className={i.iconTextClass} style={IconTextStyle}>{i.text}</span> : null;\n const divWrapStyle = { color: i.color, ...IconWrapStyle };\n const wrapperDom = (\n <div\n key={`toolList_${i.key}`}\n style={divWrapStyle}\n onClick={i.onClick}\n >\n {innerIcon}\n {innerText}\n </div>\n );\n\n if (i.render) {\n return i.render(i, innerIcon, innerText, divWrapStyle);\n }\n\n return wrapperDom;\n })\n }\n </>\n );\n};\n","import React from 'react';\nimport { BarftEditorPage, BaseEditorProps } from \"@components/Editor/BraftEditor\";\nimport { ControlsToolBar, ToolListItem } from \"@components/Editor/CommonTool/ControlsToolBar\";\nimport { ContentUtils } from \"braft-utils\";\nimport styles from './index.less';\n\ninterface SimpleEditorProps extends BaseEditorProps {\n toolAlign?: 'inner' | 'bottom' | 'both';\n toolList?: Array<ToolListItem>;\n injectControlsToolBar?: any;\n injectBraftEditorProps?: any;\n toolBarContainerStyle?: any;\n appendToolBtn?: any;\n appendInnderBar?: any;\n}\n\nconst SimpleEditor = (props: SimpleEditorProps) => {\n const {\n value,\n onChange, \n toolAlign = 'inner',\n toolList = [],\n injectControlsToolBar = {},\n toolBarContainerStyle = {},\n injectBraftEditorProps = {},\n appendToolBtn = null,\n appendInnderBar = null,\n } = props;\n\n\n if (toolAlign === 'inner') {\n return (\n <BarftEditorPage\n value={value}\n onChange={onChange}\n controls={[]}\n FloatControls={({ editorState, setEditorState }: any) => (\n <ControlsToolBar\n editorState={editorState}\n setEditorState={setEditorState}\n toolList={toolList}\n {...injectControlsToolBar}\n />)\n }\n {...injectBraftEditorProps}\n />\n )\n }\n\n if (toolAlign === 'both') {\n return (\n <div>\n <BarftEditorPage\n value={value}\n onChange={onChange}\n controls={[]}\n FloatControls={{appendInnderBar}}\n {...injectBraftEditorProps}\n />\n <div style={toolBarContainerStyle}>\n <div className={styles.bottomToolBarWrapper}>\n <ControlsToolBar\n editorState={value}\n setEditorState={onChange}\n toolList={toolList}\n {...injectControlsToolBar}\n />\n </div>\n {appendToolBtn}\n </div>\n </div>\n )\n }\n\n return (\n <div>\n <BarftEditorPage\n value={value}\n onChange={onChange}\n controls={[]}\n {...injectBraftEditorProps}\n />\n <div style={toolBarContainerStyle}>\n <div className={styles.bottomToolBarWrapper}>\n <ControlsToolBar\n editorState={value}\n setEditorState={onChange}\n toolList={toolList}\n {...injectControlsToolBar}\n />\n </div>\n {appendToolBtn}\n </div>\n </div>\n );\n}\n\nexport default SimpleEditor;"],"names":["ControlsToolBar","props","editorState","setEditorState","toolList","injectIconWrapStyle","injectIconStyle","injectIconTextStyle","IconWrapStyle","display","alignItems","cursor","textAlign","minWidth","IconStyle","fontSize","IconTextStyle","margin","length","React","createElement","Fragment","map","i","innerIcon","className","iconClass","style","innerText","text","iconTextClass","divWrapStyle","color","wrapperDom","key","onClick","render","SimpleEditor","value","onChange","toolAlign","injectControlsToolBar","toolBarContainerStyle","injectBraftEditorProps","appendToolBtn","appendInnderBar","BarftEditorPage","Object","assign","controls","FloatControls","styles","bottomToolBarWrapper"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsBO,IAAMA,eAAe,GAAG,SAAlBA,eAAkB,CAACC,KAAD,EAAgC;MAE3DC,WAF2D,GAQzDD,KARyD,CAE3DC;MACAC,cAH2D,GAQzDF,KARyD,CAG3DE;wBAKEF,KARyD,CAI3DG;MAAAA,QAJ2D,gCAIhD;8BAITH,KARyD,CAK3DI;MAAAA,mBAL2D,sCAKrC;8BAGpBJ,KARyD,CAM3DK;MAAAA,eAN2D,sCAMzC;8BAEhBL,KARyD,CAO3DM;MAAAA,mBAP2D,sCAOrC;;MAElBC,aAAa;AACjBC,IAAAA,OAAO,EAAE;AACTC,IAAAA,UAAU,EAAE;AACZC,IAAAA,MAAM,EAAE;AACRC,IAAAA,SAAS,EAAE;AACXC,IAAAA,QAAQ,EAAE;KACPR;;MAECS,SAAS;AAAKC,IAAAA,QAAQ,EAAE;KAAWT;;MACnCU,aAAa;AAAKC,IAAAA,MAAM,EAAE;KAAYV;;MAExCH,QAAQ,CAACc,MAAT,GAAkB,GAAG;WAChB;;;SAIPC,cAAA,CAAAC,aAAA,CAAAD,cAAA,CAAAE,QAAA,EAAA,IAAA,EAEEjB,QAAQ,CAACkB,GAAT,CAAa,UAAAC,CAAA,EAAI;QACTC,SAAS,GAAGL,cAAA,CAAAC,aAAA,CAAA,GAAA,EAAA;AAAGK,MAAAA,SAAS,EAAEF,CAAC,CAACG,SAAhB;AAA2BC,MAAAA,KAAK,EAAEb;AAAlC,KAAA;QACZc,SAAS,GAAGL,CAAC,CAACM,IAAF,GAASV,c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