mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-09-24 16:40:55 -06:00
Compare commits
No commits in common. "master" and "1.0.0" have entirely different histories.
@ -1,17 +0,0 @@
|
||||
# Editor configuration, see https://editorconfig.org
|
||||
root = true
|
||||
|
||||
[*]
|
||||
charset = utf-8
|
||||
end_of_line = lf
|
||||
insert_final_newline = true
|
||||
indent_size = 4
|
||||
indent_style = space
|
||||
trim_trailing_whitespace = true
|
||||
|
||||
[*.yaml]
|
||||
indent_size = 2
|
||||
|
||||
[*.md]
|
||||
max_line_length = off
|
||||
trim_trailing_whitespace = false
|
27
.eslintrc
27
.eslintrc
@ -1,27 +0,0 @@
|
||||
{
|
||||
"root": true,
|
||||
"rules": {
|
||||
"strict": 0,
|
||||
"no-console": 0,
|
||||
"quotes": [
|
||||
"error",
|
||||
"single"
|
||||
],
|
||||
"semi": [
|
||||
"error",
|
||||
"always"
|
||||
],
|
||||
"comma-dangle": [
|
||||
"error",
|
||||
"always-multiline"
|
||||
]
|
||||
},
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 2018
|
||||
},
|
||||
"extends": "eslint:recommended"
|
||||
}
|
13
.github/ISSUE_TEMPLATE.md
vendored
13
.github/ISSUE_TEMPLATE.md
vendored
@ -1,13 +0,0 @@
|
||||
<!-- Please help me process issues faster by providing the following information -->
|
||||
### I'm submitting a...
|
||||
- [x] Bug report
|
||||
- [ ] Feature request
|
||||
|
||||
### Reproduction steps
|
||||
<!-- Bonus points if you set up a [JSFiddle](https://jsfiddle.net/) that replicates the bug and link it in the issue. -->
|
||||
1. ...
|
||||
2. ...
|
||||
|
||||
### Version information
|
||||
Browser type and version:
|
||||
EasyMDE version:
|
32
.github/ISSUE_TEMPLATE/bug_report.md
vendored
32
.github/ISSUE_TEMPLATE/bug_report.md
vendored
@ -1,32 +0,0 @@
|
||||
---
|
||||
name: Bug report
|
||||
about: Create a report to help us improve
|
||||
title: ''
|
||||
labels: Bug
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe the bug**
|
||||
A clear and concise description of what the bug is.
|
||||
|
||||
**To Reproduce**
|
||||
Steps to reproduce the behavior:
|
||||
1. Go to '...'
|
||||
2. Click on '....'
|
||||
3. Scroll down to '....'
|
||||
4. See error
|
||||
|
||||
**Expected behavior**
|
||||
A clear and concise description of what you expected to happen.
|
||||
|
||||
**Screenshots**
|
||||
If applicable, add screenshots to help explain your problem.
|
||||
|
||||
**Version information**
|
||||
- OS: [e.g. Windows, MacOS]
|
||||
- Browser: [e.g. Chrome 72]
|
||||
- EasyMDE version: [e.g. 2.5.1]
|
||||
|
||||
**Additional context**
|
||||
Add any other context about the problem here.
|
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
@ -1,20 +0,0 @@
|
||||
---
|
||||
name: Feature request
|
||||
about: Suggest an idea for this project
|
||||
title: ''
|
||||
labels: Feature
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Is your feature request related to a problem? Please describe.**
|
||||
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||
|
||||
**Describe the solution you'd like**
|
||||
A clear and concise description of what you want to happen.
|
||||
|
||||
**Describe alternatives you've considered**
|
||||
A clear and concise description of any alternative solutions or features you've considered.
|
||||
|
||||
**Additional context**
|
||||
Add any other context or screenshots/mock-ups about the feature request here.
|
11
.github/ISSUE_TEMPLATE/question.md
vendored
11
.github/ISSUE_TEMPLATE/question.md
vendored
@ -1,11 +0,0 @@
|
||||
---
|
||||
name: Question
|
||||
about: Ask a question if anything is unclear
|
||||
title: ''
|
||||
labels: Question
|
||||
assignees: ''
|
||||
|
||||
---
|
||||
|
||||
**Describe your question**
|
||||
Please describe your question in as much detail as possible.
|
95
.github/workflows/cd.yaml
vendored
95
.github/workflows/cd.yaml
vendored
@ -1,95 +0,0 @@
|
||||
name: Test & Deploy
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
tags:
|
||||
- '*'
|
||||
pull_request:
|
||||
branches:
|
||||
- master
|
||||
|
||||
jobs:
|
||||
|
||||
audit:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: current
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- run: npm audit --omit=dev
|
||||
|
||||
test:
|
||||
|
||||
needs: [ audit ]
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
node-version: [ '14', '16', '18' ]
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- run: npm ci
|
||||
|
||||
- name: Test
|
||||
run: npm test
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: failure()
|
||||
with:
|
||||
name: cypress-screenshots-nodejs-${{ matrix.node-version }}
|
||||
path: cypress/screenshots
|
||||
retention-days: 7
|
||||
|
||||
- uses: actions/upload-artifact@v4
|
||||
if: always()
|
||||
with:
|
||||
name: cypress-videos-nodejs-${{ matrix.node-version }}
|
||||
path: cypress/videos
|
||||
retention-days: 7
|
||||
|
||||
deploy:
|
||||
|
||||
needs: [ test ]
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'push'
|
||||
|
||||
steps:
|
||||
- uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: current
|
||||
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- run: npm ci
|
||||
|
||||
- name: Deploy @latest version to npm
|
||||
if: startsWith(github.ref, 'refs/tags/')
|
||||
uses: JS-DevTools/npm-publish@v1
|
||||
with:
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
- name: Update @next version
|
||||
if: startsWith(github.ref, 'refs/heads/')
|
||||
run: npm version prerelease --no-git-tag-version --preid "$GITHUB_RUN_NUMBER"
|
||||
|
||||
- name: Deploy @next version to npm
|
||||
if: startsWith(github.ref, 'refs/heads/')
|
||||
uses: JS-DevTools/npm-publish@v1
|
||||
with:
|
||||
tag: next
|
||||
token: ${{ secrets.NPM_TOKEN }}
|
||||
check-version: false
|
17
.gitignore
vendored
17
.gitignore
vendored
@ -1,17 +0,0 @@
|
||||
# generated files
|
||||
dist/
|
||||
|
||||
# NPM files
|
||||
node_modules/
|
||||
|
||||
# IDE files
|
||||
*.iml
|
||||
*.ipr
|
||||
*.iws
|
||||
.idea/
|
||||
.vscode/
|
||||
dev_test/
|
||||
|
||||
# Test artifacts
|
||||
cypress/screenshots
|
||||
cypress/videos
|
478
CHANGELOG.md
478
CHANGELOG.md
@ -1,478 +0,0 @@
|
||||
# EasyMDE Changelog
|
||||
All notable changes to EasyMDE will be documented in this file.
|
||||
|
||||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
<!-- ## [Unreleased] -->
|
||||
## [2.20.0] - 2025-03-04
|
||||
### Added
|
||||
- Support for `marked` extensions (Thanks to [@codingjoe], [#611], [#514]).
|
||||
|
||||
## [2.19.0] - 2025-02-18
|
||||
### Added
|
||||
- `updateStatusBar` type to typescript definitions (Thanks to [@borodean], [#519]).
|
||||
- `"upload-image"` option to the `ToolbarButton` typescript definitions (Thanks to [@borodean], [#520]).
|
||||
- `imageInputName` option to set a custom "name" attribute for the image input (Thanks to [@robinvandernoord], [#573]).
|
||||
|
||||
### Fixed
|
||||
- Relative image paths using the stylesheet as the source instead of the document (Thanks to [@p1gp1g], [#591]).
|
||||
- Excessive memory usage with the `previewImagesInEditor` option (Thanks to [@p1gp1g], [#592]).
|
||||
- Parentheses in the alt text of images causing the image not to load then using `previewImagesInEditor` (Thanks to [@mayraamaral], [#608]).
|
||||
|
||||
## [2.18.0] - 2022-09-20
|
||||
### Added
|
||||
- `toolbarButtonClassPrefix` option to resolve conflicts with Bootstrap classes ([#493]).
|
||||
|
||||
## [2.17.0] - 2022-08-20
|
||||
### Added
|
||||
- Improved CSRF support for uploading images (Thanks to [@ZsgsDesign], [#394]).
|
||||
- Option to register an image preview handler: `imagesPreviewHandler` (Thanks to [@diego-gw], [#411]).
|
||||
- Support for `.webp` image formats (Thanks to [@sghoweri], [#417]).
|
||||
- `toggleHeading` methods for headings 4, 5 and 6 (Thanks to [@vanillajonathan], [#449] and [#492]).
|
||||
- Support for `.gif`, `.avif` and `.apng` image formats (Thanks to [@vanillajonathan], [#450], [#458] and [#459]).
|
||||
- Keyboard shortcuts for `toggleHeading` methods (Thanks to [@vanillajonathan], [#451]).
|
||||
- `iconClassMap` option to specify icon class names for toolbar buttons (Thanks to [@vanillajonathan], [#454]).
|
||||
- `role="toolbar"` on the toolbar element (Thanks to [@vanillajonathan], [#455]).
|
||||
- Support for text buttons in the toolbar (Thanks to [@vanillajonathan], [#461]).
|
||||
- `aria-label` attribute for toolbar buttons (uses the `title` option) (Thanks to [@vanillajonathan], [#463]).
|
||||
- `role="application"` on the editor container element (Thanks to [@vanillajonathan], [#464]).
|
||||
- Option to not overwrite the preview HTML by returning `null` from `previewRender` (Thanks to [@LevitatingOrange], [#471]).
|
||||
|
||||
### Fixed
|
||||
- Hyperlink doubling (Thanks to [@danielok1993], [#95]).
|
||||
- URLs with certain characters entered through prompts causing invalid markdown (Thanks to [@Zignature], [#393]).
|
||||
- Autofocus option not working properly ([#399]).
|
||||
- Inconsistent border colour (Thanks to [@vanillajonathan], [#466]).
|
||||
- Invalid regex on Safari browsers ([#478])
|
||||
- `hideIcons` option type (Thanks to [@LoyalPotato], [#488]).
|
||||
|
||||
### Changed
|
||||
- Editor now uses responsive font sizes (Thanks to [@vanillajonathan], [#452]).
|
||||
|
||||
### Documentation
|
||||
- Added several improvements to README (Thanks to [@vanillajonathan], [#436], [#438], [#440], [#444]).
|
||||
- Fixed typo in README (Thanks to [@kicksent], [#484]).
|
||||
- Added missing icon for `upload-image` in README (Thanks to [@hlf20010508], [#486]).
|
||||
|
||||
## [2.16.1] - 2022-01-14
|
||||
### Fixed
|
||||
- Incorrect initial line and column count in status bar.
|
||||
- Security issue in `marked` dependency.
|
||||
|
||||
## [2.16.0] - 2022-01-11
|
||||
### Added
|
||||
- `direction` option to enable RTL mode (Thanks to [@souljuse], [#358]).
|
||||
- `attributes` option to add custom attributes to toolbar buttons (Thanks to [@Zignature], [#388]).
|
||||
- `unorderedListStyle` option to change the character used for unordered lists (Thanks to [@Zignature], [#389]).
|
||||
|
||||
### Fixed
|
||||
- Image extension detection when extension is uppercase (Thanks to [@ukjinjang], [#357]).
|
||||
- Submenu actions not working in Chromium Browsers (Thanks to [@Offerel], [@robjean9] and [@kelvinj], [#364]).
|
||||
- Incorrect line and column count in status bar (Thanks to [@Zignature], [#384]).
|
||||
|
||||
## [2.15.0] - 2021-04-22
|
||||
### Added
|
||||
- `imagePathAbsolute` option to return the absolute path when uploading an image (Thanks to [@wwsalmon], [#313]).
|
||||
|
||||
### Fixed
|
||||
- `ToolbarIcon` typings, added `icon` (Thanks to [@ChronosMasterOfAllTime], [#308]).
|
||||
- Image link extension when it was not the last part of the URL (Thanks to [@deerboy], [#311]).
|
||||
- Preview mode did not stay enabled when toggling to fullscreen (Thanks to [@smundro], [#316]).
|
||||
- Required typings not being included in `dependencies` (Thanks to [@marekdedic], [#322]).
|
||||
|
||||
## [2.14.0] - 2021-02-14
|
||||
### Added
|
||||
- The `scrollbarStyle` option to change the style of the scrollbar (Thanks to [@danice], [#250]).
|
||||
|
||||
### Fixed
|
||||
- Issues with images not displaying correctly in the preview screen (Thanks to [@ivictbor], [#253]).
|
||||
- An error when both `sideBySideFullscreen` and `status` were set to `false` (Thanks to [@joahim], [#272]).
|
||||
- Editor trying to display non-image files (Thanks to [@Juupaa], [#277])
|
||||
- Unneeded call to `window.removeEventListener` (Thanks to [@emirotin], [#280])
|
||||
- Spell checker (Thanks to [@Fanvadar], [#284]).
|
||||
- Focus issues with toolbar dropdown menus (Thanks to [@Situphen], [#285]).
|
||||
- Interaction between the `sideBySideFullscreen` and the preview state (Thanks to [@smundro], [#286])
|
||||
- Refactored strange method of padding the toolbar into regular padding (Thanks to [@sn3p], [#293]).
|
||||
- Security issue in `marked` dependency (Thanks to [@dependabot], [#298]).
|
||||
|
||||
## [2.13.0] - 2020-11-11
|
||||
### Added
|
||||
- CodeMirror autorefresh plugin and autoRefresh option (Thanks to [@mbolli], [#249]).
|
||||
- `lineNumbers` option to display line numbers in the editor (Thanks to [@nhymxu], [#267]).
|
||||
|
||||
### Fixed
|
||||
- CSS scoping issues when the editor is used in combination with other CodeMirror instances ([#252]).
|
||||
|
||||
## [2.12.1] - 2020-10-06
|
||||
### Changed
|
||||
- Set `previewImagesInEditor` option to `false` by default ([#251]).
|
||||
|
||||
## [2.12.0] - 2020-09-29
|
||||
### Added
|
||||
- `this` context in imageUploadFunction (Thanks to [@JoshuaLicense], [#225]).
|
||||
- `previewImagesInEditor` option to display images in editor mode (Thanks to [@ivictbor], [#235]).
|
||||
- `overlayMode` options to supply an additional codemirror mode (Thanks to [@czynskee], [#244]).
|
||||
|
||||
### Fixed
|
||||
- Corrected default size units from `b,Kb,Mb` to ` B, KB, MB` ([#239]).
|
||||
- Max height less than min height (Thanks to [@nick-denry], [#222]).
|
||||
- toTextArea issue (Thanks to [@nick-denry], [#223]).
|
||||
- Error when updateStatusBar was called during image upload, but the status bar is disabled (Thanks to [@JoshuaLicense], [#224]).
|
||||
|
||||
## [2.11.0] - 2020-07-16
|
||||
### Added
|
||||
- Support for Node.js 14.
|
||||
- Preview without fullscreen (Thanks to [@nick-denry], [#196]).
|
||||
|
||||
### Fixed
|
||||
- Fix cursor displayed position on activity (Thanks to [@firm1], [#184]).
|
||||
- Checkboxes always have bullets in front of them ([#136]).
|
||||
- Save the text only when modifying the content of the easymde instance (Thanks to [@firm1], [#181]).
|
||||
|
||||
## [2.10.1] - 2020-04-06
|
||||
### Fixed
|
||||
- Typescript error when entering certain strings for toolbar buttons ([#178]).
|
||||
|
||||
## [2.10.0] - 2020-04-02
|
||||
### Added
|
||||
- `inputStyle` and `nativeSpellcheck` options to manage the native language of the browser (Thanks to [@firm1], [#143]).
|
||||
- Group buttons in drop-down lists by adding a sub-option `children` for the items in the toolbar (Thanks to [@firm1], [#141]).
|
||||
- `sanitizerFunction` option to allow custom HTML sanitizing in the markdown preview (Thanks to [@adamb70], [#147]).
|
||||
- Time formatting and custom text options for the autosave message (Thanks to [@dima-bzz], [#170]).
|
||||
|
||||
### Changed
|
||||
- Delay before assuming that submit of the form as failed is `autosave.submit_delay` instead of `autosave.delay` (Thanks to [@Situphen], [#139]).
|
||||
- Add `watch` task for gulp (Thanks to [@A-312], [#150]).
|
||||
|
||||
### Fixed
|
||||
- Issue with Marked when using IE11 and webpack (Thanks to [@felipefdl], [#169]).
|
||||
- Updated codemirror to version 5.52.2 (Thanks to [@A-312], [#173]).
|
||||
- Editor displaying on top of other elements on a webpage (Thanks to [@StefKors], [#175]).
|
||||
|
||||
## [2.9.0] - 2020-01-13
|
||||
### Added
|
||||
- Missing minHeight option in type definition (Thanks to [@t49tran], [#123]).
|
||||
- Other missing type definitions ([#126]).
|
||||
|
||||
### Changed
|
||||
- The editor will remove its saved contents when the editor is emptied, allowing to reload a default value (Thanks to [@Situphen], [#132]).
|
||||
|
||||
## [2.8.0] - 2019-08-20
|
||||
### Added
|
||||
- Upload images functionality (Thanks to [@roipoussiere] and [@JeroenvO], [#71], [#101]).
|
||||
- Allow custom image upload function (Thanks to [@sperezp], [#106]).
|
||||
- More polish to the upload images functionality (Thanks to [@jfly], [#109]).
|
||||
- Improved React compatibility (Thanks to [@richtera], [#97]).
|
||||
|
||||
### Fixed
|
||||
- Missing link in dist file header.
|
||||
|
||||
## [2.7.0] - 2019-07-13
|
||||
### Added
|
||||
- `previewClass` option for overwriting the preview screen class ([#99]).
|
||||
|
||||
### Fixed
|
||||
- Updated dependencies to resolve potential security issue.
|
||||
- Resolved small code style issues shown by new eslint rules.
|
||||
|
||||
## [2.6.1] - 2019-06-17
|
||||
### Fixed
|
||||
- Error when toggling between ordered and unordered lists (Thanks to [@roryok], [#93]).
|
||||
- Keyboard shortcuts for custom actions not working (Thanks to [@ysykzheng], [#75]).
|
||||
|
||||
## [2.6.0] - 2019-04-15
|
||||
### Added
|
||||
- Contributing guide (Thanks to [@roipoussiere], [#54]).
|
||||
- Issue templates.
|
||||
- Standardized changelog file.
|
||||
|
||||
### Changed
|
||||
- Finish rewrite of README (Thanks to [@roipoussiere], [#54]).
|
||||
- Image and link prompt fill with "https://" by default.
|
||||
- Link to markdown guide to <https://www.markdownguide.org/basic-syntax/>.
|
||||
|
||||
### Fixed
|
||||
- Backwards compatibility in the API with SimpleMDE 1.0.0 ([#41]).
|
||||
- Automatic publish of master branch to `@next`
|
||||
|
||||
### Removed
|
||||
- Distribution files from source-control.
|
||||
|
||||
## [2.5.1] - 2019-01-17
|
||||
### Fixed
|
||||
- `role="button"` needed to be `type="button"` ([#45]).
|
||||
|
||||
## [2.5.0] - 2019-01-17
|
||||
### Added
|
||||
- Typescript support (Thanks to [@FranklinWhale], [#44]).
|
||||
- `role="button"` to toolbar buttons ([#38]).
|
||||
|
||||
### Fixed
|
||||
- Eraser icon not working with FontAwesome 5.
|
||||
|
||||
## [2.4.2] - 2018-11-09
|
||||
### Added
|
||||
- Node.js 11 support.
|
||||
|
||||
### Fixed
|
||||
- Header button icons not showing sub-icons with FontAwesome 5.
|
||||
- Inconsistent autosave behaviour when submitting a form (Thanks to [@Furgas] and [@adamb70], [#31]).
|
||||
|
||||
## [2.4.1] - 2018-10-15
|
||||
### Added
|
||||
- `fa-redo` class to redo button for FA5 compatibility (Thanks to [@Summon528], [#27]).
|
||||
|
||||
## [2.4.0] - 2018-10-15
|
||||
### Added
|
||||
- Theming support (Thanks to [@LeviticusMB], [#17]).
|
||||
- onToggleFullscreen event hook (Thanks to [@n-3-0], [#16]).
|
||||
|
||||
### Fixed
|
||||
- Fullscreen not working with `toolbar: false` (Thanks to [@aphitiel], [#19]).
|
||||
|
||||
## [2.2.2] - 2019-07-03
|
||||
### Fixed
|
||||
- Automatic publish only publishing tags.
|
||||
|
||||
## [2.2.1] - 2019-06-29
|
||||
### Changed
|
||||
- Attempt automatic publish `@next` version on npm.
|
||||
- Links in the preview window will open in a new tab by default.
|
||||
|
||||
### Fixed
|
||||
- Multi-text select issue by disabling multi-select in the editor ([#10]).
|
||||
- `main` file in package.json (Thanks to [@sne11ius], [#11]).
|
||||
|
||||
## [2.0.1] - 2018-05-13
|
||||
### Changed
|
||||
- Rewrote part of the documentation for EasyMDE.
|
||||
- Updated gulp to version 4.0.0.
|
||||
|
||||
### Fixed
|
||||
- Icons for `heading-smaller`, `heading-bigger`, `heading-1`, `heading-2` and `heading-3` not showing ([#9]).
|
||||
|
||||
## [2.0.0] - 2018-04-23
|
||||
Project forked from [SimpleMDE](https://github.com/sparksuite/simplemde-markdown-editor)
|
||||
|
||||
### BREAKING CHANGES
|
||||
- Dropped Bower support.
|
||||
- Dropped support for older Node.js versions.
|
||||
|
||||
### Added
|
||||
- FontAwesome 5 support.
|
||||
- Support for newer Node.js versions.
|
||||
|
||||
### Changed
|
||||
- Packages are now version-locked.
|
||||
- Simplified build script.
|
||||
- Markdown guide button is no longer disabled in preview mode.
|
||||
|
||||
### Fixed
|
||||
- Cursor not always showing in "text" mode over the edit field
|
||||
|
||||
<!-- Linked issues -->
|
||||
[#611]: https://github.com/Ionaru/easy-markdown-editor/issues/611
|
||||
[#514]: https://github.com/Ionaru/easy-markdown-editor/issues/514
|
||||
[#493]: https://github.com/Ionaru/easy-markdown-editor/issues/493
|
||||
[#478]: https://github.com/Ionaru/easy-markdown-editor/issues/478
|
||||
[#399]: https://github.com/Ionaru/easy-markdown-editor/issues/399
|
||||
[#252]: https://github.com/Ionaru/easy-markdown-editor/issues/252
|
||||
[#251]: https://github.com/Ionaru/easy-markdown-editor/issues/251
|
||||
[#239]: https://github.com/Ionaru/easy-markdown-editor/issues/239
|
||||
[#178]: https://github.com/Ionaru/easy-markdown-editor/issues/178
|
||||
[#136]: https://github.com/Ionaru/easy-markdown-editor/issues/136
|
||||
[#126]: https://github.com/Ionaru/easy-markdown-editor/issues/126
|
||||
[#99]: https://github.com/Ionaru/easy-markdown-editor/issues/99
|
||||
[#45]: https://github.com/Ionaru/easy-markdown-editor/issues/45
|
||||
[#44]: https://github.com/Ionaru/easy-markdown-editor/issues/44
|
||||
[#41]: https://github.com/Ionaru/easy-markdown-editor/issues/41
|
||||
[#38]: https://github.com/Ionaru/easy-markdown-editor/issues/38
|
||||
[#17]: https://github.com/Ionaru/easy-markdown-editor/issues/17
|
||||
[#16]: https://github.com/Ionaru/easy-markdown-editor/issues/16
|
||||
[#11]: https://github.com/Ionaru/easy-markdown-editor/issues/11
|
||||
[#10]: https://github.com/Ionaru/easy-markdown-editor/issues/10
|
||||
[#9]: https://github.com/Ionaru/easy-markdown-editor/issues/9
|
||||
|
||||
<!-- Linked PRs -->
|
||||
[#608]: https://github.com/Ionaru/easy-markdown-editor/pull/608
|
||||
[#592]: https://github.com/Ionaru/easy-markdown-editor/pull/592
|
||||
[#591]: https://github.com/Ionaru/easy-markdown-editor/pull/591
|
||||
[#573]: https://github.com/Ionaru/easy-markdown-editor/pull/573
|
||||
[#520]: https://github.com/Ionaru/easy-markdown-editor/pull/520
|
||||
[#519]: https://github.com/Ionaru/easy-markdown-editor/pull/519
|
||||
[#492]: https://github.com/Ionaru/easy-markdown-editor/pull/492
|
||||
[#488]: https://github.com/Ionaru/easy-markdown-editor/pull/488
|
||||
[#486]: https://github.com/Ionaru/easy-markdown-editor/pull/486
|
||||
[#484]: https://github.com/Ionaru/easy-markdown-editor/pull/484
|
||||
[#479]: https://github.com/Ionaru/easy-markdown-editor/pull/479
|
||||
[#471]: https://github.com/Ionaru/easy-markdown-editor/pull/471
|
||||
[#467]: https://github.com/Ionaru/easy-markdown-editor/pull/467
|
||||
[#466]: https://github.com/Ionaru/easy-markdown-editor/pull/466
|
||||
[#464]: https://github.com/Ionaru/easy-markdown-editor/pull/464
|
||||
[#463]: https://github.com/Ionaru/easy-markdown-editor/pull/463
|
||||
[#461]: https://github.com/Ionaru/easy-markdown-editor/pull/461
|
||||
[#459]: https://github.com/Ionaru/easy-markdown-editor/pull/459
|
||||
[#458]: https://github.com/Ionaru/easy-markdown-editor/pull/458
|
||||
[#455]: https://github.com/Ionaru/easy-markdown-editor/pull/455
|
||||
[#454]: https://github.com/Ionaru/easy-markdown-editor/pull/454
|
||||
[#452]: https://github.com/Ionaru/easy-markdown-editor/pull/452
|
||||
[#451]: https://github.com/Ionaru/easy-markdown-editor/pull/451
|
||||
[#450]: https://github.com/Ionaru/easy-markdown-editor/pull/450
|
||||
[#449]: https://github.com/Ionaru/easy-markdown-editor/pull/449
|
||||
[#444]: https://github.com/Ionaru/easy-markdown-editor/pull/444
|
||||
[#440]: https://github.com/Ionaru/easy-markdown-editor/pull/440
|
||||
[#438]: https://github.com/Ionaru/easy-markdown-editor/pull/438
|
||||
[#436]: https://github.com/Ionaru/easy-markdown-editor/pull/436
|
||||
[#417]: https://github.com/Ionaru/easy-markdown-editor/pull/417
|
||||
[#411]: https://github.com/Ionaru/easy-markdown-editor/pull/411
|
||||
[#394]: https://github.com/Ionaru/easy-markdown-editor/pull/394
|
||||
[#393]: https://github.com/Ionaru/easy-markdown-editor/pull/393
|
||||
[#389]: https://github.com/Ionaru/easy-markdown-editor/pull/389
|
||||
[#388]: https://github.com/Ionaru/easy-markdown-editor/pull/388
|
||||
[#384]: https://github.com/Ionaru/easy-markdown-editor/pull/384
|
||||
[#364]: https://github.com/Ionaru/easy-markdown-editor/pull/364
|
||||
[#358]: https://github.com/Ionaru/easy-markdown-editor/pull/358
|
||||
[#357]: https://github.com/Ionaru/easy-markdown-editor/pull/357
|
||||
[#322]: https://github.com/Ionaru/easy-markdown-editor/pull/322
|
||||
[#316]: https://github.com/Ionaru/easy-markdown-editor/pull/316
|
||||
[#313]: https://github.com/Ionaru/easy-markdown-editor/pull/313
|
||||
[#311]: https://github.com/Ionaru/easy-markdown-editor/pull/311
|
||||
[#308]: https://github.com/Ionaru/easy-markdown-editor/pull/308
|
||||
[#298]: https://github.com/Ionaru/easy-markdown-editor/pull/298
|
||||
[#293]: https://github.com/Ionaru/easy-markdown-editor/pull/293
|
||||
[#286]: https://github.com/Ionaru/easy-markdown-editor/pull/286
|
||||
[#285]: https://github.com/Ionaru/easy-markdown-editor/pull/285
|
||||
[#284]: https://github.com/Ionaru/easy-markdown-editor/pull/284
|
||||
[#280]: https://github.com/Ionaru/easy-markdown-editor/pull/280
|
||||
[#277]: https://github.com/Ionaru/easy-markdown-editor/pull/277
|
||||
[#272]: https://github.com/Ionaru/easy-markdown-editor/pull/272
|
||||
[#267]: https://github.com/Ionaru/easy-markdown-editor/pull/267
|
||||
[#253]: https://github.com/Ionaru/easy-markdown-editor/pull/253
|
||||
[#250]: https://github.com/Ionaru/easy-markdown-editor/pull/250
|
||||
[#249]: https://github.com/Ionaru/easy-markdown-editor/pull/249
|
||||
[#244]: https://github.com/Ionaru/easy-markdown-editor/pull/244
|
||||
[#235]: https://github.com/Ionaru/easy-markdown-editor/pull/235
|
||||
[#225]: https://github.com/Ionaru/easy-markdown-editor/pull/225
|
||||
[#224]: https://github.com/Ionaru/easy-markdown-editor/pull/224
|
||||
[#223]: https://github.com/Ionaru/easy-markdown-editor/pull/223
|
||||
[#222]: https://github.com/Ionaru/easy-markdown-editor/pull/222
|
||||
[#196]: https://github.com/Ionaru/easy-markdown-editor/pull/196
|
||||
[#184]: https://github.com/Ionaru/easy-markdown-editor/pull/184
|
||||
[#181]: https://github.com/Ionaru/easy-markdown-editor/pull/181
|
||||
[#175]: https://github.com/Ionaru/easy-markdown-editor/pull/175
|
||||
[#173]: https://github.com/Ionaru/easy-markdown-editor/pull/173
|
||||
[#170]: https://github.com/Ionaru/easy-markdown-editor/pull/170
|
||||
[#169]: https://github.com/Ionaru/easy-markdown-editor/pull/169
|
||||
[#150]: https://github.com/Ionaru/easy-markdown-editor/pull/150
|
||||
[#147]: https://github.com/Ionaru/easy-markdown-editor/pull/147
|
||||
[#143]: https://github.com/Ionaru/easy-markdown-editor/pull/143
|
||||
[#141]: https://github.com/Ionaru/easy-markdown-editor/pull/141
|
||||
[#139]: https://github.com/Ionaru/easy-markdown-editor/pull/139
|
||||
[#132]: https://github.com/Ionaru/easy-markdown-editor/pull/132
|
||||
[#123]: https://github.com/Ionaru/easy-markdown-editor/pull/123
|
||||
[#109]: https://github.com/Ionaru/easy-markdown-editor/pull/109
|
||||
[#106]: https://github.com/Ionaru/easy-markdown-editor/pull/106
|
||||
[#101]: https://github.com/Ionaru/easy-markdown-editor/pull/101
|
||||
[#97]: https://github.com/Ionaru/easy-markdown-editor/pull/97
|
||||
[#95]: https://github.com/Ionaru/easy-markdown-editor/pull/95
|
||||
[#93]: https://github.com/Ionaru/easy-markdown-editor/pull/93
|
||||
[#75]: https://github.com/Ionaru/easy-markdown-editor/pull/75
|
||||
[#71]: https://github.com/Ionaru/easy-markdown-editor/pull/71
|
||||
[#54]: https://github.com/Ionaru/easy-markdown-editor/pull/54
|
||||
[#31]: https://github.com/Ionaru/easy-markdown-editor/pull/31
|
||||
[#27]: https://github.com/Ionaru/easy-markdown-editor/pull/27
|
||||
[#19]: https://github.com/Ionaru/easy-markdown-editor/pull/19
|
||||
|
||||
<!-- Linked users -->
|
||||
[@dependabot]: https://github.com/dependabot
|
||||
[@wwsalmon]: https://github.com/wwsalmon
|
||||
[@ChronosMasterOfAllTime]: https://github.com/ChronosMasterOfAllTime
|
||||
[@deerboy]: https://github.com/deerboy
|
||||
[@marekdedic]: https://github.com/marekdedic
|
||||
[@emirotin]: https://github.com/emirotin
|
||||
[@smundro]: https://github.com/smundro
|
||||
[@Juupaa]: https://github.com/Juupaa
|
||||
[@Fanvadar]: https://github.com/Fanvadar
|
||||
[@danice]: https://github.com/danice
|
||||
[@joahim]: https://github.com/joahim
|
||||
[@nhymxu]: https://github.com/nhymxu
|
||||
[@mbolli]: https://github.com/mbolli
|
||||
[@ivictbor]: https://github.com/ivictbor
|
||||
[@JoshuaLicense]: https://github.com/JoshuaLicense
|
||||
[@czynskee]: https://github.com/czynskee
|
||||
[@nick-denry]: https://github.com/nick-denry
|
||||
[@StefKors]: https://github.com/StefKors
|
||||
[@felipefdl]: https://github.com/felipefdl
|
||||
[@A-312]: https://github.com/A-312
|
||||
[@dima-bzz]: https://github.com/dima-bzz
|
||||
[@firm1]: https://github.com/firm1
|
||||
[@Situphen]: https://github.com/Situphen
|
||||
[@t49tran]: https://github.com/t49tran
|
||||
[@richtera]: https://github.com/richtera
|
||||
[@jfly]: https://github.com/jfly
|
||||
[@sperezp]: https://github.com/sperezp
|
||||
[@JeroenvO]: https://github.com/JeroenvO
|
||||
[@sn3p]: https://github.com/sn3p
|
||||
[@roryok]: https://github.com/roryok
|
||||
[@ysykzheng]: https://github.com/ysykzheng
|
||||
[@roipoussiere]: https://github.com/roipoussiere
|
||||
[@FranklinWhale]: https://github.com/FranklinWhale
|
||||
[@Furgas]: https://github.com/Furgas
|
||||
[@adamb70]: https://github.com/adamb70
|
||||
[@Summon528]: https://github.com/Summon528
|
||||
[@LeviticusMB]: https://github.com/LeviticusMB
|
||||
[@n-3-0]: https://github.com/n-3-0
|
||||
[@aphitiel]: https://github.com/aphitiel
|
||||
[@sne11ius]: https://github.com/sne11ius
|
||||
[@souljuse]: https://github.com/souljuse
|
||||
[@ukjinjang]: https://github.com/ukjinjang
|
||||
[@robjean9]: https://github.com/robjean9
|
||||
[@Offerel]: https://github.com/Offerel
|
||||
[@Zignature]: https://github.com/Zignature
|
||||
[@kelvinj]: https://github.com/kelvinj
|
||||
[@diego-gw]: https://github.com/diego-gw
|
||||
[@danielok1993]: https://github.com/danielok1993
|
||||
[@vanillajonathan]: https://github.com/vanillajonathan
|
||||
[@LevitatingOrange]: https://github.com/LevitatingOrange
|
||||
[@LoyalPotato]: https://github.com/LoyalPotato
|
||||
[@kicksent]: https://github.com/kicksent
|
||||
[@hlf20010508]: https://github.com/hlf20010508
|
||||
[@ZsgsDesign]: https://github.com/ZsgsDesign
|
||||
[@sghoweri]: https://github.com/sghoweri
|
||||
[@borodean]: https://github.com/borodean
|
||||
[@robinvandernoord]: https://github.com/robinvandernoord
|
||||
[@p1gp1g]: https://github.com/p1gp1g
|
||||
[@mayraamaral]: https://github.com/mayraamaral
|
||||
[@codingjoe]: https://github.com/codingjoe
|
||||
|
||||
<!-- Linked versions -->
|
||||
[Unreleased]: https://github.com/Ionaru/easy-markdown-editor/compare/2.20.0...HEAD
|
||||
[2.20.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.19.0...2.20.0
|
||||
[2.19.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.18.0...2.19.0
|
||||
[2.18.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.17.0...2.18.0
|
||||
[2.17.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.16.1...2.17.0
|
||||
[2.16.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.16.0...2.16.1
|
||||
[2.16.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.15.0...2.16.0
|
||||
[2.15.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.14.0...2.15.0
|
||||
[2.14.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.13.0...2.14.0
|
||||
[2.13.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.12.1...2.13.0
|
||||
[2.12.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.12.0...2.12.1
|
||||
[2.12.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.11.0...2.12.0
|
||||
[2.11.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.10.1...2.11.0
|
||||
[2.10.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.10.0...2.10.1
|
||||
[2.10.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.9.0...2.10.0
|
||||
[2.9.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.8.0...2.9.0
|
||||
[2.8.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.7.0...2.8.0
|
||||
[2.7.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.6.1...2.7.0
|
||||
[2.6.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.6.0...2.6.1
|
||||
[2.6.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.5.1...2.6.0
|
||||
[2.5.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.5.0...2.5.1
|
||||
[2.5.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.4.2...2.5.0
|
||||
[2.4.2]: https://github.com/Ionaru/easy-markdown-editor/compare/2.4.1...2.4.2
|
||||
[2.4.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.4.0...2.4.1
|
||||
[2.4.0]: https://github.com/Ionaru/easy-markdown-editor/compare/2.2.2...2.4.0
|
||||
[2.2.2]: https://github.com/Ionaru/easy-markdown-editor/compare/2.2.1...2.2.2
|
||||
[2.2.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.0.1...2.2.1
|
||||
[2.0.1]: https://github.com/Ionaru/easy-markdown-editor/compare/2.0.0...2.0.1
|
||||
[2.0.0]: https://github.com/Ionaru/easy-markdown-editor/compare/1.11.2...2.0.0
|
@ -1,44 +0,0 @@
|
||||
# Contributing
|
||||
|
||||
Thank you so much for your interest in contributing to EasyMDE!
|
||||
|
||||
|
||||
## Asking questions, suggesting ideas or reporting bugs
|
||||
|
||||
You can [submit an issue️](https://github.com/Ionaru/easy-markdown-editor/issues) on this GitHub repository.
|
||||
|
||||
|
||||
## Coding
|
||||
|
||||
### 📦 Prerequisites
|
||||
|
||||
To contribute code to this project you'll need an up-to-date LTS or current version of Node.js and npm.
|
||||
|
||||
Please find information about the installation on [the official Node.js website](https://nodejs.org/en/download/).
|
||||
|
||||
|
||||
### ⤴️ Workflow
|
||||
|
||||
Please make sure any code you submit is compliant and compatible with this repository's [license](./LICENSE).
|
||||
|
||||
#### Your first pull request
|
||||
1. [Create a fork of this project](https://github.com/Ionaru/easy-markdown-editor/fork).
|
||||
1. Clone your fork: `git clone https://github.com/YOUR_USERNAME/easy-markdown-editor.git`.
|
||||
1. Add the original repository as remote to keep it up-to-date: `git remote add upstream https://github.com/Ionaru/easy-markdown-editor.git`.
|
||||
1. Fetch the latest changes from upstream: `git fetch upstream`.
|
||||
1. Run `npm ci` to install the required dependencies.
|
||||
1. Create a new branch to work on: `git checkout -b MyNewFeatureName`.
|
||||
1. Write your awesome improvement and commit your work.
|
||||
1. Make sure your changes comply with the established code and tests succeed: `npm run test`.
|
||||
1. Push your changes to GitHub: `git push origin`.
|
||||
1. On GitHub, go to your forked branch, and click **New pull request**.
|
||||
1. Choose the correct branches, add a description and submit your pull request!
|
||||
|
||||
#### Continuing development
|
||||
To create more pull requests, please follow the steps below:
|
||||
1. Go back to the master branch: `git checkout master`.
|
||||
1. Fetch the upstream changes: `git fetch upstream`.
|
||||
1. Update the master branch with upstream changes: `git merge upstream/master`.
|
||||
1. Repeat ["Your first pull request"](#your-first-pull-request) from step 5.
|
||||
|
||||
Thank you! 💜
|
4
LICENSE
4
LICENSE
@ -1,7 +1,6 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015 Sparksuite, Inc.
|
||||
Copyright (c) 2017 Jeroen Akkerman.
|
||||
Copyright (c) 2015 Next Step Webs, Inc.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
@ -20,3 +19,4 @@ 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.
|
||||
|
||||
|
588
README.md
588
README.md
@ -1,571 +1,73 @@
|
||||
# EasyMDE - Markdown Editor
|
||||
# Markdownify - Markdown Editor
|
||||
A drop-in JavaScript textarea replacement for writing beautiful and understandable markdown. The WYSIWYG-esque editor allows you to modify the markdown with toolbar buttons and shortcuts. It has been designed to be easy to use by users who are less technical.
|
||||
|
||||
[](https://www.npmjs.com/package/easymde)
|
||||
[](https://www.npmjs.com/package/easymde/v/next)
|
||||
[](https://www.npmjs.com/package/easymde/v/v3-alpha)
|
||||
[](https://github.com/Ionaru/easy-markdown-editor/actions?query=branch%3Amaster)
|
||||

|
||||
|
||||
> This repository is a fork of
|
||||
[SimpleMDE, made by Sparksuite](https://github.com/sparksuite/simplemde-markdown-editor/).
|
||||
Go to the [dedicated section](#simplemde-fork) for more information.
|
||||
|
||||
A drop-in JavaScript text area replacement for writing beautiful and understandable Markdown.
|
||||
EasyMDE allows users who may be less experienced with Markdown to use familiar toolbar buttons and shortcuts.
|
||||
|
||||
In addition, the syntax is rendered while editing to clearly show the expected result. Headings are larger, emphasized words are italicized, links are underlined, etc.
|
||||
|
||||
EasyMDE also features both built-in auto saving and spell checking.
|
||||
The editor is entirely customizable, from theming to toolbar buttons and javascript hooks.
|
||||
|
||||
[**Try the demo**](https://stackblitz.com/edit/easymde/)
|
||||
|
||||
[](https://stackblitz.com/edit/easymde/)
|
||||
|
||||
|
||||
## Quick access
|
||||
|
||||
- [EasyMDE - Markdown Editor](#easymde---markdown-editor)
|
||||
- [Quick access](#quick-access)
|
||||
- [Install EasyMDE](#install-easymde)
|
||||
- [How to use](#how-to-use)
|
||||
- [Loading the editor](#loading-the-editor)
|
||||
- [Editor functions](#editor-functions)
|
||||
- [Configuration](#configuration)
|
||||
- [Options list](#options-list)
|
||||
- [Options example](#options-example)
|
||||
- [Toolbar icons](#toolbar-icons)
|
||||
- [Toolbar customization](#toolbar-customization)
|
||||
- [Keyboard shortcuts](#keyboard-shortcuts)
|
||||
- [Advanced use](#advanced-use)
|
||||
- [Event handling](#event-handling)
|
||||
- [Removing EasyMDE from text area](#removing-easymde-from-text-area)
|
||||
- [Useful methods](#useful-methods)
|
||||
- [How it works](#how-it-works)
|
||||
- [SimpleMDE fork](#simplemde-fork)
|
||||
- [Hacking EasyMDE](#hacking-easymde)
|
||||
- [Contributing](#contributing)
|
||||
- [License](#license)
|
||||
|
||||
|
||||
## Install EasyMDE
|
||||
|
||||
Via [npm](https://www.npmjs.com/package/easymde):
|
||||
## Quickstart
|
||||
|
||||
```
|
||||
npm install easymde
|
||||
<link rel="stylesheet" href="/PATH/TO/markdownify.min.css">
|
||||
<script src="/PATH/TO/markdownify.min.js"></script>
|
||||
```
|
||||
|
||||
Via the *UNPKG* CDN:
|
||||
And then load Markdownify on the first textarea on a page
|
||||
|
||||
```html
|
||||
<link rel="stylesheet" href="https://unpkg.com/easymde/dist/easymde.min.css">
|
||||
<script src="https://unpkg.com/easymde/dist/easymde.min.js"></script>
|
||||
```
|
||||
var markdownify = new Markdownify();
|
||||
markdownify.render();
|
||||
```
|
||||
|
||||
Or *jsDelivr*:
|
||||
```html
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/easymde/dist/easymde.min.js"></script>
|
||||
#### Use a specific textarea
|
||||
|
||||
Pure JavaScript method
|
||||
|
||||
```
|
||||
var markdownify = new Markdownify(document.getElementById("MyID"));
|
||||
markdownify.render();
|
||||
```
|
||||
|
||||
## How to use
|
||||
jQuery method
|
||||
|
||||
### Loading the editor
|
||||
|
||||
After installing and/or importing the module, you can load EasyMDE onto the first `textarea` element on the web page:
|
||||
|
||||
```html
|
||||
<textarea></textarea>
|
||||
<script>
|
||||
const easyMDE = new EasyMDE();
|
||||
</script>
|
||||
```
|
||||
var markdownify = new Markdownify($("#MyID")[0]);
|
||||
markdownify.render();
|
||||
```
|
||||
|
||||
Alternatively you can select a specific `textarea`, via JavaScript:
|
||||
## Get the content
|
||||
|
||||
```html
|
||||
<textarea id="my-text-area"></textarea>
|
||||
<script>
|
||||
const easyMDE = new EasyMDE({element: document.getElementById('my-text-area')});
|
||||
</script>
|
||||
```
|
||||
|
||||
### Editor functions
|
||||
|
||||
Use `easyMDE.value()` to get the content of the editor:
|
||||
|
||||
```html
|
||||
<script>
|
||||
easyMDE.value();
|
||||
</script>
|
||||
markdownify.codemirror.getValue();
|
||||
```
|
||||
|
||||
Use `easyMDE.value(val)` to set the content of the editor:
|
||||
|
||||
```html
|
||||
<script>
|
||||
easyMDE.value('New input for **EasyMDE**');
|
||||
</script>
|
||||
```
|
||||
|
||||
|
||||
## Configuration
|
||||
|
||||
### Options list
|
||||
- **element**: The DOM element for the textarea to use. Defaults to the first textarea on the page.
|
||||
- **status**: If set false, hide the statusbar. Defaults to true.
|
||||
- **tools**: If set false, hide the toolbar. Defaults to true.
|
||||
|
||||
- **autoDownloadFontAwesome**: If set to `true`, force downloads Font Awesome (used for icons). If set to `false`, prevents downloading. Defaults to `undefined`, which will intelligently check whether Font Awesome has already been included, then download accordingly.
|
||||
- **autofocus**: If set to `true`, focuses the editor automatically. Defaults to `false`.
|
||||
- **autosave**: *Saves the text that's being written and will load it back in the future. It will forget the text when the form it's contained in is submitted.*
|
||||
- **enabled**: If set to `true`, saves the text automatically. Defaults to `false`.
|
||||
- **delay**: Delay between saves, in milliseconds. Defaults to `10000` (10 seconds).
|
||||
- **submit_delay**: Delay before assuming that submit of the form failed and saving the text, in milliseconds. Defaults to `autosave.delay` or `10000` (10 seconds).
|
||||
- **uniqueId**: You must set a unique string identifier so that EasyMDE can autosave. Something that separates this from other instances of EasyMDE elsewhere on your website.
|
||||
- **timeFormat**: Set DateTimeFormat. More information see [DateTimeFormat instances](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/DateTimeFormat). Default `locale: en-US, format: hour:minute`.
|
||||
- **text**: Set text for autosave.
|
||||
- **autoRefresh**: Useful, when initializing the editor in a hidden DOM node. If set to `{ delay: 300 }`, it will check every 300 ms if the editor is visible and if positive, call CodeMirror's [`refresh()`](https://codemirror.net/doc/manual.html#refresh).
|
||||
- **blockStyles**: Customize how certain buttons that style blocks of text behave.
|
||||
- **bold**: Can be set to `**` or `__`. Defaults to `**`.
|
||||
- **code**: Can be set to ```` ``` ```` or `~~~`. Defaults to ```` ``` ````.
|
||||
- **italic**: Can be set to `*` or `_`. Defaults to `*`.
|
||||
- **unorderedListStyle**: can be `*`, `-` or `+`. Defaults to `*`.
|
||||
- **scrollbarStyle**: Chooses a scrollbar implementation. The default is "native", showing native scrollbars. The core library also provides the "null" style, which completely hides the scrollbars. Addons can implement additional scrollbar models.
|
||||
- **element**: The DOM element for the `textarea` element to use. Defaults to the first `textarea` element on the page.
|
||||
- **forceSync**: If set to `true`, force text changes made in EasyMDE to be immediately stored in original text area. Defaults to `false`.
|
||||
- **hideIcons**: An array of icon names to hide. Can be used to hide specific icons shown by default without completely customizing the toolbar.
|
||||
- **indentWithTabs**: If set to `false`, indent using spaces instead of tabs. Defaults to `true`.
|
||||
- **initialValue**: If set, will customize the initial value of the editor.
|
||||
- **previewImagesInEditor**: - EasyMDE will show preview of images, `false` by default, preview for images will appear only for images on separate lines.
|
||||
- **imagesPreviewHandler**: - A custom function for handling the preview of images. Takes the parsed string between the parantheses of the image markdown `` as argument and returns a string that serves as the `src` attribute of the `<img>` tag in the preview. Enables dynamic previewing of images in the frontend without having to upload them to a server, allows copy-pasting of images to the editor with preview.
|
||||
- **insertTexts**: Customize how certain buttons that insert text behave. Takes an array with two elements. The first element will be the text inserted before the cursor or highlight, and the second element will be inserted after. For example, this is the default link value: `["[", "](http://)"]`.
|
||||
- horizontalRule
|
||||
- image
|
||||
- link
|
||||
- table
|
||||
- **lineNumbers**: If set to `true`, enables line numbers in the editor.
|
||||
- **lineWrapping**: If set to `false`, disable line wrapping. Defaults to `true`.
|
||||
- **minHeight**: Sets the minimum height for the composition area, before it starts auto-growing. Should be a string containing a valid CSS value like `"500px"`. Defaults to `"300px"`.
|
||||
- **maxHeight**: Sets fixed height for the composition area. `minHeight` option will be ignored. Should be a string containing a valid CSS value like `"500px"`. Defaults to `undefined`.
|
||||
- **onToggleFullScreen**: A function that gets called when the editor's full screen mode is toggled. The function will be passed a boolean as parameter, `true` when the editor is currently going into full screen mode, or `false`.
|
||||
- **parsingConfig**: Adjust settings for parsing the Markdown during editing (not previewing).
|
||||
- **allowAtxHeaderWithoutSpace**: If set to `true`, will render headers without a space after the `#`. Defaults to `false`.
|
||||
- **strikethrough**: If set to `false`, will not process GFM strikethrough syntax. Defaults to `true`.
|
||||
- **underscoresBreakWords**: If set to `true`, let underscores be a delimiter for separating words. Defaults to `false`.
|
||||
- **overlayMode**: Pass a custom codemirror [overlay mode](https://codemirror.net/doc/manual.html#modeapi) to parse and style the Markdown during editing.
|
||||
- **mode**: A codemirror mode object.
|
||||
- **combine**: If set to `false`, will *replace* CSS classes returned by the default Markdown mode. Otherwise the classes returned by the custom mode will be combined with the classes returned by the default mode. Defaults to `true`.
|
||||
- **placeholder**: If set, displays a custom placeholder message.
|
||||
- **previewClass**: A string or array of strings that will be applied to the preview screen when activated. Defaults to `"editor-preview"`.
|
||||
- **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews.
|
||||
- **promptURLs**: If set to `true`, a JS alert window appears asking for the link or image URL. Defaults to `false`.
|
||||
- **promptTexts**: Customize the text used to prompt for URLs.
|
||||
- **image**: The text to use when prompting for an image's URL. Defaults to `URL of the image:`.
|
||||
- **link**: The text to use when prompting for a link's URL. Defaults to `URL for the link:`.
|
||||
- **iconClassMap**: Used to specify the icon class names for the various toolbar buttons.
|
||||
- **uploadImage**: If set to `true`, enables the image upload functionality, which can be triggered by drag and drop, copy-paste and through the browse-file window (opened when the user click on the *upload-image* icon). Defaults to `false`.
|
||||
- **imageMaxSize**: Maximum image size in bytes, checked before upload (note: never trust client, always check the image size at server-side). Defaults to `1024 * 1024 * 2` (2 MB).
|
||||
- **imageAccept**: A comma-separated list of mime-types used to check image type before upload (note: never trust client, always check file types at server-side). Defaults to `image/png, image/jpeg`.
|
||||
- **imageUploadFunction**: A custom function for handling the image upload. Using this function will render the options `imageMaxSize`, `imageAccept`, `imageUploadEndpoint` and `imageCSRFToken` ineffective.
|
||||
- The function gets a file and `onSuccess` and `onError` callback functions as parameters. `onSuccess(imageUrl: string)` and `onError(errorMessage: string)`
|
||||
- **imageUploadEndpoint**: The endpoint where the images data will be sent, via an asynchronous *POST* request. The server is supposed to save this image, and return a JSON response.
|
||||
- if the request was successfully processed (HTTP 200 OK): `{"data": {"filePath": "<filePath>"}}` where *filePath* is the path of the image (absolute if `imagePathAbsolute` is set to true, relative if otherwise);
|
||||
- otherwise: `{"error": "<errorCode>"}`, where *errorCode* can be `noFileGiven` (HTTP 400 Bad Request), `typeNotAllowed` (HTTP 415 Unsupported Media Type), `fileTooLarge` (HTTP 413 Payload Too Large) or `importError` (see *errorMessages* below). If *errorCode* is not one of the *errorMessages*, it is alerted unchanged to the user. This allows for server-side error messages.
|
||||
No default value.
|
||||
- **imagePathAbsolute**: If set to `true`, will treat `imageUrl` from `imageUploadFunction` and *filePath* returned from `imageUploadEndpoint` as an absolute rather than relative path, i.e. not prepend `window.location.origin` to it.
|
||||
- **imageCSRFToken**: CSRF token to include with AJAX call to upload image. For various instances like Django, Spring and Laravel.
|
||||
- **imageCSRFName**: CSRF token filed name to include with AJAX call to upload image, applied when `imageCSRFToken` has value, defaults to `csrfmiddlewaretoken`.
|
||||
- **imageCSRFHeader**: If set to `true`, passing CSRF token via header. Defaults to `false`, which pass CSRF through request body.
|
||||
- **imageTexts**: Texts displayed to the user (mainly on the status bar) for the import image feature, where `#image_name#`, `#image_size#` and `#image_max_size#` will replaced by their respective values, that can be used for customization or internationalization:
|
||||
- **sbInit**: Status message displayed initially if `uploadImage` is set to `true`. Defaults to `Attach files by drag and dropping or pasting from clipboard.`.
|
||||
- **sbOnDragEnter**: Status message displayed when the user drags a file to the text area. Defaults to `Drop image to upload it.`.
|
||||
- **sbOnDrop**: Status message displayed when the user drops a file in the text area. Defaults to `Uploading images #images_names#`.
|
||||
- **sbProgress**: Status message displayed to show uploading progress. Defaults to `Uploading #file_name#: #progress#%`.
|
||||
- **sbOnUploaded**: Status message displayed when the image has been uploaded. Defaults to `Uploaded #image_name#`.
|
||||
- **sizeUnits**: A comma-separated list of units used to display messages with human-readable file sizes. Defaults to ` B, KB, MB` (example: `218 KB`). You can use `B,KB,MB` instead if you prefer without whitespaces (`218KB`).
|
||||
- **errorMessages**: Errors displayed to the user, using the `errorCallback` option, where `#image_name#`, `#image_size#` and `#image_max_size#` will replaced by their respective values, that can be used for customization or internationalization:
|
||||
- **noFileGiven**: The server did not receive any file from the user. Defaults to `You must select a file.`.
|
||||
- **typeNotAllowed**: The user send a file type which doesn't match the `imageAccept` list, or the server returned this error code. Defaults to `This image type is not allowed.`.
|
||||
- **fileTooLarge**: The size of the image being imported is bigger than the `imageMaxSize`, or if the server returned this error code. Defaults to `Image #image_name# is too big (#image_size#).\nMaximum file size is #image_max_size#.`.
|
||||
- **importError**: An unexpected error occurred when uploading the image. Defaults to `Something went wrong when uploading the image #image_name#.`.
|
||||
- **errorCallback**: A callback function used to define how to display an error message. Defaults to `(errorMessage) => alert(errorMessage)`.
|
||||
- **renderingConfig**: Adjust settings for parsing the Markdown during previewing (not editing).
|
||||
- **codeSyntaxHighlighting**: If set to `true`, will highlight using [highlight.js](https://github.com/isagalaev/highlight.js). Defaults to `false`. To use this feature you must include highlight.js on your page or pass in using the `hljs` option. For example, include the script and the CSS files like:<br>`<script src="https://cdn.jsdelivr.net/highlight.js/latest/highlight.min.js"></script>`<br>`<link rel="stylesheet" href="https://cdn.jsdelivr.net/highlight.js/latest/styles/github.min.css">`
|
||||
- **hljs**: An injectible instance of [highlight.js](https://github.com/isagalaev/highlight.js). If you don't want to rely on the global namespace (`window.hljs`), you can provide an instance here. Defaults to `undefined`.
|
||||
- **markedOptions**: Set the internal Markdown renderer's [options](https://marked.js.org/#/USING_ADVANCED.md#options). Other `renderingConfig` options will take precedence.
|
||||
- **singleLineBreaks**: If set to `false`, disable parsing [GitHub Flavored Markdown](https://github.github.com/gfm/) (GFM) single line breaks. Defaults to `true`.
|
||||
- **sanitizerFunction**: Custom function for sanitizing the HTML output of Markdown renderer.
|
||||
- **shortcuts**: Keyboard shortcuts associated with this instance. Defaults to the [array of shortcuts](#keyboard-shortcuts).
|
||||
- **showIcons**: An array of icon names to show. Can be used to show specific icons hidden by default without completely customizing the toolbar.
|
||||
- **spellChecker**: If set to `false`, disable the spell checker. Defaults to `true`. Optionally pass a CodeMirrorSpellChecker-compliant function.
|
||||
- **inputStyle**: `textarea` or `contenteditable`. Defaults to `textarea` for desktop and `contenteditable` for mobile. `contenteditable` option is necessary to enable nativeSpellcheck.
|
||||
- **nativeSpellcheck**: If set to `false`, disable native spell checker. Defaults to `true`.
|
||||
- **sideBySideFullscreen**: If set to `false`, allows side-by-side editing without going into fullscreen. Defaults to `true`.
|
||||
- **status**: If set to `false`, hide the status bar. Defaults to the array of built-in status bar items.
|
||||
- Optionally, you can set an array of status bar items to include, and in what order. You can even define your own custom status bar items.
|
||||
- **styleSelectedText**: If set to `false`, remove the `CodeMirror-selectedtext` class from selected lines. Defaults to `true`.
|
||||
- **syncSideBySidePreviewScroll**: If set to `false`, disable syncing scroll in side by side mode. Defaults to `true`.
|
||||
- **tabSize**: If set, customize the tab size. Defaults to `2`.
|
||||
- **theme**: Override the theme. Defaults to `easymde`.
|
||||
- **toolbar**: If set to `false`, hide the toolbar. Defaults to the [array of icons](#toolbar-icons).
|
||||
- **toolbarTips**: If set to `false`, disable toolbar button tips. Defaults to `true`.
|
||||
- **toolbarButtonClassPrefix**: Adds a prefix to the toolbar button classes when set. For example, a value of `"mde"` results in `"mde-bold"` for the Bold button.
|
||||
- **direction**: `rtl` or `ltr`. Changes text direction to support right-to-left languages. Defaults to `ltr`.
|
||||
|
||||
|
||||
### Options example
|
||||
|
||||
Most options demonstrate the non-default behavior:
|
||||
|
||||
```js
|
||||
const editor = new EasyMDE({
|
||||
autofocus: true,
|
||||
autosave: {
|
||||
enabled: true,
|
||||
uniqueId: "MyUniqueID",
|
||||
delay: 1000,
|
||||
submit_delay: 5000,
|
||||
timeFormat: {
|
||||
locale: 'en-US',
|
||||
format: {
|
||||
year: 'numeric',
|
||||
month: 'long',
|
||||
day: '2-digit',
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
},
|
||||
},
|
||||
text: "Autosaved: "
|
||||
},
|
||||
blockStyles: {
|
||||
bold: "__",
|
||||
italic: "_",
|
||||
},
|
||||
unorderedListStyle: "-",
|
||||
element: document.getElementById("MyID"),
|
||||
forceSync: true,
|
||||
hideIcons: ["guide", "heading"],
|
||||
indentWithTabs: false,
|
||||
initialValue: "Hello world!",
|
||||
insertTexts: {
|
||||
horizontalRule: ["", "\n\n-----\n\n"],
|
||||
image: [""],
|
||||
link: ["[", "](https://)"],
|
||||
table: ["", "\n\n| Column 1 | Column 2 | Column 3 |\n| -------- | -------- | -------- |\n| Text | Text | Text |\n\n"],
|
||||
},
|
||||
lineWrapping: false,
|
||||
minHeight: "500px",
|
||||
parsingConfig: {
|
||||
allowAtxHeaderWithoutSpace: true,
|
||||
strikethrough: false,
|
||||
underscoresBreakWords: true,
|
||||
},
|
||||
placeholder: "Type here...",
|
||||
|
||||
previewClass: "my-custom-styling",
|
||||
previewClass: ["my-custom-styling", "more-custom-styling"],
|
||||
|
||||
previewRender: (plainText) => customMarkdownParser(plainText), // Returns HTML from a custom parser
|
||||
previewRender: (plainText, preview) => { // Async method
|
||||
setTimeout(() => {
|
||||
preview.innerHTML = customMarkdownParser(plainText);
|
||||
}, 250);
|
||||
|
||||
// If you return null, the innerHTML of the preview will not
|
||||
// be overwritten. Useful if you control the preview node's content via
|
||||
// vdom diffing.
|
||||
// return null;
|
||||
|
||||
return "Loading...";
|
||||
},
|
||||
promptURLs: true,
|
||||
promptTexts: {
|
||||
image: "Custom prompt for URL:",
|
||||
link: "Custom prompt for URL:",
|
||||
},
|
||||
renderingConfig: {
|
||||
singleLineBreaks: false,
|
||||
codeSyntaxHighlighting: true,
|
||||
sanitizerFunction: (renderedHTML) => {
|
||||
// Using DOMPurify and only allowing <b> tags
|
||||
return DOMPurify.sanitize(renderedHTML, {ALLOWED_TAGS: ['b']})
|
||||
},
|
||||
},
|
||||
shortcuts: {
|
||||
drawTable: "Cmd-Alt-T"
|
||||
},
|
||||
showIcons: ["code", "table"],
|
||||
spellChecker: false,
|
||||
status: false,
|
||||
status: ["autosave", "lines", "words", "cursor"], // Optional usage
|
||||
status: ["autosave", "lines", "words", "cursor", {
|
||||
className: "keystrokes",
|
||||
defaultValue: (el) => {
|
||||
el.setAttribute('data-keystrokes', 0);
|
||||
},
|
||||
onUpdate: (el) => {
|
||||
const keystrokes = Number(el.getAttribute('data-keystrokes')) + 1;
|
||||
el.innerHTML = `${keystrokes} Keystrokes`;
|
||||
el.setAttribute('data-keystrokes', keystrokes);
|
||||
},
|
||||
}], // Another optional usage, with a custom status bar item that counts keystrokes
|
||||
styleSelectedText: false,
|
||||
sideBySideFullscreen: false,
|
||||
syncSideBySidePreviewScroll: false,
|
||||
tabSize: 4,
|
||||
toolbar: false,
|
||||
toolbarTips: false,
|
||||
toolbarButtonClassPrefix: "mde",
|
||||
```
|
||||
new Markdownify({
|
||||
element: document.getElementById("MyID"),
|
||||
status: false,
|
||||
tools: false,
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
### Toolbar icons
|
||||
|
||||
Below are the built-in toolbar icons (only some of which are enabled by default), which can be reorganized however you like. "Name" is the name of the icon, referenced in the JavaScript. "Action" is either a function or a URL to open. "Class" is the class given to the icon. "Tooltip" is the small tooltip that appears via the `title=""` attribute. Note that shortcut hints are added automatically and reflect the specified action if it has a key bind assigned to it (i.e. with the value of `action` set to `bold` and that of `tooltip` set to `Bold`, the final text the user will see would be "Bold (Ctrl-B)").
|
||||
|
||||
Additionally, you can add a separator between any icons by adding `"|"` to the toolbar array.
|
||||
|
||||
Name | Action | Tooltip<br>Class
|
||||
:--- | :----- | :--------------
|
||||
bold | toggleBold | Bold<br>fa fa-bold
|
||||
italic | toggleItalic | Italic<br>fa fa-italic
|
||||
strikethrough | toggleStrikethrough | Strikethrough<br>fa fa-strikethrough
|
||||
heading | toggleHeadingSmaller | Heading<br>fa fa-header
|
||||
heading-smaller | toggleHeadingSmaller | Smaller Heading<br>fa fa-header
|
||||
heading-bigger | toggleHeadingBigger | Bigger Heading<br>fa fa-lg fa-header
|
||||
heading-1 | toggleHeading1 | Big Heading<br>fa fa-header header-1
|
||||
heading-2 | toggleHeading2 | Medium Heading<br>fa fa-header header-2
|
||||
heading-3 | toggleHeading3 | Small Heading<br>fa fa-header header-3
|
||||
code | toggleCodeBlock | Code<br>fa fa-code
|
||||
quote | toggleBlockquote | Quote<br>fa fa-quote-left
|
||||
unordered-list | toggleUnorderedList | Generic List<br>fa fa-list-ul
|
||||
ordered-list | toggleOrderedList | Numbered List<br>fa fa-list-ol
|
||||
clean-block | cleanBlock | Clean block<br>fa fa-eraser
|
||||
link | drawLink | Create Link<br>fa fa-link
|
||||
image | drawImage | Insert Image<br>fa fa-picture-o
|
||||
upload-image | drawUploadedImage | Raise browse-file window<br>fa fa-image
|
||||
table | drawTable | Insert Table<br>fa fa-table
|
||||
horizontal-rule | drawHorizontalRule | Insert Horizontal Line<br>fa fa-minus
|
||||
preview | togglePreview | Toggle Preview<br>fa fa-eye no-disable
|
||||
side-by-side | toggleSideBySide | Toggle Side by Side<br>fa fa-columns no-disable no-mobile
|
||||
fullscreen | toggleFullScreen | Toggle Fullscreen<br>fa fa-arrows-alt no-disable no-mobile
|
||||
guide | [This link](https://www.markdownguide.org/basic-syntax/) | Markdown Guide<br>fa fa-question-circle
|
||||
undo | undo | Undo<br>fa fa-undo
|
||||
redo | redo | Redo<br>fa fa-redo
|
||||
|
||||
|
||||
### Toolbar customization
|
||||
|
||||
Customize the toolbar using the `toolbar` option.
|
||||
|
||||
Only the order of existing buttons:
|
||||
|
||||
```js
|
||||
const easyMDE = new EasyMDE({
|
||||
toolbar: ["bold", "italic", "heading", "|", "quote"]
|
||||
});
|
||||
```
|
||||
|
||||
All information and/or add your own icons or text
|
||||
|
||||
```js
|
||||
const easyMDE = new EasyMDE({
|
||||
toolbar: [
|
||||
{
|
||||
name: "bold",
|
||||
action: EasyMDE.toggleBold,
|
||||
className: "fa fa-bold",
|
||||
title: "Bold",
|
||||
},
|
||||
"italic", // shortcut to pre-made button
|
||||
{
|
||||
name: "custom",
|
||||
action: (editor) => {
|
||||
// Add your own code
|
||||
},
|
||||
className: "fa fa-star",
|
||||
text: "Starred",
|
||||
title: "Custom Button",
|
||||
attributes: { // for custom attributes
|
||||
id: "custom-id",
|
||||
"data-value": "custom value" // HTML5 data-* attributes need to be enclosed in quotation marks ("") because of the dash (-) in its name.
|
||||
}
|
||||
},
|
||||
"|" // Separator
|
||||
// [, ...]
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
Put some buttons on dropdown menu
|
||||
|
||||
```js
|
||||
const easyMDE = new EasyMDE({
|
||||
toolbar: [{
|
||||
name: "heading",
|
||||
action: EasyMDE.toggleHeadingSmaller,
|
||||
className: "fa fa-header",
|
||||
title: "Headers",
|
||||
},
|
||||
"|",
|
||||
{
|
||||
name: "others",
|
||||
className: "fa fa-blind",
|
||||
title: "others buttons",
|
||||
children: [
|
||||
{
|
||||
name: "image",
|
||||
action: EasyMDE.drawImage,
|
||||
className: "fa fa-picture-o",
|
||||
title: "Image",
|
||||
},
|
||||
{
|
||||
name: "quote",
|
||||
action: EasyMDE.toggleBlockquote,
|
||||
className: "fa fa-percent",
|
||||
title: "Quote",
|
||||
},
|
||||
{
|
||||
name: "link",
|
||||
action: EasyMDE.drawLink,
|
||||
className: "fa fa-link",
|
||||
title: "Link",
|
||||
}
|
||||
]
|
||||
},
|
||||
// [, ...]
|
||||
]
|
||||
});
|
||||
```
|
||||
|
||||
### Keyboard shortcuts
|
||||
|
||||
EasyMDE comes with an array of predefined keyboard shortcuts, but they can be altered with a configuration option. The list of default ones is as follows:
|
||||
|
||||
Shortcut (Windows / Linux) | Shortcut (macOS) | Action
|
||||
:--- | :--- | :---
|
||||
<kbd>Ctrl</kbd>-<kbd>'</kbd> | <kbd>Cmd</kbd>-<kbd>'</kbd> | "toggleBlockquote"
|
||||
<kbd>Ctrl</kbd>-<kbd>B</kbd> | <kbd>Cmd</kbd>-<kbd>B</kbd> | "toggleBold"
|
||||
<kbd>Ctrl</kbd>-<kbd>E</kbd> | <kbd>Cmd</kbd>-<kbd>E</kbd> | "cleanBlock"
|
||||
<kbd>Ctrl</kbd>-<kbd>H</kbd> | <kbd>Cmd</kbd>-<kbd>H</kbd> | "toggleHeadingSmaller"
|
||||
<kbd>Ctrl</kbd>-<kbd>I</kbd> | <kbd>Cmd</kbd>-<kbd>I</kbd> | "toggleItalic"
|
||||
<kbd>Ctrl</kbd>-<kbd>K</kbd> | <kbd>Cmd</kbd>-<kbd>K</kbd> | "drawLink"
|
||||
<kbd>Ctrl</kbd>-<kbd>L</kbd> | <kbd>Cmd</kbd>-<kbd>L</kbd> | "toggleUnorderedList"
|
||||
<kbd>Ctrl</kbd>-<kbd>P</kbd> | <kbd>Cmd</kbd>-<kbd>P</kbd> | "togglePreview"
|
||||
<kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>C</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>C</kbd> | "toggleCodeBlock"
|
||||
<kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>I</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>I</kbd> | "drawImage"
|
||||
<kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>L</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>L</kbd> | "toggleOrderedList"
|
||||
<kbd>Shift</kbd>-<kbd>Ctrl</kbd>-<kbd>H</kbd> | <kbd>Shift</kbd>-<kbd>Cmd</kbd>-<kbd>H</kbd> | "toggleHeadingBigger"
|
||||
<kbd>F9</kbd> | <kbd>F9</kbd> | "toggleSideBySide"
|
||||
<kbd>F11</kbd> | <kbd>F11</kbd> | "toggleFullScreen"
|
||||
<kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>1</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>1</kbd> | "toggleHeading1"
|
||||
<kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>2</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>2</kbd> | "toggleHeading2"
|
||||
<kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>3</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>3</kbd> | "toggleHeading3"
|
||||
<kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>4</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>4</kbd> | "toggleHeading4"
|
||||
<kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>5</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>5</kbd> | "toggleHeading5"
|
||||
<kbd>Ctrl</kbd>-<kbd>Alt</kbd>-<kbd>6</kbd> | <kbd>Cmd</kbd>-<kbd>Alt</kbd>-<kbd>6</kbd> | "toggleHeading6"
|
||||
|
||||
Here is how you can change a few, while leaving others untouched:
|
||||
|
||||
```js
|
||||
const editor = new EasyMDE({
|
||||
shortcuts: {
|
||||
"toggleOrderedList": "Ctrl-Alt-K", // alter the shortcut for toggleOrderedList
|
||||
"toggleCodeBlock": null, // unbind Ctrl-Alt-C
|
||||
"drawTable": "Cmd-Alt-T", // bind Cmd-Alt-T to drawTable action, which doesn't come with a default shortcut
|
||||
}
|
||||
});
|
||||
```
|
||||
|
||||
Shortcuts are automatically converted between platforms. If you define a shortcut as "Cmd-B", on PC that shortcut will be changed to "Ctrl-B". Conversely, a shortcut defined as "Ctrl-B" will become "Cmd-B" for Mac users.
|
||||
|
||||
The list of actions that can be bound is the same as the list of built-in actions available for [toolbar buttons](#toolbar-icons).
|
||||
|
||||
|
||||
## Advanced use
|
||||
|
||||
### Event handling
|
||||
|
||||
You can catch the following list of events: https://codemirror.net/doc/manual.html#events
|
||||
|
||||
```js
|
||||
const easyMDE = new EasyMDE();
|
||||
easyMDE.codemirror.on("change", () => {
|
||||
console.log(easyMDE.value());
|
||||
});
|
||||
```
|
||||
|
||||
|
||||
### Removing EasyMDE from text area
|
||||
|
||||
You can revert to the initial text area by calling the `toTextArea` method. Note that this clears up the autosave (if enabled) associated with it. The text area will retain any text from the destroyed EasyMDE instance.
|
||||
|
||||
```js
|
||||
const easyMDE = new EasyMDE();
|
||||
// ...
|
||||
easyMDE.toTextArea();
|
||||
easyMDE = null;
|
||||
```
|
||||
|
||||
If you need to remove registered event listeners (when the editor is not needed anymore), call `easyMDE.cleanup()`.
|
||||
|
||||
|
||||
### Useful methods
|
||||
|
||||
The following self-explanatory methods may be of use while developing with EasyMDE.
|
||||
|
||||
```js
|
||||
const easyMDE = new EasyMDE();
|
||||
easyMDE.isPreviewActive(); // returns boolean
|
||||
easyMDE.isSideBySideActive(); // returns boolean
|
||||
easyMDE.isFullscreenActive(); // returns boolean
|
||||
easyMDE.clearAutosavedValue(); // no returned value
|
||||
```
|
||||
|
||||
|
||||
## How it works
|
||||
Markdownify is an improvement of [lepture's Editor project](https://github.com/lepture/editor) and includes a great many number of changes. It is bundled with [CodeMirror](https://github.com/codemirror/codemirror) and [Font Awesome](http://fortawesome.github.io/Font-Awesome/).
|
||||
|
||||
EasyMDE is a continuation of SimpleMDE.
|
||||
CodeMirror is the backbone of the project and parses much of the markdown syntax as it's being written. This allows us to add styles to the markdown that's being written. Additionally, a toolbar and statusbar has been added to the top and bottom, respectively. Previews are rendered by [Marked](https://github.com/chjj/marked).
|
||||
|
||||
SimpleMDE began as an improvement of [lepture's Editor project](https://github.com/lepture/editor), but has now taken on an identity of its own. It is bundled with [CodeMirror](https://github.com/codemirror/codemirror) and depends on [Font Awesome](http://fontawesome.io).
|
||||
## What's changed?
|
||||
As mentioned earlier, Markdownify is an improvement of [lepture's Editor project](https://github.com/lepture/editor). So you might be wondering, what's changed? Quite a bit actually. Here's some notable changes:
|
||||
|
||||
CodeMirror is the backbone of the project and parses much of the Markdown syntax as it's being written. This allows us to add styles to the Markdown that's being written. Additionally, a toolbar and status bar have been added to the top and bottom, respectively. Previews are rendered by [Marked](https://github.com/chjj/marked) using GitHub Flavored Markdown (GFM).
|
||||
|
||||
|
||||
## SimpleMDE fork
|
||||
|
||||
I originally made this fork to implement FontAwesome 5 compatibility into SimpleMDE. When that was done I submitted a [pull request](https://github.com/sparksuite/simplemde-markdown-editor/pull/666), which has not been accepted yet. This, and the project being inactive since May 2017, triggered me to make more changes and try to put new life into the project.
|
||||
|
||||
Changes include:
|
||||
* FontAwesome 5 compatibility
|
||||
* Guide button works when editor is in preview mode
|
||||
* Links are now `https://` by default
|
||||
* Small styling changes
|
||||
* Support for Node 8 and beyond
|
||||
* Lots of refactored code
|
||||
* Links in preview will open in a new tab by default
|
||||
* TypeScript support
|
||||
|
||||
My intention is to continue development on this project, improving it and keeping it alive.
|
||||
|
||||
|
||||
## Hacking EasyMDE
|
||||
|
||||
You may want to edit this library to adapt its behavior to your needs. This can be done in some quick steps:
|
||||
|
||||
1. Follow the [prerequisites](./CONTRIBUTING.md#prerequisites) and [installation](./CONTRIBUTING.md#installation) instructions in the contribution guide;
|
||||
2. Do your changes;
|
||||
3. Run `gulp` command, which will generate files: `dist/easymde.min.css` and `dist/easymde.min.js`;
|
||||
4. Copy-paste those files to your code base, and you are done.
|
||||
|
||||
|
||||
## Contributing
|
||||
|
||||
Want to contribute to EasyMDE? Thank you! We have a [contribution guide](./CONTRIBUTING.md) just for you!
|
||||
|
||||
|
||||
## License
|
||||
|
||||
This project is released under the [MIT License](./LICENSE).
|
||||
|
||||
- Copyright (c) 2015 Sparksuite, Inc.
|
||||
- Copyright (c) 2017 Jeroen Akkerman.
|
||||
- Upgraded from CodeMirror 3 to CodeMirror 5
|
||||
- Many changes to the style, appearance, and userfriendliness
|
||||
- Interface more closely resembles Bootstrap
|
||||
- Now mobile friendly
|
||||
- The text editor now automatically grows as you type more
|
||||
- Fixed a large amount of bugs
|
||||
- Switched to Font Awesome icons
|
||||
- Improved preview rendering in many ways
|
||||
- Improved as-you-type appearance of headers and code blocks
|
||||
- Simplified the toolbar
|
||||
|
@ -1,10 +0,0 @@
|
||||
import { defineConfig } from 'cypress';
|
||||
|
||||
export default defineConfig({
|
||||
e2e: {
|
||||
excludeSpecPattern: [
|
||||
'**/*.html',
|
||||
],
|
||||
video: true,
|
||||
},
|
||||
});
|
@ -1,14 +0,0 @@
|
||||
{
|
||||
"plugins": [
|
||||
"cypress"
|
||||
],
|
||||
"env": {
|
||||
"node": true,
|
||||
"es6": true,
|
||||
"cypress/globals": true
|
||||
},
|
||||
"extends": [
|
||||
"../.eslintrc",
|
||||
"plugin:cypress/recommended"
|
||||
]
|
||||
}
|
@ -1,18 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Default</title>
|
||||
<link rel="stylesheet" href="../../../dist/easymde.min.css">
|
||||
<script src="../../../dist/easymde.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<textarea id="textarea"></textarea>
|
||||
<script>
|
||||
const easyMDE = new EasyMDE();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,31 +0,0 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
describe('Preview', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit(__dirname + '/index.html');
|
||||
});
|
||||
|
||||
it('can show a preview of markdown text', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('not.be.visible');
|
||||
|
||||
// Enter markdown text.
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('# My Big Title');
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('{enter}');
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('This is some **important** text!');
|
||||
|
||||
cy.get('.EasyMDEContainer .CodeMirror-line').should('contain', '# My Big Title');
|
||||
cy.get('.EasyMDEContainer .cm-header.cm-header-1').should('contain', '#');
|
||||
cy.get('.EasyMDEContainer .cm-header.cm-header-1').should('contain', 'My Big Title');
|
||||
|
||||
cy.get('.EasyMDEContainer .CodeMirror-line').should('contain', 'This is some **important** text!');
|
||||
cy.get('.EasyMDEContainer .cm-strong').should('contain', '**');
|
||||
cy.get('.EasyMDEContainer .cm-strong').should('contain', 'important');
|
||||
|
||||
cy.previewOn();
|
||||
|
||||
// Check preview window for rendered markdown.
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<h1 id="my-big-title">My Big Title</h1>');
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p>This is some <strong>important</strong> text!</p>');
|
||||
});
|
||||
});
|
@ -1,56 +0,0 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
describe('Default statusbar', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit(__dirname + '/index.html');
|
||||
});
|
||||
|
||||
it('loads the editor with default statusbar', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('.EasyMDEContainer .editor-statusbar').should('be.visible');
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .autosave').should('be.empty');
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .lines').before('content').should('contain', 'lines: ');
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .lines').should('contain', '1');
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .words').before('content').should('contain', 'words: ');
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .words').should('contain', '0');
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .cursor').should('contain', '1:1');
|
||||
});
|
||||
|
||||
it('updates the statusbar when typing', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('.EasyMDEContainer .editor-statusbar').should('be.visible');
|
||||
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('Hello');
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .autosave').should('be.empty');
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .lines').should('contain', '1');
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .words').should('contain', '1');
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .cursor').should('contain', '1:6');
|
||||
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type(' World');
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .lines').should('contain', '1');
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .words').should('contain', '2');
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .cursor').should('contain', '1:12');
|
||||
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('{enter}');
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .lines').should('contain', '2');
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .words').should('contain', '2');
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .cursor').should('contain', '2:1');
|
||||
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('This is a sample text.{enter}We\'re testing the statusbar.{enter}Did it work?');
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .autosave').should('be.empty');
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .lines').before('content').should('contain', 'lines: ');
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .lines').should('contain', '4');
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .words').before('content').should('contain', 'words: ');
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .words').should('contain', '15');
|
||||
cy.get('.EasyMDEContainer .editor-statusbar .cursor').should('contain', '4:13');
|
||||
});
|
||||
});
|
@ -1,17 +0,0 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
describe('Default editor', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit(__dirname + '/index.html');
|
||||
});
|
||||
|
||||
it('loads the editor with default settings', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('#textarea').should('not.be.visible');
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-toolbar').should('be.visible');
|
||||
cy.get('.EasyMDEContainer .CodeMirror').should('be.visible');
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('not.be.visible');
|
||||
cy.get('.EasyMDEContainer .editor-statusbar').should('be.visible');
|
||||
});
|
||||
});
|
@ -1,20 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Default</title>
|
||||
<link rel="stylesheet" href="../../../dist/easymde.min.css">
|
||||
<script src="../../../dist/easymde.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<textarea id="textarea"></textarea>
|
||||
<script>
|
||||
const easyMDE = new EasyMDE({
|
||||
promptURLs: true,
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,232 +0,0 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
describe('URL prompts', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit(__dirname + '/index.html');
|
||||
});
|
||||
|
||||
it('must show the correct text for a link prompt', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('#textarea').should('not.be.visible');
|
||||
|
||||
cy.window().then(($win) => {
|
||||
const stub = cy.stub($win, 'prompt');
|
||||
cy.get('button.link').click();
|
||||
cy.get('button.link').then(() => {
|
||||
expect(stub).to.be.calledWith('URL for the link:', 'https://');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('must show the correct text for an image prompt', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('#textarea').should('not.be.visible');
|
||||
|
||||
cy.window().then(($win) => {
|
||||
const stub = cy.stub($win, 'prompt');
|
||||
cy.get('button.image').click();
|
||||
cy.get('button.image').then(() => {
|
||||
expect(stub).to.be.calledWith('URL of the image:', 'https://');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('must enter a link correctly through a prompt', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('#textarea').should('not.be.visible');
|
||||
|
||||
cy.window().then(($win) => {
|
||||
cy.stub($win, 'prompt').returns('https://example.com');
|
||||
cy.get('button.link').click();
|
||||
});
|
||||
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com)');
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
|
||||
|
||||
cy.previewOn();
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com" target="_blank">Link to a website!</a></p>');
|
||||
});
|
||||
|
||||
it('can use the prompt multiple times', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('#textarea').should('not.be.visible');
|
||||
|
||||
cy.window().then(($win) => {
|
||||
const stub = cy.stub($win, 'prompt');
|
||||
stub.returns('https://example.com');
|
||||
cy.get('button.link').click();
|
||||
cy.get('button.link').then(() => {
|
||||
expect(stub).to.be.calledWith('URL for the link:', 'https://');
|
||||
stub.restore();
|
||||
});
|
||||
});
|
||||
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com)');
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!{end}{enter}');
|
||||
|
||||
cy.window().then(($win) => {
|
||||
const stub = cy.stub($win, 'prompt');
|
||||
stub.returns('https://example.eu');
|
||||
cy.get('button.link').click();
|
||||
cy.get('button.link').then(() => {
|
||||
expect(stub).to.be.calledWith('URL for the link:', 'https://');
|
||||
stub.restore();
|
||||
});
|
||||
});
|
||||
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.eu)');
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a second website!');
|
||||
|
||||
cy.get('.EasyMDEContainer .CodeMirror').contains('[Link to a website!](https://example.com)');
|
||||
cy.get('.EasyMDEContainer .CodeMirror').contains('[Link to a second website!](https://example.eu)');
|
||||
|
||||
cy.previewOn();
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-preview').should(
|
||||
'contain.html',
|
||||
'<p><a href="https://example.com" target="_blank">Link to a website!</a><br><a href="https://example.eu" target="_blank">Link to a second website!</a></p>',
|
||||
);
|
||||
});
|
||||
|
||||
it('must be able to deal with parameters in links', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('#textarea').should('not.be.visible');
|
||||
|
||||
cy.window().then(($win) => {
|
||||
cy.stub($win, 'prompt').returns('https://example.com?some=param&moo=cow');
|
||||
cy.get('button.link').click();
|
||||
});
|
||||
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=param&moo=cow)');
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
|
||||
|
||||
cy.previewOn();
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=param&moo=cow" target="_blank">Link to a website!</a></p>');
|
||||
});
|
||||
|
||||
it('must be able to deal with brackets in links', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('#textarea').should('not.be.visible');
|
||||
|
||||
cy.window().then(($win) => {
|
||||
cy.stub($win, 'prompt').returns('https://example.com?some=[]param');
|
||||
cy.get('button.link').click();
|
||||
});
|
||||
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=%5B%5Dparam)');
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
|
||||
|
||||
cy.previewOn();
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=%5B%5Dparam" target="_blank">Link to a website!</a></p>');
|
||||
});
|
||||
|
||||
it('must be able to deal with parentheses in links', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('#textarea').should('not.be.visible');
|
||||
|
||||
cy.window().then(($win) => {
|
||||
cy.stub($win, 'prompt').returns('https://example.com?some=(param)');
|
||||
cy.get('button.link').click();
|
||||
});
|
||||
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=\\(param\\))');
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
|
||||
|
||||
cy.previewOn();
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=(param)" target="_blank">Link to a website!</a></p>');
|
||||
});
|
||||
|
||||
it('must be able to deal with parentheses in links (multiple)', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('#textarea').should('not.be.visible');
|
||||
|
||||
cy.window().then(($win) => {
|
||||
cy.stub($win, 'prompt').returns('https://example.com?some=(param1,param2)&more=(param3,param4)&end=true');
|
||||
cy.get('button.link').click();
|
||||
});
|
||||
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=\\(param1,param2\\)&more=\\(param3,param4\\)&end=true)');
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
|
||||
|
||||
cy.previewOn();
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=(param1,param2)&more=(param3,param4)&end=true" target="_blank">Link to a website!</a></p>');
|
||||
});
|
||||
|
||||
it('must be able to deal with unbalanced parentheses in links (opening)', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('#textarea').should('not.be.visible');
|
||||
|
||||
cy.window().then(($win) => {
|
||||
cy.stub($win, 'prompt').returns('https://example.com?some=(param');
|
||||
cy.get('button.link').click();
|
||||
});
|
||||
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=\\(param)');
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
|
||||
|
||||
cy.previewOn();
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=(param" target="_blank">Link to a website!</a></p>');
|
||||
});
|
||||
|
||||
it('must be able to deal with unbalanced parentheses in links (closing)', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('#textarea').should('not.be.visible');
|
||||
|
||||
cy.window().then(($win) => {
|
||||
cy.stub($win, 'prompt').returns('https://example.com?some=)param');
|
||||
cy.get('button.link').click();
|
||||
});
|
||||
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=\\)param)');
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
|
||||
|
||||
cy.previewOn();
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=)param" target="_blank">Link to a website!</a></p>');
|
||||
});
|
||||
|
||||
it('must be able to deal with inequality symbols in links', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('#textarea').should('not.be.visible');
|
||||
|
||||
cy.window().then(($win) => {
|
||||
cy.stub($win, 'prompt').returns('https://example.com?some=<param');
|
||||
cy.get('button.link').click();
|
||||
});
|
||||
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=%3Cparam');
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
|
||||
|
||||
cy.previewOn();
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=%3Cparam" target="_blank">Link to a website!</a></p>');
|
||||
});
|
||||
|
||||
it('must be able to deal with emoji in links', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('#textarea').should('not.be.visible');
|
||||
|
||||
cy.window().then(($win) => {
|
||||
cy.stub($win, 'prompt').returns('https://example.com?some=👷♂️');
|
||||
cy.get('button.link').click();
|
||||
});
|
||||
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=%F0%9F%91%B7%E2%80%8D%E2%99%82%EF%B8%8F');
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a 👌 website!');
|
||||
|
||||
cy.previewOn();
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=%F0%9F%91%B7%E2%80%8D%E2%99%82%EF%B8%8F" target="_blank">Link to a 👌 website!</a></p>');
|
||||
});
|
||||
|
||||
it('must be able to deal with spaces in links', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('#textarea').should('not.be.visible');
|
||||
|
||||
cy.window().then(($win) => {
|
||||
cy.stub($win, 'prompt').returns('https://example.com?some=very special param');
|
||||
cy.get('button.link').click();
|
||||
});
|
||||
cy.get('.EasyMDEContainer .CodeMirror').contains('[](https://example.com?some=very%20special%20param');
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('{home}{rightarrow}Link to a website!');
|
||||
|
||||
cy.previewOn();
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<p><a href="https://example.com?some=very%20special%20param" target="_blank">Link to a website!</a></p>');
|
||||
});
|
||||
});
|
@ -1,17 +0,0 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
describe('Default editor', () => {
|
||||
it('table', () => {
|
||||
cy.visit(__dirname + '/index-no-prefix.html');
|
||||
|
||||
cy.get('button.table').should('be.visible');
|
||||
cy.get('button.table').invoke('outerWidth').should('not.equal', 30);
|
||||
});
|
||||
|
||||
it('loads the editor with default settings', () => {
|
||||
cy.visit(__dirname + '/index.html');
|
||||
|
||||
cy.get('button.mde-table').should('be.visible');
|
||||
cy.get('button.mde-table').invoke('outerWidth').should('equal', 30);
|
||||
});
|
||||
});
|
@ -1,21 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Default</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="../../../dist/easymde.min.css">
|
||||
<script src="../../../dist/easymde.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<textarea id="textarea"></textarea>
|
||||
<script>
|
||||
const easyMDE = new EasyMDE({
|
||||
showIcons: ["table"],
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,22 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Default</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
|
||||
<link rel="stylesheet" href="../../../dist/easymde.min.css">
|
||||
<script src="../../../dist/easymde.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<textarea id="textarea"></textarea>
|
||||
<script>
|
||||
const easyMDE = new EasyMDE({
|
||||
toolbarButtonClassPrefix: 'mde',
|
||||
showIcons: ["table"],
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,43 +0,0 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
describe('Image rendering', () => {
|
||||
|
||||
const imageUrl = 'https://picsum.photos/id/237/150';
|
||||
|
||||
beforeEach(() => {
|
||||
cy.visit(__dirname + '/index.html');
|
||||
cy.intercept('GET', imageUrl).as('image');
|
||||
});
|
||||
|
||||
it('must render an image inside the editor', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('#textarea').should('not.be.visible');
|
||||
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type(imageUrl);
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('{home}');
|
||||
|
||||
cy.wait('@image');
|
||||
|
||||
cy.get(`.EasyMDEContainer [data-img-src="${imageUrl}"]`).should('be.visible');
|
||||
|
||||
cy.previewOn();
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', `<p><img src="${imageUrl}" alt="Dog!"></p>`);
|
||||
});
|
||||
|
||||
it('must be able to handle parentheses inside image alt text', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('#textarea').should('not.be.visible');
|
||||
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type(imageUrl);
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('{home}');
|
||||
|
||||
cy.wait('@image');
|
||||
|
||||
cy.get(`.EasyMDEContainer [data-img-src="${imageUrl}"]`).should('be.visible');
|
||||
|
||||
cy.previewOn();
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', `<p><img src="${imageUrl}" alt="Dog! (He's a good boy!)"></p>`);
|
||||
});
|
||||
});
|
@ -1,20 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Default</title>
|
||||
<link rel="stylesheet" href="../../../dist/easymde.min.css">
|
||||
<script src="../../../dist/easymde.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<textarea id="textarea"></textarea>
|
||||
<script>
|
||||
const easyMDE = new EasyMDE({
|
||||
previewImagesInEditor: true,
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,24 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Default</title>
|
||||
<link rel="stylesheet" href="../../../dist/easymde.min.css">
|
||||
<script src="../../../dist/easymde.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<textarea id="textarea"></textarea>
|
||||
<script>
|
||||
const easyMDE = new EasyMDE({
|
||||
renderingConfig: {
|
||||
markedOptions: {
|
||||
headerPrefix: 'header-prefix-',
|
||||
}
|
||||
}
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,18 +0,0 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
describe('Marked options', () => {
|
||||
beforeEach(() => {
|
||||
cy.visit(__dirname + '/index.html');
|
||||
});
|
||||
|
||||
it('must apply the markedOptions to the markdown parser', () => {
|
||||
cy.get('.EasyMDEContainer').should('be.visible');
|
||||
cy.get('#textarea').should('not.be.visible');
|
||||
|
||||
cy.get('.EasyMDEContainer .CodeMirror').type('# Title{enter}');
|
||||
|
||||
cy.previewOn();
|
||||
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('contain.html', '<h1 id="header-prefix-title">Title</h1>');
|
||||
});
|
||||
});
|
@ -1,10 +0,0 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
/**
|
||||
* @type {Cypress.PluginConfig}
|
||||
*/
|
||||
// eslint-disable-next-line no-unused-vars
|
||||
module.exports = (on, config) => {
|
||||
// `on` is used to hook into various events Cypress emits
|
||||
// `config` is the resolved Cypress config
|
||||
};
|
@ -1,31 +0,0 @@
|
||||
/// <reference types="cypress" />
|
||||
|
||||
const unquote = (str) => str.replace(/(^")|("$)/g, '');
|
||||
|
||||
Cypress.Commands.add(
|
||||
'before',
|
||||
{
|
||||
prevSubject: 'element',
|
||||
},
|
||||
(element, property) => {
|
||||
const win = element[0].ownerDocument.defaultView;
|
||||
const before = win.getComputedStyle(element[0], 'before');
|
||||
return unquote(before.getPropertyValue(property));
|
||||
},
|
||||
);
|
||||
|
||||
Cypress.Commands.add('previewOn' , () => {
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('not.be.visible');
|
||||
cy.get('.EasyMDEContainer .editor-toolbar button.preview').should('not.have.class', 'active');
|
||||
cy.get('.EasyMDEContainer .editor-toolbar button.preview').click();
|
||||
cy.get('.EasyMDEContainer .editor-toolbar button.preview').should('have.class', 'active');
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('be.visible');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('previewOff' , () => {
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('be.visible');
|
||||
cy.get('.EasyMDEContainer .editor-toolbar button.preview').should('have.class', 'active');
|
||||
cy.get('.EasyMDEContainer .editor-toolbar button.preview').click();
|
||||
cy.get('.EasyMDEContainer .editor-toolbar button.preview').should('not.have.class', 'active');
|
||||
cy.get('.EasyMDEContainer .editor-preview').should('not.be.visible');
|
||||
});
|
@ -1 +0,0 @@
|
||||
require('./commands');
|
@ -1,20 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Example / Preview</title>
|
||||
<link rel="stylesheet" href="../dist/easymde.min.css">
|
||||
<script src="../dist/easymde.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<textarea></textarea>
|
||||
<script>
|
||||
const easyMDE = new EasyMDE();
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
@ -1,20 +0,0 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
||||
<title>Example / Preview / sideBySideFullscreen : false</title>
|
||||
<link rel="stylesheet" href="../dist/easymde.min.css">
|
||||
<script src="../dist/easymde.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<textarea></textarea>
|
||||
<script>
|
||||
const easyMDE = new EasyMDE({sideBySideFullscreen: false});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
</html>
|
66
gulpfile.js
66
gulpfile.js
@ -1,66 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
var gulp = require('gulp');
|
||||
var cleanCSS = require('gulp-clean-css');
|
||||
var terser = require('gulp-terser');
|
||||
var concat = require('gulp-concat');
|
||||
var header = require('gulp-header');
|
||||
var buffer = require('vinyl-buffer');
|
||||
var pkg = require('./package.json');
|
||||
var eslint = require('gulp-eslint');
|
||||
var browserify = require('browserify');
|
||||
var source = require('vinyl-source-stream');
|
||||
var rename = require('gulp-rename');
|
||||
|
||||
var banner = ['/**',
|
||||
' * <%= pkg.name %> v<%= pkg.version %>',
|
||||
' * Copyright <%= pkg.author %>',
|
||||
' * @link https://github.com/ionaru/easy-markdown-editor',
|
||||
' * @license <%= pkg.license %>',
|
||||
' */',
|
||||
''].join('\n');
|
||||
|
||||
|
||||
var css_files = [
|
||||
'./node_modules/codemirror/lib/codemirror.css',
|
||||
'./src/css/*.css',
|
||||
'./node_modules/codemirror-spell-checker/src/css/spell-checker.css',
|
||||
];
|
||||
|
||||
function lint() {
|
||||
return gulp.src('./src/js/**/*.js')
|
||||
.pipe(eslint())
|
||||
.pipe(eslint.format())
|
||||
.pipe(eslint.failAfterError());
|
||||
}
|
||||
|
||||
function scripts() {
|
||||
return browserify({entries: './src/js/easymde.js', standalone: 'EasyMDE'}).bundle()
|
||||
.pipe(source('easymde.min.js'))
|
||||
.pipe(buffer())
|
||||
.pipe(terser())
|
||||
.pipe(header(banner, {pkg: pkg}))
|
||||
.pipe(gulp.dest('./dist/'));
|
||||
}
|
||||
|
||||
function styles() {
|
||||
return gulp.src(css_files)
|
||||
.pipe(concat('easymde.css'))
|
||||
.pipe(cleanCSS())
|
||||
.pipe(rename('easymde.min.css'))
|
||||
.pipe(buffer())
|
||||
.pipe(header(banner, {pkg: pkg}))
|
||||
.pipe(gulp.dest('./dist/'));
|
||||
}
|
||||
|
||||
// Watch for file changes
|
||||
function watch() {
|
||||
gulp.watch('./src/js/**/*.js', scripts);
|
||||
gulp.watch(css_files, styles);
|
||||
}
|
||||
|
||||
var build = gulp.parallel(gulp.series(lint, scripts), styles);
|
||||
|
||||
gulp.task('default', build);
|
||||
gulp.task('watch', gulp.series(build, watch));
|
||||
gulp.task('lint', lint);
|
4
markdownify.min.css
vendored
Normal file
4
markdownify.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
6
markdownify.min.js
vendored
Normal file
6
markdownify.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
17894
package-lock.json
generated
17894
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
55
package.json
55
package.json
@ -1,55 +0,0 @@
|
||||
{
|
||||
"name": "easymde",
|
||||
"version": "2.20.0",
|
||||
"description": "A simple, beautiful, and embeddable JavaScript Markdown editor that easy to use. Features include autosaving and spell checking.",
|
||||
"files": [
|
||||
"dist/**/*",
|
||||
"src/**/*",
|
||||
"types/easymde.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"embeddable",
|
||||
"markdown",
|
||||
"editor",
|
||||
"javascript",
|
||||
"fontawesome"
|
||||
],
|
||||
"main": "src/js/easymde.js",
|
||||
"types": "types/easymde.d.ts",
|
||||
"license": "MIT",
|
||||
"author": "Jeroen Akkerman",
|
||||
"dependencies": {
|
||||
"@types/codemirror": "^5.60.10",
|
||||
"@types/marked": "^4.0.7",
|
||||
"codemirror": "^5.65.15",
|
||||
"codemirror-spell-checker": "1.1.2",
|
||||
"marked": "^4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "^17.0.0",
|
||||
"cypress": "^13.2.0",
|
||||
"eslint": "^8.50.0",
|
||||
"eslint-plugin-cypress": "^2.15.1",
|
||||
"gulp": "^4.0.2",
|
||||
"gulp-clean-css": "^4.3.0",
|
||||
"gulp-concat": "^2.6.1",
|
||||
"gulp-eslint": "^6.0.0",
|
||||
"gulp-header": "^2.0.9",
|
||||
"gulp-rename": "^2.0.0",
|
||||
"gulp-terser": "^2.1.0",
|
||||
"gulp-uglify": "^3.0.2",
|
||||
"typescript": "^5.2.2",
|
||||
"vinyl-buffer": "^1.0.1",
|
||||
"vinyl-source-stream": "^2.0.0"
|
||||
},
|
||||
"repository": "github:Ionaru/easy-markdown-editor",
|
||||
"scripts": {
|
||||
"prepare": "gulp",
|
||||
"test": "npm run lint && npm run test:types && npm run e2e",
|
||||
"lint": "gulp lint",
|
||||
"cypress:lint": "eslint cypress",
|
||||
"cypress:run": "cypress run",
|
||||
"e2e": "gulp && npm run cypress:lint && npm run cypress:run",
|
||||
"test:types": "tsc --project types/tsconfig.json"
|
||||
}
|
||||
}
|
8735
source files/codemirror/codemirror.js
Normal file
8735
source files/codemirror/codemirror.js
Normal file
File diff suppressed because it is too large
Load Diff
51
source files/codemirror/continuelist.js
Normal file
51
source files/codemirror/continuelist.js
Normal file
@ -0,0 +1,51 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
var listRE = /^(\s*)(>[> ]*|[*+-]\s|(\d+)([.)]))(\s*)/,
|
||||
emptyListRE = /^(\s*)(>[> ]*|[*+-]|(\d+)[.)])(\s*)$/,
|
||||
unorderedListRE = /[*+-]\s/;
|
||||
|
||||
CodeMirror.commands.newlineAndIndentContinueMarkdownList = function(cm) {
|
||||
if (cm.getOption("disableInput")) return CodeMirror.Pass;
|
||||
var ranges = cm.listSelections(), replacements = [];
|
||||
for (var i = 0; i < ranges.length; i++) {
|
||||
var pos = ranges[i].head;
|
||||
var eolState = cm.getStateAfter(pos.line);
|
||||
var inList = eolState.list !== false;
|
||||
var inQuote = eolState.quote !== 0;
|
||||
|
||||
var line = cm.getLine(pos.line), match = listRE.exec(line);
|
||||
if (!ranges[i].empty() || (!inList && !inQuote) || !match) {
|
||||
cm.execCommand("newlineAndIndent");
|
||||
return;
|
||||
}
|
||||
if (emptyListRE.test(line)) {
|
||||
cm.replaceRange("", {
|
||||
line: pos.line, ch: 0
|
||||
}, {
|
||||
line: pos.line, ch: pos.ch + 1
|
||||
});
|
||||
replacements[i] = "\n";
|
||||
} else {
|
||||
var indent = match[1], after = match[5];
|
||||
var bullet = unorderedListRE.test(match[2]) || match[2].indexOf(">") >= 0
|
||||
? match[2]
|
||||
: (parseInt(match[3], 10) + 1) + match[4];
|
||||
|
||||
replacements[i] = "\n" + indent + bullet + after;
|
||||
}
|
||||
}
|
||||
|
||||
cm.replaceSelections(replacements);
|
||||
};
|
||||
});
|
781
source files/codemirror/markdown.js
Normal file
781
source files/codemirror/markdown.js
Normal file
@ -0,0 +1,781 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"), require("../xml/xml"), require("../meta"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror", "../xml/xml", "../meta"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
||||
|
||||
var htmlFound = CodeMirror.modes.hasOwnProperty("xml");
|
||||
var htmlMode = CodeMirror.getMode(cmCfg, htmlFound ? {name: "xml", htmlMode: true} : "text/plain");
|
||||
|
||||
function getMode(name) {
|
||||
if (CodeMirror.findModeByName) {
|
||||
var found = CodeMirror.findModeByName(name);
|
||||
if (found) name = found.mime || found.mimes[0];
|
||||
}
|
||||
var mode = CodeMirror.getMode(cmCfg, name);
|
||||
return mode.name == "null" ? null : mode;
|
||||
}
|
||||
|
||||
// Should characters that affect highlighting be highlighted separate?
|
||||
// Does not include characters that will be output (such as `1.` and `-` for lists)
|
||||
if (modeCfg.highlightFormatting === undefined)
|
||||
modeCfg.highlightFormatting = false;
|
||||
|
||||
// Maximum number of nested blockquotes. Set to 0 for infinite nesting.
|
||||
// Excess `>` will emit `error` token.
|
||||
if (modeCfg.maxBlockquoteDepth === undefined)
|
||||
modeCfg.maxBlockquoteDepth = 0;
|
||||
|
||||
// Should underscores in words open/close em/strong?
|
||||
if (modeCfg.underscoresBreakWords === undefined)
|
||||
modeCfg.underscoresBreakWords = true;
|
||||
|
||||
// Turn on fenced code blocks? ("```" to start/end)
|
||||
if (modeCfg.fencedCodeBlocks === undefined) modeCfg.fencedCodeBlocks = false;
|
||||
|
||||
// Turn on task lists? ("- [ ] " and "- [x] ")
|
||||
if (modeCfg.taskLists === undefined) modeCfg.taskLists = false;
|
||||
|
||||
// Turn on strikethrough syntax
|
||||
if (modeCfg.strikethrough === undefined)
|
||||
modeCfg.strikethrough = false;
|
||||
|
||||
var codeDepth = 0;
|
||||
|
||||
var header = 'header'
|
||||
, code = 'comment'
|
||||
, quote = 'quote'
|
||||
, list1 = 'variable-2'
|
||||
, list2 = 'variable-3'
|
||||
, list3 = 'keyword'
|
||||
, hr = 'hr'
|
||||
, image = 'tag'
|
||||
, formatting = 'formatting'
|
||||
, linkinline = 'link'
|
||||
, linkemail = 'link'
|
||||
, linktext = 'link'
|
||||
, linkhref = 'string'
|
||||
, em = 'em'
|
||||
, strong = 'strong'
|
||||
, strikethrough = 'strikethrough';
|
||||
|
||||
var hrRE = /^([*\-_])(?:\s*\1){2,}\s*$/
|
||||
, ulRE = /^[*\-+]\s+/
|
||||
, olRE = /^[0-9]+([.)])\s+/
|
||||
, taskListRE = /^\[(x| )\](?=\s)/ // Must follow ulRE or olRE
|
||||
, atxHeaderRE = /^(#+)(?: |$)/
|
||||
, setextHeaderRE = /^ *(?:\={1,}|-{1,})\s*$/
|
||||
, textRE = /^[^#!\[\]*_\\<>` "'(~]+/;
|
||||
|
||||
function switchInline(stream, state, f) {
|
||||
state.f = state.inline = f;
|
||||
return f(stream, state);
|
||||
}
|
||||
|
||||
function switchBlock(stream, state, f) {
|
||||
state.f = state.block = f;
|
||||
return f(stream, state);
|
||||
}
|
||||
|
||||
|
||||
// Blocks
|
||||
|
||||
function blankLine(state) {
|
||||
// Reset linkTitle state
|
||||
state.linkTitle = false;
|
||||
// Reset EM state
|
||||
state.em = false;
|
||||
// Reset STRONG state
|
||||
state.strong = false;
|
||||
// Reset strikethrough state
|
||||
state.strikethrough = false;
|
||||
// Reset state.quote
|
||||
state.quote = 0;
|
||||
// Reset state.indentedCode
|
||||
state.indentedCode = false;
|
||||
if (!htmlFound && state.f == htmlBlock) {
|
||||
state.f = inlineNormal;
|
||||
state.block = blockNormal;
|
||||
}
|
||||
// Reset state.trailingSpace
|
||||
state.trailingSpace = 0;
|
||||
state.trailingSpaceNewLine = false;
|
||||
// Mark this line as blank
|
||||
state.thisLineHasContent = false;
|
||||
return null;
|
||||
}
|
||||
|
||||
function blockNormal(stream, state) {
|
||||
|
||||
var sol = stream.sol();
|
||||
|
||||
var prevLineIsList = state.list !== false,
|
||||
prevLineIsIndentedCode = state.indentedCode;
|
||||
|
||||
state.indentedCode = false;
|
||||
|
||||
if (prevLineIsList) {
|
||||
if (state.indentationDiff >= 0) { // Continued list
|
||||
if (state.indentationDiff < 4) { // Only adjust indentation if *not* a code block
|
||||
state.indentation -= state.indentationDiff;
|
||||
}
|
||||
state.list = null;
|
||||
} else if (state.indentation > 0) {
|
||||
state.list = null;
|
||||
state.listDepth = Math.floor(state.indentation / 4);
|
||||
} else { // No longer a list
|
||||
state.list = false;
|
||||
state.listDepth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
var match = null;
|
||||
if (state.indentationDiff >= 4) {
|
||||
stream.skipToEnd();
|
||||
if (prevLineIsIndentedCode || !state.prevLineHasContent) {
|
||||
state.indentation -= 4;
|
||||
state.indentedCode = true;
|
||||
return code;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else if (stream.eatSpace()) {
|
||||
return null;
|
||||
} else if ((match = stream.match(atxHeaderRE)) && match[1].length <= 6) {
|
||||
state.header = match[1].length;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "header";
|
||||
state.f = state.inline;
|
||||
return getType(state);
|
||||
} else if (state.prevLineHasContent && !state.quote && !prevLineIsList && !prevLineIsIndentedCode && (match = stream.match(setextHeaderRE))) {
|
||||
state.header = match[0].charAt(0) == '=' ? 1 : 2;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "header";
|
||||
state.f = state.inline;
|
||||
return getType(state);
|
||||
} else if (stream.eat('>')) {
|
||||
state.quote = sol ? 1 : state.quote + 1;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "quote";
|
||||
stream.eatSpace();
|
||||
return getType(state);
|
||||
} else if (stream.peek() === '[') {
|
||||
return switchInline(stream, state, footnoteLink);
|
||||
} else if (stream.match(hrRE, true)) {
|
||||
state.hr = true;
|
||||
return hr;
|
||||
} else if ((!state.prevLineHasContent || prevLineIsList) && (stream.match(ulRE, false) || stream.match(olRE, false))) {
|
||||
var listType = null;
|
||||
if (stream.match(ulRE, true)) {
|
||||
listType = 'ul';
|
||||
} else {
|
||||
stream.match(olRE, true);
|
||||
listType = 'ol';
|
||||
}
|
||||
state.indentation += 4;
|
||||
state.list = true;
|
||||
state.listDepth++;
|
||||
if (modeCfg.taskLists && stream.match(taskListRE, false)) {
|
||||
state.taskList = true;
|
||||
}
|
||||
state.f = state.inline;
|
||||
if (modeCfg.highlightFormatting) state.formatting = ["list", "list-" + listType];
|
||||
return getType(state);
|
||||
} else if (modeCfg.fencedCodeBlocks && stream.match(/^```[ \t]*([\w+#]*)/, true)) {
|
||||
// try switching mode
|
||||
state.localMode = getMode(RegExp.$1);
|
||||
if (state.localMode) state.localState = state.localMode.startState();
|
||||
state.f = state.block = local;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "code-block";
|
||||
state.code = true;
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
return switchInline(stream, state, state.inline);
|
||||
}
|
||||
|
||||
function htmlBlock(stream, state) {
|
||||
var style = htmlMode.token(stream, state.htmlState);
|
||||
if ((htmlFound && state.htmlState.tagStart === null && !state.htmlState.context) ||
|
||||
(state.md_inside && stream.current().indexOf(">") > -1)) {
|
||||
state.f = inlineNormal;
|
||||
state.block = blockNormal;
|
||||
state.htmlState = null;
|
||||
}
|
||||
return style;
|
||||
}
|
||||
|
||||
function local(stream, state) {
|
||||
if (stream.sol() && stream.match("```", false)) {
|
||||
state.localMode = state.localState = null;
|
||||
state.f = state.block = leavingLocal;
|
||||
return null;
|
||||
} else if (state.localMode) {
|
||||
return state.localMode.token(stream, state.localState);
|
||||
} else {
|
||||
stream.skipToEnd();
|
||||
return code;
|
||||
}
|
||||
}
|
||||
|
||||
function leavingLocal(stream, state) {
|
||||
stream.match("```");
|
||||
state.block = blockNormal;
|
||||
state.f = inlineNormal;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "code-block";
|
||||
state.code = true;
|
||||
var returnType = getType(state);
|
||||
state.code = false;
|
||||
return returnType;
|
||||
}
|
||||
|
||||
// Inline
|
||||
function getType(state) {
|
||||
var styles = [];
|
||||
|
||||
if (state.formatting) {
|
||||
styles.push(formatting);
|
||||
|
||||
if (typeof state.formatting === "string") state.formatting = [state.formatting];
|
||||
|
||||
for (var i = 0; i < state.formatting.length; i++) {
|
||||
styles.push(formatting + "-" + state.formatting[i]);
|
||||
|
||||
if (state.formatting[i] === "header") {
|
||||
styles.push(formatting + "-" + state.formatting[i] + "-" + state.header);
|
||||
}
|
||||
|
||||
// Add `formatting-quote` and `formatting-quote-#` for blockquotes
|
||||
// Add `error` instead if the maximum blockquote nesting depth is passed
|
||||
if (state.formatting[i] === "quote") {
|
||||
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
|
||||
styles.push(formatting + "-" + state.formatting[i] + "-" + state.quote);
|
||||
} else {
|
||||
styles.push("error");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (state.taskOpen) {
|
||||
styles.push("meta");
|
||||
return styles.length ? styles.join(' ') : null;
|
||||
}
|
||||
if (state.taskClosed) {
|
||||
styles.push("property");
|
||||
return styles.length ? styles.join(' ') : null;
|
||||
}
|
||||
|
||||
if (state.linkHref) {
|
||||
styles.push(linkhref, "url");
|
||||
} else { // Only apply inline styles to non-url text
|
||||
if (state.strong) { styles.push(strong); }
|
||||
if (state.em) { styles.push(em); }
|
||||
if (state.strikethrough) { styles.push(strikethrough); }
|
||||
|
||||
if (state.linkText) { styles.push(linktext); }
|
||||
|
||||
if (state.code) { styles.push(code); }
|
||||
}
|
||||
|
||||
if (state.header) { styles.push(header); styles.push(header + "-" + state.header); }
|
||||
|
||||
if (state.quote) {
|
||||
styles.push(quote);
|
||||
|
||||
// Add `quote-#` where the maximum for `#` is modeCfg.maxBlockquoteDepth
|
||||
if (!modeCfg.maxBlockquoteDepth || modeCfg.maxBlockquoteDepth >= state.quote) {
|
||||
styles.push(quote + "-" + state.quote);
|
||||
} else {
|
||||
styles.push(quote + "-" + modeCfg.maxBlockquoteDepth);
|
||||
}
|
||||
}
|
||||
|
||||
if (state.list !== false) {
|
||||
var listMod = (state.listDepth - 1) % 3;
|
||||
if (!listMod) {
|
||||
styles.push(list1);
|
||||
} else if (listMod === 1) {
|
||||
styles.push(list2);
|
||||
} else {
|
||||
styles.push(list3);
|
||||
}
|
||||
}
|
||||
|
||||
if (state.trailingSpaceNewLine) {
|
||||
styles.push("trailing-space-new-line");
|
||||
} else if (state.trailingSpace) {
|
||||
styles.push("trailing-space-" + (state.trailingSpace % 2 ? "a" : "b"));
|
||||
}
|
||||
|
||||
return styles.length ? styles.join(' ') : null;
|
||||
}
|
||||
|
||||
function handleText(stream, state) {
|
||||
if (stream.match(textRE, true)) {
|
||||
return getType(state);
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
function inlineNormal(stream, state) {
|
||||
var style = state.text(stream, state);
|
||||
if (typeof style !== 'undefined')
|
||||
return style;
|
||||
|
||||
if (state.list) { // List marker (*, +, -, 1., etc)
|
||||
state.list = null;
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
if (state.taskList) {
|
||||
var taskOpen = stream.match(taskListRE, true)[1] !== "x";
|
||||
if (taskOpen) state.taskOpen = true;
|
||||
else state.taskClosed = true;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "task";
|
||||
state.taskList = false;
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
state.taskOpen = false;
|
||||
state.taskClosed = false;
|
||||
|
||||
if (state.header && stream.match(/^#+$/, true)) {
|
||||
if (modeCfg.highlightFormatting) state.formatting = "header";
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
// Get sol() value now, before character is consumed
|
||||
var sol = stream.sol();
|
||||
|
||||
var ch = stream.next();
|
||||
|
||||
if (ch === '\\') {
|
||||
stream.next();
|
||||
if (modeCfg.highlightFormatting) {
|
||||
var type = getType(state);
|
||||
return type ? type + " formatting-escape" : "formatting-escape";
|
||||
}
|
||||
}
|
||||
|
||||
// Matches link titles present on next line
|
||||
if (state.linkTitle) {
|
||||
state.linkTitle = false;
|
||||
var matchCh = ch;
|
||||
if (ch === '(') {
|
||||
matchCh = ')';
|
||||
}
|
||||
matchCh = (matchCh+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
|
||||
var regex = '^\\s*(?:[^' + matchCh + '\\\\]+|\\\\\\\\|\\\\.)' + matchCh;
|
||||
if (stream.match(new RegExp(regex), true)) {
|
||||
return linkhref;
|
||||
}
|
||||
}
|
||||
|
||||
// If this block is changed, it may need to be updated in GFM mode
|
||||
if (ch === '`') {
|
||||
var previousFormatting = state.formatting;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "code";
|
||||
var t = getType(state);
|
||||
var before = stream.pos;
|
||||
stream.eatWhile('`');
|
||||
var difference = 1 + stream.pos - before;
|
||||
if (!state.code) {
|
||||
codeDepth = difference;
|
||||
state.code = true;
|
||||
return getType(state);
|
||||
} else {
|
||||
if (difference === codeDepth) { // Must be exact
|
||||
state.code = false;
|
||||
return t;
|
||||
}
|
||||
state.formatting = previousFormatting;
|
||||
return getType(state);
|
||||
}
|
||||
} else if (state.code) {
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
if (ch === '!' && stream.match(/\[[^\]]*\] ?(?:\(|\[)/, false)) {
|
||||
stream.match(/\[[^\]]*\]/);
|
||||
state.inline = state.f = linkHref;
|
||||
return image;
|
||||
}
|
||||
|
||||
if (ch === '[' && stream.match(/.*\](\(.*\)| ?\[.*\])/, false)) {
|
||||
state.linkText = true;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
if (ch === ']' && state.linkText && stream.match(/\(.*\)| ?\[.*\]/, false)) {
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
var type = getType(state);
|
||||
state.linkText = false;
|
||||
state.inline = state.f = linkHref;
|
||||
return type;
|
||||
}
|
||||
|
||||
if (ch === '<' && stream.match(/^(https?|ftps?):\/\/(?:[^\\>]|\\.)+>/, false)) {
|
||||
state.f = state.inline = linkInline;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
var type = getType(state);
|
||||
if (type){
|
||||
type += " ";
|
||||
} else {
|
||||
type = "";
|
||||
}
|
||||
return type + linkinline;
|
||||
}
|
||||
|
||||
if (ch === '<' && stream.match(/^[^> \\]+@(?:[^\\>]|\\.)+>/, false)) {
|
||||
state.f = state.inline = linkInline;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
var type = getType(state);
|
||||
if (type){
|
||||
type += " ";
|
||||
} else {
|
||||
type = "";
|
||||
}
|
||||
return type + linkemail;
|
||||
}
|
||||
|
||||
if (ch === '<' && stream.match(/^\w/, false)) {
|
||||
if (stream.string.indexOf(">") != -1) {
|
||||
var atts = stream.string.substring(1,stream.string.indexOf(">"));
|
||||
if (/markdown\s*=\s*('|"){0,1}1('|"){0,1}/.test(atts)) {
|
||||
state.md_inside = true;
|
||||
}
|
||||
}
|
||||
stream.backUp(1);
|
||||
state.htmlState = CodeMirror.startState(htmlMode);
|
||||
return switchBlock(stream, state, htmlBlock);
|
||||
}
|
||||
|
||||
if (ch === '<' && stream.match(/^\/\w*?>/)) {
|
||||
state.md_inside = false;
|
||||
return "tag";
|
||||
}
|
||||
|
||||
var ignoreUnderscore = false;
|
||||
if (!modeCfg.underscoresBreakWords) {
|
||||
if (ch === '_' && stream.peek() !== '_' && stream.match(/(\w)/, false)) {
|
||||
var prevPos = stream.pos - 2;
|
||||
if (prevPos >= 0) {
|
||||
var prevCh = stream.string.charAt(prevPos);
|
||||
if (prevCh !== '_' && prevCh.match(/(\w)/, false)) {
|
||||
ignoreUnderscore = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ch === '*' || (ch === '_' && !ignoreUnderscore)) {
|
||||
if (sol && stream.peek() === ' ') {
|
||||
// Do nothing, surrounded by newline and space
|
||||
} else if (state.strong === ch && stream.eat(ch)) { // Remove STRONG
|
||||
if (modeCfg.highlightFormatting) state.formatting = "strong";
|
||||
var t = getType(state);
|
||||
state.strong = false;
|
||||
return t;
|
||||
} else if (!state.strong && stream.eat(ch)) { // Add STRONG
|
||||
state.strong = ch;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "strong";
|
||||
return getType(state);
|
||||
} else if (state.em === ch) { // Remove EM
|
||||
if (modeCfg.highlightFormatting) state.formatting = "em";
|
||||
var t = getType(state);
|
||||
state.em = false;
|
||||
return t;
|
||||
} else if (!state.em) { // Add EM
|
||||
state.em = ch;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "em";
|
||||
return getType(state);
|
||||
}
|
||||
} else if (ch === ' ') {
|
||||
if (stream.eat('*') || stream.eat('_')) { // Probably surrounded by spaces
|
||||
if (stream.peek() === ' ') { // Surrounded by spaces, ignore
|
||||
return getType(state);
|
||||
} else { // Not surrounded by spaces, back up pointer
|
||||
stream.backUp(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (modeCfg.strikethrough) {
|
||||
if (ch === '~' && stream.eatWhile(ch)) {
|
||||
if (state.strikethrough) {// Remove strikethrough
|
||||
if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
|
||||
var t = getType(state);
|
||||
state.strikethrough = false;
|
||||
return t;
|
||||
} else if (stream.match(/^[^\s]/, false)) {// Add strikethrough
|
||||
state.strikethrough = true;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "strikethrough";
|
||||
return getType(state);
|
||||
}
|
||||
} else if (ch === ' ') {
|
||||
if (stream.match(/^~~/, true)) { // Probably surrounded by space
|
||||
if (stream.peek() === ' ') { // Surrounded by spaces, ignore
|
||||
return getType(state);
|
||||
} else { // Not surrounded by spaces, back up pointer
|
||||
stream.backUp(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ch === ' ') {
|
||||
if (stream.match(/ +$/, false)) {
|
||||
state.trailingSpace++;
|
||||
} else if (state.trailingSpace) {
|
||||
state.trailingSpaceNewLine = true;
|
||||
}
|
||||
}
|
||||
|
||||
return getType(state);
|
||||
}
|
||||
|
||||
function linkInline(stream, state) {
|
||||
var ch = stream.next();
|
||||
|
||||
if (ch === ">") {
|
||||
state.f = state.inline = inlineNormal;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
var type = getType(state);
|
||||
if (type){
|
||||
type += " ";
|
||||
} else {
|
||||
type = "";
|
||||
}
|
||||
return type + linkinline;
|
||||
}
|
||||
|
||||
stream.match(/^[^>]+/, true);
|
||||
|
||||
return linkinline;
|
||||
}
|
||||
|
||||
function linkHref(stream, state) {
|
||||
// Check if space, and return NULL if so (to avoid marking the space)
|
||||
if(stream.eatSpace()){
|
||||
return null;
|
||||
}
|
||||
var ch = stream.next();
|
||||
if (ch === '(' || ch === '[') {
|
||||
state.f = state.inline = getLinkHrefInside(ch === "(" ? ")" : "]");
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link-string";
|
||||
state.linkHref = true;
|
||||
return getType(state);
|
||||
}
|
||||
return 'error';
|
||||
}
|
||||
|
||||
function getLinkHrefInside(endChar) {
|
||||
return function(stream, state) {
|
||||
var ch = stream.next();
|
||||
|
||||
if (ch === endChar) {
|
||||
state.f = state.inline = inlineNormal;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link-string";
|
||||
var returnState = getType(state);
|
||||
state.linkHref = false;
|
||||
return returnState;
|
||||
}
|
||||
|
||||
if (stream.match(inlineRE(endChar), true)) {
|
||||
stream.backUp(1);
|
||||
}
|
||||
|
||||
state.linkHref = true;
|
||||
return getType(state);
|
||||
};
|
||||
}
|
||||
|
||||
function footnoteLink(stream, state) {
|
||||
if (stream.match(/^[^\]]*\]:/, false)) {
|
||||
state.f = footnoteLinkInside;
|
||||
stream.next(); // Consume [
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
state.linkText = true;
|
||||
return getType(state);
|
||||
}
|
||||
return switchInline(stream, state, inlineNormal);
|
||||
}
|
||||
|
||||
function footnoteLinkInside(stream, state) {
|
||||
if (stream.match(/^\]:/, true)) {
|
||||
state.f = state.inline = footnoteUrl;
|
||||
if (modeCfg.highlightFormatting) state.formatting = "link";
|
||||
var returnType = getType(state);
|
||||
state.linkText = false;
|
||||
return returnType;
|
||||
}
|
||||
|
||||
stream.match(/^[^\]]+/, true);
|
||||
|
||||
return linktext;
|
||||
}
|
||||
|
||||
function footnoteUrl(stream, state) {
|
||||
// Check if space, and return NULL if so (to avoid marking the space)
|
||||
if(stream.eatSpace()){
|
||||
return null;
|
||||
}
|
||||
// Match URL
|
||||
stream.match(/^[^\s]+/, true);
|
||||
// Check for link title
|
||||
if (stream.peek() === undefined) { // End of line, set flag to check next line
|
||||
state.linkTitle = true;
|
||||
} else { // More content on line, check if link title
|
||||
stream.match(/^(?:\s+(?:"(?:[^"\\]|\\\\|\\.)+"|'(?:[^'\\]|\\\\|\\.)+'|\((?:[^)\\]|\\\\|\\.)+\)))?/, true);
|
||||
}
|
||||
state.f = state.inline = inlineNormal;
|
||||
return linkhref + " url";
|
||||
}
|
||||
|
||||
var savedInlineRE = [];
|
||||
function inlineRE(endChar) {
|
||||
if (!savedInlineRE[endChar]) {
|
||||
// Escape endChar for RegExp (taken from http://stackoverflow.com/a/494122/526741)
|
||||
endChar = (endChar+'').replace(/([.?*+^$[\]\\(){}|-])/g, "\\$1");
|
||||
// Match any non-endChar, escaped character, as well as the closing
|
||||
// endChar.
|
||||
savedInlineRE[endChar] = new RegExp('^(?:[^\\\\]|\\\\.)*?(' + endChar + ')');
|
||||
}
|
||||
return savedInlineRE[endChar];
|
||||
}
|
||||
|
||||
var mode = {
|
||||
startState: function() {
|
||||
return {
|
||||
f: blockNormal,
|
||||
|
||||
prevLineHasContent: false,
|
||||
thisLineHasContent: false,
|
||||
|
||||
block: blockNormal,
|
||||
htmlState: null,
|
||||
indentation: 0,
|
||||
|
||||
inline: inlineNormal,
|
||||
text: handleText,
|
||||
|
||||
formatting: false,
|
||||
linkText: false,
|
||||
linkHref: false,
|
||||
linkTitle: false,
|
||||
em: false,
|
||||
strong: false,
|
||||
header: 0,
|
||||
hr: false,
|
||||
taskList: false,
|
||||
list: false,
|
||||
listDepth: 0,
|
||||
quote: 0,
|
||||
trailingSpace: 0,
|
||||
trailingSpaceNewLine: false,
|
||||
strikethrough: false
|
||||
};
|
||||
},
|
||||
|
||||
copyState: function(s) {
|
||||
return {
|
||||
f: s.f,
|
||||
|
||||
prevLineHasContent: s.prevLineHasContent,
|
||||
thisLineHasContent: s.thisLineHasContent,
|
||||
|
||||
block: s.block,
|
||||
htmlState: s.htmlState && CodeMirror.copyState(htmlMode, s.htmlState),
|
||||
indentation: s.indentation,
|
||||
|
||||
localMode: s.localMode,
|
||||
localState: s.localMode ? CodeMirror.copyState(s.localMode, s.localState) : null,
|
||||
|
||||
inline: s.inline,
|
||||
text: s.text,
|
||||
formatting: false,
|
||||
linkTitle: s.linkTitle,
|
||||
em: s.em,
|
||||
strong: s.strong,
|
||||
strikethrough: s.strikethrough,
|
||||
header: s.header,
|
||||
hr: s.hr,
|
||||
taskList: s.taskList,
|
||||
list: s.list,
|
||||
listDepth: s.listDepth,
|
||||
quote: s.quote,
|
||||
indentedCode: s.indentedCode,
|
||||
trailingSpace: s.trailingSpace,
|
||||
trailingSpaceNewLine: s.trailingSpaceNewLine,
|
||||
md_inside: s.md_inside
|
||||
};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
|
||||
// Reset state.formatting
|
||||
state.formatting = false;
|
||||
|
||||
if (stream.sol()) {
|
||||
var forceBlankLine = !!state.header || state.hr;
|
||||
|
||||
// Reset state.header and state.hr
|
||||
state.header = 0;
|
||||
state.hr = false;
|
||||
|
||||
if (stream.match(/^\s*$/, true) || forceBlankLine) {
|
||||
state.prevLineHasContent = false;
|
||||
blankLine(state);
|
||||
return forceBlankLine ? this.token(stream, state) : null;
|
||||
} else {
|
||||
state.prevLineHasContent = state.thisLineHasContent;
|
||||
state.thisLineHasContent = true;
|
||||
}
|
||||
|
||||
// Reset state.taskList
|
||||
state.taskList = false;
|
||||
|
||||
// Reset state.code
|
||||
state.code = false;
|
||||
|
||||
// Reset state.trailingSpace
|
||||
state.trailingSpace = 0;
|
||||
state.trailingSpaceNewLine = false;
|
||||
|
||||
state.f = state.block;
|
||||
var indentation = stream.match(/^\s*/, true)[0].replace(/\t/g, ' ').length;
|
||||
var difference = Math.floor((indentation - state.indentation) / 4) * 4;
|
||||
if (difference > 4) difference = 4;
|
||||
var adjustedIndentation = state.indentation + difference;
|
||||
state.indentationDiff = adjustedIndentation - state.indentation;
|
||||
state.indentation = adjustedIndentation;
|
||||
if (indentation > 0) return null;
|
||||
}
|
||||
return state.f(stream, state);
|
||||
},
|
||||
|
||||
innerMode: function(state) {
|
||||
if (state.block == htmlBlock) return {state: state.htmlState, mode: htmlMode};
|
||||
if (state.localState) return {state: state.localState, mode: state.localMode};
|
||||
return {state: state, mode: mode};
|
||||
},
|
||||
|
||||
blankLine: blankLine,
|
||||
|
||||
getType: getType,
|
||||
|
||||
fold: "markdown"
|
||||
};
|
||||
return mode;
|
||||
}, "xml");
|
||||
|
||||
CodeMirror.defineMIME("text/x-markdown", "markdown");
|
||||
|
||||
});
|
384
source files/codemirror/xml.js
Normal file
384
source files/codemirror/xml.js
Normal file
@ -0,0 +1,384 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
(function(mod) {
|
||||
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
||||
mod(require("../../lib/codemirror"));
|
||||
else if (typeof define == "function" && define.amd) // AMD
|
||||
define(["../../lib/codemirror"], mod);
|
||||
else // Plain browser env
|
||||
mod(CodeMirror);
|
||||
})(function(CodeMirror) {
|
||||
"use strict";
|
||||
|
||||
CodeMirror.defineMode("xml", function(config, parserConfig) {
|
||||
var indentUnit = config.indentUnit;
|
||||
var multilineTagIndentFactor = parserConfig.multilineTagIndentFactor || 1;
|
||||
var multilineTagIndentPastTag = parserConfig.multilineTagIndentPastTag;
|
||||
if (multilineTagIndentPastTag == null) multilineTagIndentPastTag = true;
|
||||
|
||||
var Kludges = parserConfig.htmlMode ? {
|
||||
autoSelfClosers: {'area': true, 'base': true, 'br': true, 'col': true, 'command': true,
|
||||
'embed': true, 'frame': true, 'hr': true, 'img': true, 'input': true,
|
||||
'keygen': true, 'link': true, 'meta': true, 'param': true, 'source': true,
|
||||
'track': true, 'wbr': true, 'menuitem': true},
|
||||
implicitlyClosed: {'dd': true, 'li': true, 'optgroup': true, 'option': true, 'p': true,
|
||||
'rp': true, 'rt': true, 'tbody': true, 'td': true, 'tfoot': true,
|
||||
'th': true, 'tr': true},
|
||||
contextGrabbers: {
|
||||
'dd': {'dd': true, 'dt': true},
|
||||
'dt': {'dd': true, 'dt': true},
|
||||
'li': {'li': true},
|
||||
'option': {'option': true, 'optgroup': true},
|
||||
'optgroup': {'optgroup': true},
|
||||
'p': {'address': true, 'article': true, 'aside': true, 'blockquote': true, 'dir': true,
|
||||
'div': true, 'dl': true, 'fieldset': true, 'footer': true, 'form': true,
|
||||
'h1': true, 'h2': true, 'h3': true, 'h4': true, 'h5': true, 'h6': true,
|
||||
'header': true, 'hgroup': true, 'hr': true, 'menu': true, 'nav': true, 'ol': true,
|
||||
'p': true, 'pre': true, 'section': true, 'table': true, 'ul': true},
|
||||
'rp': {'rp': true, 'rt': true},
|
||||
'rt': {'rp': true, 'rt': true},
|
||||
'tbody': {'tbody': true, 'tfoot': true},
|
||||
'td': {'td': true, 'th': true},
|
||||
'tfoot': {'tbody': true},
|
||||
'th': {'td': true, 'th': true},
|
||||
'thead': {'tbody': true, 'tfoot': true},
|
||||
'tr': {'tr': true}
|
||||
},
|
||||
doNotIndent: {"pre": true},
|
||||
allowUnquoted: true,
|
||||
allowMissing: true,
|
||||
caseFold: true
|
||||
} : {
|
||||
autoSelfClosers: {},
|
||||
implicitlyClosed: {},
|
||||
contextGrabbers: {},
|
||||
doNotIndent: {},
|
||||
allowUnquoted: false,
|
||||
allowMissing: false,
|
||||
caseFold: false
|
||||
};
|
||||
var alignCDATA = parserConfig.alignCDATA;
|
||||
|
||||
// Return variables for tokenizers
|
||||
var type, setStyle;
|
||||
|
||||
function inText(stream, state) {
|
||||
function chain(parser) {
|
||||
state.tokenize = parser;
|
||||
return parser(stream, state);
|
||||
}
|
||||
|
||||
var ch = stream.next();
|
||||
if (ch == "<") {
|
||||
if (stream.eat("!")) {
|
||||
if (stream.eat("[")) {
|
||||
if (stream.match("CDATA[")) return chain(inBlock("atom", "]]>"));
|
||||
else return null;
|
||||
} else if (stream.match("--")) {
|
||||
return chain(inBlock("comment", "-->"));
|
||||
} else if (stream.match("DOCTYPE", true, true)) {
|
||||
stream.eatWhile(/[\w\._\-]/);
|
||||
return chain(doctype(1));
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else if (stream.eat("?")) {
|
||||
stream.eatWhile(/[\w\._\-]/);
|
||||
state.tokenize = inBlock("meta", "?>");
|
||||
return "meta";
|
||||
} else {
|
||||
type = stream.eat("/") ? "closeTag" : "openTag";
|
||||
state.tokenize = inTag;
|
||||
return "tag bracket";
|
||||
}
|
||||
} else if (ch == "&") {
|
||||
var ok;
|
||||
if (stream.eat("#")) {
|
||||
if (stream.eat("x")) {
|
||||
ok = stream.eatWhile(/[a-fA-F\d]/) && stream.eat(";");
|
||||
} else {
|
||||
ok = stream.eatWhile(/[\d]/) && stream.eat(";");
|
||||
}
|
||||
} else {
|
||||
ok = stream.eatWhile(/[\w\.\-:]/) && stream.eat(";");
|
||||
}
|
||||
return ok ? "atom" : "error";
|
||||
} else {
|
||||
stream.eatWhile(/[^&<]/);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function inTag(stream, state) {
|
||||
var ch = stream.next();
|
||||
if (ch == ">" || (ch == "/" && stream.eat(">"))) {
|
||||
state.tokenize = inText;
|
||||
type = ch == ">" ? "endTag" : "selfcloseTag";
|
||||
return "tag bracket";
|
||||
} else if (ch == "=") {
|
||||
type = "equals";
|
||||
return null;
|
||||
} else if (ch == "<") {
|
||||
state.tokenize = inText;
|
||||
state.state = baseState;
|
||||
state.tagName = state.tagStart = null;
|
||||
var next = state.tokenize(stream, state);
|
||||
return next ? next + " tag error" : "tag error";
|
||||
} else if (/[\'\"]/.test(ch)) {
|
||||
state.tokenize = inAttribute(ch);
|
||||
state.stringStartCol = stream.column();
|
||||
return state.tokenize(stream, state);
|
||||
} else {
|
||||
stream.match(/^[^\s\u00a0=<>\"\']*[^\s\u00a0=<>\"\'\/]/);
|
||||
return "word";
|
||||
}
|
||||
}
|
||||
|
||||
function inAttribute(quote) {
|
||||
var closure = function(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
if (stream.next() == quote) {
|
||||
state.tokenize = inTag;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return "string";
|
||||
};
|
||||
closure.isInAttribute = true;
|
||||
return closure;
|
||||
}
|
||||
|
||||
function inBlock(style, terminator) {
|
||||
return function(stream, state) {
|
||||
while (!stream.eol()) {
|
||||
if (stream.match(terminator)) {
|
||||
state.tokenize = inText;
|
||||
break;
|
||||
}
|
||||
stream.next();
|
||||
}
|
||||
return style;
|
||||
};
|
||||
}
|
||||
function doctype(depth) {
|
||||
return function(stream, state) {
|
||||
var ch;
|
||||
while ((ch = stream.next()) != null) {
|
||||
if (ch == "<") {
|
||||
state.tokenize = doctype(depth + 1);
|
||||
return state.tokenize(stream, state);
|
||||
} else if (ch == ">") {
|
||||
if (depth == 1) {
|
||||
state.tokenize = inText;
|
||||
break;
|
||||
} else {
|
||||
state.tokenize = doctype(depth - 1);
|
||||
return state.tokenize(stream, state);
|
||||
}
|
||||
}
|
||||
}
|
||||
return "meta";
|
||||
};
|
||||
}
|
||||
|
||||
function Context(state, tagName, startOfLine) {
|
||||
this.prev = state.context;
|
||||
this.tagName = tagName;
|
||||
this.indent = state.indented;
|
||||
this.startOfLine = startOfLine;
|
||||
if (Kludges.doNotIndent.hasOwnProperty(tagName) || (state.context && state.context.noIndent))
|
||||
this.noIndent = true;
|
||||
}
|
||||
function popContext(state) {
|
||||
if (state.context) state.context = state.context.prev;
|
||||
}
|
||||
function maybePopContext(state, nextTagName) {
|
||||
var parentTagName;
|
||||
while (true) {
|
||||
if (!state.context) {
|
||||
return;
|
||||
}
|
||||
parentTagName = state.context.tagName;
|
||||
if (!Kludges.contextGrabbers.hasOwnProperty(parentTagName) ||
|
||||
!Kludges.contextGrabbers[parentTagName].hasOwnProperty(nextTagName)) {
|
||||
return;
|
||||
}
|
||||
popContext(state);
|
||||
}
|
||||
}
|
||||
|
||||
function baseState(type, stream, state) {
|
||||
if (type == "openTag") {
|
||||
state.tagStart = stream.column();
|
||||
return tagNameState;
|
||||
} else if (type == "closeTag") {
|
||||
return closeTagNameState;
|
||||
} else {
|
||||
return baseState;
|
||||
}
|
||||
}
|
||||
function tagNameState(type, stream, state) {
|
||||
if (type == "word") {
|
||||
state.tagName = stream.current();
|
||||
setStyle = "tag";
|
||||
return attrState;
|
||||
} else {
|
||||
setStyle = "error";
|
||||
return tagNameState;
|
||||
}
|
||||
}
|
||||
function closeTagNameState(type, stream, state) {
|
||||
if (type == "word") {
|
||||
var tagName = stream.current();
|
||||
if (state.context && state.context.tagName != tagName &&
|
||||
Kludges.implicitlyClosed.hasOwnProperty(state.context.tagName))
|
||||
popContext(state);
|
||||
if (state.context && state.context.tagName == tagName) {
|
||||
setStyle = "tag";
|
||||
return closeState;
|
||||
} else {
|
||||
setStyle = "tag error";
|
||||
return closeStateErr;
|
||||
}
|
||||
} else {
|
||||
setStyle = "error";
|
||||
return closeStateErr;
|
||||
}
|
||||
}
|
||||
|
||||
function closeState(type, _stream, state) {
|
||||
if (type != "endTag") {
|
||||
setStyle = "error";
|
||||
return closeState;
|
||||
}
|
||||
popContext(state);
|
||||
return baseState;
|
||||
}
|
||||
function closeStateErr(type, stream, state) {
|
||||
setStyle = "error";
|
||||
return closeState(type, stream, state);
|
||||
}
|
||||
|
||||
function attrState(type, _stream, state) {
|
||||
if (type == "word") {
|
||||
setStyle = "attribute";
|
||||
return attrEqState;
|
||||
} else if (type == "endTag" || type == "selfcloseTag") {
|
||||
var tagName = state.tagName, tagStart = state.tagStart;
|
||||
state.tagName = state.tagStart = null;
|
||||
if (type == "selfcloseTag" ||
|
||||
Kludges.autoSelfClosers.hasOwnProperty(tagName)) {
|
||||
maybePopContext(state, tagName);
|
||||
} else {
|
||||
maybePopContext(state, tagName);
|
||||
state.context = new Context(state, tagName, tagStart == state.indented);
|
||||
}
|
||||
return baseState;
|
||||
}
|
||||
setStyle = "error";
|
||||
return attrState;
|
||||
}
|
||||
function attrEqState(type, stream, state) {
|
||||
if (type == "equals") return attrValueState;
|
||||
if (!Kludges.allowMissing) setStyle = "error";
|
||||
return attrState(type, stream, state);
|
||||
}
|
||||
function attrValueState(type, stream, state) {
|
||||
if (type == "string") return attrContinuedState;
|
||||
if (type == "word" && Kludges.allowUnquoted) {setStyle = "string"; return attrState;}
|
||||
setStyle = "error";
|
||||
return attrState(type, stream, state);
|
||||
}
|
||||
function attrContinuedState(type, stream, state) {
|
||||
if (type == "string") return attrContinuedState;
|
||||
return attrState(type, stream, state);
|
||||
}
|
||||
|
||||
return {
|
||||
startState: function() {
|
||||
return {tokenize: inText,
|
||||
state: baseState,
|
||||
indented: 0,
|
||||
tagName: null, tagStart: null,
|
||||
context: null};
|
||||
},
|
||||
|
||||
token: function(stream, state) {
|
||||
if (!state.tagName && stream.sol())
|
||||
state.indented = stream.indentation();
|
||||
|
||||
if (stream.eatSpace()) return null;
|
||||
type = null;
|
||||
var style = state.tokenize(stream, state);
|
||||
if ((style || type) && style != "comment") {
|
||||
setStyle = null;
|
||||
state.state = state.state(type || style, stream, state);
|
||||
if (setStyle)
|
||||
style = setStyle == "error" ? style + " error" : setStyle;
|
||||
}
|
||||
return style;
|
||||
},
|
||||
|
||||
indent: function(state, textAfter, fullLine) {
|
||||
var context = state.context;
|
||||
// Indent multi-line strings (e.g. css).
|
||||
if (state.tokenize.isInAttribute) {
|
||||
if (state.tagStart == state.indented)
|
||||
return state.stringStartCol + 1;
|
||||
else
|
||||
return state.indented + indentUnit;
|
||||
}
|
||||
if (context && context.noIndent) return CodeMirror.Pass;
|
||||
if (state.tokenize != inTag && state.tokenize != inText)
|
||||
return fullLine ? fullLine.match(/^(\s*)/)[0].length : 0;
|
||||
// Indent the starts of attribute names.
|
||||
if (state.tagName) {
|
||||
if (multilineTagIndentPastTag)
|
||||
return state.tagStart + state.tagName.length + 2;
|
||||
else
|
||||
return state.tagStart + indentUnit * multilineTagIndentFactor;
|
||||
}
|
||||
if (alignCDATA && /<!\[CDATA\[/.test(textAfter)) return 0;
|
||||
var tagAfter = textAfter && /^<(\/)?([\w_:\.-]*)/.exec(textAfter);
|
||||
if (tagAfter && tagAfter[1]) { // Closing tag spotted
|
||||
while (context) {
|
||||
if (context.tagName == tagAfter[2]) {
|
||||
context = context.prev;
|
||||
break;
|
||||
} else if (Kludges.implicitlyClosed.hasOwnProperty(context.tagName)) {
|
||||
context = context.prev;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else if (tagAfter) { // Opening tag spotted
|
||||
while (context) {
|
||||
var grabbers = Kludges.contextGrabbers[context.tagName];
|
||||
if (grabbers && grabbers.hasOwnProperty(tagAfter[2]))
|
||||
context = context.prev;
|
||||
else
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (context && !context.startOfLine)
|
||||
context = context.prev;
|
||||
if (context) return context.indent + indentUnit;
|
||||
else return 0;
|
||||
},
|
||||
|
||||
electricInput: /<\/[\s\w:]+>$/,
|
||||
blockCommentStart: "<!--",
|
||||
blockCommentEnd: "-->",
|
||||
|
||||
configuration: parserConfig.htmlMode ? "html" : "xml",
|
||||
helperType: parserConfig.htmlMode ? "html" : "xml"
|
||||
};
|
||||
});
|
||||
|
||||
CodeMirror.defineMIME("text/xml", "xml");
|
||||
CodeMirror.defineMIME("application/xml", "xml");
|
||||
if (!CodeMirror.mimeModes.hasOwnProperty("text/html"))
|
||||
CodeMirror.defineMIME("text/html", {name: "xml", htmlMode: true});
|
||||
|
||||
});
|
1801
source files/font-awesome.css
vendored
Normal file
1801
source files/font-awesome.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
677
source files/markdownify.js
Normal file
677
source files/markdownify.js
Normal file
@ -0,0 +1,677 @@
|
||||
var isMac = /Mac/.test(navigator.platform);
|
||||
|
||||
var shortcuts = {
|
||||
'Cmd-B': toggleBold,
|
||||
'Cmd-I': toggleItalic,
|
||||
'Cmd-K': drawLink,
|
||||
'Cmd-Alt-I': drawImage,
|
||||
"Cmd-'": toggleBlockquote,
|
||||
'Cmd-Alt-L': toggleOrderedList,
|
||||
'Cmd-L': toggleUnOrderedList
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Fix shortcut. Mac use Command, others use Ctrl.
|
||||
*/
|
||||
function fixShortcut(name) {
|
||||
if (isMac) {
|
||||
name = name.replace('Ctrl', 'Cmd');
|
||||
} else {
|
||||
name = name.replace('Cmd', 'Ctrl');
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Create icon element for toolbar.
|
||||
*/
|
||||
function createIcon(name, options) {
|
||||
options = options || {};
|
||||
var el = document.createElement('a');
|
||||
|
||||
var shortcut = options.shortcut || shortcuts[name];
|
||||
if (shortcut) {
|
||||
shortcut = fixShortcut(shortcut);
|
||||
el.title = shortcut;
|
||||
el.title = el.title.replace('Cmd', '⌘');
|
||||
if (isMac) {
|
||||
el.title = el.title.replace('Alt', '⌥');
|
||||
}
|
||||
}
|
||||
|
||||
el.className = options.className || 'icon-' + name;
|
||||
return el;
|
||||
}
|
||||
|
||||
function createSep() {
|
||||
el = document.createElement('i');
|
||||
el.className = 'separator';
|
||||
el.innerHTML = '|';
|
||||
return el;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The state of CodeMirror at the given position.
|
||||
*/
|
||||
function getState(cm, pos) {
|
||||
pos = pos || cm.getCursor('start');
|
||||
var stat = cm.getTokenAt(pos);
|
||||
if (!stat.type) return {};
|
||||
|
||||
var types = stat.type.split(' ');
|
||||
|
||||
var ret = {},
|
||||
data, text;
|
||||
for (var i = 0; i < types.length; i++) {
|
||||
data = types[i];
|
||||
if (data === 'strong') {
|
||||
ret.bold = true;
|
||||
} else if (data === 'variable-2') {
|
||||
text = cm.getLine(pos.line);
|
||||
if (/^\s*\d+\.\s/.test(text)) {
|
||||
ret['ordered-list'] = true;
|
||||
} else {
|
||||
ret['unordered-list'] = true;
|
||||
}
|
||||
} else if (data === 'atom') {
|
||||
ret.quote = true;
|
||||
} else if (data === 'em') {
|
||||
ret.italic = true;
|
||||
} else if (data === 'quote') {
|
||||
ret.quote = true;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Toggle full screen of the editor.
|
||||
*/
|
||||
function toggleFullScreen(editor) {
|
||||
var el = editor.codemirror.getWrapperElement();
|
||||
|
||||
// https://developer.mozilla.org/en-US/docs/DOM/Using_fullscreen_mode
|
||||
var doc = document;
|
||||
var isFull = doc.fullScreen || doc.mozFullScreen || doc.webkitFullScreen;
|
||||
var request = function() {
|
||||
if (el.requestFullScreen) {
|
||||
el.requestFullScreen();
|
||||
} else if (el.mozRequestFullScreen) {
|
||||
el.mozRequestFullScreen();
|
||||
} else if (el.webkitRequestFullScreen) {
|
||||
el.webkitRequestFullScreen(Element.ALLOW_KEYBOARD_INPUT);
|
||||
}
|
||||
};
|
||||
var cancel = function() {
|
||||
if (doc.cancelFullScreen) {
|
||||
doc.cancelFullScreen();
|
||||
} else if (doc.mozCancelFullScreen) {
|
||||
doc.mozCancelFullScreen();
|
||||
} else if (doc.webkitCancelFullScreen) {
|
||||
doc.webkitCancelFullScreen();
|
||||
}
|
||||
};
|
||||
if (!isFull) {
|
||||
request();
|
||||
} else if (cancel) {
|
||||
cancel();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action for toggling bold.
|
||||
*/
|
||||
function toggleBold(editor) {
|
||||
_toggleBlock(editor, 'bold', '**');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action for toggling italic.
|
||||
*/
|
||||
function toggleItalic(editor) {
|
||||
_toggleBlock(editor, 'italic', '*');
|
||||
}
|
||||
|
||||
/**
|
||||
* Action for toggling code block.
|
||||
*/
|
||||
function toggleCodeBlock(editor) {
|
||||
_toggleBlock(editor, 'code', '```\r\n', '\r\n```');
|
||||
}
|
||||
|
||||
/**
|
||||
* Action for toggling blockquote.
|
||||
*/
|
||||
function toggleBlockquote(editor) {
|
||||
var cm = editor.codemirror;
|
||||
_toggleLine(cm, 'quote');
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Action for toggling ul.
|
||||
*/
|
||||
function toggleUnOrderedList(editor) {
|
||||
var cm = editor.codemirror;
|
||||
_toggleLine(cm, 'unordered-list');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action for toggling ol.
|
||||
*/
|
||||
function toggleOrderedList(editor) {
|
||||
var cm = editor.codemirror;
|
||||
_toggleLine(cm, 'ordered-list');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action for drawing a link.
|
||||
*/
|
||||
function drawLink(editor) {
|
||||
var cm = editor.codemirror;
|
||||
var stat = getState(cm);
|
||||
_replaceSelection(cm, stat.link, '[', '](http://)');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Action for drawing an img.
|
||||
*/
|
||||
function drawImage(editor) {
|
||||
var cm = editor.codemirror;
|
||||
var stat = getState(cm);
|
||||
_replaceSelection(cm, stat.image, '');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Undo action.
|
||||
*/
|
||||
function undo(editor) {
|
||||
var cm = editor.codemirror;
|
||||
cm.undo();
|
||||
cm.focus();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Redo action.
|
||||
*/
|
||||
function redo(editor) {
|
||||
var cm = editor.codemirror;
|
||||
cm.redo();
|
||||
cm.focus();
|
||||
}
|
||||
|
||||
/**
|
||||
* Preview action.
|
||||
*/
|
||||
function togglePreview(editor) {
|
||||
var toolbar = editor.toolbar.preview;
|
||||
var parse = editor.constructor.markdown;
|
||||
var cm = editor.codemirror;
|
||||
var wrapper = cm.getWrapperElement();
|
||||
var preview = wrapper.lastChild;
|
||||
if (!/editor-preview/.test(preview.className)) {
|
||||
preview = document.createElement('div');
|
||||
preview.className = 'editor-preview';
|
||||
wrapper.appendChild(preview);
|
||||
}
|
||||
if (/editor-preview-active/.test(preview.className)) {
|
||||
preview.className = preview.className.replace(
|
||||
/\s*editor-preview-active\s*/g, ''
|
||||
);
|
||||
toolbar.className = toolbar.className.replace(/\s*active\s*/g, '');
|
||||
} else {
|
||||
/* When the preview button is clicked for the first time,
|
||||
* give some time for the transition from editor.css to fire and the view to slide from right to left,
|
||||
* instead of just appearing.
|
||||
*/
|
||||
setTimeout(function() {
|
||||
preview.className += ' editor-preview-active'
|
||||
}, 1);
|
||||
toolbar.className += ' active';
|
||||
}
|
||||
var text = cm.getValue();
|
||||
preview.innerHTML = parse(text);
|
||||
}
|
||||
|
||||
function _replaceSelection(cm, active, start, end) {
|
||||
var text;
|
||||
var startPoint = cm.getCursor('start');
|
||||
var endPoint = cm.getCursor('end');
|
||||
if (active) {
|
||||
text = cm.getLine(startPoint.line);
|
||||
start = text.slice(0, startPoint.ch);
|
||||
end = text.slice(startPoint.ch);
|
||||
cm.replaceRange(start + end, {
|
||||
line: startPoint.line,
|
||||
ch: 0
|
||||
});
|
||||
} else {
|
||||
text = cm.getSelection();
|
||||
cm.replaceSelection(start + text + end);
|
||||
|
||||
startPoint.ch += start.length;
|
||||
endPoint.ch += start.length;
|
||||
}
|
||||
cm.setSelection(startPoint, endPoint);
|
||||
cm.focus();
|
||||
}
|
||||
|
||||
|
||||
function _toggleLine(cm, name) {
|
||||
var stat = getState(cm);
|
||||
var startPoint = cm.getCursor('start');
|
||||
var endPoint = cm.getCursor('end');
|
||||
var repl = {
|
||||
'quote': /^(\s*)\>\s+/,
|
||||
'unordered-list': /^(\s*)(\*|\-|\+)\s+/,
|
||||
'ordered-list': /^(\s*)\d+\.\s+/
|
||||
};
|
||||
var map = {
|
||||
'quote': '> ',
|
||||
'unordered-list': '* ',
|
||||
'ordered-list': '1. '
|
||||
};
|
||||
for (var i = startPoint.line; i <= endPoint.line; i++) {
|
||||
(function(i) {
|
||||
var text = cm.getLine(i);
|
||||
if (stat[name]) {
|
||||
text = text.replace(repl[name], '$1');
|
||||
} else {
|
||||
text = map[name] + text;
|
||||
}
|
||||
cm.replaceRange(text, {
|
||||
line: i,
|
||||
ch: 0
|
||||
}, {
|
||||
line: i,
|
||||
ch: 99999999999999
|
||||
});
|
||||
})(i);
|
||||
}
|
||||
cm.focus();
|
||||
}
|
||||
|
||||
function _toggleBlock(editor, type, start_chars, end_chars) {
|
||||
end_chars = (typeof end_chars === 'undefined') ? start_chars : end_chars;
|
||||
var cm = editor.codemirror;
|
||||
var stat = getState(cm);
|
||||
|
||||
var text;
|
||||
var start = start_chars;
|
||||
var end = end_chars;
|
||||
|
||||
var startPoint = cm.getCursor('start');
|
||||
var endPoint = cm.getCursor('end');
|
||||
|
||||
if (stat[type]) {
|
||||
text = cm.getLine(startPoint.line);
|
||||
start = text.slice(0, startPoint.ch);
|
||||
end = text.slice(startPoint.ch);
|
||||
if (type == "bold") {
|
||||
start = start.replace(/(\*\*|__)(?![\s\S]*(\*\*|__))/, "");
|
||||
end = end.replace(/(\*\*|__)/, "");
|
||||
} else if (type == "italic") {
|
||||
start = start.replace(/(\*|_)(?![\s\S]*(\*|_))/, "");
|
||||
end = end.replace(/(\*|_)/, "");
|
||||
}
|
||||
cm.replaceRange(start + end, {
|
||||
line: startPoint.line,
|
||||
ch: 0
|
||||
}, {
|
||||
line: startPoint.line,
|
||||
ch: 99999999999999
|
||||
});
|
||||
|
||||
startPoint.ch -= 2;
|
||||
endPoint.ch -= 2;
|
||||
} else {
|
||||
text = cm.getSelection();
|
||||
if (type == "bold") {
|
||||
text = text.split("**").join("");
|
||||
text = text.split("__").join("");
|
||||
} else if (type == "italic") {
|
||||
text = text.split("*").join("");
|
||||
text = text.split("_").join("");
|
||||
}
|
||||
cm.replaceSelection(start + text + end);
|
||||
|
||||
startPoint.ch += start_chars.length;
|
||||
endPoint.ch = startPoint.ch + text.length;
|
||||
}
|
||||
|
||||
cm.setSelection(startPoint, endPoint);
|
||||
cm.focus();
|
||||
}
|
||||
|
||||
|
||||
/* The right word count in respect for CJK. */
|
||||
function wordCount(data) {
|
||||
var pattern = /[a-zA-Z0-9_\u0392-\u03c9]+|[\u4E00-\u9FFF\u3400-\u4dbf\uf900-\ufaff\u3040-\u309f\uac00-\ud7af]+/g;
|
||||
var m = data.match(pattern);
|
||||
var count = 0;
|
||||
if (m === null) return count;
|
||||
for (var i = 0; i < m.length; i++) {
|
||||
if (m[i].charCodeAt(0) >= 0x4E00) {
|
||||
count += m[i].length;
|
||||
} else {
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
var toolbar = [{
|
||||
name: 'bold',
|
||||
action: toggleBold,
|
||||
className: "fa fa-bold"
|
||||
}, {
|
||||
name: 'italic',
|
||||
action: toggleItalic,
|
||||
className: "fa fa-italic"
|
||||
},
|
||||
'|',
|
||||
|
||||
{
|
||||
name: 'quote',
|
||||
action: toggleBlockquote,
|
||||
className: "fa fa-quote-left"
|
||||
}, {
|
||||
name: 'unordered-list',
|
||||
action: toggleUnOrderedList,
|
||||
className: "fa fa-list-ul"
|
||||
}, {
|
||||
name: 'ordered-list',
|
||||
action: toggleOrderedList,
|
||||
className: "fa fa-list-ol"
|
||||
},
|
||||
'|',
|
||||
|
||||
{
|
||||
name: 'link',
|
||||
action: drawLink,
|
||||
className: "fa fa-link"
|
||||
}, {
|
||||
name: 'image',
|
||||
action: drawImage,
|
||||
className: "fa fa-picture-o"
|
||||
},
|
||||
'|',
|
||||
|
||||
{
|
||||
name: 'preview',
|
||||
action: togglePreview,
|
||||
className: "fa fa-eye"
|
||||
},
|
||||
];
|
||||
|
||||
/**
|
||||
* Interface of Markdownify.
|
||||
*/
|
||||
function Markdownify(options) {
|
||||
options = options || {};
|
||||
|
||||
if (options.element) {
|
||||
this.element = options.element;
|
||||
}
|
||||
|
||||
options.toolbar = options.toolbar || Markdownify.toolbar;
|
||||
// you can customize toolbar with object
|
||||
// [{name: 'bold', shortcut: 'Ctrl-B', className: 'icon-bold'}]
|
||||
|
||||
if (!options.hasOwnProperty('status')) {
|
||||
options.status = ['lines', 'words', 'cursor'];
|
||||
}
|
||||
|
||||
this.options = options;
|
||||
|
||||
// If user has passed an element, it should auto rendered
|
||||
if (this.element) {
|
||||
this.render();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Default toolbar elements.
|
||||
*/
|
||||
Markdownify.toolbar = toolbar;
|
||||
|
||||
/**
|
||||
* Default markdown render.
|
||||
*/
|
||||
Markdownify.markdown = function(text) {
|
||||
if (window.marked) {
|
||||
// use marked as markdown parser
|
||||
return marked(text);
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Render editor to the given element.
|
||||
*/
|
||||
Markdownify.prototype.render = function(el) {
|
||||
if (!el) {
|
||||
el = this.element || document.getElementsByTagName('textarea')[0];
|
||||
}
|
||||
|
||||
if (this._rendered && this._rendered === el) {
|
||||
// Already rendered.
|
||||
return;
|
||||
}
|
||||
|
||||
this.element = el;
|
||||
var options = this.options;
|
||||
|
||||
var self = this;
|
||||
var keyMaps = {};
|
||||
|
||||
for (var key in shortcuts) {
|
||||
(function(key) {
|
||||
keyMaps[fixShortcut(key)] = function(cm) {
|
||||
shortcuts[key](self);
|
||||
};
|
||||
})(key);
|
||||
}
|
||||
|
||||
keyMaps["Enter"] = "newlineAndIndentContinueMarkdownList";
|
||||
keyMaps['Tab'] = 'tabAndIndentContinueMarkdownList';
|
||||
keyMaps['Shift-Tab'] = 'shiftTabAndIndentContinueMarkdownList';
|
||||
|
||||
this.codemirror = CodeMirror.fromTextArea(el, {
|
||||
mode: 'markdown',
|
||||
theme: 'paper',
|
||||
tabSize: '2',
|
||||
indentWithTabs: true,
|
||||
lineNumbers: false,
|
||||
autofocus: false,
|
||||
extraKeys: keyMaps,
|
||||
lineWrapping: true
|
||||
});
|
||||
|
||||
if (options.toolbar !== false) {
|
||||
this.createToolbar();
|
||||
}
|
||||
if (options.status !== false) {
|
||||
this.createStatusbar();
|
||||
}
|
||||
|
||||
this._rendered = this.element;
|
||||
};
|
||||
|
||||
Markdownify.prototype.createToolbar = function(items) {
|
||||
items = items || this.options.toolbar;
|
||||
|
||||
if (!items || items.length === 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var bar = document.createElement('div');
|
||||
bar.className = 'editor-toolbar';
|
||||
|
||||
var self = this;
|
||||
|
||||
var el;
|
||||
self.toolbar = {};
|
||||
|
||||
for (var i = 0; i < items.length; i++) {
|
||||
(function(item) {
|
||||
var el;
|
||||
if (item.name) {
|
||||
el = createIcon(item.name, item);
|
||||
} else if (item === '|') {
|
||||
el = createSep();
|
||||
} else {
|
||||
el = createIcon(item);
|
||||
}
|
||||
|
||||
// bind events, special for info
|
||||
if (item.action) {
|
||||
if (typeof item.action === 'function') {
|
||||
el.onclick = function(e) {
|
||||
item.action(self);
|
||||
};
|
||||
} else if (typeof item.action === 'string') {
|
||||
el.href = item.action;
|
||||
el.target = '_blank';
|
||||
}
|
||||
}
|
||||
self.toolbar[item.name || item] = el;
|
||||
bar.appendChild(el);
|
||||
})(items[i]);
|
||||
}
|
||||
|
||||
var cm = this.codemirror;
|
||||
cm.on('cursorActivity', function() {
|
||||
var stat = getState(cm);
|
||||
|
||||
for (var key in self.toolbar) {
|
||||
(function(key) {
|
||||
var el = self.toolbar[key];
|
||||
if (stat[key]) {
|
||||
el.className += ' active';
|
||||
} else {
|
||||
el.className = el.className.replace(/\s*active\s*/g, '');
|
||||
}
|
||||
})(key);
|
||||
}
|
||||
});
|
||||
|
||||
var cmWrapper = cm.getWrapperElement();
|
||||
cmWrapper.parentNode.insertBefore(bar, cmWrapper);
|
||||
return bar;
|
||||
};
|
||||
|
||||
Markdownify.prototype.createStatusbar = function(status) {
|
||||
status = status || this.options.status;
|
||||
|
||||
if (!status || status.length === 0) return;
|
||||
|
||||
var bar = document.createElement('div');
|
||||
bar.className = 'editor-statusbar';
|
||||
|
||||
var pos, cm = this.codemirror;
|
||||
for (var i = 0; i < status.length; i++) {
|
||||
(function(name) {
|
||||
var el = document.createElement('span');
|
||||
el.className = name;
|
||||
if (name === 'words') {
|
||||
el.innerHTML = '0';
|
||||
cm.on('update', function() {
|
||||
el.innerHTML = wordCount(cm.getValue());
|
||||
});
|
||||
} else if (name === 'lines') {
|
||||
el.innerHTML = '0';
|
||||
cm.on('update', function() {
|
||||
el.innerHTML = cm.lineCount();
|
||||
});
|
||||
} else if (name === 'cursor') {
|
||||
el.innerHTML = '0:0';
|
||||
cm.on('cursorActivity', function() {
|
||||
pos = cm.getCursor();
|
||||
el.innerHTML = pos.line + ':' + pos.ch;
|
||||
});
|
||||
}
|
||||
bar.appendChild(el);
|
||||
})(status[i]);
|
||||
}
|
||||
var cmWrapper = this.codemirror.getWrapperElement();
|
||||
cmWrapper.parentNode.insertBefore(bar, cmWrapper.nextSibling);
|
||||
return bar;
|
||||
};
|
||||
|
||||
/**
|
||||
* Get or set the text content.
|
||||
*/
|
||||
Markdownify.prototype.value = function(val) {
|
||||
if (val) {
|
||||
this.codemirror.getDoc().setValue(val);
|
||||
return this;
|
||||
} else {
|
||||
return this.codemirror.getValue();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Bind static methods for exports.
|
||||
*/
|
||||
Markdownify.toggleBold = toggleBold;
|
||||
Markdownify.toggleItalic = toggleItalic;
|
||||
Markdownify.toggleBlockquote = toggleBlockquote;
|
||||
Markdownify.toggleUnOrderedList = toggleUnOrderedList;
|
||||
Markdownify.toggleOrderedList = toggleOrderedList;
|
||||
Markdownify.drawLink = drawLink;
|
||||
Markdownify.drawImage = drawImage;
|
||||
Markdownify.undo = undo;
|
||||
Markdownify.redo = redo;
|
||||
Markdownify.togglePreview = togglePreview;
|
||||
Markdownify.toggleFullScreen = toggleFullScreen;
|
||||
|
||||
/**
|
||||
* Bind instance methods for exports.
|
||||
*/
|
||||
Markdownify.prototype.toggleBold = function() {
|
||||
toggleBold(this);
|
||||
};
|
||||
Markdownify.prototype.toggleItalic = function() {
|
||||
toggleItalic(this);
|
||||
};
|
||||
Markdownify.prototype.toggleBlockquote = function() {
|
||||
toggleBlockquote(this);
|
||||
};
|
||||
Markdownify.prototype.toggleUnOrderedList = function() {
|
||||
toggleUnOrderedList(this);
|
||||
};
|
||||
Markdownify.prototype.toggleOrderedList = function() {
|
||||
toggleOrderedList(this);
|
||||
};
|
||||
Markdownify.prototype.drawLink = function() {
|
||||
drawLink(this);
|
||||
};
|
||||
Markdownify.prototype.drawImage = function() {
|
||||
drawImage(this);
|
||||
};
|
||||
Markdownify.prototype.undo = function() {
|
||||
undo(this);
|
||||
};
|
||||
Markdownify.prototype.redo = function() {
|
||||
redo(this);
|
||||
};
|
||||
Markdownify.prototype.togglePreview = function() {
|
||||
togglePreview(this);
|
||||
};
|
||||
Markdownify.prototype.toggleFullScreen = function() {
|
||||
toggleFullScreen(this);
|
||||
};
|
1165
source files/marked.js
Normal file
1165
source files/marked.js
Normal file
File diff suppressed because it is too large
Load Diff
371
source files/theme.css
Normal file
371
source files/theme.css
Normal file
@ -0,0 +1,371 @@
|
||||
/* BASICS */
|
||||
|
||||
.CodeMirror {
|
||||
|
||||
}
|
||||
.CodeMirror-scroll {
|
||||
/* Set scrolling behaviour here */
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
/* PADDING */
|
||||
|
||||
.CodeMirror-lines {
|
||||
padding: 4px 0; /* Vertical padding around content */
|
||||
}
|
||||
.CodeMirror pre {
|
||||
padding: 0 4px; /* Horizontal padding of content */
|
||||
}
|
||||
|
||||
.CodeMirror-scrollbar-filler {
|
||||
background-color: white; /* The little square between H and V scrollbars */
|
||||
}
|
||||
|
||||
/* CURSOR */
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
border-left: 1px solid black;
|
||||
z-index: 3;
|
||||
}
|
||||
/* Shown when moving in bi-directional text */
|
||||
.CodeMirror div.CodeMirror-secondarycursor {
|
||||
border-left: 1px solid silver;
|
||||
}
|
||||
.CodeMirror.cm-keymap-fat-cursor div.CodeMirror-cursor {
|
||||
width: auto;
|
||||
border: 0;
|
||||
background: #7e7;
|
||||
z-index: 1;
|
||||
}
|
||||
/* Can style cursor different in overwrite (non-insert) mode */
|
||||
.CodeMirror div.CodeMirror-cursor.CodeMirror-overwrite {}
|
||||
|
||||
/* DEFAULT THEME */
|
||||
|
||||
.cm-s-paper .cm-keyword {color: #555;}
|
||||
.cm-s-paper .cm-atom {color: #7f8c8d;}
|
||||
.cm-s-paper .cm-number {color: #7f8c8d;}
|
||||
.cm-s-paper .cm-def {color: #00f;}
|
||||
.cm-s-paper .cm-variable {color: black;}
|
||||
.cm-s-paper .cm-variable-2 {color: #555;}
|
||||
.cm-s-paper .cm-variable-3 {color: #085;}
|
||||
.cm-s-paper .cm-property {color: black;}
|
||||
.cm-s-paper .cm-operator {color: black;}
|
||||
.cm-s-paper .cm-comment {color: #959595;}
|
||||
.cm-s-paper .cm-string {color: #7f8c8d;}
|
||||
.cm-s-paper .cm-string-2 {color: #f50;}
|
||||
.cm-s-paper .cm-meta {color: #555;}
|
||||
.cm-s-paper .cm-error {color: #f00;}
|
||||
.cm-s-paper .cm-qualifier {color: #555;}
|
||||
.cm-s-paper .cm-builtin {color: #555;}
|
||||
.cm-s-paper .cm-bracket {color: #997;}
|
||||
.cm-s-paper .cm-tag {color: #7f8c8d;}
|
||||
.cm-s-paper .cm-attribute {color: #7f8c8d;}
|
||||
.cm-s-paper .cm-header {color: #000;}
|
||||
.cm-s-paper .cm-quote {color: #888;}
|
||||
.cm-s-paper .cm-hr {color: #999;}
|
||||
.cm-s-paper .cm-link {color: #7f8c8d;}
|
||||
|
||||
.cm-negative {color: #d44;}
|
||||
.cm-positive {color: #292;}
|
||||
.cm-header, .cm-strong {font-weight: bold;}
|
||||
.cm-em {font-style: italic;}
|
||||
.cm-link {text-decoration: underline;}
|
||||
|
||||
.cm-invalidchar {color: #f00;}
|
||||
|
||||
div.CodeMirror span.CodeMirror-matchingbracket {color: #0f0;}
|
||||
div.CodeMirror span.CodeMirror-nonmatchingbracket {color: #f22;}
|
||||
|
||||
|
||||
/* STOP */
|
||||
|
||||
/* The rest of this file contains styles related to the mechanics of
|
||||
the editor. You probably shouldn't touch them. */
|
||||
|
||||
.CodeMirror {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.CodeMirror-scroll {
|
||||
/* 30px is the magic margin used to hide the element's real scrollbars */
|
||||
/* See overflow: hidden in .CodeMirror, and the paddings in .CodeMirror-sizer */
|
||||
margin-bottom: -30px; margin-right: -30px;
|
||||
padding-bottom: 30px; padding-right: 30px;
|
||||
height: 100%;
|
||||
outline: none; /* Prevent dragging from highlighting the element */
|
||||
position: relative;
|
||||
}
|
||||
.CodeMirror-sizer {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* The fake, visible scrollbars. Used to force redraw during scrolling
|
||||
before actuall scrolling happens, thus preventing shaking and
|
||||
flickering artifacts. */
|
||||
.CodeMirror-vscrollbar, .CodeMirror-hscrollbar, .CodeMirror-scrollbar-filler {
|
||||
position: absolute;
|
||||
z-index: 6;
|
||||
display: none;
|
||||
}
|
||||
.CodeMirror-vscrollbar {
|
||||
right: 0; top: 0;
|
||||
overflow-x: hidden;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
.CodeMirror-hscrollbar {
|
||||
bottom: 0; left: 0;
|
||||
overflow-y: hidden;
|
||||
overflow-x: scroll;
|
||||
}
|
||||
.CodeMirror-scrollbar-filler {
|
||||
right: 0; bottom: 0;
|
||||
z-index: 6;
|
||||
}
|
||||
|
||||
.CodeMirror-lines {
|
||||
cursor: text;
|
||||
}
|
||||
.CodeMirror pre {
|
||||
/* Reset some styles that the rest of the page might have set */
|
||||
-moz-border-radius: 0; -webkit-border-radius: 0; -o-border-radius: 0; border-radius: 0;
|
||||
border-width: 0;
|
||||
background: transparent;
|
||||
font-family: inherit;
|
||||
font-size: inherit;
|
||||
margin: 0;
|
||||
white-space: pre-wrap;
|
||||
word-wrap: normal;
|
||||
line-height: inherit;
|
||||
color: inherit;
|
||||
z-index: 2;
|
||||
position: relative;
|
||||
overflow: visible;
|
||||
}
|
||||
.CodeMirror-wrap pre {
|
||||
word-wrap: break-word;
|
||||
white-space: pre-wrap;
|
||||
word-break: normal;
|
||||
}
|
||||
.CodeMirror-linebackground {
|
||||
position: absolute;
|
||||
left: 0; right: 0; top: 0; bottom: 0;
|
||||
z-index: 0;
|
||||
}
|
||||
|
||||
.CodeMirror-linewidget {
|
||||
position: relative;
|
||||
z-index: 2;
|
||||
overflow: auto;
|
||||
}
|
||||
|
||||
.CodeMirror-widget {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.CodeMirror-wrap .CodeMirror-scroll {
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.CodeMirror-measure {
|
||||
position: absolute;
|
||||
width: 100%; height: 0px;
|
||||
overflow: hidden;
|
||||
visibility: hidden;
|
||||
}
|
||||
.CodeMirror-measure pre { position: static; }
|
||||
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
position: absolute;
|
||||
visibility: hidden;
|
||||
border-right: none;
|
||||
width: 0;
|
||||
}
|
||||
.CodeMirror-focused div.CodeMirror-cursor {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.CodeMirror-selected { background: #d9d9d9; }
|
||||
.CodeMirror-focused .CodeMirror-selected { background: #BDC3C7; }
|
||||
|
||||
.cm-searching {
|
||||
background: #ffa;
|
||||
background: rgba(255, 255, 0, .4);
|
||||
}
|
||||
|
||||
/* IE7 hack to prevent it from returning funny offsetTops on the spans */
|
||||
.CodeMirror span { *vertical-align: text-bottom; }
|
||||
|
||||
@media print {
|
||||
/* Hide the cursor when printing */
|
||||
.CodeMirror div.CodeMirror-cursor {
|
||||
visibility: hidden;
|
||||
}
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-header-1{
|
||||
font-size:200%;
|
||||
line-height:200%;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-header-2{
|
||||
font-size:160%;
|
||||
line-height:160%;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-header-3{
|
||||
font-size:125%;
|
||||
line-height:125%;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-header-4{
|
||||
font-size:110%;
|
||||
line-height:110%;
|
||||
}
|
||||
|
||||
.CodeMirror .CodeMirror-code .cm-comment{
|
||||
background:#eee;
|
||||
border-radius:2px;
|
||||
}
|
||||
|
||||
.CodeMirror {
|
||||
height:auto;
|
||||
min-height: 300px;
|
||||
border:1px solid #ddd;
|
||||
border-bottom-left-radius:4px;
|
||||
border-bottom-right-radius:4px;
|
||||
padding:10px;
|
||||
}
|
||||
:-webkit-full-screen {
|
||||
background: #f9f9f5;
|
||||
padding: 0.5em 1em;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
:-moz-full-screen {
|
||||
padding: 0.5em 1em;
|
||||
background: #f9f9f5;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
}
|
||||
.editor-wrapper {
|
||||
font: 16px/1.62 "Helvetica Neue", "Xin Gothic", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft YaHei", sans-serif;
|
||||
color: #2c3e50;
|
||||
}
|
||||
/* this is the title */
|
||||
.editor-wrapper input.title {
|
||||
font: 18px "Helvetica Neue", "Xin Gothic", "Hiragino Sans GB", "WenQuanYi Micro Hei", "Microsoft YaHei", sans-serif;
|
||||
background: transparent;
|
||||
padding: 4px;
|
||||
width: 100%;
|
||||
border: none;
|
||||
outline: none;
|
||||
opacity: 0.6;
|
||||
}
|
||||
.editor-toolbar {
|
||||
position: relative;
|
||||
opacity: 0.6;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
-o-user-select: none;
|
||||
user-select: none;
|
||||
padding:0 10px;
|
||||
border-top:1px solid #bbb;
|
||||
border-left:1px solid #bbb;
|
||||
border-right:1px solid #bbb;
|
||||
border-top-left-radius:4px;
|
||||
border-top-right-radius:4px;
|
||||
}
|
||||
.editor-toolbar:before, .editor-toolbar:after {
|
||||
display: block;
|
||||
content: ' ';
|
||||
height: 1px;
|
||||
}
|
||||
.editor-toolbar:before {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
.editor-toolbar:after {
|
||||
margin-top: 8px;
|
||||
}
|
||||
.editor-wrapper input.title:hover, .editor-wrapper input.title:focus, .editor-toolbar:hover {
|
||||
opacity: 0.8;
|
||||
}
|
||||
.editor-toolbar a {
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
text-decoration: none !important;
|
||||
color: #2c3e50 !important;
|
||||
width:30px;
|
||||
height:30px;
|
||||
margin:0;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
}
|
||||
.editor-toolbar a:hover, .editor-toolbar a.active {
|
||||
background: #fcfcfc;
|
||||
border-color: #95a5a6;
|
||||
}
|
||||
.editor-toolbar a:before {
|
||||
line-height:30px;
|
||||
}
|
||||
.editor-toolbar i.separator {
|
||||
display: inline-block;
|
||||
width: 0;
|
||||
border-left: 1px solid #d9d9d9;
|
||||
border-right: 1px solid white;
|
||||
color: transparent;
|
||||
text-indent: -10px;
|
||||
margin: 0 6px;
|
||||
}
|
||||
.editor-toolbar a.icon-fullscreen {
|
||||
position: absolute;
|
||||
right:10px;
|
||||
}
|
||||
.editor-statusbar {
|
||||
padding: 8px 10px;
|
||||
font-size: 12px;
|
||||
color: #959694;
|
||||
text-align: right;
|
||||
}
|
||||
.editor-statusbar span {
|
||||
display: inline-block;
|
||||
min-width: 4em;
|
||||
margin-left: 1em;
|
||||
}
|
||||
.editor-statusbar .lines:before {
|
||||
content: 'lines: ';
|
||||
}
|
||||
.editor-statusbar .words:before {
|
||||
content: 'words: ';
|
||||
}
|
||||
.editor-preview {
|
||||
padding:10px;
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
background: #fff;
|
||||
z-index: 9999;
|
||||
overflow: auto;
|
||||
display:none;
|
||||
|
||||
}
|
||||
.editor-preview-active {
|
||||
display:block;
|
||||
}
|
||||
.editor-preview > p {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.editor-preview pre{
|
||||
background:#eee;
|
||||
margin-bottom:10px;
|
||||
}
|
||||
|
||||
.editor-preview table td, .editor-preview table th {
|
||||
border: solid 1px #bbb;
|
||||
padding: 5px;
|
||||
}
|
@ -1,403 +0,0 @@
|
||||
.EasyMDEContainer {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.CodeMirror-rtl pre {
|
||||
direction: rtl;
|
||||
}
|
||||
|
||||
.EasyMDEContainer.sided--no-fullscreen {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
.EasyMDEContainer .CodeMirror {
|
||||
box-sizing: border-box;
|
||||
height: auto;
|
||||
border: 1px solid #ced4da;
|
||||
border-bottom-left-radius: 4px;
|
||||
border-bottom-right-radius: 4px;
|
||||
padding: 10px;
|
||||
font: inherit;
|
||||
z-index: 0;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.EasyMDEContainer .CodeMirror-scroll {
|
||||
cursor: text;
|
||||
}
|
||||
|
||||
.EasyMDEContainer .CodeMirror-fullscreen {
|
||||
background: #fff;
|
||||
position: fixed !important;
|
||||
top: 50px;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
height: auto;
|
||||
z-index: 8;
|
||||
border-right: none !important;
|
||||
border-bottom-right-radius: 0 !important;
|
||||
}
|
||||
|
||||
.EasyMDEContainer .CodeMirror-sided {
|
||||
width: 50% !important;
|
||||
}
|
||||
|
||||
.EasyMDEContainer.sided--no-fullscreen .CodeMirror-sided {
|
||||
border-right: none !important;
|
||||
border-bottom-right-radius: 0;
|
||||
position: relative;
|
||||
flex: 1 1 auto;
|
||||
}
|
||||
|
||||
.EasyMDEContainer .CodeMirror-placeholder {
|
||||
opacity: .5;
|
||||
}
|
||||
|
||||
.EasyMDEContainer .CodeMirror-focused .CodeMirror-selected {
|
||||
background: #d9d9d9;
|
||||
}
|
||||
|
||||
.editor-toolbar {
|
||||
position: relative;
|
||||
-webkit-user-select: none;
|
||||
-moz-user-select: none;
|
||||
-ms-user-select: none;
|
||||
-o-user-select: none;
|
||||
user-select: none;
|
||||
padding: 9px 10px;
|
||||
border-top: 1px solid #ced4da;
|
||||
border-left: 1px solid #ced4da;
|
||||
border-right: 1px solid #ced4da;
|
||||
border-top-left-radius: 4px;
|
||||
border-top-right-radius: 4px;
|
||||
}
|
||||
|
||||
.editor-toolbar.fullscreen {
|
||||
width: 100%;
|
||||
height: 50px;
|
||||
padding-top: 10px;
|
||||
padding-bottom: 10px;
|
||||
box-sizing: border-box;
|
||||
background: #fff;
|
||||
border: 0;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
opacity: 1;
|
||||
z-index: 9;
|
||||
}
|
||||
|
||||
.editor-toolbar.fullscreen::before {
|
||||
width: 20px;
|
||||
height: 50px;
|
||||
background: -moz-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||
background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 1)), color-stop(100%, rgba(255, 255, 255, 0)));
|
||||
background: -webkit-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||
background: -o-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||
background: -ms-linear-gradient(left, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||
background: linear-gradient(to right, rgba(255, 255, 255, 1) 0%, rgba(255, 255, 255, 0) 100%);
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.editor-toolbar.fullscreen::after {
|
||||
width: 20px;
|
||||
height: 50px;
|
||||
background: -moz-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||
background: -webkit-gradient(linear, left top, right top, color-stop(0%, rgba(255, 255, 255, 0)), color-stop(100%, rgba(255, 255, 255, 1)));
|
||||
background: -webkit-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||
background: -o-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||
background: -ms-linear-gradient(left, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||
background: linear-gradient(to right, rgba(255, 255, 255, 0) 0%, rgba(255, 255, 255, 1) 100%);
|
||||
position: fixed;
|
||||
top: 0;
|
||||
right: 0;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.EasyMDEContainer.sided--no-fullscreen .editor-toolbar {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.editor-toolbar button, .editor-toolbar .easymde-dropdown {
|
||||
background: transparent;
|
||||
display: inline-block;
|
||||
text-align: center;
|
||||
text-decoration: none !important;
|
||||
height: 30px;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
border: 1px solid transparent;
|
||||
border-radius: 3px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.editor-toolbar button {
|
||||
font-weight: bold;
|
||||
min-width: 30px;
|
||||
padding: 0 6px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.editor-toolbar button.active,
|
||||
.editor-toolbar button:hover {
|
||||
background: #fcfcfc;
|
||||
border-color: #95a5a6;
|
||||
}
|
||||
|
||||
.editor-toolbar i.separator {
|
||||
display: inline-block;
|
||||
width: 0;
|
||||
border-left: 1px solid #d9d9d9;
|
||||
border-right: 1px solid #fff;
|
||||
color: transparent;
|
||||
text-indent: -10px;
|
||||
margin: 0 6px;
|
||||
}
|
||||
|
||||
.editor-toolbar button:after {
|
||||
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
|
||||
font-size: 65%;
|
||||
vertical-align: text-bottom;
|
||||
position: relative;
|
||||
top: 2px;
|
||||
}
|
||||
|
||||
.editor-toolbar button.heading-1:after {
|
||||
content: "1";
|
||||
}
|
||||
|
||||
.editor-toolbar button.heading-2:after {
|
||||
content: "2";
|
||||
}
|
||||
|
||||
.editor-toolbar button.heading-3:after {
|
||||
content: "3";
|
||||
}
|
||||
|
||||
.editor-toolbar button.heading-bigger:after {
|
||||
content: "▲";
|
||||
}
|
||||
|
||||
.editor-toolbar button.heading-smaller:after {
|
||||
content: "▼";
|
||||
}
|
||||
|
||||
.editor-toolbar.disabled-for-preview button:not(.no-disable) {
|
||||
opacity: .6;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
@media only screen and (max-width: 700px) {
|
||||
.editor-toolbar i.no-mobile {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
.editor-statusbar {
|
||||
padding: 8px 10px;
|
||||
font-size: 12px;
|
||||
color: #959694;
|
||||
text-align: right;
|
||||
}
|
||||
|
||||
.EasyMDEContainer.sided--no-fullscreen .editor-statusbar {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.editor-statusbar span {
|
||||
display: inline-block;
|
||||
min-width: 4em;
|
||||
margin-left: 1em;
|
||||
}
|
||||
|
||||
.editor-statusbar .lines:before {
|
||||
content: 'lines: '
|
||||
}
|
||||
|
||||
.editor-statusbar .words:before {
|
||||
content: 'words: '
|
||||
}
|
||||
|
||||
.editor-statusbar .characters:before {
|
||||
content: 'characters: '
|
||||
}
|
||||
|
||||
.editor-preview-full {
|
||||
position: absolute;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
top: 0;
|
||||
left: 0;
|
||||
z-index: 7;
|
||||
overflow: auto;
|
||||
display: none;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.editor-preview-side {
|
||||
position: fixed;
|
||||
bottom: 0;
|
||||
width: 50%;
|
||||
top: 50px;
|
||||
right: 0;
|
||||
z-index: 9;
|
||||
overflow: auto;
|
||||
display: none;
|
||||
box-sizing: border-box;
|
||||
border: 1px solid #ddd;
|
||||
word-wrap: break-word;
|
||||
}
|
||||
|
||||
.editor-preview-active-side {
|
||||
display: block
|
||||
}
|
||||
|
||||
.EasyMDEContainer.sided--no-fullscreen .editor-preview-active-side {
|
||||
flex: 1 1 auto;
|
||||
height: auto;
|
||||
position: static;
|
||||
}
|
||||
|
||||
.editor-preview-active {
|
||||
display: block
|
||||
}
|
||||
|
||||
.editor-preview {
|
||||
padding: 10px;
|
||||
background: #fafafa;
|
||||
}
|
||||
|
||||
.editor-preview > p {
|
||||
margin-top: 0
|
||||
}
|
||||
|
||||
.editor-preview pre {
|
||||
background: #eee;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.editor-preview table td,
|
||||
.editor-preview table th {
|
||||
border: 1px solid #ddd;
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
.cm-s-easymde .cm-tag {
|
||||
color: #63a35c;
|
||||
}
|
||||
|
||||
.cm-s-easymde .cm-attribute {
|
||||
color: #795da3;
|
||||
}
|
||||
|
||||
.cm-s-easymde .cm-string {
|
||||
color: #183691;
|
||||
}
|
||||
|
||||
.cm-s-easymde .cm-header-1 {
|
||||
font-size: calc(1.375rem + 1.5vw);
|
||||
}
|
||||
|
||||
.cm-s-easymde .cm-header-2 {
|
||||
font-size: calc(1.325rem + .9vw);
|
||||
}
|
||||
|
||||
.cm-s-easymde .cm-header-3 {
|
||||
font-size: calc(1.3rem + .6vw);
|
||||
}
|
||||
|
||||
.cm-s-easymde .cm-header-4 {
|
||||
font-size: calc(1.275rem + .3vw);
|
||||
}
|
||||
|
||||
.cm-s-easymde .cm-header-5 {
|
||||
font-size: 1.25rem;
|
||||
}
|
||||
|
||||
.cm-s-easymde .cm-header-6 {
|
||||
font-size: 1rem;
|
||||
}
|
||||
|
||||
.cm-s-easymde .cm-header-1,
|
||||
.cm-s-easymde .cm-header-2,
|
||||
.cm-s-easymde .cm-header-3,
|
||||
.cm-s-easymde .cm-header-4,
|
||||
.cm-s-easymde .cm-header-5,
|
||||
.cm-s-easymde .cm-header-6 {
|
||||
margin-bottom: .5rem;
|
||||
line-height: 1.2;
|
||||
}
|
||||
|
||||
.cm-s-easymde .cm-comment {
|
||||
background: rgba(0, 0, 0, .05);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.cm-s-easymde .cm-link {
|
||||
color: #7f8c8d;
|
||||
}
|
||||
|
||||
.cm-s-easymde .cm-url {
|
||||
color: #aab2b3;
|
||||
}
|
||||
|
||||
.cm-s-easymde .cm-quote {
|
||||
color: #7f8c8d;
|
||||
font-style: italic;
|
||||
}
|
||||
|
||||
.editor-toolbar .easymde-dropdown {
|
||||
position: relative;
|
||||
background: linear-gradient(to bottom right, #fff 0%, #fff 84%, #333 50%, #333 100%);
|
||||
border-radius: 0;
|
||||
border: 1px solid #fff;
|
||||
}
|
||||
|
||||
.editor-toolbar .easymde-dropdown:hover {
|
||||
background: linear-gradient(to bottom right, #fff 0%, #fff 84%, #333 50%, #333 100%);
|
||||
}
|
||||
|
||||
.easymde-dropdown-content {
|
||||
display: block;
|
||||
visibility: hidden;
|
||||
position: absolute;
|
||||
background-color: #f9f9f9;
|
||||
box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.2);
|
||||
padding: 8px;
|
||||
z-index: 2;
|
||||
top: 30px;
|
||||
}
|
||||
|
||||
.easymde-dropdown:active .easymde-dropdown-content,
|
||||
.easymde-dropdown:focus .easymde-dropdown-content,
|
||||
.easymde-dropdown:focus-within .easymde-dropdown-content {
|
||||
visibility: visible;
|
||||
}
|
||||
|
||||
.easymde-dropdown-content button {
|
||||
display: block;
|
||||
}
|
||||
|
||||
span[data-img-src]::after {
|
||||
content: '';
|
||||
/*noinspection CssUnresolvedCustomProperty, added through JS*/
|
||||
background-image: var(--bg-image);
|
||||
display: block;
|
||||
max-height: 100%;
|
||||
max-width: 100%;
|
||||
background-size: contain;
|
||||
height: 0;
|
||||
/*noinspection CssUnresolvedCustomProperty, added through JS*/
|
||||
padding-top: var(--height);
|
||||
/*noinspection CssUnresolvedCustomProperty, added through JS*/
|
||||
width: var(--width);
|
||||
background-repeat: no-repeat;
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
||||
// Distributed under an MIT license: http://codemirror.net/LICENSE
|
||||
|
||||
var CodeMirror = require('codemirror');
|
||||
|
||||
CodeMirror.commands.tabAndIndentMarkdownList = function (cm) {
|
||||
var ranges = cm.listSelections();
|
||||
var pos = ranges[0].head;
|
||||
var eolState = cm.getStateAfter(pos.line);
|
||||
var inList = eolState.list !== false;
|
||||
|
||||
if (inList) {
|
||||
cm.execCommand('indentMore');
|
||||
return;
|
||||
}
|
||||
|
||||
if (cm.options.indentWithTabs) {
|
||||
cm.execCommand('insertTab');
|
||||
} else {
|
||||
var spaces = Array(cm.options.tabSize + 1).join(' ');
|
||||
cm.replaceSelection(spaces);
|
||||
}
|
||||
};
|
||||
|
||||
CodeMirror.commands.shiftTabAndUnindentMarkdownList = function (cm) {
|
||||
var ranges = cm.listSelections();
|
||||
var pos = ranges[0].head;
|
||||
var eolState = cm.getStateAfter(pos.line);
|
||||
var inList = eolState.list !== false;
|
||||
|
||||
if (inList) {
|
||||
cm.execCommand('indentLess');
|
||||
return;
|
||||
}
|
||||
|
||||
if (cm.options.indentWithTabs) {
|
||||
cm.execCommand('insertTab');
|
||||
} else {
|
||||
var spaces = Array(cm.options.tabSize + 1).join(' ');
|
||||
cm.replaceSelection(spaces);
|
||||
}
|
||||
};
|
3052
src/js/easymde.js
3052
src/js/easymde.js
File diff suppressed because it is too large
Load Diff
@ -1,238 +0,0 @@
|
||||
// Create new instance
|
||||
import EasyMDE = require('./easymde');
|
||||
|
||||
const editor = new EasyMDE({
|
||||
autoDownloadFontAwesome: false,
|
||||
element: document.getElementById('mdEditor')!,
|
||||
hideIcons: ['side-by-side', 'fullscreen'],
|
||||
inputStyle: 'textarea',
|
||||
shortcuts: {
|
||||
drawTable: 'Cmd-Alt-T',
|
||||
toggleFullScreen: null,
|
||||
},
|
||||
previewClass: 'my-custom-class',
|
||||
spellChecker: false,
|
||||
onToggleFullScreen: (full: boolean) => {
|
||||
console.log('FullscreenToggled', full);
|
||||
},
|
||||
theme: 'someOtherTheme',
|
||||
minHeight: '200px',
|
||||
});
|
||||
|
||||
// Editor functions
|
||||
const value = editor.value() as string;
|
||||
editor.value(value.toUpperCase());
|
||||
|
||||
const sbs = editor.isSideBySideActive() as boolean;
|
||||
const fullscreen = editor.isFullscreenActive() as boolean;
|
||||
|
||||
// Access to codemirror object
|
||||
editor.codemirror.setOption('readOnly', true);
|
||||
|
||||
// Static properties
|
||||
EasyMDE.toggleItalic = (editor: EasyMDE) => {
|
||||
console.log('SomeButtonOverride');
|
||||
};
|
||||
|
||||
const editor2 = new EasyMDE({
|
||||
autoDownloadFontAwesome: undefined,
|
||||
previewClass: ['my-custom-class', 'some-other-class'],
|
||||
nativeSpellcheck: true,
|
||||
unorderedListStyle: '-',
|
||||
inputStyle: 'contenteditable',
|
||||
toolbar: [
|
||||
{
|
||||
name: 'bold',
|
||||
action: EasyMDE.toggleBold,
|
||||
className: 'fa fas fa-bolt',
|
||||
title: 'Bold',
|
||||
},
|
||||
'|',
|
||||
'undo',
|
||||
{
|
||||
name: 'alert',
|
||||
action: (editor: EasyMDE) => {
|
||||
alert('This is from a custom button action!');
|
||||
// Custom functions have access to the `editor` instance.
|
||||
},
|
||||
className: 'fa fas fa-star',
|
||||
title: 'A Custom Button',
|
||||
noDisable: undefined,
|
||||
noMobile: false,
|
||||
attributes: {
|
||||
'data-custom': 'attribute',
|
||||
}
|
||||
},
|
||||
'|',
|
||||
{
|
||||
name: 'link',
|
||||
action: 'https://github.com/Ionaru/easy-markdown-editor',
|
||||
className: 'fa fab fa-github',
|
||||
title: 'A Custom Link',
|
||||
noDisable: true,
|
||||
noMobile: true,
|
||||
},
|
||||
'preview',
|
||||
{
|
||||
name: 'links',
|
||||
className: 'fa fas fa-arrow-down',
|
||||
title: 'A Custom Link',
|
||||
children: [
|
||||
{
|
||||
name: 'link',
|
||||
action: 'https://github.com/Ionaru/easy-markdown-editor',
|
||||
className: 'fa fab fa-github',
|
||||
title: 'A Custom Link',
|
||||
noDisable: true,
|
||||
noMobile: true,
|
||||
},
|
||||
'preview',
|
||||
{
|
||||
name: 'bold',
|
||||
action: EasyMDE.toggleBold,
|
||||
className: 'fa fas fa-bold',
|
||||
title: 'Bold',
|
||||
attributes: {
|
||||
'data-custom': 'some value',
|
||||
'data-custom-2': 'another value',
|
||||
}
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
editor2.clearAutosavedValue();
|
||||
editor2.updateStatusBar('upload-image', 'Drag & drop images!');
|
||||
|
||||
EasyMDE.togglePreview(editor2);
|
||||
EasyMDE.toggleSideBySide(editor2);
|
||||
|
||||
const editorImages = new EasyMDE({
|
||||
uploadImage: true,
|
||||
previewImagesInEditor: false,
|
||||
imageAccept: 'image/png, image/bmp',
|
||||
imageCSRFToken: undefined,
|
||||
unorderedListStyle: '+',
|
||||
imageMaxSize: 10485760,
|
||||
imageUploadEndpoint: 'https://my.domain/image-upload/',
|
||||
imageTexts: {
|
||||
sbInit: 'Drag & drop images!',
|
||||
sbOnDragEnter: 'Let it go, let it go',
|
||||
sbOnDrop: 'Uploading...',
|
||||
sbProgress: 'Uploading... (#progress#)',
|
||||
sbOnUploaded: 'Upload complete!',
|
||||
sizeUnits: 'b,Kb,Mb',
|
||||
},
|
||||
errorMessages: {
|
||||
noFileGiven: 'Please select a file',
|
||||
typeNotAllowed: 'This file type is not allowed!',
|
||||
fileTooLarge: 'Image too big',
|
||||
importError: 'Something went oops!',
|
||||
},
|
||||
errorCallback: errorMessage => {
|
||||
console.error(errorMessage);
|
||||
},
|
||||
});
|
||||
|
||||
const editorImagesCustom = new EasyMDE({
|
||||
uploadImage: true,
|
||||
imageAccept: 'image/png, image/bmp',
|
||||
imageCSRFToken: undefined,
|
||||
imageMaxSize: 10485760,
|
||||
imageUploadFunction: (file: File, onSuccess, onError) => {
|
||||
console.log(file);
|
||||
onSuccess('http://image.url/9.png');
|
||||
onError('Failed because reasons.');
|
||||
},
|
||||
imageTexts: {
|
||||
sbInit: 'Drag & drop images!',
|
||||
sbOnDragEnter: 'Let it go, let it go',
|
||||
sbOnDrop: 'Uploading...',
|
||||
sbProgress: 'Uploading... (#progress#)',
|
||||
sbOnUploaded: 'Upload complete!',
|
||||
sizeUnits: 'b,Kb,Mb',
|
||||
},
|
||||
errorMessages: {
|
||||
noFileGiven: 'Please select a file',
|
||||
typeNotAllowed: 'This file type is not allowed!',
|
||||
fileTooLarge: 'Image too big',
|
||||
importError: 'Something went oops!',
|
||||
},
|
||||
errorCallback: errorMessage => {
|
||||
console.error(errorMessage);
|
||||
},
|
||||
renderingConfig: {
|
||||
codeSyntaxHighlighting: true,
|
||||
markedOptions: {
|
||||
silent: true,
|
||||
highlight(code: string, lang: string, callback?: (error: (any | undefined), code: string) => void): string {
|
||||
return 'something';
|
||||
},
|
||||
},
|
||||
},
|
||||
promptTexts: {
|
||||
image: 'Insert URL',
|
||||
},
|
||||
syncSideBySidePreviewScroll: true,
|
||||
});
|
||||
|
||||
new EasyMDE({
|
||||
toolbarButtonClassPrefix: 'mde',
|
||||
sideBySideFullscreen: true,
|
||||
lineNumbers: false,
|
||||
unorderedListStyle: '*',
|
||||
autosave: {
|
||||
enabled: true,
|
||||
delay: 2000,
|
||||
submit_delay: 10000,
|
||||
uniqueId: 'abc',
|
||||
timeFormat: {
|
||||
locale: 'en-GB',
|
||||
format: {
|
||||
month: 'long',
|
||||
},
|
||||
},
|
||||
text: 'Stored: ',
|
||||
},
|
||||
});
|
||||
|
||||
new EasyMDE({
|
||||
sideBySideFullscreen: false,
|
||||
lineNumbers: true,
|
||||
maxHeight: '500px',
|
||||
toolbar: [
|
||||
'bold',
|
||||
'italic',
|
||||
'heading',
|
||||
'|',
|
||||
'quote',
|
||||
'unordered-list',
|
||||
'ordered-list',
|
||||
'table',
|
||||
'upload-image',
|
||||
'|',
|
||||
'link',
|
||||
],
|
||||
});
|
||||
|
||||
new EasyMDE({
|
||||
direction: 'ltr',
|
||||
});
|
||||
|
||||
new EasyMDE({
|
||||
direction: 'rtl',
|
||||
});
|
||||
|
||||
new EasyMDE({
|
||||
previewRender: (plainText: string) => {
|
||||
return '<pre>' + plainText + '</pre>';
|
||||
}
|
||||
});
|
||||
|
||||
new EasyMDE({
|
||||
previewRender: (plainText: string, preview) => {
|
||||
preview.innerHTML = '<pre>' + plainText + '</pre>';
|
||||
return null;
|
||||
}
|
||||
});
|
294
types/easymde.d.ts
vendored
294
types/easymde.d.ts
vendored
@ -1,294 +0,0 @@
|
||||
// This file is based on https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/simplemde/index.d.ts,
|
||||
// which is written by Scalesoft <https://github.com/Scalesoft> and licensed under the MIT license:
|
||||
//
|
||||
// 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:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included in all
|
||||
// copies or substantial portions of the Software.
|
||||
//
|
||||
// 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.
|
||||
|
||||
/// <reference types="codemirror"/>
|
||||
|
||||
import { marked } from 'marked';
|
||||
|
||||
interface ArrayOneOrMore<T> extends Array<T> {
|
||||
0: T;
|
||||
}
|
||||
|
||||
type ToolbarButton =
|
||||
'bold'
|
||||
| 'italic'
|
||||
| 'quote'
|
||||
| 'unordered-list'
|
||||
| 'ordered-list'
|
||||
| 'link'
|
||||
| 'image'
|
||||
| 'upload-image'
|
||||
| 'strikethrough'
|
||||
| 'code'
|
||||
| 'table'
|
||||
| 'redo'
|
||||
| 'heading'
|
||||
| 'undo'
|
||||
| 'heading-bigger'
|
||||
| 'heading-smaller'
|
||||
| 'heading-1'
|
||||
| 'heading-2'
|
||||
| 'heading-3'
|
||||
| 'clean-block'
|
||||
| 'horizontal-rule'
|
||||
| 'preview'
|
||||
| 'side-by-side'
|
||||
| 'fullscreen'
|
||||
| 'guide';
|
||||
|
||||
declare namespace EasyMDE {
|
||||
|
||||
interface TimeFormatOptions {
|
||||
locale?: string | string[];
|
||||
format?: Intl.DateTimeFormatOptions;
|
||||
}
|
||||
|
||||
interface AutoSaveOptions {
|
||||
enabled?: boolean;
|
||||
delay?: number;
|
||||
submit_delay?: number;
|
||||
uniqueId: string;
|
||||
timeFormat?: TimeFormatOptions;
|
||||
text?: string;
|
||||
}
|
||||
|
||||
interface BlockStyleOptions {
|
||||
bold?: string;
|
||||
code?: string;
|
||||
italic?: string;
|
||||
}
|
||||
|
||||
interface CustomAttributes {
|
||||
[key: string]: string;
|
||||
}
|
||||
|
||||
interface InsertTextOptions {
|
||||
horizontalRule?: ReadonlyArray<string>;
|
||||
image?: ReadonlyArray<string>;
|
||||
link?: ReadonlyArray<string>;
|
||||
table?: ReadonlyArray<string>;
|
||||
}
|
||||
|
||||
interface ParsingOptions {
|
||||
allowAtxHeaderWithoutSpace?: boolean;
|
||||
strikethrough?: boolean;
|
||||
underscoresBreakWords?: boolean;
|
||||
}
|
||||
|
||||
interface PromptTexts {
|
||||
image?: string;
|
||||
link?: string;
|
||||
}
|
||||
|
||||
interface RenderingOptions {
|
||||
codeSyntaxHighlighting?: boolean;
|
||||
hljs?: any;
|
||||
markedOptions?: marked.MarkedExtension;
|
||||
sanitizerFunction?: (html: string) => string;
|
||||
singleLineBreaks?: boolean;
|
||||
}
|
||||
|
||||
interface Shortcuts {
|
||||
[action: string]: string | undefined | null;
|
||||
|
||||
toggleBlockquote?: string | null;
|
||||
toggleBold?: string | null;
|
||||
cleanBlock?: string | null;
|
||||
toggleHeadingSmaller?: string | null;
|
||||
toggleItalic?: string | null;
|
||||
drawLink?: string | null;
|
||||
toggleUnorderedList?: string | null;
|
||||
togglePreview?: string | null;
|
||||
toggleCodeBlock?: string | null;
|
||||
drawImage?: string | null;
|
||||
toggleOrderedList?: string | null;
|
||||
toggleHeadingBigger?: string | null;
|
||||
toggleSideBySide?: string | null;
|
||||
toggleFullScreen?: string | null;
|
||||
}
|
||||
|
||||
interface StatusBarItem {
|
||||
className: string;
|
||||
defaultValue: (element: HTMLElement) => void;
|
||||
onUpdate: (element: HTMLElement) => void;
|
||||
}
|
||||
|
||||
interface ToolbarDropdownIcon {
|
||||
name: string;
|
||||
children: ArrayOneOrMore<ToolbarIcon | ToolbarButton>;
|
||||
className: string;
|
||||
title: string;
|
||||
noDisable?: boolean;
|
||||
noMobile?: boolean;
|
||||
}
|
||||
|
||||
interface ToolbarIcon {
|
||||
name: string;
|
||||
action: string | ((editor: EasyMDE) => void);
|
||||
className: string;
|
||||
title: string;
|
||||
noDisable?: boolean;
|
||||
noMobile?: boolean;
|
||||
icon?: string;
|
||||
attributes?: CustomAttributes;
|
||||
}
|
||||
|
||||
interface ImageTextsOptions {
|
||||
sbInit?: string;
|
||||
sbOnDragEnter?: string;
|
||||
sbOnDrop?: string;
|
||||
sbProgress?: string;
|
||||
sbOnUploaded?: string;
|
||||
sizeUnits?: string;
|
||||
}
|
||||
|
||||
interface ImageErrorTextsOptions {
|
||||
noFileGiven?: string;
|
||||
typeNotAllowed?: string;
|
||||
fileTooLarge?: string;
|
||||
importError?: string;
|
||||
}
|
||||
|
||||
interface OverlayModeOptions {
|
||||
mode: CodeMirror.Mode<any>;
|
||||
combine?: boolean;
|
||||
}
|
||||
|
||||
interface SpellCheckerOptions {
|
||||
codeMirrorInstance: CodeMirror.Editor;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
autoDownloadFontAwesome?: boolean;
|
||||
autofocus?: boolean;
|
||||
autosave?: AutoSaveOptions;
|
||||
autoRefresh?: boolean | { delay: number; };
|
||||
blockStyles?: BlockStyleOptions;
|
||||
element?: HTMLElement;
|
||||
forceSync?: boolean;
|
||||
hideIcons?: ReadonlyArray<ToolbarButton>;
|
||||
indentWithTabs?: boolean;
|
||||
initialValue?: string;
|
||||
insertTexts?: InsertTextOptions;
|
||||
lineNumbers?: boolean;
|
||||
lineWrapping?: boolean;
|
||||
minHeight?: string;
|
||||
maxHeight?: string;
|
||||
parsingConfig?: ParsingOptions;
|
||||
placeholder?: string;
|
||||
previewClass?: string | ReadonlyArray<string>;
|
||||
previewImagesInEditor?: boolean;
|
||||
imagesPreviewHandler?: (src: string) => string,
|
||||
previewRender?: (markdownPlaintext: string, previewElement: HTMLElement) => string | null;
|
||||
promptURLs?: boolean;
|
||||
renderingConfig?: RenderingOptions;
|
||||
shortcuts?: Shortcuts;
|
||||
showIcons?: ReadonlyArray<ToolbarButton>;
|
||||
spellChecker?: boolean | ((options: SpellCheckerOptions) => void);
|
||||
inputStyle?: 'textarea' | 'contenteditable';
|
||||
nativeSpellcheck?: boolean;
|
||||
sideBySideFullscreen?: boolean;
|
||||
status?: boolean | ReadonlyArray<string | StatusBarItem>;
|
||||
styleSelectedText?: boolean;
|
||||
tabSize?: number;
|
||||
toolbar?: boolean | ReadonlyArray<'|' | ToolbarButton | ToolbarIcon | ToolbarDropdownIcon>;
|
||||
toolbarTips?: boolean;
|
||||
toolbarButtonClassPrefix?: string;
|
||||
onToggleFullScreen?: (goingIntoFullScreen: boolean) => void;
|
||||
theme?: string;
|
||||
scrollbarStyle?: string;
|
||||
unorderedListStyle?: '*' | '-' | '+';
|
||||
|
||||
uploadImage?: boolean;
|
||||
imageMaxSize?: number;
|
||||
imageAccept?: string;
|
||||
imageUploadFunction?: (file: File, onSuccess: (url: string) => void, onError: (error: string) => void) => void;
|
||||
imageUploadEndpoint?: string;
|
||||
imagePathAbsolute?: boolean;
|
||||
imageCSRFToken?: string;
|
||||
imageCSRFName?: string;
|
||||
imageCSRFHeader?: boolean;
|
||||
imageTexts?: ImageTextsOptions;
|
||||
imageInputName?: string
|
||||
errorMessages?: ImageErrorTextsOptions;
|
||||
errorCallback?: (errorMessage: string) => void;
|
||||
|
||||
promptTexts?: PromptTexts;
|
||||
syncSideBySidePreviewScroll?: boolean;
|
||||
|
||||
overlayMode?: OverlayModeOptions;
|
||||
|
||||
direction?: 'ltr' | 'rtl';
|
||||
}
|
||||
}
|
||||
|
||||
declare class EasyMDE {
|
||||
constructor(options?: EasyMDE.Options);
|
||||
|
||||
value(): string;
|
||||
value(val: string): void;
|
||||
|
||||
codemirror: CodeMirror.Editor;
|
||||
|
||||
cleanup(): void;
|
||||
|
||||
toTextArea(): void;
|
||||
|
||||
isPreviewActive(): boolean;
|
||||
|
||||
isSideBySideActive(): boolean;
|
||||
|
||||
isFullscreenActive(): boolean;
|
||||
|
||||
clearAutosavedValue(): void;
|
||||
|
||||
updateStatusBar(itemName: string, content: string): void;
|
||||
|
||||
static toggleBold: (editor: EasyMDE) => void;
|
||||
static toggleItalic: (editor: EasyMDE) => void;
|
||||
static toggleStrikethrough: (editor: EasyMDE) => void;
|
||||
static toggleHeadingSmaller: (editor: EasyMDE) => void;
|
||||
static toggleHeadingBigger: (editor: EasyMDE) => void;
|
||||
static toggleHeading1: (editor: EasyMDE) => void;
|
||||
static toggleHeading2: (editor: EasyMDE) => void;
|
||||
static toggleHeading3: (editor: EasyMDE) => void;
|
||||
static toggleHeading4: (editor: EasyMDE) => void;
|
||||
static toggleHeading5: (editor: EasyMDE) => void;
|
||||
static toggleHeading6: (editor: EasyMDE) => void;
|
||||
static toggleCodeBlock: (editor: EasyMDE) => void;
|
||||
static toggleBlockquote: (editor: EasyMDE) => void;
|
||||
static toggleUnorderedList: (editor: EasyMDE) => void;
|
||||
static toggleOrderedList: (editor: EasyMDE) => void;
|
||||
static cleanBlock: (editor: EasyMDE) => void;
|
||||
static drawLink: (editor: EasyMDE) => void;
|
||||
static drawImage: (editor: EasyMDE) => void;
|
||||
static drawUploadedImage: (editor: EasyMDE) => void;
|
||||
static drawTable: (editor: EasyMDE) => void;
|
||||
static drawHorizontalRule: (editor: EasyMDE) => void;
|
||||
static togglePreview: (editor: EasyMDE) => void;
|
||||
static toggleSideBySide: (editor: EasyMDE) => void;
|
||||
static toggleFullScreen: (editor: EasyMDE) => void;
|
||||
static undo: (editor: EasyMDE) => void;
|
||||
static redo: (editor: EasyMDE) => void;
|
||||
}
|
||||
|
||||
export as namespace EasyMDE;
|
||||
export = EasyMDE;
|
@ -1,9 +0,0 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"target": "es3",
|
||||
"ignoreDeprecations": "5.0",
|
||||
"strict": true,
|
||||
"noImplicitReturns": true,
|
||||
"noEmit": true
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user