├── .gitignore ├── LICENSE.txt ├── README.md ├── demo.jpg ├── lerna.json ├── package.json ├── packages ├── demo │ ├── .babelrc │ ├── .gitignore │ ├── CHANGELOG.md │ ├── LICENSE.txt │ ├── README.md │ ├── package.json │ └── src │ │ ├── App.js │ │ ├── default.md │ │ ├── index.css │ │ ├── index.html │ │ ├── index.js │ │ ├── mdx │ │ └── Grid.js │ │ └── serviceWorker.js └── editor │ ├── .gitignore │ ├── CHANGELOG.md │ ├── LICENSE.txt │ ├── README.md │ ├── package.json │ └── src │ ├── Toolbar.js │ └── index.js └── yarn.lock /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | lerna-debug.log 3 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Benedikt Rötsch 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MDX Live Editor 2 | 3 | > Extensible mdx editor to edit mdx and preview live in your browser. 4 | 5 | * Based on [EasyMDE](https://github.com/Ionaru/easy-markdown-editor) and [MDX Runtime](https://mdxjs.com/advanced/runtime/) 6 | 7 | [![](https://raw.githubusercontent.com/axe312ger/mdx-live-editor/master/demo.jpg)](https://axe312ger.github.io/mdx-live-editor/) 8 | 9 | ## Goals 10 | 11 | * Live preview of MDX 12 | * Flawless editing through good UX 13 | * Guiding the non-technical user 14 | * Standalone lib with embeddability to any web based system 15 | 16 | # Development 17 | 18 | This repository is a [monorepo](https://trunkbaseddevelopment.com/monorepos/) managed using [Lerna](https://lerna.js.org/). This means there are multiple [packages](https://github.com/axe312ger/mdx-live-editor/tree/packages) managed in this codebase, even though we publish them to NPM as separate packages. 19 | 20 | ## Requirements 21 | 22 | * [yarn](https://yarnpkg.com/en/docs/install) 23 | 24 | ## Install dependencies 25 | ``` 26 | lerna bootstrap 27 | ``` 28 | -------------------------------------------------------------------------------- /demo.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/axe312ger/mdx-live-editor/0b92471f701e39e4d0cf3414cb304ac10f37b2c0/demo.jpg -------------------------------------------------------------------------------- /lerna.json: -------------------------------------------------------------------------------- 1 | { 2 | "packages": ["packages/*"], 3 | "version": "independent", 4 | "npmClient": "yarn", 5 | "useWorkspaces": true 6 | } 7 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "mdx-live", 3 | "private": true, 4 | "scripts": { 5 | "build": "lerna run build", 6 | "publish": "lerna version --no-push --conventional-commits && lerna publish from-git" 7 | }, 8 | "devDependencies": { 9 | "lerna": "^3.13.3" 10 | }, 11 | "workspaces": [ 12 | "packages/*" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /packages/demo/.babelrc: -------------------------------------------------------------------------------- 1 | { 2 | "plugins": [ 3 | "@babel/plugin-proposal-class-properties", 4 | [ 5 | "@axe312/babel-plugin-inline-import", 6 | { 7 | "extensions": [".md"] 8 | } 9 | ] 10 | ] 11 | } 12 | -------------------------------------------------------------------------------- /packages/demo/.gitignore: -------------------------------------------------------------------------------- 1 | dist 2 | .cache 3 | 4 | # Created by https://www.gitignore.io/api/node,linux,macos,windows,visualstudiocode 5 | # Edit at https://www.gitignore.io/?templates=node,linux,macos,windows,visualstudiocode 6 | 7 | ### Linux ### 8 | *~ 9 | 10 | # temporary files which can be created if a process still has a handle open of a deleted file 11 | .fuse_hidden* 12 | 13 | # KDE directory preferences 14 | .directory 15 | 16 | # Linux trash folder which might appear on any partition or disk 17 | .Trash-* 18 | 19 | # .nfs files are created when an open file is removed but is still being accessed 20 | .nfs* 21 | 22 | ### macOS ### 23 | # General 24 | .DS_Store 25 | .AppleDouble 26 | .LSOverride 27 | 28 | # Icon must end with two \r 29 | Icon 30 | 31 | # Thumbnails 32 | ._* 33 | 34 | # Files that might appear in the root of a volume 35 | .DocumentRevisions-V100 36 | .fseventsd 37 | .Spotlight-V100 38 | .TemporaryItems 39 | .Trashes 40 | .VolumeIcon.icns 41 | .com.apple.timemachine.donotpresent 42 | 43 | # Directories potentially created on remote AFP share 44 | .AppleDB 45 | .AppleDesktop 46 | Network Trash Folder 47 | Temporary Items 48 | .apdisk 49 | 50 | ### Node ### 51 | # Logs 52 | logs 53 | *.log 54 | npm-debug.log* 55 | yarn-debug.log* 56 | yarn-error.log* 57 | lerna-debug.log* 58 | 59 | # Diagnostic reports (https://nodejs.org/api/report.html) 60 | report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json 61 | 62 | # Runtime data 63 | pids 64 | *.pid 65 | *.seed 66 | *.pid.lock 67 | 68 | # Directory for instrumented libs generated by jscoverage/JSCover 69 | lib-cov 70 | 71 | # Coverage directory used by tools like istanbul 72 | coverage 73 | 74 | # nyc test coverage 75 | .nyc_output 76 | 77 | # Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) 78 | .grunt 79 | 80 | # Bower dependency directory (https://bower.io/) 81 | bower_components 82 | 83 | # node-waf configuration 84 | .lock-wscript 85 | 86 | # Compiled binary addons (https://nodejs.org/api/addons.html) 87 | build/Release 88 | 89 | # Dependency directories 90 | node_modules/ 91 | jspm_packages/ 92 | 93 | # TypeScript v1 declaration files 94 | typings/ 95 | 96 | # Optional npm cache directory 97 | .npm 98 | 99 | # Optional eslint cache 100 | .eslintcache 101 | 102 | # Optional REPL history 103 | .node_repl_history 104 | 105 | # Output of 'npm pack' 106 | *.tgz 107 | 108 | # Yarn Integrity file 109 | .yarn-integrity 110 | 111 | # dotenv environment variables file 112 | .env 113 | .env.test 114 | 115 | # parcel-bundler cache (https://parceljs.org/) 116 | .cache 117 | 118 | # next.js build output 119 | .next 120 | 121 | # nuxt.js build output 122 | .nuxt 123 | 124 | # vuepress build output 125 | .vuepress/dist 126 | 127 | # Serverless directories 128 | .serverless/ 129 | 130 | # FuseBox cache 131 | .fusebox/ 132 | 133 | # DynamoDB Local files 134 | .dynamodb/ 135 | 136 | ### VisualStudioCode ### 137 | .vscode/* 138 | !.vscode/settings.json 139 | !.vscode/tasks.json 140 | !.vscode/launch.json 141 | !.vscode/extensions.json 142 | 143 | ### VisualStudioCode Patch ### 144 | # Ignore all local history of files 145 | .history 146 | 147 | ### Windows ### 148 | # Windows thumbnail cache files 149 | Thumbs.db 150 | ehthumbs.db 151 | ehthumbs_vista.db 152 | 153 | # Dump file 154 | *.stackdump 155 | 156 | # Folder config file 157 | [Dd]esktop.ini 158 | 159 | # Recycle Bin used on file shares 160 | $RECYCLE.BIN/ 161 | 162 | # Windows Installer files 163 | *.cab 164 | *.msi 165 | *.msix 166 | *.msm 167 | *.msp 168 | 169 | # Windows shortcuts 170 | *.lnk 171 | 172 | # End of https://www.gitignore.io/api/node,linux,macos,windows,visualstudiocode 173 | -------------------------------------------------------------------------------- /packages/demo/CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Change Log 2 | 3 | All notable changes to this project will be documented in this file. 4 | See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. 5 | 6 | ## [0.0.9](https://github.com/axe312ger/mdx-live-editor/compare/@mdx-live/demo@0.0.8...@mdx-live/demo@0.0.9) (2019-04-18) 7 | 8 | 9 | ### Bug Fixes 10 | 11 | * **demo:** improve styling while loading ([19ea0db](https://github.com/axe312ger/mdx-live-editor/commit/19ea0db)) 12 | * **grid:** use proper icon ([bab8644](https://github.com/axe312ger/mdx-live-editor/commit/bab8644)) 13 | 14 | 15 | 16 | 17 | 18 | ## [0.0.8](https://github.com/axe312ger/mdx-live-editor/compare/@mdx-live/demo@0.0.7...@mdx-live/demo@0.0.8) (2019-04-18) 19 | 20 | **Note:** Version bump only for package @mdx-live/demo 21 | 22 | 23 | 24 | 25 | 26 | ## [0.0.7](https://github.com/axe312ger/mdx-live-editor/compare/@mdx-live/demo@0.0.6...@mdx-live/demo@0.0.7) (2019-04-18) 27 | 28 | **Note:** Version bump only for package @mdx-live/demo 29 | 30 | 31 | 32 | 33 | 34 | ## [0.0.2](https://github.com/axe312ger/mdx-live-editor/compare/@mdx-live/demo@0.0.2...@mdx-live/demo@0.0.2) (2019-04-18) 35 | -------------------------------------------------------------------------------- /packages/demo/LICENSE.txt: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Benedikt Rötsch 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /packages/demo/README.md: -------------------------------------------------------------------------------- 1 | # MDX Live Editor Preview 2 | 3 | [![](https://raw.githubusercontent.com/axe312ger/mdx-live-editor/master/demo.jpg)](https://axe312ger.github.io/mdx-live-editor/) 4 | 5 | ## Available Scripts 6 | 7 | ### `npm start` 8 | 9 | Run development server with live-reload. 10 | 11 | ### `npm run build` 12 | 13 | Build production ready static version of this demo. 14 | 15 | ### `npm run analyze` 16 | 17 | Analyze bundle size of last production build. 18 | 19 | ### `npm run deploy` 20 | 21 | Deploy demo to GitHub pages. 22 | -------------------------------------------------------------------------------- /packages/demo/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "@mdx-live/demo", 3 | "description": "See here https://axe312ger.github.io/mdx-live-editor/", 4 | "version": "0.0.9", 5 | "private": true, 6 | "homepage": "https://axe312ger.github.io/mdx-live-editor/", 7 | "dependencies": { 8 | "@axe312/easymde": "^2.7.1", 9 | "@mdx-live/editor": "^0.0.5", 10 | "prop-types": "^15.7.2", 11 | "react": "^16.8.6", 12 | "react-dom": "^16.8.6", 13 | "styled-components": "^4.2.0" 14 | }, 15 | "devDependencies": { 16 | "@axe312/babel-plugin-inline-import": "^4.0.0", 17 | "@babel/core": "^7.4.3", 18 | "@babel/plugin-proposal-class-properties": "^7.4.0", 19 | "gh-pages": "^2.0.1", 20 | "source-map-explorer": "^1.8.0" 21 | }, 22 | "scripts": { 23 | "analyze": "source-map-explorer 'dist/*.js'", 24 | "dev": "parcel src/index.html", 25 | "build": "parcel build src/index.html", 26 | "deploy": "npm run build && gh-pages -d build" 27 | }, 28 | "browserslist": [ 29 | ">0.2%", 30 | "not dead", 31 | "not ie <= 11", 32 | "not op_mini all" 33 | ], 34 | "gitHead": "d33cf9119e9ca9493c309cc7f4fbd898e80b1c96" 35 | } 36 | -------------------------------------------------------------------------------- /packages/demo/src/App.js: -------------------------------------------------------------------------------- 1 | import React, { useEffect, useRef, useState } from 'react' 2 | 3 | import mdxLiveEditor from '@mdx-live/editor' 4 | import styled from 'styled-components' 5 | import '@axe312/easymde/dist/easymde.min.css' 6 | 7 | import Grid from './mdx/Grid' 8 | import defaultMarkdownValue from './default.md' 9 | 10 | const Textarea = styled.textarea` 11 | min-width: 100vw; 12 | min-height: 100vh; 13 | ` 14 | 15 | const components = [ 16 | { 17 | tagname: 'Grid', 18 | component: Grid, 19 | title: 'Grid', 20 | description: 'Display content next to each other', 21 | icon: 'grip-horizontal', 22 | demo: ` 23 | 24 | 25 | 26 | ` 27 | } 28 | ] 29 | 30 | const replacements = { 31 | h1: ({ children, ...props }) => ( 32 |

33 | {children} 34 |

35 | ) 36 | } 37 | 38 | export default function App() { 39 | const editorRef = useRef(null) 40 | const [editor, setEditor] = useState(null) 41 | 42 | useEffect(() => { 43 | if (!editor) { 44 | setEditor( 45 | mdxLiveEditor({ 46 | components, 47 | replacements, 48 | easymde: { element: editorRef.current } 49 | }) 50 | ) 51 | } 52 | }) 53 | 54 | return ( 55 |