1
0
Fork 0
mirror of https://github.com/codex-team/codex.docs.git synced 2025-07-20 13:49:41 +02:00

feat(editor): raw tool added (#105)

This commit is contained in:
Peter Savchenko 2020-10-15 19:55:34 +03:00 committed by GitHub
parent 94a9a963ff
commit 7a98b6cfd3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 91 additions and 1209 deletions

View file

@ -13,7 +13,7 @@
"build:dev": "webpack ./src/frontend/js/app.js --o='./public/dist/[name].bundle.js' --output-library=Docs --output-public-path=/dist/ -p --mode=development --watch", "build:dev": "webpack ./src/frontend/js/app.js --o='./public/dist/[name].bundle.js' --output-library=Docs --output-public-path=/dist/ -p --mode=development --watch",
"precommit": "yarn lint && yarn test --exit", "precommit": "yarn lint && yarn test --exit",
"generatePassword": "node ./generatePassword.js", "generatePassword": "node ./generatePassword.js",
"editor-upgrade": "yarn add -D @editorjs/{editorjs,header,code,delimiter,list,link,image,table,inline-code,marker,warning,checklist}@latest" "editor-upgrade": "yarn add -D @editorjs/{editorjs,header,code,delimiter,list,link,image,table,inline-code,marker,warning,checklist,raw}@latest"
}, },
"dependencies": { "dependencies": {
"bcrypt": "^3.0.3", "bcrypt": "^3.0.3",
@ -45,18 +45,19 @@
"@babel/polyfill": "^7.2.5", "@babel/polyfill": "^7.2.5",
"@babel/preset-env": "^7.1.0", "@babel/preset-env": "^7.1.0",
"@codexteam/misprints": "^1.0.0", "@codexteam/misprints": "^1.0.0",
"@editorjs/checklist": "^1.1.0", "@editorjs/checklist": "^1.2.0",
"@editorjs/code": "^2.5.0", "@editorjs/code": "^2.6.0",
"@editorjs/delimiter": "^1.1.0", "@editorjs/delimiter": "^1.2.0",
"@editorjs/editorjs": "^2.18.0", "@editorjs/editorjs": "^2.19.0",
"@editorjs/header": "^2.5.0", "@editorjs/header": "^2.6.0",
"@editorjs/image": "^2.4.2", "@editorjs/image": "^2.6.0",
"@editorjs/inline-code": "^1.3.1", "@editorjs/inline-code": "^1.3.1",
"@editorjs/link": "^2.2.1", "@editorjs/link": "^2.3.1",
"@editorjs/list": "^1.5.0", "@editorjs/list": "^1.6.0",
"@editorjs/marker": "^1.2.2", "@editorjs/marker": "^1.2.2",
"@editorjs/table": "^1.2.2", "@editorjs/raw": "^2.2.0",
"@editorjs/warning": "^1.1.1", "@editorjs/table": "^1.3.0",
"@editorjs/warning": "^1.2.0",
"autoprefixer": "^9.1.3", "autoprefixer": "^9.1.3",
"babel": "^6.23.0", "babel": "^6.23.0",
"babel-eslint": "^10.0.1", "babel-eslint": "^10.0.1",

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -12,6 +12,7 @@ import Table from '@editorjs/table';
import Warning from '@editorjs/warning'; import Warning from '@editorjs/warning';
import Checklist from '@editorjs/checklist'; import Checklist from '@editorjs/checklist';
import LinkTool from '@editorjs/link'; import LinkTool from '@editorjs/link';
import RawTool from '@editorjs/raw';
/** /**
* Inline Tools for the Editor * Inline Tools for the Editor
@ -25,6 +26,7 @@ import Marker from '@editorjs/marker';
export default class Editor { export default class Editor {
/** /**
* Creates Editor instance * Creates Editor instance
*
* @param {object} editorConfig - configuration object for Editor.js * @param {object} editorConfig - configuration object for Editor.js
* @param {object} data.blocks - data to start with * @param {object} data.blocks - data to start with
* @param {object} options * @param {object} options
@ -37,8 +39,8 @@ export default class Editor {
class: Header, class: Header,
inlineToolbar: ['marker', 'inlineCode'], inlineToolbar: ['marker', 'inlineCode'],
config: { config: {
placeholder: options.headerPlaceholder || '' placeholder: options.headerPlaceholder || '',
} },
}, },
image: { image: {
@ -48,45 +50,45 @@ export default class Editor {
types: 'image/*, video/mp4', types: 'image/*, video/mp4',
endpoints: { endpoints: {
byFile: '/api/transport/image', byFile: '/api/transport/image',
byUrl: '/api/transport/fetch' byUrl: '/api/transport/fetch',
}, },
additionalRequestData: { additionalRequestData: {
map: JSON.stringify({ map: JSON.stringify({
path: 'file:url', path: 'file:url',
size: 'file:size', size: 'file:size',
mimetype: 'file:mime' mimetype: 'file:mime',
}) }),
} },
} },
}, },
linkTool: { linkTool: {
class: LinkTool, class: LinkTool,
config: { config: {
endpoint: '/api/fetchUrl', endpoint: '/api/fetchUrl',
} },
}, },
code: { code: {
class: CodeTool, class: CodeTool,
shortcut: 'CMD+SHIFT+D' shortcut: 'CMD+SHIFT+D',
}, },
list: { list: {
class: List, class: List,
inlineToolbar: true inlineToolbar: true,
}, },
delimiter: Delimiter, delimiter: Delimiter,
table: { table: {
class: Table, class: Table,
inlineToolbar: true inlineToolbar: true,
}, },
warning: { warning: {
class: Warning, class: Warning,
inlineToolbar: true inlineToolbar: true,
}, },
checklist: { checklist: {
@ -99,13 +101,15 @@ export default class Editor {
*/ */
inlineCode: { inlineCode: {
class: InlineCode, class: InlineCode,
shortcut: 'CMD+SHIFT+C' shortcut: 'CMD+SHIFT+C',
}, },
marker: { marker: {
class: Marker, class: Marker,
shortcut: 'CMD+SHIFT+M' shortcut: 'CMD+SHIFT+M',
} },
raw: RawTool,
}, },
data: { data: {
blocks: [ blocks: [
@ -113,11 +117,11 @@ export default class Editor {
type: 'header', type: 'header',
data: { data: {
text: '', text: '',
level: 2 level: 2,
} },
} },
] ],
} },
}; };
this.editor = new EditorJS(Object.assign(defaultConfig, editorConfig)); this.editor = new EditorJS(Object.assign(defaultConfig, editorConfig));
@ -125,7 +129,8 @@ export default class Editor {
/** /**
* Return Editor data * Return Editor data
* @return {Promise.<{}>} *
* @returns {Promise.<{}>}
*/ */
save() { save() {
return this.editor.saver.save(); return this.editor.saver.save();

1201
yarn.lock

File diff suppressed because it is too large Load diff