├── .babelrc ├── .eslintignore ├── .eslintrc ├── .flowconfig ├── .github └── FUNDING.yml ├── .gitignore ├── .npmignore ├── .nvmrc ├── .storybook ├── main.js ├── preview.js └── webpack.config.js ├── .travis.yml ├── CHANGELOG.md ├── LICENSE ├── README.md ├── config ├── test-compiler.js ├── test-setup.js └── webpack.config.js ├── css └── Draft.css ├── docs ├── .babelrc ├── config │ ├── server.dev.js │ ├── webpack.dev.config.js │ └── webpack.prod.config.js ├── css │ ├── carbon.css │ ├── fonts.css │ └── normalize.css ├── images │ ├── demo │ │ ├── bold.gif │ │ ├── center-align.gif │ │ ├── erase.gif │ │ ├── image.gif │ │ ├── indent.gif │ │ ├── italic.gif │ │ ├── justify.gif │ │ ├── left-align.gif │ │ ├── link.gif │ │ ├── ordered.gif │ │ ├── outdent.gif │ │ ├── redo.gif │ │ ├── right-align.gif │ │ ├── strikethrough.gif │ │ ├── subscript.gif │ │ ├── superscript.gif │ │ ├── underline.gif │ │ ├── undo.gif │ │ ├── unlink.gif │ │ └── unordered.gif │ ├── feather.svg │ ├── github.png │ └── paper_pen.svg ├── index.html ├── package.json ├── src │ ├── components │ │ ├── App │ │ │ ├── index.js │ │ │ └── styles.css │ │ ├── Author │ │ │ ├── index.js │ │ │ └── styles.css │ │ ├── Demo │ │ │ ├── EditorConvertToHTML │ │ │ │ ├── index.js │ │ │ │ └── styles.css │ │ │ ├── EditorConvertToJSON │ │ │ │ └── index.js │ │ │ ├── EditorConvertToMarkdown │ │ │ │ └── index.js │ │ │ ├── EditorCustomToolbarOption │ │ │ │ └── index.js │ │ │ ├── EditorCustomizedToolbarOption │ │ │ │ ├── ColorPic │ │ │ │ │ ├── index.js │ │ │ │ │ └── styles.css │ │ │ │ └── index.js │ │ │ ├── EditorEmbedded │ │ │ │ └── index.js │ │ │ ├── EditorI18n │ │ │ │ └── index.js │ │ │ ├── EditorImage │ │ │ │ └── index.js │ │ │ ├── EditorStyledToolbar │ │ │ │ └── index.js │ │ │ ├── EditorToolbarWhenFocused │ │ │ │ └── index.js │ │ │ ├── EditorWithMentionHashtag │ │ │ │ └── index.js │ │ │ ├── index.js │ │ │ └── styles.css │ │ ├── Docs │ │ │ ├── ARIASupport │ │ │ │ └── index.js │ │ │ ├── DataConversion │ │ │ │ └── index.js │ │ │ ├── Installation │ │ │ │ └── index.js │ │ │ ├── Props │ │ │ │ ├── BlockRenderingProp │ │ │ │ │ └── index.js │ │ │ │ ├── CustomStyleProp │ │ │ │ │ └── index.js │ │ │ │ ├── CustomizingToolbarProp │ │ │ │ │ ├── CustomToolbarOption │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── CustomizeToolbarOption │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── I18N │ │ │ │ │ │ └── index.js │ │ │ │ │ ├── defaultToolbar.js │ │ │ │ │ └── index.js │ │ │ │ ├── DecoratorProp │ │ │ │ │ └── index.js │ │ │ │ ├── DraftjsProp │ │ │ │ │ └── index.js │ │ │ │ ├── EditorRef │ │ │ │ │ └── index.js │ │ │ │ ├── EditorStateProp │ │ │ │ │ └── index.js │ │ │ │ ├── EditorStyleProp │ │ │ │ │ └── index.js │ │ │ │ ├── EventCallbackProp │ │ │ │ │ └── index.js │ │ │ │ ├── HashtagProp │ │ │ │ │ └── index.js │ │ │ │ ├── MentionProp │ │ │ │ │ └── index.js │ │ │ │ ├── ReadOnlyProp │ │ │ │ │ └── index.js │ │ │ │ ├── TextAlignmentProp │ │ │ │ │ └── index.js │ │ │ │ ├── WrapperIdProp │ │ │ │ │ └── index.js │ │ │ │ └── index.js │ │ │ ├── Usage │ │ │ │ └── index.js │ │ │ ├── index.js │ │ │ └── styles.css │ │ ├── Home │ │ │ ├── index.js │ │ │ └── styles.css │ │ ├── Menu │ │ │ ├── index.js │ │ │ └── styles.css │ │ └── index.js │ ├── icons │ │ └── palette.svg │ ├── index.js │ └── util │ │ ├── sampleEditorContent.js │ │ └── uploadImageCallBack.js ├── static │ ├── bundle.js │ ├── c9203522b9cb8ed7ec319eb07e8731b1.svg │ ├── main.css │ └── main.css.map ├── template │ └── index.html └── yarn.lock ├── images ├── align-center.svg ├── align-justify.svg ├── align-left.svg ├── align-right.svg ├── bold.svg ├── color.svg ├── embedded.svg ├── emoji.svg ├── eraser.svg ├── font-size.svg ├── image.svg ├── indent.svg ├── italic.svg ├── link.svg ├── list-ordered.svg ├── list-unordered.svg ├── monospace.svg ├── openlink.svg ├── ordered.svg ├── outdent.svg ├── redo.svg ├── strikethrough.svg ├── subscript.svg ├── superscript.svg ├── underline.svg ├── undo.svg ├── unlink.svg └── unordered.svg ├── interfaces ├── CSSModule.js ├── draftjs-to-html.js ├── draftjs-utils.js ├── images.js └── mocha.js ├── package-lock.json ├── package.json ├── postcss.config.js ├── scripts └── publish.sh ├── src ├── Editor │ ├── __test__ │ │ └── editorTest.js │ ├── index.js │ └── styles.css ├── components │ ├── Dropdown │ │ ├── Dropdown │ │ │ ├── __test__ │ │ │ │ └── dropdownTest.js │ │ │ ├── index.js │ │ │ └── styles.css │ │ ├── DropdownOption │ │ │ ├── __test__ │ │ │ │ └── dropdownOptionTest.js │ │ │ ├── index.js │ │ │ └── styles.css │ │ └── index.js │ ├── Option │ │ ├── __test__ │ │ │ └── optionTest.js │ │ ├── index.js │ │ └── styles.css │ └── Spinner │ │ ├── __test__ │ │ └── spinnerTest.js │ │ ├── index.js │ │ └── styles.css ├── config │ └── defaultToolbar.js ├── controls │ ├── BlockType │ │ ├── Component │ │ │ ├── index.js │ │ │ └── styles.css │ │ ├── __test__ │ │ │ └── blockControlTest.js │ │ └── index.js │ ├── ColorPicker │ │ ├── Component │ │ │ ├── index.js │ │ │ └── styles.css │ │ ├── __test__ │ │ │ └── colorPickerTest.js │ │ └── index.js │ ├── Embedded │ │ ├── Component │ │ │ ├── index.js │ │ │ └── styles.css │ │ └── index.js │ ├── Emoji │ │ ├── Component │ │ │ ├── index.js │ │ │ └── styles.css │ │ └── index.js │ ├── FontFamily │ │ ├── Component │ │ │ ├── index.js │ │ │ └── styles.css │ │ ├── __test__ │ │ │ └── fontFamilyControlTest.js │ │ └── index.js │ ├── FontSize │ │ ├── Component │ │ │ ├── index.js │ │ │ └── styles.css │ │ ├── __test__ │ │ │ └── fontSizeControlTest.js │ │ └── index.js │ ├── History │ │ ├── Component │ │ │ ├── index.js │ │ │ └── styles.css │ │ ├── __test__ │ │ │ └── historyControlTest.js │ │ └── index.js │ ├── Image │ │ ├── Component │ │ │ ├── index.js │ │ │ └── styles.css │ │ ├── __test__ │ │ │ └── imageControlTest.js │ │ └── index.js │ ├── Inline │ │ ├── Component │ │ │ ├── index.js │ │ │ └── styles.css │ │ ├── __test__ │ │ │ └── inlineControlTest.js │ │ └── index.js │ ├── Link │ │ ├── Component │ │ │ ├── index.js │ │ │ └── styles.css │ │ ├── __test__ │ │ │ └── linkControlTest.js │ │ └── index.js │ ├── List │ │ ├── Component │ │ │ ├── index.js │ │ │ └── styles.css │ │ ├── __test__ │ │ │ └── listControlsTest.js │ │ └── index.js │ ├── Remove │ │ ├── Component │ │ │ ├── index.js │ │ │ └── styles.css │ │ └── index.js │ ├── TextAlign │ │ ├── Component │ │ │ ├── index.js │ │ │ └── styles.css │ │ ├── __test__ │ │ │ └── textAlignControlTest.js │ │ └── index.js │ └── index.js ├── decorators │ ├── HashTag │ │ ├── index.js │ │ └── styles.css │ ├── Link │ │ ├── __test__ │ │ │ └── linkDecoratorTest.js │ │ ├── index.js │ │ └── styles.css │ └── Mention │ │ ├── Mention │ │ ├── index.js │ │ └── styles.css │ │ ├── Suggestion │ │ ├── index.js │ │ └── styles.css │ │ ├── addMention.js │ │ └── index.js ├── event-handler │ ├── focus.js │ ├── keyDown.js │ ├── modals.js │ └── suggestions.js ├── i18n │ ├── da.js │ ├── de.js │ ├── en.js │ ├── es.js │ ├── fr.js │ ├── index.js │ ├── it.js │ ├── ja.js │ ├── ko.js │ ├── nl.js │ ├── pl.js │ ├── pt.js │ ├── ru.js │ ├── zh.js │ └── zh_tw.js ├── index.js ├── renderer │ ├── Embedded │ │ └── index.js │ ├── Image │ │ ├── __test__ │ │ │ └── imageRendererTest.js │ │ ├── index.js │ │ └── styles.css │ └── index.js ├── stories │ ├── Basic │ │ └── index.stories.js │ ├── BasicContentState │ │ └── index.stories.js │ ├── BasicControlled │ │ └── index.stories.js │ ├── ControlledSelectedOptions │ │ └── index.stories.js │ ├── ConvertFromHTML │ │ └── index.stories.js │ ├── ConvertFromRawDraftContent │ │ └── index.stories.js │ ├── ConvertToHTML │ │ └── index.stories.js │ ├── ConvertToMarkdown │ │ └── index.stories.js │ ├── ConvertToRawDraftContent │ │ └── index.stories.js │ ├── CustomToolbar │ │ ├── index.stories.js │ │ └── styles.css │ ├── Embeddable │ │ └── index.stories.js │ ├── FloatingToolbar │ │ ├── index.stories.js │ │ └── styles.css │ ├── FocusBlurCallbacks │ │ ├── index.stories.js │ │ └── styles.css │ ├── HashTag │ │ └── index.stories.js │ ├── I18n │ │ ├── index.stories.js │ │ └── styles.css │ ├── ImageDataURI │ │ └── index.stories.js │ ├── ImageUpload │ │ └── index.stories.js │ ├── Mention │ │ └── index.stories.js │ ├── ReadOnly │ │ └── index.stories.js │ ├── SelectedOptions │ │ └── index.stories.js │ ├── SpellCheck │ │ └── index.stories.js │ ├── ToolbarHidden │ │ ├── index.stories.js │ │ └── styles.css │ └── styles.css └── utils │ ├── BlockStyle.js │ ├── common.js │ ├── handlePaste.js │ ├── toolbar.js │ └── url.js └── yarn.lock /.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env", "@babel/preset-react"], 3 | "plugins": [ 4 | ["transform-flow-strip-types"], 5 | ["@babel/plugin-transform-class-properties"], 6 | [ 7 | "@babel/plugin-proposal-class-properties", 8 | { 9 | "loose": true 10 | } 11 | ] 12 | ] 13 | } 14 | -------------------------------------------------------------------------------- /.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "parser": "babel-eslint", 3 | "env": { 4 | "browser": true, 5 | "es6": true 6 | }, 7 | "extends": ["airbnb", "prettier"], 8 | "parserOptions": { 9 | "ecmaFeatures": { 10 | "jsx": true 11 | }, 12 | "ecmaVersion": 2018, 13 | "sourceType": "module" 14 | }, 15 | "plugins": ["babel", "react"], 16 | "rules": { 17 | "import/no-unresolved": 0, 18 | "import/no-extraneous-dependencies": 0, 19 | "react/jsx-filename-extension": 0, 20 | "jsx-a11y/label-has-for": 0 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /.flowconfig: -------------------------------------------------------------------------------- 1 | [ignore] 2 | .*node_modules* 3 | .*node_modules/fbjs.* 4 | .*/__test__/* 5 | ./images/*.svg 6 | 7 | [include] 8 | .*/js/* 9 | 10 | [libs] 11 | ./interfaces/mocha.js 12 | ./interfaces/images.js 13 | ./interfaces/CSSModule.js 14 | ./interfaces/draftjs-to-html.js 15 | ./interfaces/draftjs-utils.js 16 | ./node_modules/draft-js 17 | 18 | [options] 19 | esproposal.class_static_fields=enable 20 | esproposal.class_instance_fields=enable 21 | module.name_mapper='^.*.css' -> 'CSSModule' 22 | module.name_mapper='^.*.svg' -> 'images' 23 | module.system=haste 24 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] 4 | patreon: jyotipuri 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 13 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store 3 | npm-debug.log 4 | dist 5 | docs/.yalc/ 6 | docs/yalc.lock 7 | stats.json 8 | report.html -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .storybook 2 | config 3 | css 4 | docs 5 | images 6 | interfaces 7 | scripts 8 | src 9 | stories 10 | node_modules 11 | .babelrc 12 | .eslintignore 13 | .eslintrc 14 | .flowconfig 15 | .travis.yml 16 | .gitignore 17 | postcss.config.js 18 | .npmignore 19 | yarn.lock 20 | CHANGELOG.md -------------------------------------------------------------------------------- /.nvmrc: -------------------------------------------------------------------------------- 1 | v16 -------------------------------------------------------------------------------- /.storybook/main.js: -------------------------------------------------------------------------------- 1 | /** @type { import('@storybook/react-webpack5').StorybookConfig } */ 2 | const config = { 3 | stories: ["../src/**/*.mdx", "../src/**/*.stories.@(js|jsx|ts|tsx)"], 4 | addons: [ 5 | "@storybook/addon-links", 6 | "@storybook/addon-essentials", 7 | "@storybook/addon-interactions", 8 | ], 9 | framework: { 10 | name: "@storybook/react-webpack5", 11 | options: {}, 12 | }, 13 | docs: { 14 | autodocs: "tag", 15 | }, 16 | }; 17 | export default config; 18 | -------------------------------------------------------------------------------- /.storybook/preview.js: -------------------------------------------------------------------------------- 1 | /** @type { import('@storybook/react').Preview } */ 2 | const preview = { 3 | parameters: { 4 | actions: { argTypesRegex: "^on[A-Z].*" }, 5 | controls: { 6 | matchers: { 7 | color: /(background|color)$/i, 8 | date: /Date$/, 9 | }, 10 | }, 11 | }, 12 | }; 13 | 14 | export default preview; 15 | -------------------------------------------------------------------------------- /.storybook/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | // const autoprefixer = require('autoprefixer'); 3 | // const precss = require('precss'); 4 | // you can use this file to add your custom webpack plugins, loaders and anything you like. 5 | // This is just the basic way to add additional webpack configurations. 6 | // For more information refer the docs: https://storybook.js.org/configurations/custom-webpack-config 7 | 8 | // IMPORTANT 9 | // When you add this file, we won't add the default configurations which is similar 10 | // to "React Create App". This only has babel loader to load JavaScript. 11 | 12 | module.exports = { 13 | module: { 14 | rules: [ 15 | { 16 | test: /\.css$/, 17 | loaders: ['style-loader', 'css-loader'], 18 | include: path.resolve(__dirname, '../'), 19 | }, 20 | { 21 | test: /\.(png|jpg)$/, 22 | loader: 'url-loader?limit=8192', 23 | include: path.resolve(__dirname, '../'), 24 | }, 25 | { 26 | test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, 27 | loader: 'url-loader?limit=10000&mimetype=image/svg+xml', 28 | include: path.resolve(__dirname, '../'), 29 | }, 30 | ], 31 | }, 32 | }; 33 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | os: 3 | - osx 4 | language: node_js 5 | node_js: 6 | - "10" 7 | script: 8 | - npm test 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2016 Jyoti Puri 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: 4 | 5 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. 6 | 7 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 8 | -------------------------------------------------------------------------------- /config/test-compiler.js: -------------------------------------------------------------------------------- 1 | require("@babel/core"); 2 | 3 | function noop() { 4 | return null; 5 | } 6 | require.extensions[".css"] = noop; 7 | require.extensions[".svg"] = noop; 8 | require.extensions[".png"] = noop; 9 | -------------------------------------------------------------------------------- /config/test-setup.js: -------------------------------------------------------------------------------- 1 | require("@babel/register")(); 2 | const { configure } = require("enzyme"); 3 | const Adapter = require("@wojtekmaj/enzyme-adapter-react-17"); 4 | 5 | configure({ adapter: new Adapter() }); 6 | 7 | const jsdom = require("jsdom"); 8 | 9 | const { JSDOM } = jsdom; 10 | 11 | const { document } = new JSDOM({ 12 | url: "http://localhost", 13 | }).window; 14 | global.document = document; 15 | 16 | global.window = document.defaultView; 17 | global.HTMLElement = window.HTMLElement; 18 | global.HTMLAnchorElement = window.HTMLAnchorElement; 19 | 20 | global.navigator = { 21 | userAgent: "node.js", 22 | }; 23 | 24 | configure({ adapter: new Adapter() }); 25 | -------------------------------------------------------------------------------- /config/webpack.config.js: -------------------------------------------------------------------------------- 1 | const path = require("path"); 2 | const webpack = require("webpack"); 3 | const MiniCssExtractPlugin = require("mini-css-extract-plugin"); 4 | const autoprefixer = require("autoprefixer"); 5 | const precss = require("precss"); 6 | const TerserPlugin = require("terser-webpack-plugin"); 7 | 8 | module.exports = { 9 | devtool: "source-map", 10 | entry: ["./src/index"], 11 | output: { 12 | path: path.join(__dirname, "../dist"), 13 | filename: "react-draft-wysiwyg.js", 14 | library: "reactDraftWysiwyg", 15 | libraryTarget: "umd", 16 | }, 17 | externals: { 18 | react: "react", 19 | immutable: "immutable", 20 | "react-dom": "react-dom", 21 | "draft-js": "draft-js", 22 | }, 23 | optimization: { 24 | minimize: true, 25 | minimizer: [new TerserPlugin()], 26 | }, 27 | plugins: [ 28 | new webpack.DefinePlugin({ 29 | "process.env": { 30 | NODE_ENV: JSON.stringify("production"), 31 | }, 32 | }), 33 | new MiniCssExtractPlugin({ 34 | filename: "react-draft-wysiwyg.css", 35 | chunkFilename: "[id].css", 36 | ignoreOrder: false, 37 | }), 38 | new webpack.LoaderOptionsPlugin({ 39 | options: { 40 | postcss: [autoprefixer, precss], 41 | }, 42 | }), 43 | ], 44 | module: { 45 | rules: [ 46 | { 47 | test: /\.js$/, 48 | use: [{ loader: "babel-loader" }], 49 | exclude: /immutable\.js$|draftjs-utils\.js$/, 50 | }, 51 | { 52 | test: /\.css$/, 53 | use: [ 54 | { 55 | loader: MiniCssExtractPlugin.loader, 56 | options: { 57 | publicPath: "../", 58 | hmr: process.env.NODE_ENV === "development", 59 | }, 60 | }, 61 | "css-loader", 62 | ], 63 | }, 64 | { test: /\.(png|jpg)$/, use: [{ loader: "url-loader?limit=8192" }] }, 65 | { 66 | test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, 67 | use: [{ loader: "url-loader?limit=10000&mimetype=image/svg+xml" }], 68 | }, 69 | ], 70 | }, 71 | resolve: { 72 | extensions: [".js", ".json"], 73 | }, 74 | }; 75 | -------------------------------------------------------------------------------- /docs/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "presets": ["@babel/preset-env", "@babel/preset-react"], 3 | "plugins": [ 4 | ["transform-flow-strip-types"], 5 | [ 6 | "@babel/plugin-proposal-class-properties", 7 | { 8 | "loose": true 9 | } 10 | ] 11 | ] 12 | } 13 | -------------------------------------------------------------------------------- /docs/config/server.dev.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const webpack = require('webpack'); 3 | const config = require('./webpack.dev.config'); 4 | const express = require('express'); 5 | 6 | const app = express(); 7 | const compiler = webpack(config); 8 | 9 | app.use(require('webpack-dev-middleware')(compiler, { 10 | noInfo: true, 11 | publicPath: config.output.publicPath, 12 | })); 13 | 14 | app.use(require('webpack-hot-middleware')(compiler)); 15 | 16 | app.get('*', (req, res) => { 17 | res.sendFile(path.join(__dirname, '../index.html')); 18 | }); 19 | 20 | app.listen(3000, 'localhost', (err) => { 21 | if (err) { 22 | console.log(err); 23 | return; 24 | } 25 | console.log('Listening at http://localhost:3000'); 26 | }); 27 | -------------------------------------------------------------------------------- /docs/config/webpack.dev.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const MiniCssExtractPlugin = require('mini-css-extract-plugin'); 3 | const autoprefixer = require('autoprefixer'); 4 | const precss = require('precss'); 5 | const HtmlWebpackPlugin = require('html-webpack-plugin'); 6 | const webpack = require('webpack'); 7 | 8 | module.exports = { 9 | devtool: 'cheap-module-eval-source-map', 10 | entry: ['webpack-hot-middleware/client', './src/index'], 11 | output: { 12 | path: path.join(__dirname, '../static'), 13 | filename: 'bundle.js', 14 | publicPath: '/static/', 15 | }, 16 | module: { 17 | rules: [ 18 | { 19 | test: /\.js$/, 20 | loader: 'babel-loader', 21 | exclude: /react-draft-wysiwyg\.js$|immutable\.js$|draftjs-utils\.js$|draftjs-to-markdown\.js$|draftjs-to-html\.js$|lodash\.js$/, 22 | }, 23 | { 24 | test: /\.css$/, 25 | use: [ 26 | { 27 | loader: MiniCssExtractPlugin.loader, 28 | options: { 29 | publicPath: '../', 30 | hmr: process.env.NODE_ENV === 'development', 31 | }, 32 | }, 33 | 'css-loader', 34 | ], 35 | }, 36 | { 37 | test: /Draft\.css$/, 38 | use: [{ loader: 'style-loader!css-loader' }], 39 | }, 40 | { test: /\.(png|jpg|gif)$/, loader: 'url-loader?limit=8192' }, 41 | { 42 | test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, 43 | use: [{ loader: 'url-loader?limit=10000&mimetype=image/svg+xml' }], 44 | }, 45 | { 46 | test: /\.(eot|ttf|woff|woff2)$/, 47 | use: [{ loader: 'file-loader?name=public/fonts/[name].[ext]' }], 48 | }, 49 | ], 50 | }, 51 | plugins: [ 52 | new MiniCssExtractPlugin({ 53 | filename: '[name].css', 54 | chunkFilename: '[id].css', 55 | ignoreOrder: false, 56 | }), 57 | new HtmlWebpackPlugin({ 58 | template: './template/index.html', 59 | inject: true, 60 | }), 61 | new webpack.HotModuleReplacementPlugin(), 62 | new webpack.NoEmitOnErrorsPlugin(), 63 | new webpack.LoaderOptionsPlugin({ 64 | options: { 65 | postcss: [autoprefixer, precss], 66 | }, 67 | }), 68 | ], 69 | resolve: { 70 | extensions: ['.js', '.json'], 71 | }, 72 | }; 73 | -------------------------------------------------------------------------------- /docs/config/webpack.prod.config.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const webpack = require('webpack'); 3 | const autoprefixer = require('autoprefixer'); 4 | const precss = require('precss'); 5 | const MiniCssExtractPlugin = require('mini-css-extract-plugin'); 6 | const UglifyJsPlugin = require('uglifyjs-webpack-plugin'); 7 | 8 | module.exports = { 9 | devtool: 'source-map', 10 | entry: ['./src/index'], 11 | output: { 12 | path: path.join(__dirname, '../static'), 13 | filename: 'bundle.js', 14 | publicPath: '', 15 | }, 16 | optimization: { 17 | minimizer: [new UglifyJsPlugin()], 18 | }, 19 | plugins: [ 20 | new MiniCssExtractPlugin({ 21 | filename: '[name].css', 22 | chunkFilename: '[id].css', 23 | ignoreOrder: false, 24 | }), 25 | new webpack.DefinePlugin({ 26 | 'process.env': { 27 | NODE_ENV: JSON.stringify('production'), 28 | }, 29 | }), 30 | new webpack.LoaderOptionsPlugin({ 31 | options: { 32 | postcss: [autoprefixer, precss], 33 | }, 34 | }), 35 | ], 36 | module: { 37 | rules: [ 38 | { 39 | test: /\.js$/, 40 | loader: 'babel-loader', 41 | exclude: /react-draft-wysiwyg\.js$|immutable\.js$|draftjs-utils\.js$|draftjs-to-markdown\.js$|draftjs-to-html\.js$|lodash\.js$/, 42 | }, 43 | { 44 | test: /\.css$/, 45 | use: [ 46 | { 47 | loader: MiniCssExtractPlugin.loader, 48 | options: { 49 | publicPath: '../', 50 | hmr: process.env.NODE_ENV === 'development', 51 | }, 52 | }, 53 | 'css-loader', 54 | ], 55 | }, 56 | { 57 | test: /Draft\.css$/, 58 | use: [{ loader: 'style-loader!css-loader' }], 59 | }, 60 | { test: /\.(png|jpg|gif)$/, loader: 'url-loader?limit=8192' }, 61 | { 62 | test: /\.svg(\?v=\d+\.\d+\.\d+)?$/, 63 | use: [{ loader: 'url-loader?limit=10000&mimetype=image/svg+xml' }], 64 | }, 65 | { 66 | test: /\.(eot|ttf|woff|woff2)$/, 67 | use: [{ loader: 'file-loader?name=public/fonts/[name].[ext]' }], 68 | }, 69 | ], 70 | }, 71 | resolve: { 72 | extensions: ['.js', '.json'], 73 | }, 74 | }; 75 | -------------------------------------------------------------------------------- /docs/css/carbon.css: -------------------------------------------------------------------------------- 1 | #carbonads { 2 | display: flex; 3 | float: right; 4 | margin: 0 0 20px 20px; 5 | max-width: 130px; 6 | border-radius: 4px; 7 | background-color: hsl(0, 0%, 98%); 8 | box-shadow: 0 0 1px hsla(0, 0%, 0%, 0.15); 9 | font-size: 11px; 10 | font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, 11 | Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", Helvetica, Arial, 12 | sans-serif; 13 | } 14 | 15 | #carbonads a { 16 | color: #111; 17 | text-decoration: none; 18 | } 19 | 20 | #carbonads a:hover { 21 | color: #111; 22 | } 23 | 24 | .carbon-img { 25 | display: block; 26 | margin-bottom: 8px; 27 | max-width: 130px; 28 | line-height: 1; 29 | } 30 | 31 | .carbon-img img { 32 | display: block; 33 | margin: 0 auto; 34 | max-width: 130px; 35 | width: 130px; 36 | height: auto; 37 | } 38 | 39 | .carbon-text { 40 | display: block; 41 | padding: 0 10px 8px; 42 | text-align: left; 43 | line-height: 1.35; 44 | } 45 | 46 | .carbon-poweredby { 47 | display: block; 48 | padding: 10px; 49 | background: repeating-linear-gradient( 50 | -45deg, 51 | transparent, 52 | transparent 5px, 53 | hsla(0, 0%, 0%, 0.025) 5px, 54 | hsla(0, 0%, 0%, 0.025) 10px 55 | ) 56 | hsla(203, 11%, 95%, 0.4); 57 | text-transform: uppercase; 58 | letter-spacing: 0.5px; 59 | font-weight: 600; 60 | font-size: 8px; 61 | line-height: 0; 62 | } 63 | 64 | @media only screen and (min-width: 320px) and (max-width: 759px) { 65 | #carbonads { 66 | position: relative; 67 | float: none; 68 | margin: 20px 0; 69 | max-width: 330px; 70 | } 71 | 72 | .carbon-wrap { 73 | display: flex; 74 | flex-direction: row; 75 | } 76 | 77 | .carbon-img { 78 | margin: 0; 79 | } 80 | 81 | .carbon-text { 82 | padding: 10px 10px 0 10px; 83 | font-size: 12px; 84 | } 85 | 86 | .carbon-poweredby { 87 | position: absolute; 88 | right: 0; 89 | bottom: 0; 90 | border-radius: 0; 91 | border-top-left-radius: 3px; 92 | text-align: center; 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /docs/images/demo/bold.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/bold.gif -------------------------------------------------------------------------------- /docs/images/demo/center-align.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/center-align.gif -------------------------------------------------------------------------------- /docs/images/demo/erase.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/erase.gif -------------------------------------------------------------------------------- /docs/images/demo/image.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/image.gif -------------------------------------------------------------------------------- /docs/images/demo/indent.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/indent.gif -------------------------------------------------------------------------------- /docs/images/demo/italic.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/italic.gif -------------------------------------------------------------------------------- /docs/images/demo/justify.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/justify.gif -------------------------------------------------------------------------------- /docs/images/demo/left-align.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/left-align.gif -------------------------------------------------------------------------------- /docs/images/demo/link.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/link.gif -------------------------------------------------------------------------------- /docs/images/demo/ordered.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/ordered.gif -------------------------------------------------------------------------------- /docs/images/demo/outdent.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/outdent.gif -------------------------------------------------------------------------------- /docs/images/demo/redo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/redo.gif -------------------------------------------------------------------------------- /docs/images/demo/right-align.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/right-align.gif -------------------------------------------------------------------------------- /docs/images/demo/strikethrough.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/strikethrough.gif -------------------------------------------------------------------------------- /docs/images/demo/subscript.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/subscript.gif -------------------------------------------------------------------------------- /docs/images/demo/superscript.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/superscript.gif -------------------------------------------------------------------------------- /docs/images/demo/underline.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/underline.gif -------------------------------------------------------------------------------- /docs/images/demo/undo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/undo.gif -------------------------------------------------------------------------------- /docs/images/demo/unlink.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/unlink.gif -------------------------------------------------------------------------------- /docs/images/demo/unordered.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/demo/unordered.gif -------------------------------------------------------------------------------- /docs/images/github.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jpuri/react-draft-wysiwyg/4743d7387474d7f88a16e40d3c0e3a9cc9c7a3f9/docs/images/github.png -------------------------------------------------------------------------------- /docs/index.html: -------------------------------------------------------------------------------- 1 | 2 |
3 | 4 | 5 | 12 | 13 |