-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(Add UMD, CJS, and ESM support): Add UMD, CJS, and ESM support
- Loading branch information
Showing
19 changed files
with
514 additions
and
1,589 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,12 @@ | ||
module.exports = { | ||
presets: [ | ||
"@babel/preset-env", | ||
"@babel/preset-react", | ||
["@babel/preset-flow", { "all": true}] | ||
'@babel/preset-env', | ||
'@babel/preset-react', | ||
['@babel/preset-flow', { all: true }], | ||
], | ||
env: { | ||
production: { | ||
plugins: [ | ||
["react-remove-properties", { "properties": ["data-testid" ]}] | ||
] | ||
} | ||
} | ||
plugins: ['babel-plugin-jsx-remove-data-test-id'], | ||
}, | ||
}, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import resolve from 'rollup-plugin-node-resolve'; | ||
import commonjs from 'rollup-plugin-commonjs'; | ||
import babel from 'rollup-plugin-babel'; | ||
import css from 'rollup-plugin-css-only'; | ||
import autoExternal from 'rollup-plugin-auto-external'; | ||
import copy from 'rollup-plugin-copy'; | ||
import pkg from './package.json'; | ||
|
||
const commonPlugins = [ | ||
babel(), | ||
autoExternal(), | ||
resolve(), | ||
css({ output: 'dist/react-draftable.css' }), | ||
copy({ | ||
targets: [ | ||
'src/react-draftable.esm.js.flow', | ||
], | ||
outputFolder: 'dist', | ||
}), | ||
]; | ||
|
||
export default [ | ||
// browser-friendly UMD build | ||
{ | ||
input: 'src/index.js', | ||
output: { | ||
name: 'react-draftable', | ||
file: pkg.browser, | ||
format: 'umd', | ||
}, | ||
plugins: [ | ||
...commonPlugins, | ||
commonjs(), | ||
], | ||
}, | ||
|
||
// CommonJS (for Node) and ES module (for bundlers) build. | ||
{ | ||
input: 'src/index.js', | ||
output: [ | ||
{ file: pkg.main, format: 'cjs' }, | ||
{ file: pkg.module, format: 'es' }, | ||
], | ||
plugins: commonPlugins, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// @flow | ||
import { EditorState } from 'draft-js'; | ||
|
||
export default function changeBlockDepth( | ||
editorState: EditorState, | ||
blockKey: string, | ||
newDepth: number, | ||
): EditorState { | ||
const content = editorState.getCurrentContent(); | ||
const block = content.getBlockForKey(blockKey); | ||
const depth = block.getDepth(); | ||
|
||
if (depth === newDepth) { | ||
return editorState; | ||
} | ||
|
||
const newBlock = block.set('depth', newDepth); | ||
const newContent = content.merge({ | ||
blockMap: content.getBlockMap().set(blockKey, newBlock), | ||
}); | ||
return EditorState.push( | ||
editorState, | ||
newContent, | ||
'adjust-depth', | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
// @flow | ||
import * as Draftable from '../src'; /* eslint-disable-line */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
@import '~draft-js/dist/Draft.css'; | ||
|
||
.public-DraftEditor-content { | ||
font-family: "Helvetica Neue", Helvetica, "Arial Nova", Arial, sans-serif; | ||
font-size: 16px; | ||
line-height: 1.25; | ||
} | ||
|
||
.Toolbar-root { | ||
display: flex; | ||
margin: 14px 0; | ||
} | ||
|
||
.ToolbarGroup-root { | ||
display: flex; | ||
} | ||
|
||
.ToolbarGroup-root:not(:first-of-type):not(:last-of-type) { | ||
margin: 0 14px; | ||
} | ||
|
||
.ToolbarButton-root { | ||
border: none; | ||
background: none; | ||
margin: 0 8px; | ||
padding: 0; | ||
} | ||
|
||
.ToolbarButton-root:first-of-type { | ||
margin-left: 0; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.