{"_id":"draft-js-prism-plugin","_rev":"988937","name":"draft-js-prism-plugin","description":"Add syntax highlighting support to your DraftJS editor","dist-tags":{"alpha":"0.1.0-0","latest":"0.1.3"},"maintainers":[{"name":"mxstbr","email":"npm@mxstbr.com"}],"time":{"modified":"2024-09-06T23:42:10.000Z","created":"2017-09-21T13:41:17.345Z","0.1.3":"2018-03-21T08:44:45.830Z","0.1.2":"2018-03-21T08:29:44.085Z","0.1.1":"2017-09-21T14:00:04.693Z","0.1.0":"2017-09-21T13:55:19.210Z","0.1.0-0":"2017-09-21T13:41:17.345Z"},"users":{},"repository":{"type":"git","url":"git+https://github.com/withspectrum/draft-js-prism-plugin.git"},"versions":{"0.1.3":{"name":"draft-js-prism-plugin","version":"0.1.3","description":"Add syntax highlighting support to your DraftJS editor","repository":{"type":"git","url":"git+https://github.com/withspectrum/draft-js-prism-plugin.git"},"main":"dist/index.js","license":"MIT","scripts":{"precommit":"lint-staged","prebuild":"rimraf dist","build":"babel src --out-dir dist --ignore '*.test.js'","test":"jest src","prettier":"prettier --write --single-quote --trailing-comma es5 'src/**/*.js'","prepublishOnly":"yarn run build","flow":"flow src"},"lint-staged":{"*.js":["prettier --write --single-quote --trailing-comma es5","git add"]},"devDependencies":{"babel-cli":"^6.26.0","babel-plugin-transform-react-jsx":"^6.24.1","babel-preset-env":"^1.6.0","babel-preset-flow":"^6.23.0","flow-bin":"^0.55.0","husky":"^0.14.3","jest":"^21.1.0","lint-staged":"^4.2.1","prettier":"^1.7.0","prismjs":"^1.0.0","rimraf":"^2.6.2"},"dependencies":{"draft-js-prism":"^1.0.6","react":"*"},"peerDependencies":{"prismjs":"^1.0.0"},"gitHead":"b989a43c15a8f0bc7fe4fb8fefe4e419673d8075","bugs":{"url":"https://github.com/withspectrum/draft-js-prism-plugin/issues"},"homepage":"https://github.com/withspectrum/draft-js-prism-plugin#readme","_id":"draft-js-prism-plugin@0.1.3","_npmVersion":"5.6.0","_nodeVersion":"9.8.0","_npmUser":{"name":"mxstbr","email":"npm@mxstbr.com"},"dist":{"integrity":"sha512-w/agtisitO7SCHBBqa5vfkwy7DlhfKMCak6ivE4GpSV97MYLUIuRtafP1ei5tCMwGkJxJDKMv3Bgrd5miG55ZA==","shasum":"b33669bae009749d876986c6b19b0d6936f311fd","tarball":"http://registry-npm.ywwl.com/draft-js-prism-plugin/download/draft-js-prism-plugin-0.1.3.tgz","fileCount":27,"unpackedSize":373630,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCate4YEzSnEq4u6yYJQgvSV1E+CfhbdoHyOTsRVCqwOgIgI1GZJHDoF1/T7mXvvyvcv4tIEqfEW57DHknLwTgm9+8="}],"size":84818,"noattachment":false,"key":"/draft-js-prism-plugin/-/draft-js-prism-plugin-0.1.3.tgz"},"maintainers":[{"name":"mxstbr","email":"npm@mxstbr.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/draft-js-prism-plugin_0.1.3_1521621885624_0.638844728181015"},"_hasShrinkwrap":false,"publish_time":1521621885830,"_cnpm_publish_time":1521621885830},"0.1.2":{"name":"draft-js-prism-plugin","version":"0.1.2","description":"Add syntax highlighting support to your DraftJS editor","repository":{"type":"git","url":"git+https://github.com/withspectrum/draft-js-prism-plugin.git"},"main":"dist/index.js","license":"MIT","scripts":{"precommit":"lint-staged","prebuild":"rimraf dist","build":"babel src --out-dir dist --ignore '*.test.js'","test":"jest src","prettier":"prettier --write --single-quote --trailing-comma es5 'src/**/*.js'","prepublishOnly":"yarn run build","flow":"flow src"},"lint-staged":{"*.js":["prettier --write --single-quote --trailing-comma es5","git add"]},"devDependencies":{"babel-cli":"^6.26.0","babel-plugin-transform-react-jsx":"^6.24.1","babel-preset-env":"^1.6.0","babel-preset-flow":"^6.23.0","flow-bin":"^0.55.0","husky":"^0.14.3","jest":"^21.1.0","lint-staged":"^4.2.1","prettier":"^1.7.0","prismjs":"^1.0.0","rimraf":"^2.6.2"},"dependencies":{"draft-js-prism":"^1.0.4","react":"*"},"peerDependencies":{"prismjs":"^1.0.0"},"gitHead":"547fd8eb6bde445e0d116f2c672a358a7b422328","bugs":{"url":"https://github.com/withspectrum/draft-js-prism-plugin/issues"},"homepage":"https://github.com/withspectrum/draft-js-prism-plugin#readme","_id":"draft-js-prism-plugin@0.1.2","_npmVersion":"5.6.0","_nodeVersion":"9.8.0","_npmUser":{"name":"mxstbr","email":"npm@mxstbr.com"},"dist":{"integrity":"sha512-MFl4LUKN38287gISHe1c6pQyk+z5/1IfY9m2tSx0/CilMXC04FwsEoh0U0sURQxVdR0gdorpTQ7EJTMruQIeZA==","shasum":"0d87bae1c5560b45c939af25e2d98cb708b14608","tarball":"http://registry-npm.ywwl.com/draft-js-prism-plugin/download/draft-js-prism-plugin-0.1.2.tgz","fileCount":27,"unpackedSize":372867,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCTQ3Edf9WzmMjC+xKr9IqWdUWjfJzs2IeRTO/Jlv2z3QIhAMGKiplsHk922j7k5Vj0M7gNsiry3enxRthTYqpqQAv7"}],"size":84417,"noattachment":false,"key":"/draft-js-prism-plugin/-/draft-js-prism-plugin-0.1.2.tgz"},"maintainers":[{"name":"mxstbr","email":"npm@mxstbr.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/draft-js-prism-plugin_0.1.2_1521620984029_0.631220986757248"},"_hasShrinkwrap":false,"publish_time":1521620984085,"_cnpm_publish_time":1521620984085},"0.1.1":{"name":"draft-js-prism-plugin","version":"0.1.1","description":"Add syntax highlighting support to your DraftJS editor","repository":{"type":"git","url":"git+https://github.com/withspectrum/draft-js-prism-plugin.git"},"main":"dist/index.js","license":"MIT","scripts":{"precommit":"lint-staged","prebuild":"rimraf dist","build":"babel src --out-dir dist --ignore '*.test.js'","test":"jest src","prettier":"prettier --write --single-quote --trailing-comma es5 'src/**/*.js'","flow":"flow src"},"lint-staged":{"*.js":["prettier --write --single-quote --trailing-comma es5","git add"]},"devDependencies":{"babel-cli":"^6.26.0","babel-plugin-transform-react-jsx":"^6.24.1","babel-preset-env":"^1.6.0","babel-preset-flow":"^6.23.0","flow-bin":"^0.55.0","husky":"^0.14.3","jest":"^21.1.0","lint-staged":"^4.2.1","prettier":"^1.7.0","rimraf":"^2.6.2"},"dependencies":{"draft-js-prism":"github:ngs/draft-js-prism#6edb31c3805dd1de3fb897cc27fced6bac1bafbb","react":"*"},"peerDependencies":{"prismjs":"^1.0.0"},"gitHead":"ad9a196c678faff5505e3e487979c7ea1c086eb0","bugs":{"url":"https://github.com/withspectrum/draft-js-prism-plugin/issues"},"homepage":"https://github.com/withspectrum/draft-js-prism-plugin#readme","_id":"draft-js-prism-plugin@0.1.1","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"mxstbr","email":"npm@mxstbr.com"},"dist":{"integrity":"sha512-0lvgDB+AGI5M/B0Eh6PLNIJ1PdCEz0EhDG8pZ7rfrnqmtlCVfpXF3Yk7gtTApHL6qQUyxGOQtrerSKTsWTZaIw==","shasum":"c8cdf3841e6e3fdfc766f2131e47a49fb972367e","tarball":"http://registry-npm.ywwl.com/draft-js-prism-plugin/download/draft-js-prism-plugin-0.1.1.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHXnXtZn5TXTACmnUedmS+r8gb5m03MdMoVCh06byKIwAiEA0c5ME9GniPhLD7A5Z9Xi++ZBi88MDt5lgUExu8BBfuc="}],"size":49705,"noattachment":false,"key":"/draft-js-prism-plugin/-/draft-js-prism-plugin-0.1.1.tgz"},"maintainers":[{"name":"mxstbr","email":"npm@mxstbr.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/draft-js-prism-plugin-0.1.1.tgz_1506002403496_0.8132252062205225"},"directories":{},"publish_time":1506002404693,"_cnpm_publish_time":1506002404693},"0.1.0":{"name":"draft-js-prism-plugin","version":"0.1.0","description":"Add syntax highlighting support to your DraftJS editor","repository":{"type":"git","url":"git+https://github.com/withspectrum/draft-js-prism-plugin.git"},"main":"dist/index.js","license":"MIT","scripts":{"precommit":"lint-staged","prebuild":"rimraf dist","build":"babel src --out-dir dist --ignore '*.test.js'","test":"jest src","prettier":"prettier --write --single-quote --trailing-comma es5 'src/**/*.js'","flow":"flow src"},"lint-staged":{"*.js":["prettier --write --single-quote --trailing-comma es5","git add"]},"devDependencies":{"babel-cli":"^6.26.0","babel-plugin-transform-react-jsx":"^6.24.1","babel-preset-env":"^1.6.0","babel-preset-flow":"^6.23.0","flow-bin":"^0.55.0","husky":"^0.14.3","jest":"^21.1.0","lint-staged":"^4.2.1","prettier":"^1.7.0","rimraf":"^2.6.2"},"dependencies":{"draft-js-prism":"github:ngs/draft-js-prism#6edb31c3805dd1de3fb897cc27fced6bac1bafbb","react":"*"},"peerDependencies":{"prismjs":"^1.0.0"},"gitHead":"ea0acba7201d91b5144531e4dda8dfadde4654a4","bugs":{"url":"https://github.com/withspectrum/draft-js-prism-plugin/issues"},"homepage":"https://github.com/withspectrum/draft-js-prism-plugin#readme","_id":"draft-js-prism-plugin@0.1.0","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"mxstbr","email":"npm@mxstbr.com"},"dist":{"integrity":"sha512-lPD0+YR6sShtIyL8WTSFn2WAaOaAh9vT/wyxWx2bKki/nR94wDW0q0aV8rLeBo2lM76UfTejYNxehK9eqolI2w==","shasum":"d54095e79379f92ba4071231160975150af5d6a6","tarball":"http://registry-npm.ywwl.com/draft-js-prism-plugin/download/draft-js-prism-plugin-0.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCDOZqOOkZu3C/kzrrHm9c8F9Rl9VeS8maPyNopBNE73QIgf01QeJKaR5NkZGv36r2LrcXmohOWyCV0eJdIM3Nj3ZQ="}],"size":49700,"noattachment":false,"key":"/draft-js-prism-plugin/-/draft-js-prism-plugin-0.1.0.tgz"},"maintainers":[{"name":"mxstbr","email":"npm@mxstbr.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/draft-js-prism-plugin-0.1.0.tgz_1506002118002_0.6331869540736079"},"directories":{},"publish_time":1506002119210,"_cnpm_publish_time":1506002119210},"0.1.0-0":{"name":"draft-js-prism-plugin","version":"0.1.0-0","description":"Add syntax highlighting support to your DraftJS editor","repository":{"type":"git","url":"git+https://github.com/withspectrum/draft-js-prism-plugin.git"},"main":"dist/index.js","license":"MIT","scripts":{"precommit":"lint-staged","prebuild":"rimraf dist","build":"babel src --out-dir dist --ignore '*.test.js'","test":"jest src","prettier":"prettier --write --single-quote --trailing-comma es5 'src/**/*.js'","flow":"flow src"},"lint-staged":{"*.js":["prettier --write --single-quote --trailing-comma es5","git add"]},"devDependencies":{"babel-cli":"^6.26.0","babel-plugin-transform-react-jsx":"^6.24.1","babel-preset-env":"^1.6.0","babel-preset-flow":"^6.23.0","flow-bin":"^0.55.0","husky":"^0.14.3","jest":"^21.1.0","lint-staged":"^4.2.1","prettier":"^1.7.0","rimraf":"^2.6.2"},"dependencies":{"draft-js-prism":"github:ngs/draft-js-prism#6edb31c3805dd1de3fb897cc27fced6bac1bafbb","react":"*"},"peerDependencies":{"prismjs":"^1.0.0"},"gitHead":"871a7f64b8c73d7d2b22efb8039134109ffaba11","bugs":{"url":"https://github.com/withspectrum/draft-js-prism-plugin/issues"},"homepage":"https://github.com/withspectrum/draft-js-prism-plugin#readme","_id":"draft-js-prism-plugin@0.1.0-0","_npmVersion":"5.3.0","_nodeVersion":"8.4.0","_npmUser":{"name":"mxstbr","email":"npm@mxstbr.com"},"dist":{"integrity":"sha512-cMmrsIMCY0a77SpFqdPeqxrQx+6M7Xnh9b/LdI9m096FIz4b18Ll3YuZUEKaOUWAWCTaC3ANG5TFp6OPf5+Nlw==","shasum":"def8a6d6456578386bba60a3bd42f297f0708edf","tarball":"http://registry-npm.ywwl.com/draft-js-prism-plugin/download/draft-js-prism-plugin-0.1.0-0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDzVQCHx04iBQl0csVAW5RYpKuBLPsj2WSUpPwKyEK5LAiEAr/ezCSyuf4WCw/g3O7A+ZR740xdi/+WbTP9jIt2ljQQ="}],"size":49705,"noattachment":false,"key":"/draft-js-prism-plugin/-/draft-js-prism-plugin-0.1.0-0.tgz"},"maintainers":[{"name":"mxstbr","email":"npm@mxstbr.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/draft-js-prism-plugin-0.1.0-0.tgz_1506001276093_0.2408972349949181"},"directories":{},"publish_time":1506001277345,"_cnpm_publish_time":1506001277345}},"readme":"# `draft-js-prism-plugin`\n\nA DraftJS plugin to add syntax highlighting support to your code blocks. Use in combination with [`draft-js-plugins`](https://github.com/draft-js-plugins/draft-js-plugins).\n\n## Usage\n\nFirst, create the plugin and add it to the `plugins` array of your PluginsEditor:\n\n```JS\nimport Prism from 'prismjs';\nimport createPrismPlugin from 'draft-js-prism-plugin';\n\nclass MyEditor extends React.Component {\n  constructor(props) {\n    super(props);\n\n    const prismPlugin = createPrismPlugin({\n      // It's required to provide your own instance of Prism\n      prism: Prism\n    });\n\n    this.state = {\n      plugins: [prismPlugin]\n    }\n  }\n\n  render() {\n    return (\n      <PluginsEditor\n        plugins={this.state.plugins}\n      />\n    )\n  }\n}\n```\n\nNow add a `language` key to the data of the code block you want to highlight:\n\n```JS\n// TODO: Somehow get a code block and its key, this is up to you\nconst { block, key } = getCurrentBlock();\nif (block.getType() !== \"code-block\") return;\n\n// Replace the code block with a new one with the data.language changed to \"javascript\"\nconst data = block.getData().merge({ language: 'javascript' });\nconst newBlock = block.merge({ data });\nconst newContentState = currentContent.merge({\n  blockMap: blockMap.set(key, newBlock),\n  selectionAfter: currentSelection\n})\n\n// Now that code block will be highlighted as JavaScript!\nthis.setState({\n  editorState: EditorState.push(editorState, newContentState, \"change-block-data\")\n})\n```\n\n## License\n\nThis code uses the [`draft-js-prism` decorator](https://github.com/SamyPesse/draft-js-prism) by [@SamyPesse](https://github.com/SamyPesse) and is based on code extracted from the [`draft-js-markdown-shortcuts-plugin`](https://github.com/ngs/draft-js-markdown-shortcuts-plugin) by [@ngs](https://github.com/ngs).\n\nLicensed under the MIT License, Copyright ©️  2017 Space Program Inc. See [LICENSE.md](LICENSE.md) for more information.\n","_attachments":{},"homepage":"https://github.com/withspectrum/draft-js-prism-plugin#readme","bugs":{"url":"https://github.com/withspectrum/draft-js-prism-plugin/issues"},"license":"MIT"}