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

[Feature] ABC Notation Extension #1354

Merged
merged 18 commits into from
Aug 22, 2018
Merged

Conversation

flxwu
Copy link
Contributor

@flxwu flxwu commented Aug 1, 2018

For users to be able to document their music note sheets live in StackEdit, I implemented an extension that parses an ```abc block an renders an svg using abcjs.

Resolves #1339.

Screenshot:
2018-08-01_22_42_09

@flxwu flxwu mentioned this pull request Aug 1, 2018
@flxwu flxwu changed the title Feature/abc notation - Implements #1339 [Feature] ABC Notation Extension Aug 1, 2018
@flxwu
Copy link
Contributor Author

flxwu commented Aug 16, 2018

@benweet Are you reviewing this? 😃

@@ -0,0 +1,23 @@
import abcjs from 'abcjs';
Copy link
Owner

Choose a reason for hiding this comment

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

Please rename the file to abcExtension.js.

@@ -89,5 +97,8 @@ export default {
mermaid: {
enabled: true,
},
abc: {
enabled: false,
Copy link
Owner

Choose a reason for hiding this comment

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

I think we can enable the extension by default.

if (document.querySelector('#abcSheetPaper') != null && abc != null) {
abcjs.renderAbc('abcSheetPaper', abc, {});
}
});
Copy link
Owner

Choose a reason for hiding this comment

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

No need to do all of this. No need to have a markdown-it plugin. Please have a look at the mermaid extension. You only need to do this:

extensionSvc.onGetOptions((options, properties) => {
  options.abc = properties.extensions.abc.enabled;
});

extensionSvc.onSectionPreview((elt) => {
  elt.querySelectorAll('.prism.language-abc')
    .cl_each(diagramElt => render(diagramElt.parentNode));
});

@flxwu
Copy link
Contributor Author

flxwu commented Aug 21, 2018

done @benweet

See https://abcjs.net/
*/
abc: {
enabled: true,
Copy link
Owner

Choose a reason for hiding this comment

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

In the zero preset, it should be off.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

right

@@ -25,6 +25,7 @@
},
"dependencies": {
"@vue/test-utils": "^1.0.0-beta.16",
"abcjs": "git+https://[email protected]/flxwu/abcjs.git",
Copy link
Owner

Choose a reason for hiding this comment

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

Should point to an actual version. Why not use the official one ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because we have to modify a css property in the abcjs svg generator to generate overflow:scroll instead of hidden

Copy link
Owner

Choose a reason for hiding this comment

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

Why not override the css property in StackEdit? (with an !important rule I suggest)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what I initially thought would work as well but abcjs overwrites the parent div's style property entirely

const render = (elt) => {
const abcContent = elt.textContent;
elt.parentNode.parentNode.id = 'abcSheetPaper';
abcjs.renderAbc('abcSheetPaper', abcContent, {});
Copy link
Owner

Choose a reason for hiding this comment

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

No need to use an id, you can pass the element itself.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

@benweet benweet merged commit 72e5ac8 into benweet:master Aug 22, 2018
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.

None yet

2 participants