Skip to content

Commit

Permalink
docs: update readme to ask use $:/SuperTag/TraitTag
Browse files Browse the repository at this point in the history
  • Loading branch information
linonetwo committed Jun 1, 2023
1 parent ef1a74e commit 2c3eb69
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 66 deletions.
11 changes: 11 additions & 0 deletions demo/tiddlers/Advanced user - use TraitTag create SuperTag.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
created: 20230601114910642
creator: 林一二
modified: 20230601114933159
modifier: 林一二
tags: UserManual
title: Advanced user - use TraitTag create SuperTag
type: text/vnd.tiddlywiki

Some plugins you installed to your wiki will provide TraitTag that can be used to create your own SuperTag. Just add one or more TraitTag on a tiddler, this tiddler will become a SuperTag.

<$whiteboard tiddler="HowToCreateSuperTagDiagram" readonly="yes" />
2 changes: 1 addition & 1 deletion demo/tiddlers/Diagrams/HowToCreateTraitTagDiagram.tldr
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"document":{"id":"doc","name":"HowToCreateTraitTagDiagram","version":15.5,"pages":{"page":{"id":"page","name":"Page 1","childIndex":1,"shapes":{"b9ca5198-900e-49c9-2c69-ef1a87f25070":{"id":"b9ca5198-900e-49c9-2c69-ef1a87f25070","type":"rectangle","name":"Rectangle","parentId":"page","childIndex":1,"point":[23.54,43.8],"size":[456.79,269.91],"rotation":0,"style":{"color":"violet","size":"small","isFilled":false,"dash":"draw","scale":1},"label":"","labelPoint":[0.5,0.5]},"8ea4c2e7-1e2a-49ba-2c23-ad5db9c6c715":{"id":"8ea4c2e7-1e2a-49ba-2c23-ad5db9c6c715","type":"text","name":"Text","parentId":"page","childIndex":2,"point":[30.89,56.63],"rotation":0,"text":"CompletedTrait","style":{"color":"violet","size":"medium","isFilled":false,"dash":"draw","scale":1,"font":"script","textAlign":"middle"}},"5f34fcf8-9685-4464-33be-88c73121a3b9":{"id":"5f34fcf8-9685-4464-33be-88c73121a3b9","type":"text","name":"Text","parentId":"page","childIndex":1,"point":[31.07,447.22],"rotation":0,"text":"{\n \"title\": \"Person\",\n \"type\": \"object\",\n \"properties\": {\n \"firstName\": {\n \"type\": \"string\"\n },\n \"lastName\": {\n \"type\": \"string\"\n },\n \"age\": {\n \"description\": \"Age in years\",\n \"type\": \"integer\",\n \"minimum\": 0\n },\n \"shippingAddress\": {\n \"$ref\": \"#/properties/address/properties/addressId\"\n }\n },\n \"required\": [\n \"firstName\",\n \"lastName\"\n ]\n}","style":{"color":"violet","size":"small","isFilled":false,"dash":"draw","scale":0.3670787277238889,"font":"script","textAlign":"start"}},"648e4ca1-b4fc-4e5f-2a6a-b94f50601526":{"id":"648e4ca1-b4fc-4e5f-2a6a-b94f50601526","type":"text","name":"Text","parentId":"page","childIndex":3,"point":[173.53,317.78],"rotation":0,"text":"Trait tiddler\ncontains a JSONSchema\nin \"schema\" field","style":{"color":"violet","size":"small","isFilled":false,"dash":"draw","scale":1,"font":"script","textAlign":"start"}},"f0f52ba2-25e4-41bd-0ee2-ac4c79f7c1cd":{"id":"f0f52ba2-25e4-41bd-0ee2-ac4c79f7c1cd","type":"rectangle","name":"Rectangle","parentId":"page","childIndex":5,"point":[8.53,425.01],"size":[406.96,294.91],"rotation":0,"style":{"color":"violet","size":"small","isFilled":false,"dash":"draw","scale":1,"textAlign":"start"},"label":"","labelPoint":[0.5,0.5]},"aa8737f0-6a7d-45b4-14d5-d4dcfe07848a":{"id":"aa8737f0-6a7d-45b4-14d5-d4dcfe07848a","type":"text","name":"Text","parentId":"page","childIndex":6,"point":[38.28,126.23],"rotation":0,"text":"description in\nText field","style":{"color":"black","size":"small","isFilled":false,"dash":"draw","scale":1,"font":"script","textAlign":"start"}},"5780bc17-5680-44c2-31fe-301a5f29f34b":{"id":"5780bc17-5680-44c2-31fe-301a5f29f34b","type":"text","name":"Text","parentId":"page","childIndex":7,"point":[37.94,215.56],"rotation":0,"text":"schema","style":{"color":"violet","size":"small","isFilled":false,"dash":"draw","scale":1,"font":"script","textAlign":"start"}},"7b5097dd-4b54-48d7-0962-0e0d227e3cfa":{"id":"7b5097dd-4b54-48d7-0962-0e0d227e3cfa","type":"arrow","name":"Arrow","parentId":"page","childIndex":8,"point":[124.23,261.56],"rotation":0,"bend":0,"handles":{"start":{"id":"start","index":0,"point":[46.15,163.45],"canBind":true,"bindingId":"beed6595-d9a8-4162-2c54-71994e509011"},"end":{"id":"end","index":1,"point":[0,0],"canBind":true,"bindingId":"47a4e44d-0f7d-42eb-3f66-88b1a72b0c02"},"bend":{"id":"bend","index":2,"point":[23.08,81.72]}},"decorations":{"end":"arrow"},"style":{"color":"violet","size":"small","isFilled":false,"dash":"draw","scale":1,"textAlign":"start"},"label":"","labelPoint":[0.5,0.5]}},"bindings":{"beed6595-d9a8-4162-2c54-71994e509011":{"id":"beed6595-d9a8-4162-2c54-71994e509011","type":"arrow","fromId":"7b5097dd-4b54-48d7-0962-0e0d227e3cfa","toId":"f0f52ba2-25e4-41bd-0ee2-ac4c79f7c1cd","handleId":"start","point":[0.5,0.5],"distance":16},"47a4e44d-0f7d-42eb-3f66-88b1a72b0c02":{"id":"47a4e44d-0f7d-42eb-3f66-88b1a72b0c02","type":"arrow","fromId":"7b5097dd-4b54-48d7-0962-0e0d227e3cfa","toId":"5780bc17-5680-44c2-31fe-301a5f29f34b","handleId":"end","point":[0.65,0.23],"distance":8}}}},"pageStates":{"page":{"id":"page","selectedIds":["5780bc17-5680-44c2-31fe-301a5f29f34b"],"camera":{"point":[0,0],"zoom":1}}},"assets":{}},"updatedCount":282}
{"document":{"id":"doc","name":"HowToCreateTraitTagDiagram","version":15.5,"pages":{"page":{"id":"page","name":"Page 1","childIndex":1,"shapes":{"b9ca5198-900e-49c9-2c69-ef1a87f25070":{"id":"b9ca5198-900e-49c9-2c69-ef1a87f25070","type":"rectangle","name":"Rectangle","parentId":"page","childIndex":1,"point":[23.54,43.8],"size":[514.79,267.91],"rotation":0,"style":{"color":"violet","size":"small","isFilled":false,"dash":"draw","scale":1},"label":"","labelPoint":[0.5,0.5]},"8ea4c2e7-1e2a-49ba-2c23-ad5db9c6c715":{"id":"8ea4c2e7-1e2a-49ba-2c23-ad5db9c6c715","type":"text","name":"Text","parentId":"page","childIndex":2,"point":[30.89,56.63],"rotation":0,"text":"CompletedTrait","style":{"color":"violet","size":"medium","isFilled":false,"dash":"draw","scale":1,"font":"script","textAlign":"middle"}},"5f34fcf8-9685-4464-33be-88c73121a3b9":{"id":"5f34fcf8-9685-4464-33be-88c73121a3b9","type":"text","name":"Text","parentId":"page","childIndex":1,"point":[31.07,447.22],"rotation":0,"text":"{\n \"title\": \"Person\",\n \"type\": \"object\",\n \"properties\": {\n \"firstName\": {\n \"type\": \"string\"\n },\n \"lastName\": {\n \"type\": \"string\"\n },\n \"age\": {\n \"description\": \"Age in years\",\n \"type\": \"integer\",\n \"minimum\": 0\n },\n \"shippingAddress\": {\n \"$ref\": \"#/properties/address/properties/addressId\"\n }\n },\n \"required\": [\n \"firstName\",\n \"lastName\"\n ]\n}","style":{"color":"violet","size":"small","isFilled":false,"dash":"draw","scale":0.3670787277238889,"font":"script","textAlign":"start"}},"648e4ca1-b4fc-4e5f-2a6a-b94f50601526":{"id":"648e4ca1-b4fc-4e5f-2a6a-b94f50601526","type":"text","name":"Text","parentId":"page","childIndex":3,"point":[173.53,317.78],"rotation":0,"text":"Trait tiddler\ncontains a JSONSchema\nin \"schema\" field","style":{"color":"violet","size":"small","isFilled":false,"dash":"draw","scale":1,"font":"script","textAlign":"start"}},"f0f52ba2-25e4-41bd-0ee2-ac4c79f7c1cd":{"id":"f0f52ba2-25e4-41bd-0ee2-ac4c79f7c1cd","type":"rectangle","name":"Rectangle","parentId":"page","childIndex":5,"point":[8.53,425.01],"size":[406.96,294.91],"rotation":0,"style":{"color":"violet","size":"small","isFilled":false,"dash":"draw","scale":1,"textAlign":"start"},"label":"","labelPoint":[0.5,0.5]},"aa8737f0-6a7d-45b4-14d5-d4dcfe07848a":{"id":"aa8737f0-6a7d-45b4-14d5-d4dcfe07848a","type":"text","name":"Text","parentId":"page","childIndex":6,"point":[38.28,126.23],"rotation":0,"text":"description in\nText field","style":{"color":"black","size":"small","isFilled":false,"dash":"draw","scale":1,"font":"script","textAlign":"start"}},"5780bc17-5680-44c2-31fe-301a5f29f34b":{"id":"5780bc17-5680-44c2-31fe-301a5f29f34b","type":"text","name":"Text","parentId":"page","childIndex":7,"point":[37.94,215.56],"rotation":0,"text":"schema","style":{"color":"violet","size":"small","isFilled":false,"dash":"draw","scale":1,"font":"script","textAlign":"start"}},"7b5097dd-4b54-48d7-0962-0e0d227e3cfa":{"id":"7b5097dd-4b54-48d7-0962-0e0d227e3cfa","type":"arrow","name":"Arrow","parentId":"page","childIndex":8,"point":[124.23,261.56],"rotation":0,"bend":0,"handles":{"start":{"id":"start","index":0,"point":[46.15,163.45],"canBind":true,"bindingId":"beed6595-d9a8-4162-2c54-71994e509011"},"end":{"id":"end","index":1,"point":[0,0],"canBind":true,"bindingId":"47a4e44d-0f7d-42eb-3f66-88b1a72b0c02"},"bend":{"id":"bend","index":2,"point":[23.08,81.72]}},"decorations":{"end":"arrow"},"style":{"color":"violet","size":"small","isFilled":false,"dash":"draw","scale":1,"textAlign":"start"},"label":"","labelPoint":[0.5,0.5]},"13196878-c4f3-49f4-194d-0be81095f167":{"id":"13196878-c4f3-49f4-194d-0be81095f167","type":"text","name":"Text","parentId":"page","childIndex":1,"point":[165.5,213],"rotation":0,"text":"$:/SuperTag/TraitTag","style":{"color":"violet","size":"small","isFilled":false,"dash":"solid","scale":1,"font":"script"}},"c88219cc-d413-4bb4-0814-8552473672fa":{"id":"c88219cc-d413-4bb4-0814-8552473672fa","type":"text","name":"Text","parentId":"page","childIndex":9,"point":[526,425.88],"rotation":0,"text":"Also add\nthis tag\nto make\nit work","style":{"color":"violet","size":"small","isFilled":false,"dash":"draw","scale":1,"font":"script","textAlign":"middle"}},"fcbb25ba-3a8f-4254-0abf-e3b54f8c4c14":{"id":"fcbb25ba-3a8f-4254-0abf-e3b54f8c4c14","type":"arrow","name":"Arrow","parentId":"page","childIndex":10,"point":[371.63,259],"rotation":0,"bend":0,"handles":{"start":{"id":"start","index":0,"point":[165.77,166.88],"canBind":true,"bindingId":"49f56a9e-673f-43d2-2bf7-ca3dd7ca8d7f"},"end":{"id":"end","index":1,"point":[0,0],"canBind":true,"bindingId":"4e8509e6-07d0-41a1-04b7-25975d3437fd"},"bend":{"id":"bend","index":2,"point":[82.89,83.44]}},"decorations":{"end":"arrow"},"style":{"color":"violet","size":"small","isFilled":false,"dash":"dashed","scale":1},"label":"","labelPoint":[0.5,0.5]},"a783963d-ced4-4778-0f9e-acba34ef9511":{"id":"a783963d-ced4-4778-0f9e-acba34ef9511","type":"rectangle","name":"Rectangle","parentId":"page","childIndex":11,"point":[164,209.38],"size":[349,45],"rotation":0,"style":{"color":"violet","size":"small","isFilled":false,"dash":"solid","scale":1},"label":"","labelPoint":[0.5,0.5]}},"bindings":{"beed6595-d9a8-4162-2c54-71994e509011":{"id":"beed6595-d9a8-4162-2c54-71994e509011","type":"arrow","fromId":"7b5097dd-4b54-48d7-0962-0e0d227e3cfa","toId":"f0f52ba2-25e4-41bd-0ee2-ac4c79f7c1cd","handleId":"start","point":[0.5,0.5],"distance":16},"47a4e44d-0f7d-42eb-3f66-88b1a72b0c02":{"id":"47a4e44d-0f7d-42eb-3f66-88b1a72b0c02","type":"arrow","fromId":"7b5097dd-4b54-48d7-0962-0e0d227e3cfa","toId":"5780bc17-5680-44c2-31fe-301a5f29f34b","handleId":"end","point":[0.65,0.23],"distance":8},"49f56a9e-673f-43d2-2bf7-ca3dd7ca8d7f":{"id":"49f56a9e-673f-43d2-2bf7-ca3dd7ca8d7f","type":"arrow","fromId":"fcbb25ba-3a8f-4254-0abf-e3b54f8c4c14","toId":"c88219cc-d413-4bb4-0814-8552473672fa","handleId":"start","point":[0.5,0.5],"distance":8},"4e8509e6-07d0-41a1-04b7-25975d3437fd":{"id":"4e8509e6-07d0-41a1-04b7-25975d3437fd","type":"arrow","fromId":"fcbb25ba-3a8f-4254-0abf-e3b54f8c4c14","toId":"13196878-c4f3-49f4-194d-0be81095f167","handleId":"end","point":[0.47,0.18],"distance":8}}}},"pageStates":{"page":{"id":"page","selectedIds":["a783963d-ced4-4778-0f9e-acba34ef9511"],"camera":{"point":[0,-28.5],"zoom":1}}},"assets":{}},"updatedCount":283}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
created: 20230217153330945
creator: 林一二
modified: 20230219091456256
modified: 20230601114221337
modifier: 林一二
title: HowToCreateTraitTagDiagram
type: application/tldr
19 changes: 19 additions & 0 deletions demo/tiddlers/HowItWorks.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
created: 20230601115327988
creator: 林一二
modified: 20230601115347563
modifier: 林一二
tags: Index
title: HowItWorks
type: text/vnd.tiddlywiki

