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

Added ability to create extensions #6

Merged
merged 13 commits into from
Apr 20, 2023
Merged

Conversation

slaveeks
Copy link
Contributor

  1. Templates moved to /templates folder
  2. Added Extension type
  3. Added css template, and base styles for stand
  4. Added StandAPI to work with editor.js wrapper
  5. Added extensions and StandAPI to stand.js
  6. Added Read only extension

@slaveeks slaveeks requested a review from neSpecc April 19, 2023 21:09
editorConfig: {
inlineToolbar: true,
readOnly: false,
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -32,6 +33,11 @@ export default class Stand {
*/
private JSData: FileData;

/**
* Data to store into stand style file
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed it

@@ -0,0 +1,18 @@
/**
* Class for stand API, which is used to interact with editor.js wrapper
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* Class for stand API, which is used to interact with editor.js wrapper
* Class for stand API, which is used to interact with Stand

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment on lines 27 to 55
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');
Copy link
Contributor

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

Copy link
Contributor Author

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');
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@slaveeks slaveeks requested a review from neSpecc April 20, 2023 10:30
tsconfig.json Outdated
Comment on lines 17 to 18
"include": ["editorjs.config.ts",
"setup", "editorjs.config.sample.ts", "vite.config.ts", "dev-stand"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad line breaks

Copy link
Contributor Author

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);
Copy link
Contributor

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@slaveeks slaveeks requested a review from neSpecc April 20, 2023 10:55
@slaveeks slaveeks requested a review from ilyamore88 April 20, 2023 12:36
@slaveeks slaveeks merged commit 3f559e0 into master Apr 20, 2023
@slaveeks slaveeks deleted the feature/added-extensions branch April 20, 2023 15:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants