סקר מחקר: נשמח לשמוע על החוויה שלך עם Blockly
לפתיחת הסקר
שדות תווית שניתן לערוך
קל לארגן דפים בעזרת אוספים
אפשר לשמור ולסווג תוכן על סמך ההעדפות שלך.
תוויות שניתנות לסריאליזציה פועלות בדיוק כמו תוויות רגילות, אלא שהן גם עוברות סריאליזציה ל-XML. צריך להשתמש בהם רק אם עורכים את התוכן של תווית באופן פרוגרמטי, ומעוניינים לבצע סריאליזציה ל-XML.
שדה תווית שניתן לסריאליזציה

שדה תווית לצורך שרשור בבלוק מצומצם

יצירה
JSON
{
"type": "example_serializable_label",
"message0": "%1",
"args0": [
{
"type": "field_label_serializable",
"name": "FIELDNAME",
"text": "a serializable label"
}
]
}
JavaScript
Blockly.Blocks['example_serializable_label'] = {
init: function() {
this.appendDummyInput()
.appendField(new Blockly.FieldLabelSerializable("a serializable label"), "FIELDNAME");
}
};
שדה התווית שניתן לסריאליזציה מקבל ערך אופציונלי ומחרוזת של סיווג CSS אופציונלי. ברירת המחדל של שניהם היא מחרוזת ריקה.
סידור הפרקים
JSON
ה-JSON של שדה תווית שניתן לסריאליזציה נראה כך:
{
"fields": {
"FIELDNAME": text
}
}
כאשר FIELDNAME
היא מחרוזת שמפנה לשדה תווית שניתן לסריאליזציה, והערך הוא הערך שרוצים להחיל על השדה. הערך צריך לעמוד באותם כללים כמו הערך של ה-constructor.
XML
קוד ה-XML של שדה תווית שניתן לסריאליזציה נראה כך:
<field name="FIELDNAME">text</field>
המאפיין name
של הצומת field
מכיל מחרוזת שמפנה לשדה תווית שניתן לסריאליזציה, והטקסט הפנימי של הצומת הוא הערך שצריך להחיל על השדה.
כלי אימות
שדות תווית שניתנים לסריאליזציה לא תומכים בכלי אימות, כי המשתמשים לא יכולים לערוך אותם.
אלא אם צוין אחרת, התוכן של דף זה הוא ברישיון Creative Commons Attribution 4.0 ודוגמאות הקוד הן ברישיון Apache 2.0. לפרטים, ניתן לעיין במדיניות האתר Google Developers. Java הוא סימן מסחרי רשום של חברת Oracle ו/או של השותפים העצמאיים שלה.
עדכון אחרון: 2025-07-26 (שעון UTC).
[null,null,["עדכון אחרון: 2025-07-26 (שעון UTC)."],[[["\u003cp\u003eSerializable labels function identically to regular labels but with the added capability of serializing to XML for programmatic content editing.\u003c/p\u003e\n"],["\u003cp\u003eThese labels are defined using JSON or JavaScript, specifying their type, message, arguments, and field name.\u003c/p\u003e\n"],["\u003cp\u003eSerialization of serializable labels is achieved through JSON or XML, representing the field name and its corresponding text value.\u003c/p\u003e\n"],["\u003cp\u003eUnlike regular labels, serializable labels lack validator support due to their non-editable nature.\u003c/p\u003e\n"]]],[],null,["# Serializable label fields\n\nSerializable labels work exactly the same as [normal labels](/blockly/guides/create-custom-blocks/fields/built-in-fields/label)\nexcept they also serialize to XML. They should only be used if you are editing\nthe content of a label programmatically, and wish it to serialize to XML.\n\n#### Serializable label field\n\n#### Serializable label field on a collapsed block\n\nCreation\n--------\n\n### JSON\n\n {\n \"type\": \"example_serializable_label\",\n \"message0\": \"%1\",\n \"args0\": [\n {\n \"type\": \"field_label_serializable\",\n \"name\": \"FIELDNAME\",\n \"text\": \"a serializable label\"\n }\n ]\n }\n\n### JavaScript\n\n Blockly.Blocks['example_serializable_label'] = {\n init: function() {\n this.appendDummyInput()\n .appendField(new Blockly.FieldLabelSerializable(\"a serializable label\"), \"FIELDNAME\");\n }\n };\n\nThe serializable label field takes in an optional value, and an optional css\nclass string. Both default to an empty string.\n\nSerialization\n-------------\n\n### JSON\n\nThe JSON for a serializable label field looks like so: \n\n {\n \"fields\": {\n \"FIELDNAME\": text\n }\n }\n\nWhere `FIELDNAME` is a string referencing a serializable label field, and\nthe value is the value to apply to the field. The value\nfollows the same rules as the constructor value.\n\n### XML\n\nThe XML for a serializable label field looks like so: \n\n \u003cfield name=\"FIELDNAME\"\u003etext\u003c/field\u003e\n\nThe `field` node's `name` attribute contains a string referencing a serializable\nlabel field, and the node's inner text is the value to apply to the field.\n\nValidators\n----------\n\nSerializable label fields do not support validators, because they are not\neditable by a user."]]