Нет описания

index.js.map 6.8KB

1
  1. {"version":3,"file":"index.js","sources":["../../src/components/Editor/BraftEditor/index.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport classnames from \"classnames\";\nimport BraftEditor, { ControlType, EditorState } from \"braft-editor\";\nimport styles from \"./index.less\";\nimport \"braft-editor/dist/index.css\";\n\n// 引入表情包扩展模块样式文件\nimport \"braft-extensions/dist/emoticon.css\";\n// 引入表情包扩展模块和默认表情包列表\nimport Emoticon, { defaultEmoticons } from \"braft-extensions/dist/emoticon\";\nimport MaxLength from \"braft-extensions/dist/max-length\";\n\nconst lengthOptions = {\n defaultValue: 100 // 指定默认限制数,如不指定则为Infinity(无限)\n // includeEditors: ['editor-id-1'], // 指定该模块对哪些BraftEditor生效,不传此属性则对所有BraftEditor有效\n // excludeEditors: ['editor-id-2'], // 指定该模块对哪些BraftEditor无效\n};\nBraftEditor.use(MaxLength(lengthOptions));\n\n// 转换默认表情包列表,让webpack可以正确加载到默认表情包中的图片,请确保已对png格式的文件配置了loader\n// 如果你使用的webpack版本不支持动态require,或者使用的其他打包工具,请勿使用此写法\nconst emoticons = defaultEmoticons.map((item: string) =>\n require(`braft-extensions/dist/assets/${item}`)\n);\n\n// 也可以使用自己的表情包资源,不受打包工具限制\n// const emoticons = ['http://path/to/emoticon-1.png', 'http://path/to/emoticon-2.png', 'http://path/to/emoticon-3.png', 'http://path/to/emoticon-4.png', ...]\n\nconst emotionOptions = {\n // includeEditors: ['editor-id-1'], // 指定该模块对哪些BraftEditor生效,不传此属性则对所有BraftEditor有效\n // excludeEditors: ['editor-id-2'], // 指定该模块对哪些BraftEditor无效\n emoticons: emoticons, // 指定可用表情图片列表,默认为空\n closeOnBlur: true, // 指定是否在点击表情选择器之外的地方时关闭表情选择器,默认false\n closeOnSelect: false // 指定是否在选择表情后关闭表情选择器,默认false\n};\n\nBraftEditor.use(Emoticon(emotionOptions));\n\nexport interface BaseEditorProps {\n value: EditorState;\n onChange: (editorState: EditorState) => void;\n controls?: ControlType[];\n FloatControls?: any;\n}\n\nexport const BarftEditorPage = ({\n value,\n onChange,\n controls,\n FloatControls\n}: BaseEditorProps) => {\n const optionsControls = controls\n ? controls\n : [\n \"bold\",\n \"italic\",\n \"underline\",\n \"separator\",\n \"link\",\n \"emoji\",\n \"separator\",\n \"media\"\n ];\n const options: any = {\n controls: optionsControls,\n showControlsBar:\n optionsControls && optionsControls.length > 0 && !FloatControls,\n showFloatControls: FloatControls\n };\n\n const [focusState, setFocusState] = useState(false);\n\n return (\n <div className={styles.baseWrapper}>\n <BraftEditor\n value={value}\n onChange={onChange}\n controls={options.controls}\n controlBarClassName={classnames(styles.controlBar, {\n [styles.focus]: focusState\n })}\n controlBarStyle={options.showControlsBar ? {} : { display: \"none\" }}\n contentClassName={classnames(styles.editorContent, {\n [styles.focus]: focusState,\n [styles.hasFloatControls]: options.showFloatControls\n })}\n contentStyle={{}}\n onFocus={() => setFocusState(true)}\n onBlur={() => setFocusState(false)}\n hooks={{\n \"toggle-link\": ({ href, target }) => {\n href = href.indexOf(\"http\") === 0 ? href : `http://${href}`;\n return { href, target };\n }\n }}\n />\n {options.showFloatControls ? (\n <div className={classnames(styles.floatControls)}>\n {\n <FloatControls\n editorState={value}\n setEditorState={onChange}\n />\n }\n </div>\n ) : null}\n </div>\n );\n};\n\nexport default BarftEditorPage;\n"],"names":["lengthOptions","defaultValue","BraftEditor","use","MaxLength","emoticons","defaultEmoticons","map","item","require","emotionOptions","closeOnBlur","closeOnSelect","Emoticon","BarftEditorPage","value","onChange","controls","FloatControls","optionsControls","options","showControlsBar","length","showFloatControls","useState","focusState","setFocusState","React","createElement","className","styles","baseWrapper","controlBarClassName","classnames","controlBar","focus","controlBarStyle","display","contentClassName","editorContent","hasFloatControls","contentStyle","onFocus","onBlur","hooks","href","target","indexOf","floatControls","editorState","setEditorState"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAYA,IAAMA,aAAa,GAAG;AACpBC,EAAAA,YAAY,EAAE;AADM,CAAtB;AA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