This is how SuperTag plugin works:

# Auto generated form is displayed in a ViewTemplate that will show on the bottom of the tiddler
## This ViewTemplate have a `<$list>` widget that conditionally shows the content
## It shows if the tiddler has a SuperTag, and SuperTag has a TraitTag that tagged with `$:/SuperTag/TraitTag`.
# A `<$supertag-form />` widget on this ViewTemplate
## This widget will gather `schema` field on these TraitTags upon running
## It uses [[eclipsesource/jsonforms|https://github.com/eclipsesource/jsonforms]] open source library to build the form
## Fill in the form using tiddler's existed data

<$whiteboard tiddler="HowTechnicallySuperTagWorks" readonly="yes" height="900px" />
67 changes: 3 additions & 64 deletions demo/tiddlers/Index.tid
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
created: 20230218072320640
creator: 林一二
modified: 20230219091548144
modified: 20230601115351731
modifier: 林一二
title: Index
type: text/vnd.tiddlywiki
Expand All @@ -19,69 +19,8 @@ Also allows developers to use the same set of fields, so their plugins works tog

!! How to use

!!! Normal user - use SuperTag

Some of plugins will provide SuperTag that you can already use, just add these tag to a tiddler, a form will automatically generate on the tiddler view mode.

By simply adding a SuperTag to a tiddler (For example, Task), you will see a form showing in your tiddler (e.g. completed and completeType field editor), see screenshot below:

[img[https://talk.tiddlywiki.org/uploads/default/optimized/2X/1/187e4fb88404427a4f2704e4d1ea07bda6b69653_2_832x750.png]]

The field is only shown if your tiddler already had this field. To edit non-existed field that defined by SuperTag, click " ≡ properties" button to expand the available field editor list:

[img[https://talk.tiddlywiki.org/uploads/default/optimized/2X/e/e26960678985eea0da9f54c43b075ad1c9cd277a_2_1035x621.png]]

See [[Examples]] in this demo site to play around with the auto generated form.

<$whiteboard tiddler="HowToUseSuperTagDiagram" readonly="yes" />

!!! Advanced user - use TraitTag create SuperTag

Some of plugins will provide TraitTag that can be used to create your own SuperTag. Just add one or more TraitTag on a tiddler, this tiddler will become a SuperTag.

<$whiteboard tiddler="HowToCreateSuperTagDiagram" readonly="yes" />

!!! TraitTag developer - create TraitTag

As a developer, you will want to create your own TraitTag.

A TraitTag has a important field `"schema"`.

<$whiteboard tiddler="HowToCreateTraitTagDiagram" readonly="yes" height="750px" />

* schema: a [[JSON Schema|https://json-schema.org/]] that describe what data a form will receive.
** You may refer to [[JSON Editor Doc#JSON Schema Support|https://github.com/json-editor/json-editor#json-schema-support]] for advanced features in the form
** A basic assumption is that the JSON Schema are `type: "object"` and has only 1 level of properties.
** All properties provided by all trait tags are merged into a single JSON Schema, and then is used to display the SuperTag Form

See links above to learn how to write them. You can also learn from some existed [[TraitTag Examples|$:/SuperTag/TraitTag]].

!!! Plugin developer

If you are creating a plugin that heavily make use of tiddler fields, You'd better search for existed supertag sub-plugins that provides trait tags, or search in [[tiddlywiki forum|https://talk.tiddlywiki.org]] for it.

So you can reuse existed TraitTags. In this way, plugins in our community can work together, make users' tiddlywiki a real unified database.

<$whiteboard tiddler="SuperTagShareTheTraitsDiagram" readonly="yes" height="400px" />

!!! General propose JSON Form Editor

See [[WidgetExamples]] or [[Examples]].

This is only provided as a tool for plugin developers to build custom forms.

For interoperability consideration, it is better to use the TraitTag approach described above, so our TiddlyWiki developer community can have a consistent way to deliver form to end users.
{{UserManual}}

!! Develop

This is how SuperTag plugin works:

# Auto generated form is displayed in a ViewTemplate that will show on the bottom of the tiddler
## This ViewTemplate have a `<$list>` widget that conditionally shows the content
## It shows if the tiddler has a SuperTag, and SuperTag has a TraitTag that tagged with `$:/SuperTag/TraitTag`.
# A `<$supertag-form />` widget on this ViewTemplate
## This widget will gather `schema` field on these TraitTags upon running
## It uses [[eclipsesource/jsonforms|https://github.com/eclipsesource/jsonforms]] open source library to build the form
## Fill in the form using tiddler's existed data

<$whiteboard tiddler="HowTechnicallySuperTagWorks" readonly="yes" height="900px" />
[[HowItWorks]]
21 changes: 21 additions & 0 deletions demo/tiddlers/Normal user - use SuperTag.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
created: 20230601114941962
creator: 林一二
modified: 20230601114958899
modifier: 林一二
tags: UserManual
title: Normal user - use SuperTag
type: text/vnd.tiddlywiki

Some of plugins will provide SuperTag that you can already use, just add these tag to a tiddler, a form will automatically generate on the tiddler view mode.

By simply adding a SuperTag to a tiddler (For example, Task), you will see a form showing in your tiddler (e.g. completed and completeType field editor), see screenshot below:

[img[https://talk.tiddlywiki.org/uploads/default/optimized/2X/1/187e4fb88404427a4f2704e4d1ea07bda6b69653_2_832x750.png]]

The field is only shown if your tiddler already had this field. To edit non-existed field that defined by SuperTag, click " ≡ properties" button to expand the available field editor list:

[img[https://talk.tiddlywiki.org/uploads/default/optimized/2X/e/e26960678985eea0da9f54c43b075ad1c9cd277a_2_1035x621.png]]

See [[Examples]] in this demo site to play around with the auto generated form.

<$whiteboard tiddler="HowToUseSuperTagDiagram" readonly="yes" />
26 changes: 26 additions & 0 deletions demo/tiddlers/Plugin developer.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
created: 20230601114716879
creator: 林一二
modified: 20230601114858083
modifier: 林一二
tags: UserManual
title: Plugin developer
type: text/vnd.tiddlywiki

!!! For all plugin developer

[[Suggestion for all Plugin developers about field name: Let’s use Ontology to maintain Interoperability - talk.tiddlywiki.org|https://talk.tiddlywiki.org/t/suggestion-for-all-plugin-developers-about-field-name-lets-use-ontology-to-maintain-interoperability/1923]]

If you are creating a plugin that heavily make use of tiddler fields, You'd better search for existed supertag sub-plugins that provides trait tags, or search in [[tiddlywiki forum|https://talk.tiddlywiki.org]] for it.

So you can reuse existed TraitTags. In this way, plugins in our community can work together, make users' tiddlywiki a real unified database.

<$whiteboard tiddler="SuperTagShareTheTraitsDiagram" readonly="yes" height="400px" />


!!! General propose JSON Form Editor

See [[WidgetExamples]] or [[Examples]].

This is only provided as a tool for plugin developers to build custom forms.

For interoperability consideration, it is better to use the TraitTag approach described above, so our TiddlyWiki developer community can have a consistent way to deliver form to end users.
27 changes: 27 additions & 0 deletions demo/tiddlers/TraitTag developer - create TraitTag.tid
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
created: 20230601114503385
creator: 林一二
modified: 20230601114655643
modifier: 林一二
tags: UserManual
title: TraitTag developer - create TraitTag
type: text/vnd.tiddlywiki

As a developer, you will want to create your own TraitTag.

A TraitTag has a important field `"schema"`.

<$whiteboard tiddler="HowToCreateTraitTagDiagram" readonly="yes" height="750px" />

* schema: a [[JSON Schema|https://json-schema.org/]] that describe what data a form will receive.
** You may refer to [[JSON Editor Doc#JSON Schema Support|https://github.com/json-editor/json-editor#json-schema-support]] for advanced features in the form
** A basic assumption is that the JSON Schema are `type: "object"` and has only 1 level of properties.
** All properties provided by all trait tags are merged into a single JSON Schema, and then is used to display the SuperTag Form

See links above to learn how to write them. You can also learn from some existed [[TraitTag Examples|$:/SuperTag/TraitTag]].

* Online free JSONSchema editors
** [ext[bjdash/JSON-Schema-Builder|https://bjdash.github.io/JSON-Schema-Builder/]]
** [ext[hellosean1025/json-schema-visual-editor|https://hellosean1025.github.io/json-schema-visual-editor/]]

* Tiddlywiki plugins useful in creating TraitTag tiddlers
** [[wikilabs/field-editor - Side by side multiline field editor|https://tw-cpl.netlify.app/#Plugin_202203243721287]]
Loading

0 comments on commit 2c3eb69

Please sign in to comment.