Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • 05:55
    eric-burel closed #1318
  • 05:55
    eric-burel commented #1318
  • Oct 05 08:26
    marijnh commented #476
  • Oct 05 08:25
    marijnh commented #1319
  • Oct 05 08:24
    marijnh closed #1319
  • Oct 05 08:17
    eric-burel commented #1318
  • Oct 04 18:22
    fletchertyler914 opened #1319
  • Oct 04 16:46
    marijnh commented #1318
  • Oct 04 14:47
    eric-burel opened #1318
  • Oct 04 09:02
    roman-kulakov commented #476
  • Oct 02 17:32
    marijnh closed #1316
  • Oct 02 17:32
    marijnh commented #1316
  • Oct 02 17:27
    marijnh commented #1317
  • Oct 01 23:01
    xiaweiss commented #1317
  • Oct 01 15:54
    marijnh commented #1317
  • Oct 01 10:06
    xiaweiss edited #1317
  • Oct 01 10:06
    xiaweiss opened #1317
  • Oct 01 07:09
    mfissehaye opened #1316
  • Sep 30 10:43
    marijnh commented #476
  • Sep 29 09:06
    marijnh commented #1314
Attila Gazso
@agazso
@Juxsta you can make a plugin that implements appendTransaction, newState.selection returns the cursor (or selection) position
Anton Kireev
@AGKireev
list.png
Anton Kireev
@AGKireev
Hello everyone. I'm working with a todo-lists in ProseMirror, and trying to solve the following quest: how not focus the Editor after applying a transaction (changing the attribute of a list item to "done"). On a mobile when I hit the checkbox the keyboard is shown on screen every time ('cause the Editor gets the focus). Appreciate any hint how to solve it.
Marijn Haverbeke
@marijnh
If you handle and preventDefault the mousedown event, the editor shouldn't be receiving focus
Zeljko Bulatovic
@zeljko-bulatovic
Hi all... i started experiencing RangeError: Position X out of range on ClientA since he has wifi issues, and in the meantime ClientB edits the doc.. Then when ClientA sends the data, his version is for example 410, and on the server it is stored version 400... Then this part of code throws exception

`
let doc = schema.nodeFromJSON(storedData.doc);
let newSteps = steps.map(step => {
const newStep = Step.fromJSON(schema, step);
newStep.clientID = clientID;

// apply step to document
let result = newStep.apply(doc);
doc = result.doc;
return newStep;
});
`

Sometimes result.doc is null
Sebastian Podgajny
@SebastianPodgajny
Hi, is it expected that Fragment doesn't have 'textBetween' method documented?
Zeljko Bulatovic
@zeljko-bulatovic
Also, any server side examples regarding collaboration? Is using Firestore good option when comes to collaboration? I started occurring issues with websockets, poor network connection and synchronization between..
Marijn Haverbeke
@marijnh
@zeljko-bulatovic The collaborative demo on the website might be useful example https://github.com/ProseMirror/website/tree/master/src/collab . I know some people are using Firebase to store steps and it seems to work well for them, but I don't know these products well enough to comment on that myself.
@SebastianPodgajny I think the reasoning was that client code will typically have a node when it needs textBetween. Are you running into a situation where you only have the fragment?
Sebastian Podgajny
@SebastianPodgajny
@marijnh I would like to use default implementation of clipboardTextSerializer but with single \n as block separator
https://github.com/ProseMirror/prosemirror-view/blob/d01c420d9c087f7ba56fc4db2081823ff491dc9d/src/clipboard.js#L30-L31
Marijn Haverbeke
@marijnh
All right, I'll document it and make it public in the next release. Feel free to rely on it. (TS types are likely to lag behind until you create a PR there.)
Zeljko Bulatovic
@zeljko-bulatovic
Thank you very much, i will check!
Sebastian Podgajny
@SebastianPodgajny
Awesome, thanks!
Zeljko Bulatovic
@zeljko-bulatovic

