webNBT icon indicating copy to clipboard operation
webNBT copied to clipboard

Copy & paste as SNBT

Open Vftdan opened this issue 2 years ago • 2 comments

Implement copying & pasting of subtrees as text, that should be valid SNBT (the syntax used in command blocks, but I have not tested).

Current limitations

  • The only pasting option available is replacement of an existing tag; old & new tag types must much, so new tags should be created, named & set the the correct type manually
  • Recovery from end of input while checking number type may be incomlete, so you may want add a trailing space when pasting double/int tags (or just use Edit value... instead)
  • Not tested very much (especially different *ArrayTags), so there may be other problems
  • It currently uses old clipboard API, pasting falls back to prompt

Closes https://github.com/iRath96/webNBT/issues/5, https://github.com/iRath96/webNBT/issues/15

Vftdan avatar Apr 29 '22 17:04 Vftdan

There seems to be a problem with copying doubles. They are exported in hexadecimal notation, which they are not supposed to be afaik.

iRath96 avatar Apr 30 '22 17:04 iRath96

The error message when pasting something of incorrect type is confusing. It says "Parse error at position 0" even though the pasted content is syntactically correct. Perhaps it should say something along the lines of, e.g., "Cannot paste content of type 'Double' into property of type 'Long'".

In the future, it would be cool to automatically cast at some of the types (in particular among the numerical types). But for now we can live without this :-)

iRath96 avatar Apr 30 '22 17:04 iRath96