mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-07-22 17:34:37 -06:00
Merge branch 'master' into feature/137-custom-icons
This commit is contained in:
commit
85e59747ab
14
CHANGELOG.md
14
CHANGELOG.md
@ -9,9 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- `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.
|
||||
- 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]).
|
||||
|
||||
## [2.9.0] - 2020-01-13
|
||||
### Added
|
||||
@ -148,7 +152,12 @@ Project forked from [SimpleMDE](https://github.com/sparksuite/simplemde-markdown
|
||||
[#9]: https://github.com/Ionaru/easy-markdown-editor/issues/9
|
||||
|
||||
<!-- Linked PRs -->
|
||||
[#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
|
||||
@ -165,6 +174,9 @@ Project forked from [SimpleMDE](https://github.com/sparksuite/simplemde-markdown
|
||||
[#19]: https://github.com/Ionaru/easy-markdown-editor/pull/19
|
||||
|
||||
<!-- Linked users -->
|
||||
[@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
|
||||
|
33
README.md
33
README.md
@ -25,18 +25,18 @@ The editor is entirely customizable, from theming to toolbar buttons and javascr
|
||||
|
||||
- [Install EasyMDE](#install-easymde)
|
||||
- [How to use](#how-to-use)
|
||||
- [Loading the editor](#loading-the-editor)
|
||||
- [Editor functions](#editor-functions)
|
||||
- [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)
|
||||
- [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)
|
||||
- [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)
|
||||
@ -122,6 +122,8 @@ easyMDE.value('New input for **EasyMDE**');
|
||||
- **delay**: Delay between saves, in milliseconds. Defaults to `10000` (10s).
|
||||
- **submit_delay**: Delay before assuming that submit of the form failed and saving the text, in milliseconds. Defaults to `autosave.delay` or `10000` (10s).
|
||||
- **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.
|
||||
- **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 ```` ``` ````.
|
||||
@ -206,6 +208,17 @@ var editor = new EasyMDE({
|
||||
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: "__",
|
||||
|
@ -55,8 +55,8 @@ function styles() {
|
||||
|
||||
// Watch for file changes
|
||||
function watch() {
|
||||
gulp.watch('./src/js/**/*.js', scripts)
|
||||
gulp.watch(css_files, styles)
|
||||
gulp.watch('./src/js/**/*.js', scripts);
|
||||
gulp.watch(css_files, styles);
|
||||
}
|
||||
|
||||
var build = gulp.parallel(gulp.series(lint, scripts), styles);
|
||||
|
1410
package-lock.json
generated
1410
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -19,12 +19,12 @@
|
||||
"license": "MIT",
|
||||
"author": "Jeroen Akkerman",
|
||||
"dependencies": {
|
||||
"codemirror": "^5.51.0",
|
||||
"codemirror": "^5.52.2",
|
||||
"codemirror-spell-checker": "1.1.2",
|
||||
"marked": "^0.8.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/codemirror": "0.0.85",
|
||||
"@types/codemirror": "0.0.88",
|
||||
"@types/marked": "^0.7.2",
|
||||
"browserify": "^16.5.0",
|
||||
"gulp": "^4.0.2",
|
||||
|
@ -11,7 +11,7 @@ require('codemirror/addon/search/searchcursor.js');
|
||||
require('codemirror/mode/gfm/gfm.js');
|
||||
require('codemirror/mode/xml/xml.js');
|
||||
var CodeMirrorSpellChecker = require('codemirror-spell-checker');
|
||||
var marked = require('marked');
|
||||
var marked = require('marked/lib/marked');
|
||||
|
||||
|
||||
// Some variables
|
||||
@ -1484,6 +1484,14 @@ var promptTexts = {
|
||||
image: 'URL of the image:',
|
||||
};
|
||||
|
||||
var timeFormat = {
|
||||
locale: 'en-US',
|
||||
format: {
|
||||
hour: '2-digit',
|
||||
minute: '2-digit',
|
||||
},
|
||||
};
|
||||
|
||||
var blockStyles = {
|
||||
'bold': '**',
|
||||
'code': '```',
|
||||
@ -1624,6 +1632,12 @@ function EasyMDE(options) {
|
||||
options.blockStyles = extend({}, blockStyles, options.blockStyles || {});
|
||||
|
||||
|
||||
if (options.autosave != undefined) {
|
||||
// Merging the Autosave timeFormat, with the given options
|
||||
options.autosave.timeFormat = extend({}, timeFormat, options.autosave.timeFormat || {});
|
||||
}
|
||||
|
||||
|
||||
// Merging the shortcuts, with the given options
|
||||
options.shortcuts = extend({}, shortcuts, options.shortcuts || {});
|
||||
|
||||
@ -2005,20 +2019,10 @@ EasyMDE.prototype.autosave = function () {
|
||||
var el = document.getElementById('autosaved');
|
||||
if (el != null && el != undefined && el != '') {
|
||||
var d = new Date();
|
||||
var hh = d.getHours();
|
||||
var m = d.getMinutes();
|
||||
var dd = 'am';
|
||||
var h = hh;
|
||||
if (h >= 12) {
|
||||
h = hh - 12;
|
||||
dd = 'pm';
|
||||
}
|
||||
if (h == 0) {
|
||||
h = 12;
|
||||
}
|
||||
m = m < 10 ? '0' + m : m;
|
||||
var dd = new Intl.DateTimeFormat([this.options.autosave.timeFormat.locale, 'en-US'], this.options.autosave.timeFormat.format).format(d);
|
||||
var save = this.options.autosave.text == undefined ? 'Autosaved: ' : this.options.autosave.text;
|
||||
|
||||
el.innerHTML = 'Autosaved: ' + h + ':' + m + ' ' + dd;
|
||||
el.innerHTML = save + dd;
|
||||
}
|
||||
|
||||
this.autosaveTimeoutId = setTimeout(function () {
|
||||
|
@ -161,7 +161,7 @@ const editorImagesCustom = new EasyMDE({
|
||||
image: 'Insert URL'
|
||||
},
|
||||
syncSideBySidePreviewScroll: true
|
||||
});
|
||||
});
|
||||
|
||||
const editorAutosave = new EasyMDE({
|
||||
autosave: {
|
||||
@ -169,5 +169,12 @@ const editorAutosave = new EasyMDE({
|
||||
delay: 2000,
|
||||
submit_delay: 10000,
|
||||
uniqueId: 'abc',
|
||||
timeFormat: {
|
||||
locale: 'en-GB',
|
||||
format: {
|
||||
month: 'long',
|
||||
}
|
||||
},
|
||||
text: 'Stored: ',
|
||||
}
|
||||
});
|
||||
|
8
types/easymde.d.ts
vendored
8
types/easymde.d.ts
vendored
@ -46,11 +46,19 @@ type ToolbarButton =
|
||||
| '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 {
|
||||
|
Loading…
x
Reference in New Issue
Block a user