Comments (22)
What browser?
from codejar.
In Chrome.
from codejar.
However when I play with the demo on the CodeJar website it works.
It only happens in my own code which is why I was thinking I might need some custom code...
from codejar.
Please show code.
from codejar.
Okay, I am uploading two screen shots....The first one will be when I click on the editor and try to add a line.....and then after....
from codejar.
It is a little hard to see but the cursor goes from the middle to the bottom....
from codejar.
const editor = this.element.querySelector(".editor");
const options = {tab: ' '.repeat(2)}
const highlight = (editor) => {
editor.textContent = editor.textContent
hljs.highlightBlock(editor)
}
this.codejar = new CodeJar(editor, highlight, options);
if (this.content) {
this.codejar.updateCode(this.content);
}
from codejar.
This is the code that sets up the editor....I am using HighlightJS.
from codejar.
Here is the HTML:
<div class="editor ${language}" contenteditable="true" spellcheck="false"></div>
The ${language}
is rendered as language-html
, etc.
from codejar.
Take a look at https://github.com/antonmedv/codejar/blob/master/index.html#L51-L56
And try:
const highlight = editor => {
// highlight.js does not trim old tags,
// let's do it by this hack.
editor.textContent = editor.textContent
hljs.highlightBlock(editor)
}
from codejar.
I am already doing that from code I provided.
from codejar.
Try to debug. Place debug point before restore call.
from codejar.
Okay, where is the restore call?
Is it this?
editor.textContent = editor.textContent
from codejar.
Okay, I have created a working example for you to look at. Try and interact with the editor and you will see the behavior I am talking about.
https://gist.dumber.app/?gist=2d92b9a716610764fe4d4a9210b5c388
from codejar.
The code to look at is in code-editor.js
in the attached
function. You will see that is where I am setting up CodeJar....
from codejar.
Okay, it appears that CodeJar doesn't support ShadowDOM. I have been testing by building web components with ShadowDOM turned on and the moment I turned it off, it seems to work fine.
It would be really nice to support this. It is very easy to detect this on an element checking for shadowRoot
.
I would love to see this support get added!
from codejar.
Nice!
from codejar.
So, do you plan on supporting ShadowDOM?
from codejar.
I was able to modify the source code slightly to support ShadowDOM.
from codejar.
Please send PR.
from codejar.
Done. I updated the .gitignore in my version. Sorry about that.
from codejar.
I am running into the same issue myself with the editor inside a web component using the Shadow DOM. I hope the PR will be merged soon 😊
from codejar.
Related Issues (20)
- missing line numbers HOT 8
- Conflict with ibus IME if highlighting is enabled HOT 8
- HTML tag Bug
- Uncaught SyntaxError: ambiguous indirect export: CodeJar HOT 1
- demo.html won't render HOT 1
- Allow keyboard navigation when capturing tab HOT 1
- cursor hides behind linenumbers HOT 2
- Cursor jumps to end of editor when deleting certain text nodes in Firefox HOT 1
- [Feature request] Add option to auto-unindent
- addClosing: Tab should jump to after the bracket
- Backspace forces cursor to end of text (Firefox)
- addClosing option doesn't work with CDN import
- Document Issue: `Prism.highlightElement` should not be directly used as highlighting function HOT 1
- Strg+A Strg+C copies only subselection in Firefox (when plaintext-only is not supported) HOT 5
- README image has uses `new CodeJar` instead of just `CodeJar`
- Self closing characters logic HOT 4
- Is there any way to configure text wrapping? HOT 1
- [BUG] Cut text & undo not working
- [Feature Request] Multiline Indentation with Tab Key HOT 6
- Typescript source files in bundled package HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from codejar.