Hi @marijnh , i checked the collab demo from the ProseMirror docs, and i got similar situation like i had right now.. The use case is that two clients are working on the same doc, and then server is down during deploy, or clients got network issues, but they are not aware of it and they continue to type, but as soon as server is up or they come online, multiple new steps are sent, i am getting the following error (this is error from ProseMirror collab server)

Error: Invalid version 91
at Instance.checkVersion (/website/src/collab/server/instance.js:73:17)
at Instance.getEvents (/website/src/collab/server/instance.js:83:10)
at handle (/website/src/collab/server/server.js:140:19)
at finish (/website/src/collab/server/server.js:53:34)
at Object.router.add.args [as handler] (/website/src/collab/server/server.js:67:7)
at routes.some.route (/website/src/collab/server/route.js:47:13)
at Array.some (<anonymous>)
at Router.resolve (/website/src/collab/server/route.js:42:24)
at exports.handleCollabRequest (/website/src/collab/server/server.js:10:17)
at maybeCollab (/website/src/devserver.js:59:9)

Any suggestion how to handle multiple steps with higher version (db has version 10, and client is sending version 15 for example)
Marijn Haverbeke
@marijnh
Clients only roll forward their version when the server has confirmed that it's received the changes, so the scenario you describe shouldn't happen unless the server lost data on restart.
Zeljko Bulatovic
@zeljko-bulatovic
Bigger issue is because some clients has poor wifi connection, and while websockets reconnect and everything is synced, their local version is higher than server version and then i am receiving this error when they send all steps at once
Marijn Haverbeke
@marijnh
No, something else is going wrong, because, as I said, a proper client implementation does not increase its version until it receives the steps it submitted back from the server, to avoid exactly this problem.
Cris Ward
@crisward
Hey all, I'm trying to make the html in my prosemirror editable using codemirror. I have this working, but because I update the whole state on every key press I loose the prosemirror undo stack. I realise I probably need to do a state transform but have no idea where to start with this (eg identify the correct node, change etc). Is there anything in code/prosemirror I can use to map a change in one into a transform into the other?
Cris Ward
@crisward
Ended up doing this, which gives me my undos. Probably not ideal as I'm still replacing the whole doc, but seems performant enough for now.
function updateHTML(view,html){
    let domNode = document.createElement("div");
    domNode.innerHTML = html;
    let tr = view.state.tr;
    let node = DOMParser.fromSchema(schema).parse(domNode);
    tr.setSelection(new AllSelection(view.state.doc));
    tr.replaceSelectionWith(node);
    view.dispatch(tr);
}
Marijn Haverbeke
@marijnh
The example of CodeMirror integration on the website converts code changes to precise ProseMirror transactions. Does that help?
Cris Ward
@crisward
@marijnh thanks for link. I'll take another look. I didn't realise it update the prosemirror state.
Cris Ward
@crisward
It looks like the example updates plain text into a single node. So not exactly what I'm after. But thanks for the feedback. Prosemirror is an excellent library BTW, having fought with contenteditable in the past and working with other less stable abstractions over that it's a pleasure to use. Many thanks for all the work you've put into it.
Zeljko Bulatovic
@zeljko-bulatovic
Hmm, i will take a look, thank you!
Zeljko Bulatovic
@zeljko-bulatovic

Who is responsible for increasing version on the front-end (i am using tiptap v1). As far as i found, 'prosemirror-collab' is the main, and here is the line 122:
let version = collabState.version + steps.length

any chance to tell this module not to increase version when user is offline (i have flag for dettecting it)?

Marijn Haverbeke
@marijnh
You should not be calling receiveTransaction when the user is offline, so I think that's where the problem lies.
Zeljko Bulatovic
@zeljko-bulatovic
Thank you!
ithil
@ithil

