2
0
mirror of https://github.com/Ionaru/easy-markdown-editor synced 2025-07-17 06:54:27 -06:00

Merge pull request #358 from souljuse/master

Add support for RTL languages
This commit is contained in:
Jeroen Akkerman 2021-10-05 21:59:05 +02:00 committed by GitHub
commit 534e2cadee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 1 deletions

View File

@ -154,7 +154,7 @@ easyMDE.value('New input for **EasyMDE**');
- **underscoresBreakWords**: If set to `true`, let underscores be a delimiter for separating words. Defaults to `false`. - **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. - **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. - **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`. - **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. - **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"`. - **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. - **previewRender**: Custom function for parsing the plaintext Markdown and returning HTML. Used when user previews.
@ -206,6 +206,7 @@ easyMDE.value('New input for **EasyMDE**');
- **theme**: Override the theme. Defaults to `easymde`. - **theme**: Override the theme. Defaults to `easymde`.
- **toolbar**: If set to `false`, hide the toolbar. Defaults to the [array of icons](#toolbar-icons). - **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`. - **toolbarTips**: If set to `false`, disable toolbar button tips. Defaults to `true`.
- **direction**: `rtl` or `ltr`. Changes text direction to support right-to-left languages. Defaults to `ltr`.
### Options example ### Options example

View File

@ -2,6 +2,10 @@
display: block; display: block;
} }
.CodeMirror-rtl pre {
direction: rtl;
}
.EasyMDEContainer.sided--no-fullscreen { .EasyMDEContainer.sided--no-fullscreen {
display: flex; display: flex;
flex-direction: row; flex-direction: row;

View File

@ -1767,6 +1767,8 @@ function EasyMDE(options) {
options.shortcuts = extend({}, shortcuts, options.shortcuts || {}); options.shortcuts = extend({}, shortcuts, options.shortcuts || {});
options.maxHeight = options.maxHeight || undefined; options.maxHeight = options.maxHeight || undefined;
options.direction = options.direction || 'ltr';
if (typeof options.maxHeight !== 'undefined') { if (typeof options.maxHeight !== 'undefined') {
// Min and max height are equal if maxHeight is set // Min and max height are equal if maxHeight is set
@ -2080,6 +2082,7 @@ EasyMDE.prototype.render = function (el) {
lineNumbers: (options.lineNumbers === true) ? true : false, lineNumbers: (options.lineNumbers === true) ? true : false,
autofocus: (options.autofocus === true) ? true : false, autofocus: (options.autofocus === true) ? true : false,
extraKeys: keyMaps, extraKeys: keyMaps,
direction: options.direction,
lineWrapping: (options.lineWrapping === false) ? false : true, lineWrapping: (options.lineWrapping === false) ? false : true,
allowDropFileTypes: ['text/plain'], allowDropFileTypes: ['text/plain'],
placeholder: options.placeholder || el.getAttribute('placeholder') || '', placeholder: options.placeholder || el.getAttribute('placeholder') || '',