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

Make line numbers in the editor optional #879

Merged
merged 4 commits into from
Feb 3, 2018

Conversation

xxdavid
Copy link
Contributor

@xxdavid xxdavid commented Sep 20, 2017

Add an option to disable the line numbers in the Markdown editor.

@asmsuechan
Copy link
Contributor

image

Copy link
Contributor

@asmsuechan asmsuechan left a comment

Choose a reason for hiding this comment

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

Please add it in snippet note
image

@@ -50,7 +50,7 @@ export default class CodeEditor extends React.Component {
this.value = this.props.value
this.editor = CodeMirror(this.refs.root, {
value: this.props.value,
lineNumbers: true,
lineNumbers: this.props.lineNumber,
Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer lineNumbers as the variable name.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I prefer lineNumbers too. I used lineNumber as it was already used somewhere else in the code.

Copy link
Contributor

@asmsuechan asmsuechan Oct 1, 2017

Choose a reason for hiding this comment

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

it was already used somewhere else in the code.

Where is it? I could not find it...
Does it mean you chose lineNumber because there are probabilities to conflict?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's used for the line numbers in the preview. Here, for example.

Copy link
Contributor

@asmsuechan asmsuechan Oct 1, 2017

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So should I change it to lineNumbers?

@@ -213,6 +213,8 @@ class MarkdownEditor extends React.Component {
if (!(editorFontSize > 0 && editorFontSize < 101)) editorFontSize = 14
let editorIndentSize = parseInt(config.editor.indentSize, 10)
if (!(editorFontSize > 0 && editorFontSize < 132)) editorIndentSize = 4
let editorLineNumber = config.editor.lineNumber
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think the name editorLineNumber is appropriate because it's a boolean.

Copy link
Contributor Author

@xxdavid xxdavid Oct 1, 2017

Choose a reason for hiding this comment

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

Is editorShowLineNumbers better? Or just showLineNumbers? Or what do you propose?

Copy link
Contributor

@asmsuechan asmsuechan Oct 1, 2017

Choose a reason for hiding this comment

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

isLineNumberShown? Umm, I'm not sure if it's better...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't think that fits the plural form (lineNumbers) you suggested...

Copy link
Contributor

@asmsuechan asmsuechan Oct 1, 2017

Choose a reason for hiding this comment

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

I often use is even if the var name is plural, and the prefix is describes it's a boolean value. isLineNumbersShown...?
Did you mean this kind of thing?

https://stackoverflow.com/questions/12960554/java-boolean-getters-is-vs-are

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 then. I meant just the language (English) thing. Other than that, I think isLineNumbersShown is fine.

@@ -213,6 +213,8 @@ class MarkdownEditor extends React.Component {
if (!(editorFontSize > 0 && editorFontSize < 101)) editorFontSize = 14
let editorIndentSize = parseInt(config.editor.indentSize, 10)
if (!(editorFontSize > 0 && editorFontSize < 132)) editorIndentSize = 4
let editorLineNumber = config.editor.lineNumber
if (editorLineNumber === undefined) editorLineNumber = true
Copy link
Contributor

Choose a reason for hiding this comment

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

const editorLineNumber = config.editor.lineNumber || true or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If config.editor.lineNumber were false (disabled), config.editor.lineNumber || true would be true. I don't think that's what you want.

Copy link
Contributor

@asmsuechan asmsuechan Oct 1, 2017

Choose a reason for hiding this comment

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

What are cases that config.editor.lineNumber to be undefined? The setting should be true or false.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, sorry, of course, you are right. I used that before I declared the property in the ConfigManager.js.

Copy link
Contributor

@asmsuechan asmsuechan Oct 1, 2017

Choose a reason for hiding this comment

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

If config.editor.lineNumber were false (disabled), config.editor.lineNumber || true would be true. I don't think that's what you want.

I got it.

const editorLineNumber = config.editor.lineNumber === undefined ? config.editor.lineNumber : true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm confused, sorry. The variable can't be undefined (as you said), can it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I was confused, too lol

Forget about the ternary operation.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Or we can just use config.editor.lineNumber directly here, I think 😄 .

@@ -530,6 +530,7 @@ class SnippetNoteDetail extends React.Component {
fontSize={editorFontSize}
indentType={config.editor.indentType}
indentSize={editorIndentSize}
lineNumber
Copy link
Contributor

Choose a reason for hiding this comment

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

?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought Snippet notes should always have line numbers. Shouldn't they?
(lineNumber is equal to lineNumber={true}.)

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 a little regarding the specification.

(lineNumber is equal to lineNumber={true}.)

Understood.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So do you want Snippet notes to respect this setting or should they always show the line numbers?

@kazup01
Copy link
Member

kazup01 commented Oct 26, 2017

Hi @asmsuechan and @xxdavid , how is this state?

@xxdavid
Copy link
Contributor Author

xxdavid commented Oct 26, 2017

@kazup01, I'm waiting for @asmsuechan to tell what we have agreed on and what to change.

@@ -141,6 +141,10 @@ export default class CodeEditor extends React.Component {
this.editor.setOption('indentWithTabs', this.props.indentType !== 'space')
}

if (prevProps.lineNumber !== this.props.lineNumber) {
this.editor.setOption('lineNumbers', this.props.lineNumber)
}
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 you can set even if prevProps.lineNumber !== this.props.lineNumber is false.
Is it for performance?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it is and as you can see, the checks are performed for all the options in the componentDidUpdate method.

@sota1235
Copy link
Contributor

sota1235 commented Nov 5, 2017

@xxdavid Hi! I'm one of maintainers of Boostnote.
How's this PR status? I think you got some advices from @asmsuechan .
After you fix, plz tell me. Then I will check and merge!
Thank you

@kazup01 kazup01 added awaiting review ❇️ Pull request is awaiting a review. awaiting changes 🖊️ Pull request has been reviewed, but contributor needs to make changes. and removed awaiting review ❇️ Pull request is awaiting a review. labels Nov 7, 2017
@kazup01
Copy link
Member

kazup01 commented Nov 20, 2017

Hi @asmsuechan , we are waiting for your reply. Could you check @xxdavid's comments ?

@xxdavid
Copy link
Contributor Author

xxdavid commented Nov 20, 2017

Sorry for still not updating the PR, but I'm unsure about the variable naming (lineNumbers/lineNumbers) and whether should snippet notes respect this option (and don't show the line numbers if it is disabled) or show it always.

@kazup01 kazup01 added awaiting review ❇️ Pull request is awaiting a review. and removed awaiting changes 🖊️ Pull request has been reviewed, but contributor needs to make changes. labels Dec 9, 2017
@sota1235 sota1235 removed their assignment Dec 13, 2017
@kazup01 kazup01 added awaiting changes 🖊️ Pull request has been reviewed, but contributor needs to make changes. and removed awaiting review ❇️ Pull request is awaiting a review. labels Dec 14, 2017
@sferra
Copy link
Contributor

sferra commented Dec 21, 2017

@xxdavid just in case you are still pondering on the variable naming: maybe consider the name displayLineNumbers.

i would also suggest handling the snippets separately (as in: new ticket/discussion, new pull request). that way this pull request could be closed while still keeping the discussion/issue alive.

@xxdavid
Copy link
Contributor Author

xxdavid commented Dec 23, 2017

@sferra, yeah, I agree, this suits the purpose best in my opinion.
I'll change all the variables to displayLineNumbers.

@xxdavid
Copy link
Contributor Author

xxdavid commented Dec 23, 2017

I've pushed the changes. I also changed snippet notes to respect the option.
Could it be merged now, please?
And merry Christmas to you all! :)

@Rokt33r
Copy link
Member

Rokt33r commented Jan 25, 2018

@xxdavid
Sorry for being late. I'll review this on this weekend and release within the next week.

@Rokt33r Rokt33r merged commit a64f73c into BoostIO:master Feb 3, 2018
@Rokt33r Rokt33r added next release (v0.8.21) and removed awaiting changes 🖊️ Pull request has been reviewed, but contributor needs to make changes. labels Feb 3, 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.

6 participants