I'm feeling really stupid but I just don't get it to work: in an input rule I want to replace a text with another text that has a mark applied to it. I tried the following:

        this.inputRules.push(new InputRule(/...../,
        (state, match, start, end) => {
          var label =  match[0]
          var linkMarkSchema = state.schema.marks.link
          var linkMark = linkMarkSchema.create()
          linkMark.attrs.href = `/note/${label}`
          var tr = state.tr
          tr = tr.addMark(start, end, linkMark)
          tr = tr.insertText(label, start, end)
          return tr
        }))

What happens is that the text gets replaced with the new text but the mark is lost. If I switch addMark and insertText around I simply get Cannot read property 'nodeSize' of undefined. So I figured maybe I have to insert the text first and then get the range of the transaction so I can use it in addMark, but... how do I do that?

ithil
@ithil

Ahh now I have found a solution:

tr = tr.insertText(label, start, end)
tr = tr.addMark(start, start+label.length, linkMark)

Though I'm not sure this is the most robust way?

Sebastian Podgajny
@SebastianPodgajny
Is there a way to render prosemirror state as plain html? (without event listeners)
Cris Ward
@crisward
I'm doing this...
let copy = slide.node.copy(start,end)
tr.delete(start,end)
tr.insert(insertPos, copy)
But sometimes the content of the copy is being added to multiple nodes. Specifically images. So the copy if a div wrapped around and image. There are muliple divs in a surrounding div. Not sure what I'm doing wrong. But insert should only effect one node.. correct?
(I'm guessing I'm screwing up somewhere else in my app)
Cris Ward
@crisward
Found the solution to my own problem. Before the above step I was doing a transform that was updating the attributes of a node, but setting the attributes to the same value as they already had. For some reason this caused the insert/delete to be performed on the wrong nodes, checking and skipping over the non changes fixed the issue.
Marijn Haverbeke
@marijnh
@SebastianPodgajny Look into the DOMSerializer class
Manuel Jacob
@manueljacob
Is there a plugin that implements nested sections, similar to what’s described in https://discuss.prosemirror.net/t/nested-sections-and-splitblock/2323 ?
Manuel Jacob
@manueljacob
Is it possible to get a stable identifier for some block element?
Manuel Jacob
@manueljacob
The background is: In a React application, I’m rendering the document structure (outline) next to the editor. Each node in the outline tree view component needs to have some ID, e.g. for tracking whether the node was expanded in the tree view or not.
Marijn Haverbeke
@marijnh
I'm not aware of a plugin that does the nested section structure. (But I know several people have implemented it in their proprietary systems.)
Assigning and deduplicating IDs is usually done in an appendTransaction hook.
andreas
@andreasvirkus
Hi everyone! I'm seeing a weird behaviour with a plugin where i return a handlePaste handler in my props. I'm trying to read multiple images/files from the clipboard but only get the very last one. Even though all file names are still pasted into the editor
Andrew Kirwin
@amk221

If I have a doc schema of block+, then I create some state:

EditorState.create({
  doc: schema.nodeFromJSON({
    type: 'doc',
    content: []
  })
});

I think this sets up prosemirror in a funny state, because it was expecting at least 1 block. But, we didn't give it 1 block.

(This leads to issues with decoration position)

Can/should prosemirror throw an error in this circumstance?

Marijn Haverbeke
@marijnh
It would be rather expensive to check its entire content every time a node is created, so ProseMirror doesn't do that. Passing invalid content to NodeType.create is considered an error in the calling code.
Andrew Kirwin
@amk221

Thanks, that makes sense. How about not every time a node is created, but at the time the EditorState.create is called?

If not, I'm just thinking about where/how I can guard for this in our app. As it will undoubtedly lead to issues when we render prosemirror with json from our backend api.

Marijn Haverbeke
@marijnh
You can call .check() on a node if you want to assert that it has valid structure.
Andrew Kirwin
@amk221
Nice
Andrew Kirwin
@amk221
Yeh that's perfect, cheers