mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-06-29 14:11:02 -06:00
Added option time format for autosave (12/24). Added option text for autosave.
This commit is contained in:
parent
3096bbe291
commit
ad83e77aee
44
README.md
44
README.md
@ -23,25 +23,27 @@ The editor is entirely customizable, from theming to toolbar buttons and javascr
|
|||||||
|
|
||||||
## Quick access
|
## Quick access
|
||||||
|
|
||||||
- [Install EasyMDE](#install-easymde)
|
- [EasyMDE - Markdown Editor](#easymde---markdown-editor)
|
||||||
- [How to use](#how-to-use)
|
- [Quick access](#quick-access)
|
||||||
- [Loading the editor](#loading-the-editor)
|
- [Install EasyMDE](#install-easymde)
|
||||||
- [Editor functions](#editor-functions)
|
- [How to use](#how-to-use)
|
||||||
- [Configuration](#configuration)
|
- [Loading the editor](#loading-the-editor)
|
||||||
- [Options list](#options-list)
|
- [Editor functions](#editor-functions)
|
||||||
- [Options example](#options-example)
|
- [Configuration](#configuration)
|
||||||
- [Toolbar icons](#toolbar-icons)
|
- [Options list](#options-list)
|
||||||
- [Toolbar customization](#toolbar-customization)
|
- [Options example](#options-example)
|
||||||
- [Keyboard shortcuts](#keyboard-shortcuts)
|
- [Toolbar icons](#toolbar-icons)
|
||||||
- [Advanced use](#advanced-use)
|
- [Toolbar customization](#toolbar-customization)
|
||||||
- [Event handling](#event-handling)
|
- [Keyboard shortcuts](#keyboard-shortcuts)
|
||||||
- [Removing EasyMDE from text area](#removing-easymde-from-text-area)
|
- [Advanced use](#advanced-use)
|
||||||
- [Useful methods](#useful-methods)
|
- [Event handling](#event-handling)
|
||||||
- [How it works](#how-it-works)
|
- [Removing EasyMDE from text area](#removing-easymde-from-text-area)
|
||||||
- [SimpleMDE fork](#simplemde-fork)
|
- [Useful methods](#useful-methods)
|
||||||
- [Hacking EasyMDE](#hacking-easymde)
|
- [How it works](#how-it-works)
|
||||||
- [Contributing](#contributing)
|
- [SimpleMDE fork](#simplemde-fork)
|
||||||
- [License](#license)
|
- [Hacking EasyMDE](#hacking-easymde)
|
||||||
|
- [Contributing](#contributing)
|
||||||
|
- [License](#license)
|
||||||
|
|
||||||
|
|
||||||
## Install EasyMDE
|
## Install EasyMDE
|
||||||
@ -122,6 +124,8 @@ easyMDE.value('New input for **EasyMDE**');
|
|||||||
- **delay**: Delay between saves, in milliseconds. Defaults to `10000` (10s).
|
- **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).
|
- **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.
|
- **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**: Time format 12/24. Defaults to 12.
|
||||||
|
- **text**: Set text for autosave.
|
||||||
- **blockStyles**: Customize how certain buttons that style blocks of text behave.
|
- **blockStyles**: Customize how certain buttons that style blocks of text behave.
|
||||||
- **bold**: Can be set to `**` or `__`. Defaults to `**`.
|
- **bold**: Can be set to `**` or `__`. Defaults to `**`.
|
||||||
- **code**: Can be set to ```` ``` ```` or `~~~`. Defaults to ```` ``` ````.
|
- **code**: Can be set to ```` ``` ```` or `~~~`. Defaults to ```` ``` ````.
|
||||||
@ -206,6 +210,8 @@ var editor = new EasyMDE({
|
|||||||
uniqueId: "MyUniqueID",
|
uniqueId: "MyUniqueID",
|
||||||
delay: 1000,
|
delay: 1000,
|
||||||
submit_delay: 5000,
|
submit_delay: 5000,
|
||||||
|
timeFormat: 24,
|
||||||
|
text: "Autosaved: "
|
||||||
},
|
},
|
||||||
blockStyles: {
|
blockStyles: {
|
||||||
bold: "__",
|
bold: "__",
|
||||||
|
@ -2004,16 +2004,27 @@ EasyMDE.prototype.autosave = function () {
|
|||||||
var m = d.getMinutes();
|
var m = d.getMinutes();
|
||||||
var dd = 'am';
|
var dd = 'am';
|
||||||
var h = hh;
|
var h = hh;
|
||||||
if (h >= 12) {
|
var html = '';
|
||||||
h = hh - 12;
|
var save = this.options.autosave.text == undefined ? 'Autosaved: ' : this.options.autosave.text;
|
||||||
dd = 'pm';
|
|
||||||
}
|
|
||||||
if (h == 0) {
|
|
||||||
h = 12;
|
|
||||||
}
|
|
||||||
m = m < 10 ? '0' + m : m;
|
m = m < 10 ? '0' + m : m;
|
||||||
|
|
||||||
el.innerHTML = 'Autosaved: ' + h + ':' + m + ' ' + dd;
|
if (this.options.autosave.timeFormat == undefined || this.options.autosave.timeFormat == 12) {
|
||||||
|
if (h >= 12) {
|
||||||
|
h = hh - 12;
|
||||||
|
dd = 'pm';
|
||||||
|
}
|
||||||
|
if (h == 0) {
|
||||||
|
h = 12;
|
||||||
|
}
|
||||||
|
|
||||||
|
html = save + h + ':' + m + ' ' + dd;
|
||||||
|
}
|
||||||
|
if (this.options.autosave.timeFormat == 24) {
|
||||||
|
html = save + h + ':' + m;
|
||||||
|
}
|
||||||
|
|
||||||
|
el.innerHTML = html;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.autosaveTimeoutId = setTimeout(function () {
|
this.autosaveTimeoutId = setTimeout(function () {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user