-
Notifications
You must be signed in to change notification settings - Fork 0
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
Added ability to create extensions #6
Conversation
editorjs.config.sample.ts
Outdated
editorConfig: { | ||
inlineToolbar: true, | ||
readOnly: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it is the default value, could be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
src/Stand/Stand.ts
Outdated
@@ -32,6 +33,11 @@ export default class Stand { | |||
*/ | |||
private JSData: FileData; | |||
|
|||
/** | |||
* Data to store into stand style file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Description is not clear. What kind of data?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed it
src/Stand/StandAPI/StandAPI.ts
Outdated
@@ -0,0 +1,18 @@ | |||
/** | |||
* Class for stand API, which is used to interact with editor.js wrapper |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Class for stand API, which is used to interact with editor.js wrapper | |
* Class for stand API, which is used to interact with Stand |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
for (const extensionClass of extensions) { | ||
/** | ||
* Create extension | ||
*/ | ||
const extension = new extensionClass(editor, standAPI); | ||
|
||
/** | ||
* If extension has styles, add them to the stand | ||
*/ | ||
if (extension.styles) { | ||
styleElement.textContent += extension.styles; | ||
} | ||
|
||
/** | ||
* Create button to toggle extension | ||
*/ | ||
const btn = document.createElement('button'); | ||
btn.addEventListener('click', () => { | ||
extension.control.onActivate(); | ||
btn.classList.toggle('dev-stand__extensions-button--active'); | ||
}); | ||
btn.innerHTML = extension.control.icon; | ||
btn.classList.add('dev-stand__extensions-button'); | ||
|
||
/** | ||
* Create container for extension | ||
*/ | ||
const extensionContainer = document.createElement('div'); | ||
extensionContainer.classList.add('dev-stand__extensions-item'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code could be organised better with classes or methods
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
// {{{ Core }}} | ||
|
||
const standAPI = new StandAPI('editorjs'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think editorWrapper should not be hardcoded here, but passed from somewhere as link
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Co-authored-by: Peter Savchenko <[email protected]>
…s to stand, created two folders
tsconfig.json
Outdated
"include": ["editorjs.config.ts", | ||
"setup", "editorjs.config.sample.ts", "vite.config.ts", "dev-stand"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bad line breaks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed
|
||
// {{{ Core }}} | ||
|
||
const standAPI = new StandAPI(editorHolderId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we pass editorHolder
element instead of id? so we won't need to find it again in DOM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
Co-authored-by: Peter Savchenko <[email protected]>
…ools into feature/added-extensions
/templates
folderExtension
typeStandAPI
to work with editor.js wrapperstand.js