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

Code highlight doesn't update unless a model is linked #35

Closed
leandro-benedet-garcia opened this issue Aug 14, 2019 · 4 comments · Fixed by #57
Closed

Code highlight doesn't update unless a model is linked #35

leandro-benedet-garcia opened this issue Aug 14, 2019 · 4 comments · Fixed by #57
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@leandro-benedet-garcia
Copy link

Hello, I was testing this package and I found it quite interesting, however, I found a issue, which happens in the main demo too. If I update the code, aka, type a new one in the window, the new code won't have a new highlight. If I set a default code, it will have the highlight.

However, if I link it to a data model, the highlight works just fine. Below I gave some snippets.

Also, if that's expected, just ignore me :-P

Browser: Firefox 68.0.1
example code:
With this code the highlight doesn't work

Vue.use(BootstrapVue);
Vue.component("prism-editor", VuePrismEditor);

var default_app = new Vue({el: "#app"});
<prism-editor emit-events line-numbers language="js"></prism-editor>

With this code, the highlight work just fine.

Vue.use(BootstrapVue);
Vue.component("prism-editor", VuePrismEditor);

var default_app = new Vue({
    el: "#app",
    data: {
        code: ""
    }
});
<prism-editor v-model="code" emit-events line-numbers language="js"></prism-editor>

Also, if you want a complete working code can be found in my package:
https://github.com/Cerberus1746/PandaCoreData/tree/development/panda_core_data/ui

@koca
Copy link
Owner

koca commented Aug 14, 2019

Hi thanks.
If you don't give a model what is the purpose of using it? Just trying to understand your use case.

@leandro-benedet-garcia
Copy link
Author

Exactly! :V

But I took a while to realize what the issue was because I am a noob with vue. So I would suggest raising an exception if a model could not be found, and it was kinda weird because it was an error that was happening in the demo too.

@koca koca added the good first issue Good for newcomers label Aug 14, 2019
@koca
Copy link
Owner

koca commented Aug 14, 2019

Alright maybe we'll do sth about it :) Cheers.

@koca koca added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels Aug 14, 2019
@trusktr
Copy link

trusktr commented Aug 16, 2019

Note! Without using v-model, it's still useful to use prism-editor with the @change event to achieve similar results.

		<prism-editor
			:code="value"
			@change="handleChange"
			language="html"
			:lineNumbers="false"
		/>

That's a good reason for it to work without v-model. Other than syntax-highlight not updating, @change is working great for my purposes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants