-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
How I achieved image sizing, and a question about setNode (Low priority) #1283
Comments
Ah I can see the image extensions has already been updated to use |
I've updated my example to use insertContent or updateAttributes after tracing setNode through to where it calls setBlockType in ProseMirror, which only operates on text blocks. |
@joevallender How would u solve image alignment with text? |
In the same way, I think. Just as I've added Do you have a particular use case in mind to share? |
@joevallender I have my own implementation, so I was curious. I have multiple types of bubble menu content depending on the node. What about image resizing on dragging the image? |
So far I'm using v2 on one project which only requires some preset image sizes, not as a full text/page editor, so I haven't looked into it. For resizing, I'd probably leverage an existing library invoked based on the image class, and then run equivalent commands on the extensions to set node attributes for width and height in the 'stopped resizing' callback of the library. |
I'd be interested to see your approach if you can link to a repo or example? |
@joevallender Still in progress, but you can check: https://github.com/ExtensionEngine/tce-tiptap/tree/v2 |
Ah that's interesting, thanks! I know the documentation is still in progress on tiptap, but this gives me a few ideas :) |
If I build something more complete like this, I'll share it too. I just thought I'd pull out a few references from my quite project-specific code to share |
@joevallender I learned lot from here: https://github.com/Leecason/element-tiptap. My repo for v1 was heavily inspired by this. |
@joevallender when updating attributes I think you should leverage the this.editor.commands.updateAttributes('image', { size }); Btw, also check this issue when working with images and bubble menu: #1313 |
Thanks again. Yep, updateAttributes is what I ended up using in I'd actually noticed issues with bubble menu positioning even without floats on images, but the code I shared was just some (hopefully) helpful snippets for others to read - I wasn't actually using the bubble menu in my project's UI. However, it would be nice to get to the bottom of it - so I'll look into it too. Thus far I've only been playing with extensions, but this is such a great project, it definitely warrants cloning and playing with :) |
Thanks for sharing @joevallender! |
Not really a problem, just sharing some code to possible help others, and a quick question about how to improve the implementation.
I needed to add basic image sizing in tiptap2/vue3 and did so by referring to a mixture of the existing code for image, heading, and bubble menu.
Here is a
Question
My question is about the best way to update the node. The image extension replaces the selection with a new node, and the heading extension runs
commands.setNode
which appears to be the cleaner options.When setting a size attribute on images,
commands.setNode
appeared to have no effect. I guessed that maybe a selected image needs to be treated differently to selected text, but I couldn't work it out. When I'm replacing the selection, changing between image sizes isn't as slick as I would like because of the delay in the browser re-drawing the image node. I'm wondering if I can get setNode to work, it might simply update the attributes, and keep things smoother?If you can clarify, and I can better understand, I'd be happy to work on a more fully featured image extension.
And, thanks for tiptap!
The text was updated successfully, but these errors were encountered: