{"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