-
Notifications
You must be signed in to change notification settings - Fork 185
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
percentage-fontsize plugin implementation #688
base: master
Are you sure you want to change the base?
Conversation
specifying font size as a percent value as used in phpBB system.
344f1d2
to
28e44d7
Compare
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.
For now, just those. I'll think about the (non-obvious) others when able.
src/lib/SCEditor.js
Outdated
* @memberOf SCEditor.prototype | ||
*/ | ||
base.wysiwygGetTags = function (tagName) { | ||
return wysiwygDocument.getElementsByTagName(tagName); |
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 returns a live ordered collection of Elements by tag name.
Either be explicit about it in its documentation or change the code into something most programmers would expect from it
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'll check other methods, maybe it will be easier to just inject the HTML tags instead of using execCommand
* @type {Object} | ||
* @private | ||
*/ | ||
var sizes = [50, 75, 100, 150, 200]; |
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.
Does this behave like a constant? If so, turn the variable name into CAPS
Personally, I'd have a default value but allow setting options to change it
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.
good point. updating.
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.
Is there a documentation for plugin configuration fomat?
Couldn't find any documentation for format.js configuration for example...
sceditor.command.set('size', { | ||
exec: commandHandler, | ||
txtExec: commandHandler, | ||
tooltip: 'Font Size' |
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.
Use _
function to make it translatable or allow it to be translable somehow.
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.
Please explain what do you mean here.
_
for what function?
What does "translatable" means?
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's a function named _
. See: https://www.sceditor.com/api/sceditor/underscore/
"translatable" <=> To be able to have a different text on the node based on the current language
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.
Sorry, but I don't understand what function do you mean that have to be with underscore or translatable.
I'm basing my code the same way as is appears in the format plugin that Sam wrote and as defaultCommands.js code looks like...
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.
Ah, OK. The code sends tooltips through the translation function when displaying:
https://github.com/samclarke/SCEditor/blob/master/src/lib/SCEditor.js#L712
I had forgotten about that.
src/plugins/percentage-fontsize.js
Outdated
var size; | ||
|
||
if (!fontSize) { | ||
fontSize = element.style['font-size']; |
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.
element.style['font-size']
-> element.style.fontSize
Change the method to inject the HTML.
The plugin allows specifying font size as a percent value as used in phpBB system.