Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Nov 26 14:47
    marijnh commented #1218
  • Nov 26 14:41
    katepol commented #1218
  • Nov 26 14:37
    marijnh commented #1218
  • Nov 26 14:14
    katepol commented #1218
  • Nov 26 09:23
    lmf commented #1223
  • Nov 26 08:38
    marijnh commented #1223
  • Nov 26 08:07
    lmf commented #1223
  • Nov 26 07:49
    marijnh commented #1223
  • Nov 26 07:49
    marijnh closed #1223
  • Nov 26 07:48
    marijnh commented #1223
  • Nov 26 02:48
    lmf opened #1223
  • Nov 25 17:16
    chrisdone commented #1222
  • Nov 25 14:47
    chrisdone commented #1222
  • Nov 25 12:56
    marijnh closed #1222
  • Nov 25 12:56
    marijnh commented #1222
  • Nov 25 11:57
    chrisdone opened #1222
  • Nov 25 07:18
    lmf commented #1221
  • Nov 25 07:16
    lmf commented #1221
  • Nov 25 07:03
    marijnh closed #1221
  • Nov 25 07:03
    marijnh commented #1221
Michael Rutter
@m-rutter
Say I have a Slice that has nodes tied to a specific schema
and I want to replace all of those nodes with something else, what would I need to do? It doesn't seem like I can perform a transaction on Slice
I can get a flat list of the nodes via descendents callback on the Fragment content on the slice, but I'm not sure how to replace content
for some context, I have a tool that allows authors to create snippets for later insertation into another document that need to be serialized to the database. Some of the custom nodes on the document are essentially variables that I want to identify and replace
effectively, I'm creating a template
Marijn Haverbeke
@marijnh
A recursive function that runs through the slice's fragment, building up a new tree and returning that, seems like the way to do that.
Michael Rutter
@m-rutter
Are you suggesting doing that in its serialized or deserialised form?
I'm guessing deserialised Slice or Fragment I'm guessing you are suggesting I build a second fragment recurively calling appendChild or append, and computing a new fragment on each step?
Or if its serialised JSON mutating a copy the tree in place as I step through the tree?
Michael Rutter
@m-rutter
first time using prosemirror, and quite liking it
Marijn Haverbeke
@marijnh
Both work. I'd just build up the children on a given level as an array, and then call Fragment.from to create the fragment.
Andrew Kirwin
@amk221

I'm trying to write a test that interacts with a prosemirror instance. It is using Ember's test helper e.g. await fillIn('.ProseMirror', '<p><a href="#">test</a></p>');. (this is essentially the same as setting .innerHTML).

With the goal of acceptance testing, a round-trip through parseDOM to make sure the markup generated is as expected.

But this doesn't work - the result is just <p>test</p>. Where did the mark go?

This is reproducible on the demo on the Prosemirror website if you use the dev tools to edit the HTML. Sometimes it works, others it doesn't, I can't seem to find a pattern.

What's going on here and what's the best way to achieve this?

I could of course use ProseMirror commands, but then that is not testing our application as if a user was interacting with it.

ravi7mech
@ravi7mech
Hi
ravi7mech
@ravi7mech
I have successfully integrated the https://github.com/benrbray/prosemirror-math, with https://www.npmjs.com/package/ngx-editor. But when I try to insert the latex using the insertMathCmd(https://github.com/benrbray/prosemirror-math/blob/master/src/commands/insert-math-cmd.ts), The data is not updating in view(or i don't know how to pass the data to that command). Actually, it returns the NodeType instance... But dont how to write the data in view using that? Can anybody help me with this?
Marijn Haverbeke
@marijnh
@amk221 Does this reproduce when you directly call DOMParser methods to parse? What does the fromDOM for your link mark look like? I can't reproduce this on the demos
I'll take a look at the fromDOM 👀
edit wait, do you mean parseDOM :)
Andrew Kirwin
@amk221
thanks yeh I think it was that, I needed to provide a title for it to work
Andrew Kirwin
@amk221
Quick Q - how come the list schema uses order which then maps to the start attribute? Wouldn't it make more sense to call it start?
Is there something else going on here that I'm no aware of?
Marijn Haverbeke
@marijnh
That descend from terminology used in markdown-it, which I later realized is kind of quicky, but it doesn't seem a big enough deal to cause a breaking change for at this point.
Andrew Kirwin
@amk221
Ok thanks 👍🏻
Andrew Kirwin
@amk221

Hi all, I'm still battling with the kludge line breaks.

As I understand it, they are added to a node to make that node visible - so the cursor can land in it (otherwise it would collapse).

What I don't understand is why it is added when there is already content there, preventing such a collapse.

It seems (to me at least) to create more problems than it solves in this scenario.

Our prosemirror instance supports quite a broad range of HTML nodes and styles, and no matter how hard I try, whatever I paste into ProseMirror, it never looks like the source it was copied from.

Can anybody help?

Marijn Haverbeke
@marijnh
It only adds the extra nodes to non-empty blocks when they end in an uneditable node, because otherwise the browser (often, depending on the situation and browser) won't let you put your cursor after that.
As for the pasting problem, I don't think that has much to do with the hack nodes.
Andrew Kirwin
@amk221

Thanks for the response, but I still must be missing the point!

