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

<textarea> and <pre> are not aligned when a width is set #34

Closed
francesca-cicileo opened this issue Mar 23, 2017 · 19 comments
Closed

<textarea> and <pre> are not aligned when a width is set #34

francesca-cicileo opened this issue Mar 23, 2017 · 19 comments
Labels
Milestone

Comments

@francesca-cicileo
Copy link

Testcase: http://codepen.io/fcicileo/pen/LWrGwE

image

It appears that when the container has a specific width set via CSS, the code in the <textarea> and the <pre> is not aligned anymore.

@kazzkiq kazzkiq added the bug label Mar 23, 2017
@d4hines
Copy link

d4hines commented Mar 24, 2017

I've noticed this too. Can anyone recommend short term fix? Any kind of workaround would do for my purposes.

@kazzkiq
Copy link
Owner

kazzkiq commented Mar 24, 2017

@d4hines These properties seem to quick-fix the issue:

.CodeFlask__textarea {
  white-space: nowrap;
  overflow-x: hidden;
}

While this CSS helps, the real solution will be implementing horizontal scrolling support for CodeFlask. As of today, it only support vertical scrolling it seems.

@kazzkiq kazzkiq added this to the v0.3.0 milestone Mar 24, 2017
@d4hines
Copy link

d4hines commented Mar 28, 2017

Thanks for the response! I tried implementing the above CSS, but didn't notice any difference in the issue.

@kazzkiq
Copy link
Owner

kazzkiq commented Apr 18, 2017

@d4hines That must be overriding by another rule. Adding .CodeFlask to the selector should help override it:

.CodeFlask .CodeFlask__textarea {
  white-space: nowrap;
  overflow-x: hidden;
}

@d4hines
Copy link

d4hines commented Apr 18, 2017

Hi Kazzkiq,
I tried adding the code you suggested, but am still getting weird formatting issues. If you have the time, could you look at this JsFiddle I've created and tell me what I'm doing wrong: https://jsfiddle.net/d4hines/bb02ykx7/
Thanks!

@kazzkiq
Copy link
Owner

kazzkiq commented Apr 19, 2017

@d4hines It seems to be a issue with the CSS. The selector is applying same properties to both <pre> and <code>, where <code> shouldn't receive those.

The main issue seems to be with <code> also receiving position: absolute. Removing that property for this element seems to fix the issue, as you can see here.

So basically a quick-fix should be adding this to your CSS in order to override the property from CodeFlask:

.CodeFlask .CodeFlask__code {
  position: relative;
}

I will take a closer look to this bug this weekend, until there you can probably run smoothly with the CSS code above.

@klocus
Copy link

klocus commented Apr 30, 2017

@kazzkiq: Your fix works but after that .CodeFlask__code changes its position. I've dealt with this by adding padding: 0 !important.

bug

@ivanalemunioz
Copy link

@kazzkiq This issue was resolved in commit c441164 , but this generated a new bug, solved in Pull request #41

@scaddenp
Copy link

scaddenp commented Aug 1, 2017

I added #41 to my code and it fixed issue with very long text getting truncated in view too. I have issues with very long text getting the caret discordant with underlying text. #41 improved (out by only 1 instead of 6-7 characters) but not fixed.

@kazzkiq
Copy link
Owner

kazzkiq commented May 6, 2018

This was fixed in 1.0. Lots of changes though, since its a major version upgrade.

@kazzkiq kazzkiq closed this as completed May 6, 2018
@scaddenp
Copy link

scaddenp commented May 8, 2018

Having some is issues moving from early version to new. I have a prism language definition (sql) included as a js, (eg Prism.languages.sql={comment: etc)
but
sqlflask = new CodeFlask('#codeFlaskSQL', {language: "sql"});
isnt picking it up. Do I need to do an add language? Old version has css file. Incorporated in new?

@kazzkiq
Copy link
Owner

kazzkiq commented May 8, 2018

@scaddenp You now have to add new languages by using .addLanguage method. Example:

const sqlflask = new CodeFlask('#codeFlaskSQL', {language: "sql"});
sqlflask.addLanguage('sql', {comment: etc...});

@scaddenp
Copy link

scaddenp commented May 8, 2018

thanks. That works for highlighting. Now to sort out the css miasma...

@scaddenp
Copy link

scaddenp commented May 8, 2018

Hmm. <label>Base Query:</label> <div class="codeFlask" id="codeFlaskSQL"></div>
and stripping out any styling of that div other than body and page locators. I get textarea with no caret and odd location.
image
I am delving into the css but is this what you expect?

@scaddenp
Copy link

scaddenp commented May 8, 2018

Got the css sorted, except that no text cursor in box no matter what I do. is there an example project using codeflask that could be used for reference?

@kazzkiq
Copy link
Owner

kazzkiq commented May 8, 2018

@scaddenp You can take a look at the project website, or take a look at this example here:

https://jsfiddle.net/yx3qpqpe/

@scaddenp
Copy link

scaddenp commented May 9, 2018

Yes, thanks very much for that. What I notice is that editor.js has the codeflask-style that I see on the fiddle. However, the .codeflask-style that is injected when using codeflask.min.js is different. ie
.codeflask { position: relative; min-width: 500px; min-height: 400px; border: 1px solid #ccc; overflow: hidden; }
compared to
.codeflask { position: absolute; width: 100%; height: 100%; overflow: hidden; }
I have yet to see where this is the issue, but it looks to me as if codeflask.min.js is not reflecting the source code.

@kazzkiq
Copy link
Owner

kazzkiq commented May 10, 2018

@scaddenp You're right. There was an error with the release on npm.

It is now fixed and the version 1.0.5 now uses position: absolute as it should.

@scaddenp
Copy link

Thanks very much for your persistence. With new code and one more fiddle to css (background was same colour as text caret), I now have the caret and everything looking nice. I salute your efforts to make life easier for the rest of us.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants