How can i insert text node which is editable?

hello, i run into a problem ,when i try to create inline text node and make it editable.

< p><span data-id="xxxxxx">yyyy</s pan></p >

the text node i created only have 1position in the doc and when i click the cursor on top of it ,

the cursor can only select the whole node ,

my goal is to create a textNode more like a span , and it can have data of it’s own, also, it can be editable, (cursor can be inside it can cursor can be changed by code)

i know in prose mirror, inline node (strong, em) are marks

can anyone tell me how to create new mark of my own ? or any other approach. image the text inside the ‘[]’ must be editable, and it must have some data in it , because it’s more like an input element , the content insert it must be collected and send to a server

many thanks

What are you trying to represent with that node? It would help to state your requirement, there might be a better solution…

hello , what i need to represent is more like an < input / > in an editor , but it must look like text image there is more to it ,when clicked on top of it , there have to be a option menu available. image

Sounds like you need a custom inline node spec. How do the users insert this in the document? Would there be a button in a toolbar?

I would start by adapting the dinos example to get your custom node. The menu you want to show can be something like the tooltip example, or perhaps a NodeView (for which I can’t find a ready example in the docs).

The examples are here: https://prosemirror.net/examples/

hmm ,there would be a toolbar . it’s complicated , i want to build something like Microsoft Word but it’s in the browser, which can be use to produce template html instead of word file, and people can edit part of the produced html and send data to a server. so i have to add data property to the ‘[xxx]’ element. (user’s actions are limited, they can’t delete elements, but they can edit text ,so i have keep ‘[’ and ‘]’ always untouched to make that possible ,

i want to use ‘filter transaction’ to see if nodeBefore the cursor is ended with “]”,or the character before the cursor is “[” ,if so, skip the transaction , so i still need the curSelection)

i used insertText and addMark , which produced some bug, i’m trying to find out why . when i press backspace , a whole row or a DOM element is deleted .

any idea ?

i read the example, i tried NodeSpec with {selectable:false}, but it can not have cursor in it

I’m also a novice ProseMirror user, so I can’t help a lot :slight_smile: But my advice is to shift your thinking from HTML elements into Prosemirror Nodes. So e.g. don’t think about adding a data property to the [xxx] element, think about:

The HTML representation is actually quite straightforward as you can write custom code to do exactly what you want in the parseDOM/toDOM.