MMOframework
Pourquoi l'IA Playground Bibliothèques Documentation Rechercher Agence
FR EN
Index

SectionEditor

MMO.editor · 1 symbole · générée le 27 Oct 2026

class

SectionEditor

SectionEditor.js:19

The section-type editor: the types of section of the site -- their fields (the schema), their template (PHP), their styles -- made and changed from the browser, with a live preview. Everything goes through the api (admin/section-types…, `MMO.editor.config.sectionTypes). <mmo-section-editor>` is its element.

class MMO.editor.SectionEditor
Espace de noms
MMO.editor
- The site's types are written (the folder `Pages::$typesFolder`); the others -- mmo.editor's, another folder's -- are shown read only, and « Copy to my site » makes a copy that replaces them. - « Fields » edits the schema as a form: each field has a kind (text, rich text, link, image, choice, list…), a label, an example. « Schema » is the same json, by hand. « Template » is the PHP drawing the section: « Generate from the fields » writes one to start from. « Styles » is the type's css. - A template is PHP that the server runs: the right to write one (`editor.sections#edit`) is a developer's. Events: `api` (each call), `saved` (`detail`: the type).
new MMO.editor.SectionEditor(document.getElementById('types'), {type: 'faq'});

Index

KINDS staticthe kinds of field, and the schema each one is
constructor(node, options)
destroy()
h(tag, attrs, children)
$(name)
t(text, context)
notify(text)
ask(title, text)
confirm(title, text)
code(name, oninput)[internal] A code area: monospace, Tab indents
build()[internal] The editor's own nodes: a bar, the tabs, the preview
showTab(id)
call(method, path, body, {raw = false, retry = true}) async
start() async
loadTypes() asyncThe types, in the picker: the site's first, then the others (read only)
open(name, force) async
setType(type)
renderStatus()
changed()
create() asyncMake a new type of the site: a name, then a title field to start from (saved with « Save »)
save() async
copy() async
remove() async
generate() async
showErrors(errors)Show what the api says is wrong: in a list, and on the tab of each
parse(json)
setSchemaText(text)The json was typed by hand: the fields follow it when it is valid
schemaChanged()The fields changed: the json follows
kindOf(field)
convert(field, kind)
renderFields()[internal] The type's settings, and its fields as cards
fieldsEditor(properties, ro, nested)[internal] @return {HTMLElement} the cards of the fields of $properties (an object's, or a list's items')
fieldCard(key, field, {rename, move, remove, index, first, last, ro, nested})[internal] @return {HTMLElement} the card of one field: its name, its kind, its label… its own fields for a list
input(label, value, onchange, {help = null, wide = false, area = false, type = 'text', change = false, disabled = false})[internal] @return {HTMLElement} a labelled input; onchange gets the value (false keeps the input as it was)
select(label, value, options, onchange, disabled)
check(label, checked, onchange, disabled)
preview()Render a page holding one section of the type as the editor has it, a moment after the last change

Constantes1

KINDS

staticSectionEditor.js:21

the kinds of field, and the schema each one is

static KINDS = { text: {label: 'Text', schema: () => ({type: 'string', default: ''})}, inline: {label: 'Rich text, one line', schema: () => ({type: 'string', format: 'html', editor: 'inline', default: ''})}, rich: {label: 'Rich text', schema: () => ({type: 'string', format: 'html', tools: 'bold,italic,link|ul,ol', default: '<p></p>'})}, link: {label: 'Link (text and address)', schema: () => ({type: 'object', properties: {label: {type: 'string', label: 'Text', default: 'Read more'}, url: {type: 'string', format: 'url', label: 'Link', default: '#'}}})}, url: {label: 'Address', schema: () => ({type: 'string', format: 'url', default: ''})}, image: {label: 'Image', schema: () => ({type: 'object', format: 'image', properties: {src: {type: 'string', label: 'Address', default: ''}, alt: {type: 'string', label: 'Description', level: 'standard', default: ''}}})}, choice: {label: 'Choice', schema: () => ({type: 'string', enum: ['one', 'two'], default: 'one'})}, boolean: {label: 'Yes / no', schema: () => ({type: 'boolean', default: false})}, number: {label: 'Number', schema: () => ({type: 'integer', default: 0})}, list: {label: 'List of items', schema: () => ({type: 'array', items: {type: 'object', properties: {title: {type: 'string', label: 'Title', minLength: 1, default: 'An item'}}}, default: [{title: 'An item'}]})}, object: {label: 'Group of fields (edit it in « Schema »)', schema: () => ({type: 'object', properties: {}})}, };

Méthodes36

constructor(node, options)

SectionEditor.js:40
constructor(node, options = {})
nodeHTMLElement- where it is built
options = {}

h(tag, attrs, children)

SectionEditor.js:74
h(tag, attrs = {}, ...children)
tag
attrs = {}
...children

ask(title, text)

SectionEditor.js:100
ask(title, text)
title
text
retournePromise<string | false>what the user typed, false when cancelled

code(name, oninput)

SectionEditor.js:111

[internal] A code area: monospace, Tab indents

code(name, oninput)
name
oninput

call(method, path, body, {raw = false, retry = true})

asyncSectionEditor.js:173
async call(method, path, body = undefined, {raw = false, retry = true} = {})
method
path
body = undefined
{raw = false, retry = true} = {}

loadTypes()

asyncSectionEditor.js:210

The types, in the picker: the site's first, then the others (read only)

async loadTypes()

create()

asyncSectionEditor.js:276

Make a new type of the site: a name, then a title field to start from (saved with « Save »)

async create()

showErrors(errors)

SectionEditor.js:340

Show what the api says is wrong: in a list, and on the tab of each

showErrors(errors)
errors

parse(json)

SectionEditor.js:356
parse(json)
json
retourne?Object$json parsed, null when it is not a json object

setSchemaText(text)

SectionEditor.js:365

The json was typed by hand: the fields follow it when it is valid

setSchemaText(text)
text

convert(field, kind)

SectionEditor.js:397
convert(field, kind)
field
kind
retourneObject$field as a $kind: its label, help and level kept

renderFields()

SectionEditor.js:404

[internal] The type's settings, and its fields as cards

renderFields()

fieldsEditor(properties, ro, nested)

SectionEditor.js:423

[internal] @return {HTMLElement} the cards of the fields of $properties (an object's, or a list's items')

fieldsEditor(properties, ro, nested = false)
properties
ro
nested = false

fieldCard(key, field, {rename, move, remove, index, first, last, ro, nested})

SectionEditor.js:454

[internal] @return {HTMLElement} the card of one field: its name, its kind, its label… its own fields for a list

fieldCard(key, field, {rename, move, remove, index, first, last, ro, nested})
key
field
{rename, move, remove, index, first, last, ro, nested}

input(label, value, onchange, {help = null, wide = false, area = false, type = 'text', change = false, disabled = false})

SectionEditor.js:521

[internal] @return {HTMLElement} a labelled input; onchange gets the value (false keeps the input as it was)

input(label, value, onchange, {help = null, wide = false, area = false, type = 'text', change = false, disabled = false} = {})
label
value
onchange
{help = null, wide = false, area = false, type = 'text', change = false, disabled = false} = {}

select(label, value, options, onchange, disabled)

SectionEditor.js:528
select(label, value, options, onchange, disabled = false)
label
value
options
onchange
disabled = false

check(label, checked, onchange, disabled)

SectionEditor.js:534
check(label, checked, onchange, disabled = false)
label
checked
onchange
disabled = false

preview()

SectionEditor.js:542

Render a page holding one section of the type as the editor has it, a moment after the last change

preview()