Skip to main content

SchemaFieldBase

interface

Declares that a serialized property *is* a node field, read and written directly rather than through an accessor method. The kind is stated rather than inferred from the name: a field and a method are different things to reach for, and deciding between them by looking at the string would make a node's field naming part of this API's contract.

interface SchemaFieldBase

Import

import { SchemaFieldBase } from '@modular/sdk/editor';

Members2

field
string
methodoptional
string

The accessor method this direct field access stands in for, when it is not the conventional `get<Prop>`/`set<Prop>` for the property. Naming one keeps a subclass in charge of its own property: if any class between the one that declared this field and the node's own class overrides that method, the field access is abandoned and the method is called instead. Leaving it out defers to the conventional name, which is what nearly every property wants — a node that predates its schema already has those accessors, and overriding `getStyle()` on a TextNode subclass is ordinary, so migrating a property to a field must not silently take that back. Name one only when the accessor is spelled differently, as TextNode's `text` is (`getTextContent`) and LinkNode's `url` is (`getURL`). A class with no such method defers to nothing, since both prototypes then resolve `undefined`.