Re: Web editor UndoManager and properties

Carlos Villegas <[email protected]> Fri, 19 Sep 2025 20:00:08 +0900
Newsgroups gmane.editors.xxe.general
Message-ID <CAAQ46WZ5zfML_xnrThdi5eP-057fd8pENjUxCef+GFTk_jFvFQ@mail.gmail.com>
--===============4038125405606191112==
Content-Type: multipart/alternative; boundary="0000000000002172e2063f256033"

--0000000000002172e2063f256033
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

I think we had the same behaviour in this case, but the I think the undo is
acting on the structural change (Cut in this case). And the editor seems to
be storing (correctly) the previous state together with the property.
So when the Undo action executes, it restores the node with its property.
Which is what I expected, I think this is correct.
However, if I add the property and I try to undo just the property
addition, standalone, it doesn't work. In fact, I can't, it looks like
nothing is added to the Undo history and the Undo button remains disabled.
I think the first screenshot shows that. So maybe if I pair it with another
XML change like an attribute change, then it will work. Can I hide an
attribute from the interface? Well in that case, I may as well use this
hidden attribute to store my metadata instead of properties...

Carlos



On Fri, Sep 19, 2025 at 7:19=E2=80=AFPM Hussein Shafie <[email protected]=
> wrote:

> Carlos Villegas wrote:
> >
> > We had to switch to a different project and now we are back to keep
> > evaluating the Web edition.
> > We have a question about the Undo/Redo actions.
> > We added some metadata to the XML nodes using the property feature of
> > XMLMind through an extension. That works fine and we can style based on
> the
> > properties, which is great.
> > However, we noticed the property changes are not being recorded (ignore=
d)
> > by the UndoManager.
>
> In theory, this is not possible because the UndoManager always works on
> the original nodes being edited (possibly having custom node properties)
> and not on copies.
>
> This is true for both XXE desktop and Web Edition which use the exact
> same UndoManager (on the server side for Web Edition; like everything
> related to the model).
>
> This, in contrast with XXE clipboard manager which does not serialize
> node properties when you invoke the Copy or Cut commands.
>
>
>
>
> > Is there a way to make the UndoManager work with properties. We're usin=
g
> > the <xxe-client> integrated into our React app. The properties are bein=
g
> > added by executing a remote command on the extension, which adds the
> > properties on the server side to the XML nodes.
>
> In order to reproduce the issue, I did what follows:
>
> * Added this to "docbook.xxe": pressing F2 adds property "important" to
> implicitly or explicitly selected element.
> ---
>    <binding>
>      <keyPressed code=3D"F2" />
>      <command name=3D"setProperty"
>        parameter=3D"[implicitElement][rebuildView] important true" />
>    </binding>
> ---
>
> * Added this to "docbook.css": elements having an "important" property
> are made bold, red and underlined:
> ---
> *:property(|important) {
>      font-weight: bold;
>      color: red;
>      text-decoration: underline;
> }
> ---
>
> 0) Started xxeserver. Opened "demo/docbook/docbook-table.xml" in
> XXEW/Chrome and clicked inside first para.
>
> 1) Pressed F2 to add property "important" to first para. See attached
> screenshot "1_set_prop_important.png".
>
> 2) Clicked the Cut icon. See attached screenshot
> "2_cut_important_para.png".
>
> 3) Clicked the Undo icon. See attached screenshot "3_after_undo_cut.png".
> Notice that "restored" first para is still bold, red and underlined
> which indicates that property "important" is still there.
>

--0000000000002172e2063f256033
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">I think we had the same behaviour in this case, but the I =
think the undo is acting on the structural change (Cut in this case). And t=
he editor seems to be storing (correctly) the previous state together with =
the property.<div>So when the Undo action executes, it restores the node wi=
th its property. Which is what I expected, I think this is correct.</div><d=
iv>However, if I add the property and I try to undo just the property addit=
ion, standalone, it doesn&#39;t work. In fact, I can&#39;t, it looks like n=
othing is added to the Undo history and the Undo button remains disabled. I=
 think the first screenshot shows that. So maybe if I pair it with another =
XML change like an=C2=A0attribute change, then it will work. Can I hide an =
attribute from the interface? Well in that case, I may as well use this hid=
den attribute to store my metadata instead of properties...</div><div><br><=
/div><div>Carlos</div><div><br></div><div><br></div></div><br><div class=3D=
"gmail_quote gmail_quote_container"><div dir=3D"ltr" class=3D"gmail_attr">O=
n Fri, Sep 19, 2025 at 7:19=E2=80=AFPM Hussein Shafie &lt;<a href=3D"mailto=
:[email protected]">[email protected]</a>&gt; wrote:<br></div><blockquo=
te class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px =
solid rgb(204,204,204);padding-left:1ex">Carlos Villegas wrote:<br>
&gt; <br>
&gt; We had to switch to a different project and now we are back to keep<br=
>
&gt; evaluating the Web edition.<br>
&gt; We have a question about the Undo/Redo actions.<br>
&gt; We added some metadata to the XML nodes using the property feature of<=
br>
&gt; XMLMind through an extension. That works fine and we can style based o=
n the<br>
&gt; properties, which is great.<br>
&gt; However, we noticed the property changes are not being recorded (ignor=
ed)<br>
&gt; by the UndoManager.<br>
<br>
In theory, this is not possible because the UndoManager always works on <br=
>
the original nodes being edited (possibly having custom node properties) <b=
r>
and not on copies.<br>
<br>
This is true for both XXE desktop and Web Edition which use the exact <br>
same UndoManager (on the server side for Web Edition; like everything <br>
related to the model).<br>
<br>
This, in contrast with XXE clipboard manager which does not serialize <br>
node properties when you invoke the Copy or Cut commands.<br>
<br>
<br>
<br>
<br>
&gt; Is there a way to make the UndoManager work with properties. We&#39;re=
 using<br>
&gt; the &lt;xxe-client&gt; integrated into our React app. The properties a=
re being<br>
&gt; added by executing a remote command on the extension, which adds the<b=
r>
&gt; properties on the server side to the XML nodes.<br>
<br>
In order to reproduce the issue, I did what follows:<br>
<br>
* Added this to &quot;docbook.xxe&quot;: pressing F2 adds property &quot;im=
portant&quot; to <br>
implicitly or explicitly selected element.<br>
---<br>
=C2=A0 =C2=A0&lt;binding&gt;<br>
=C2=A0 =C2=A0 =C2=A0&lt;keyPressed code=3D&quot;F2&quot; /&gt;<br>
=C2=A0 =C2=A0 =C2=A0&lt;command name=3D&quot;setProperty&quot;<br>
=C2=A0 =C2=A0 =C2=A0 =C2=A0parameter=3D&quot;[implicitElement][rebuildView]=
 important true&quot; /&gt;<br>
=C2=A0 =C2=A0&lt;/binding&gt;<br>
---<br>
<br>
* Added this to &quot;docbook.css&quot;: elements having an &quot;important=
&quot; property <br>
are made bold, red and underlined:<br>
---<br>
*:property(|important) {<br>
=C2=A0 =C2=A0 =C2=A0font-weight: bold;<br>
=C2=A0 =C2=A0 =C2=A0color: red;<br>
=C2=A0 =C2=A0 =C2=A0text-decoration: underline;<br>
}<br>
---<br>
<br>
0) Started xxeserver. Opened &quot;demo/docbook/docbook-table.xml&quot; in =
<br>
XXEW/Chrome and clicked inside first para.<br>
<br>
1) Pressed F2 to add property &quot;important&quot; to first para. See atta=
ched <br>
screenshot &quot;1_set_prop_important.png&quot;.<br>
<br>
2) Clicked the Cut icon. See attached screenshot &quot;2_cut_important_para=
.png&quot;.<br>
<br>
3) Clicked the Undo icon. See attached screenshot &quot;3_after_undo_cut.pn=
g&quot;.<br>
Notice that &quot;restored&quot; first para is still bold, red and underlin=
ed <br>
which indicates that property &quot;important&quot; is still there.<br>
</blockquote></div>

--0000000000002172e2063f256033--

--===============4038125405606191112==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline


--
XMLmind XML Editor Support List
[email protected]
http://www.xmlmind.com/mailman/listinfo/xmleditor-support

--===============4038125405606191112==--