Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(editor): raw tool added #105

Merged
merged 1 commit into from
Oct 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 12 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
"precommit": "yarn lint && yarn test --exit",
"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": {
"bcrypt": "^3.0.3",
Expand Down Expand Up @@ -45,18 +45,19 @@
"@babel/polyfill": "^7.2.5",
"@babel/preset-env": "^7.1.0",
"@codexteam/misprints": "^1.0.0",
"@editorjs/checklist": "^1.1.0",
"@editorjs/code": "^2.5.0",
"@editorjs/delimiter": "^1.1.0",
"@editorjs/editorjs": "^2.18.0",
"@editorjs/header": "^2.5.0",
"@editorjs/image": "^2.4.2",
"@editorjs/checklist": "^1.2.0",
"@editorjs/code": "^2.6.0",
"@editorjs/delimiter": "^1.2.0",
"@editorjs/editorjs": "^2.19.0",
"@editorjs/header": "^2.6.0",
"@editorjs/image": "^2.6.0",
"@editorjs/inline-code": "^1.3.1",
"@editorjs/link": "^2.2.1",
"@editorjs/list": "^1.5.0",
"@editorjs/link": "^2.3.1",
"@editorjs/list": "^1.6.0",
"@editorjs/marker": "^1.2.2",
"@editorjs/table": "^1.2.2",
"@editorjs/warning": "^1.1.1",
"@editorjs/raw": "^2.2.0",
"@editorjs/table": "^1.3.0",
"@editorjs/warning": "^1.2.0",
"autoprefixer": "^9.1.3",
"babel": "^6.23.0",
"babel-eslint": "^10.0.1",
Expand Down
2 changes: 1 addition & 1 deletion public/dist/code-styling.bundle.js

Large diffs are not rendered by default.

21 changes: 15 additions & 6 deletions public/dist/editor.bundle.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions public/dist/main.bundle.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion public/dist/main.css

Large diffs are not rendered by default.

47 changes: 26 additions & 21 deletions src/frontend/js/classes/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Table from '@editorjs/table';
import Warning from '@editorjs/warning';
import Checklist from '@editorjs/checklist';
import LinkTool from '@editorjs/link';
import RawTool from '@editorjs/raw';

/**
* Inline Tools for the Editor
Expand All @@ -25,6 +26,7 @@ import Marker from '@editorjs/marker';
export default class Editor {
/**
* Creates Editor instance
*
* @param {object} editorConfig - configuration object for Editor.js
* @param {object} data.blocks - data to start with
* @param {object} options
Expand All @@ -37,8 +39,8 @@ export default class Editor {
class: Header,
inlineToolbar: ['marker', 'inlineCode'],
config: {
placeholder: options.headerPlaceholder || ''
}
placeholder: options.headerPlaceholder || '',
},
},

image: {
Expand All @@ -48,45 +50,45 @@ export default class Editor {
types: 'image/*, video/mp4',
endpoints: {
byFile: '/api/transport/image',
byUrl: '/api/transport/fetch'
byUrl: '/api/transport/fetch',
},
additionalRequestData: {
map: JSON.stringify({
path: 'file:url',
size: 'file:size',
mimetype: 'file:mime'
})
}
}
mimetype: 'file:mime',
}),
},
},
},

linkTool: {
class: LinkTool,
config: {
endpoint: '/api/fetchUrl',
}
},
},

code: {
class: CodeTool,
shortcut: 'CMD+SHIFT+D'
shortcut: 'CMD+SHIFT+D',
},

list: {
class: List,
inlineToolbar: true
inlineToolbar: true,
},

delimiter: Delimiter,

table: {
class: Table,
inlineToolbar: true
inlineToolbar: true,
},

warning: {
class: Warning,
inlineToolbar: true
inlineToolbar: true,
},

checklist: {
Expand All @@ -99,33 +101,36 @@ export default class Editor {
*/
inlineCode: {
class: InlineCode,
shortcut: 'CMD+SHIFT+C'
shortcut: 'CMD+SHIFT+C',
},

marker: {
class: Marker,
shortcut: 'CMD+SHIFT+M'
}
shortcut: 'CMD+SHIFT+M',
},

raw: RawTool,
},
data: {
blocks: [
{
type: 'header',
data: {
text: '',
level: 2
}
}
]
}
level: 2,
},
},
],
},
};

this.editor = new EditorJS(Object.assign(defaultConfig, editorConfig));
}

/**
* Return Editor data
* @return {Promise.<{}>}
*
* @returns {Promise.<{}>}
*/
save() {
return this.editor.saver.save();
Expand Down
Loading