Here is a screencast example: https://share.getcloudapp.com/jku4WGzm

In it, I:

Notice how the kludge br means the pasted HTML does not visually match where it was copied from. (It creates a space underneath the icons)

How can I get it to render the same as the serialized HTML?

Andrew Kirwin
@amk221

I've narrowed it down to something to do with:

<img class="ProseMirror-separator" />
<br>

...when inside a table:
Instructions for reproducing here: https://jsfiddle.net/amk221/L2mqevax/

Andrew Kirwin
@amk221
I'm hoping to raise an issue, with your approval Marijn
Marijn Haverbeke
@marijnh
I don't think there is an issue. The HTML in the editor will look different from the plain document HTML, if you don't add a kludge for this to your serializer. And that's okay—it's a semantic editor, not microsoft word.
Andrew Kirwin
@amk221

Ok thank you I undertsand that :thumbsup: Ignoring my screen cast though, did you try the js fiddle?

I'm not sure if it's something that should be fixed in prosemirror-tables or prosemirror-view.

Andrew Kirwin
@amk221
(an img with no src, followed by a br in a td seems to be behaving oddly)
Marijn Haverbeke
@marijnh
The bug tracker might be better for this kind of thing. I still don't understand what the problem is or how you could manage to copy a ProseMirror-separator node (copying from the editor should not include those), nor how the table plugin could be involved in the pasting of <img> and <br> nodes.
Andrew Kirwin
@amk221
Oh no I didn't copy it, it gets created when pasting
Andrew Kirwin
@amk221
I understand whats going on now. addHackNode is used when a node is a block level element and contains only inline content. But, crucially - if one of those inline elements has a style that turns it in into block level element the hack node will apply when it doesn’t need to.
Andrew Kirwin
@amk221
:) So it's not to do with tables, it just happens that that's how discovered it.
Could ProseMirror could use getComputedStyle to check for genuinely inline elements? instead of using the schema?
Marijn Haverbeke
@marijnh
Okay, I think I see what you're doing now, but my suggested solution would be to not do that. If your images are blocks, define them as block nodes in the schema. If they are inline, make sure they are styled to be inline as well. The correspondence between schema block/inline nature and styling is just an assumption the library makes.
Andrew Kirwin
@amk221
Thanks for baring with me on that one!
Would you consider adding a class name to the hack <br> element, in the same way that you do for the hack <img class="ProseMirror-separator"> element. That would help distinguish them.
Marijn Haverbeke
@marijnh
I guess we could do that. Do you intend to hide them with CSS somehow? A PR that adds this should be noncontroversial.
Andrew Kirwin
@amk221
Yes, that would be great. I could do that,
Do you have any idea what such a class name would be acceptable?
Marijn Haverbeke
@marijnh
I'd go with "ProseMirror-trailingBreak"
denny
@dennyluan
hello is there an easy way to merge two editor states?
say that I'm trying to create an updated EditorState from react props changing
or is it better to just make the editorstate receiveTransaction() on whatever the diff is?
denny
@dennyluan
Sarvar Dhillon
@SarvarD

Hi, I have what's likely a very silly question but haven't been able to find docs/similar recent Gitter posts. I'm trying to write tests for my inputrules by simulating user text input. I first tried @marijnh's suggestion here to no avail - I found using the view.someProp(handleTextInput) with text that matches input rule regex triggers basic input rules, but using that same function with text that doesn't trigger any input rules doesn't update the view's state at all. I've also tried copying pieces of the tests from prosemirror-view (and using the compose function) and am able to edit the DOM, but it doesn't seem like those DOM edit events are being propagated to the view.

My question is: what's the recommended way to simulate users entering input for the purposes of integration testing?

Marijn Haverbeke
@marijnh
You could either make your test asynchronous, so that the mutation observer fires, or call view.domObserver.flush() to force synchronous reading from the DOM. That's not part of the public interface, but should be stable enough for a test.
Shaun Grady
@shaungrady
Hi y'all. Is it possible to force the order of node content? I want to create a definition list with a single DT first, then one or more DL's; e.g., content: 'DT{1} DL{1,}'
Shaun Grady
@shaungrady
OK, got it implemented, now I see why no one replied. 😛 Just wasn't specified in the docs.
Sarvar Dhillon
@SarvarD
@shaungrady, how'd you do it?
2 replies
Sarvar Dhillon
@SarvarD

@marijnh, thanks for the advice. I've been tinkering with this for a few days, and the async approach seems to work (wrapping my assertion in a setTimeout). However, i'd really like to get this to work synchronously via the flush call. Right now, that call is failing to mark the docview as dirty (domobserver.js line 173) because from is always -1. I suspect this is due to my test environment using jsdom, and jsdom not having implementations of certain functions like getClientRects, getBoundingClientRect. Because markDirty doesn't get called, we skip the updateState call on line 177.

I don't follow how the prosemirror-view tests emulate a browser env, and think that's the piece i'm missing here to get things working synchronously. Apologies if my debugging here is totally off, and thanks for the help so far

1 reply
Marijn Haverbeke
@marijnh
Oh, no, running the view on JSDOM is definitely not going to work. I'm surprised it didn't crash on some missing API right away.
1 reply
The library's own tests don't emulate a browser env, they run in a full browser.