mirror of
https://github.com/Ionaru/easy-markdown-editor
synced 2025-07-03 16:14:29 -06:00
commit
61b8aa2293
@ -6,7 +6,9 @@ node_js:
|
|||||||
- '6' # EOL: April 2019
|
- '6' # EOL: April 2019
|
||||||
before_script:
|
before_script:
|
||||||
- npm install -g gulp
|
- npm install -g gulp
|
||||||
script: gulp
|
script:
|
||||||
|
- gulp
|
||||||
|
- npm run test:types
|
||||||
deploy:
|
deploy:
|
||||||
- provider: npm
|
- provider: npm
|
||||||
email: info@saturnserver.org
|
email: info@saturnserver.org
|
||||||
|
30
package-lock.json
generated
30
package-lock.json
generated
@ -24,6 +24,30 @@
|
|||||||
"js-tokens": "^4.0.0"
|
"js-tokens": "^4.0.0"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"@types/codemirror": {
|
||||||
|
"version": "0.0.71",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/codemirror/-/codemirror-0.0.71.tgz",
|
||||||
|
"integrity": "sha512-b2oEEnno1LIGKMR7uBEsr40al1UijF1HEpRn0+Yf1xOLl24iQgB7DBpZVMM7y54G5wCNoclDrRO65E6KHPNO2w==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/tern": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@types/estree": {
|
||||||
|
"version": "0.0.39",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz",
|
||||||
|
"integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
|
"@types/tern": {
|
||||||
|
"version": "0.22.1",
|
||||||
|
"resolved": "https://registry.npmjs.org/@types/tern/-/tern-0.22.1.tgz",
|
||||||
|
"integrity": "sha512-CRzPRkg8hYLwunsj61r+rqPJQbiCIEQqlMMY/0k7krgIsoSaFgGg1ZH2f9qaR1YpenaMl6PnlTtUkCbNH/uo+A==",
|
||||||
|
"dev": true,
|
||||||
|
"requires": {
|
||||||
|
"@types/estree": "*"
|
||||||
|
}
|
||||||
|
},
|
||||||
"JSONStream": {
|
"JSONStream": {
|
||||||
"version": "1.3.5",
|
"version": "1.3.5",
|
||||||
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz",
|
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz",
|
||||||
@ -5198,6 +5222,12 @@
|
|||||||
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
|
"integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=",
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
|
"typescript": {
|
||||||
|
"version": "3.2.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/typescript/-/typescript-3.2.2.tgz",
|
||||||
|
"integrity": "sha512-VCj5UiSyHBjwfYacmDuc/NOk4QQixbE+Wn7MFJuS0nRuPQbof132Pw4u53dm264O8LPc2MVsc7RJNml5szurkg==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"typo-js": {
|
"typo-js": {
|
||||||
"version": "1.0.3",
|
"version": "1.0.3",
|
||||||
"resolved": "https://registry.npmjs.org/typo-js/-/typo-js-1.0.3.tgz",
|
"resolved": "https://registry.npmjs.org/typo-js/-/typo-js-1.0.3.tgz",
|
||||||
|
@ -9,7 +9,8 @@
|
|||||||
"javascript",
|
"javascript",
|
||||||
"fontawesome"
|
"fontawesome"
|
||||||
],
|
],
|
||||||
"main": "./src/js/easymde.js",
|
"main": "src/js/easymde.js",
|
||||||
|
"types": "types/easymde.d.ts",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "Jeroen Akkerman",
|
"author": "Jeroen Akkerman",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
@ -21,6 +22,7 @@
|
|||||||
"marked": "^0.5.1"
|
"marked": "^0.5.1"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
"@types/codemirror": "0.0.71",
|
||||||
"browserify": "^16.2.3",
|
"browserify": "^16.2.3",
|
||||||
"gulp": "^4.0.0",
|
"gulp": "^4.0.0",
|
||||||
"gulp-clean-css": "^3.10.0",
|
"gulp-clean-css": "^3.10.0",
|
||||||
@ -29,6 +31,7 @@
|
|||||||
"gulp-header": "^2.0.5",
|
"gulp-header": "^2.0.5",
|
||||||
"gulp-rename": "^1.4.0",
|
"gulp-rename": "^1.4.0",
|
||||||
"gulp-uglify": "^3.0.1",
|
"gulp-uglify": "^3.0.1",
|
||||||
|
"typescript": "^3.2.2",
|
||||||
"vinyl-buffer": "^1.0.0",
|
"vinyl-buffer": "^1.0.0",
|
||||||
"vinyl-source-stream": "^2.0.0"
|
"vinyl-source-stream": "^2.0.0"
|
||||||
},
|
},
|
||||||
@ -37,6 +40,7 @@
|
|||||||
"url": "https://github.com/ionaru/easy-markdown-editor"
|
"url": "https://github.com/ionaru/easy-markdown-editor"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"prepare": "gulp"
|
"prepare": "gulp",
|
||||||
|
"test:types": "tsc --project types/tsconfig.json"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
26
types/easymde-test.ts
Normal file
26
types/easymde-test.ts
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Create new instance
|
||||||
|
const editor = new EasyMDE({
|
||||||
|
autoDownloadFontAwesome: false,
|
||||||
|
element: document.getElementById("mdEditor")!,
|
||||||
|
hideIcons: ["side-by-side", "fullscreen"],
|
||||||
|
shortcuts: {
|
||||||
|
drawTable: "Cmd-Alt-T",
|
||||||
|
toggleFullScreen: null
|
||||||
|
},
|
||||||
|
spellChecker: false,
|
||||||
|
onToggleFullScreen: (full: boolean) => { console.log('FullscreenToggled', full); },
|
||||||
|
theme: 'someOtherTheme',
|
||||||
|
});
|
||||||
|
|
||||||
|
// 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'); };
|
152
types/easymde.d.ts
vendored
Normal file
152
types/easymde.d.ts
vendored
Normal file
@ -0,0 +1,152 @@
|
|||||||
|
// 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"/>
|
||||||
|
|
||||||
|
declare namespace EasyMDE {
|
||||||
|
interface AutoSaveOptions {
|
||||||
|
enabled?: boolean;
|
||||||
|
delay?: number;
|
||||||
|
uniqueId: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface BlockStyleOptions {
|
||||||
|
bold?: string;
|
||||||
|
code?: string;
|
||||||
|
italic?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface InsertTextOptions {
|
||||||
|
horizontalRule?: ReadonlyArray<string>;
|
||||||
|
image?: ReadonlyArray<string>;
|
||||||
|
link?: ReadonlyArray<string>;
|
||||||
|
table?: ReadonlyArray<string>;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface ParsingOptions {
|
||||||
|
allowAtxHeaderWithoutSpace?: boolean;
|
||||||
|
strikethrough?: boolean;
|
||||||
|
underscoresBreakWords?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface RenderingOptions {
|
||||||
|
singleLineBreaks?: boolean;
|
||||||
|
codeSyntaxHighlighting: 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 ToolbarIcon {
|
||||||
|
name: string;
|
||||||
|
action: string|((editor: EasyMDE) => void);
|
||||||
|
className: string;
|
||||||
|
title: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface Options {
|
||||||
|
autoDownloadFontAwesome?: boolean;
|
||||||
|
autofocus?: boolean;
|
||||||
|
autosave?: AutoSaveOptions;
|
||||||
|
blockStyles?: BlockStyleOptions;
|
||||||
|
element?: HTMLElement;
|
||||||
|
forceSync?: boolean;
|
||||||
|
hideIcons?: ReadonlyArray<string>;
|
||||||
|
indentWithTabs?: boolean;
|
||||||
|
initialValue?: string;
|
||||||
|
insertTexts?: InsertTextOptions;
|
||||||
|
lineWrapping?: boolean;
|
||||||
|
parsingConfig?: ParsingOptions;
|
||||||
|
placeholder?: string;
|
||||||
|
previewRender?: (markdownPlaintext: string, previewElement: HTMLElement) => string;
|
||||||
|
promptURLs?: boolean;
|
||||||
|
renderingConfig?: RenderingOptions;
|
||||||
|
shortcuts?: Shortcuts;
|
||||||
|
showIcons?: ReadonlyArray<string>;
|
||||||
|
spellChecker?: boolean;
|
||||||
|
status?: boolean|ReadonlyArray<string|StatusBarItem>;
|
||||||
|
styleSelectedText?: boolean;
|
||||||
|
tabSize?: number;
|
||||||
|
toolbar?: boolean|ReadonlyArray<string|ToolbarIcon>;
|
||||||
|
toolbarTips?: boolean;
|
||||||
|
onToggleFullScreen?: (goingIntoFullScreen: boolean) => void;
|
||||||
|
theme?: string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declare class EasyMDE {
|
||||||
|
constructor(options?: EasyMDE.Options);
|
||||||
|
value(): string;
|
||||||
|
value(val: string): void;
|
||||||
|
codemirror: CodeMirror.Editor;
|
||||||
|
toTextArea(): void;
|
||||||
|
isPreviewActive(): boolean;
|
||||||
|
isSideBySideActive(): boolean;
|
||||||
|
isFullscreenActive(): boolean;
|
||||||
|
clearAutosavedValue(): 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 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 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;
|
8
types/tsconfig.json
Normal file
8
types/tsconfig.json
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "es3",
|
||||||
|
"strict": true,
|
||||||
|
"noImplicitReturns": true,
|
||||||
|
"noEmit": true
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user