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

Vue 3 support #277

Open
oleksii-shaposhnikov opened this issue Apr 13, 2021 · 9 comments
Open

Vue 3 support #277

oleksii-shaposhnikov opened this issue Apr 13, 2021 · 9 comments
Labels
enhancement New feature or request

Comments

@oleksii-shaposhnikov
Copy link

Hey guys, are you going to add support for Vue 3?

@inspire22
Copy link

Anyone make any progress with this? It kinda works with 3.1 but there are errors with trying to access refs.trix for some reason.

vue-trix.esm.js:83 Uncaught TypeError: Cannot read property 'editor' of undefined at Proxy.emitBeforeInitialize (vue-trix.esm.js:83) at callWithErrorHandling (vue.runtime.esm-bundler.js:1341) at callWithAsyncErrorHandling (vue.runtime.esm-bundler.js:1350) at HTMLElement.invoker (vue.runtime.esm-bundler.js:10704) at triggerEvent (trix.js:15) at HTMLElement.connect (trix.js:21) at HTMLElement.n (trix.js:15) at insert (vue.runtime.esm-bundler.js:10341) at mountElement (vue.runtime.esm-bundler.js:6894)

@inspire22
Copy link

I found this guy saying to add it to the compiler options, but this doesn't work with the current 3.1 with or without compabitlity mode.

https://laracasts.com/discuss/channels/vue/vue3-and-trixeditor-failed-to-resolve-component-trix-editor

Looking at the source, this seems to be the problem:
*/
function EmitBeforeInitialize (component) {
return {
methods: {
emitBeforeInitialize: function emitBeforeInitialize (event) {
this.$emit('trix-before-initialize', this.$refs.trix.editor, event);
}
}
}
}

I believe it's because $refs isn't populated currently until after initialization (which seems stupid)

Having vue return in this method instead of emitting seems to solve it; I'm not sure if anything depends on this signal or not...

@hanhdt hanhdt added the enhancement New feature or request label Jun 18, 2021
@AminaMAHROUCH
Copy link

There's no update for this issue ?

@inspire22
Copy link

It's working great for me now on 3.1 if you edit the source after installing and have that function return

vi ./node_modules/vue-trix/dist/vue-trix.esm.js
line 82-82

I'm not sure what the consequences of not having that event are.

Also v-model isn't working with 3.x as it's changed, but you can have a function in @input that sets your local variable with the passed in value.

<VueTrix @input="trixSave" />

then in methods:

trixSave(v) {
			this.body= v;
		},

@eugenevk
Copy link

eugenevk commented Jan 4, 2022

Any update on supporting VueJS 3.0?

@sawirricardo
Copy link

Any update?

1 similar comment
@gideonpeters
Copy link

Any update?

@nomadjimbob
Copy link

nomadjimbob commented Jan 7, 2023

I've written my own Vue3 component heavily based on this and made it public at https://gist.github.com/nomadjimbob/db6d3cdb630a931722595f9adf75ca53

Not 100% tested but a starting point

  • srcContent prop is updated correctly
  • Fixed the ref issues. Seems under Vue3 Trix is not fully initialized when mounted or when some of the watchers are called, so I have added the code to queue calls until Trix is initalized

Also includes a few little helpers for creating toolbar buttons with some examples included based on some submitted over on the Trix repo

@mralston
Copy link

I've written my own Vue3 component heavily based on this and made it public at https://gist.github.com/nomadjimbob/db6d3cdb630a931722595f9adf75ca53

Thanks James! 😃

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

No branches or pull requests

9 participants