Path in the Gestor bibliotecas/html-editor.php
The editor that shows up in the forms of pages, layouts, components, templates, publications, menus, galleries, forms and indexes (about 30 calls in 12 modules). The server builds the screen and answers AJAX; the editing itself runs in the browser (interface/html-editor.js and html-editor-interface.js).
Opening the editor: html_editor_componente()
gestor_incluir_biblioteca('html-editor');
$_GESTOR['pagina'] = modelo_var_troca($_GESTOR['pagina'], '#html-editor#', html_editor_componente([
'editar' => true,
'modulo' => $modulo, // the module JSON
'alvo' => 'paginas', // picks templates and AI prompts
'css_precompiled' => $record['css_precompiled'],
'layout_id' => $record['layout_id'], // to preview with the layout cascade
]));Parameters: editar / adicionarEditar (editing, or adding while already editing HTML and CSS), modulo, alvo, alvos_modelos (extra template targets), publisher and publisherPage (publisher variable controls, html_editor_publisher_controls()), css_precompiled and layout_id.
The screen has:
-
HTML and CSS code in CodeMirror (external assets);
-
visual mode and preview in an
iframewith Tailwind running in the browser (registry version,html_editor_tailwind_browser_version()), in desktop, tablet and phone sizes; the base CSS is the same cascade as the site: precompiled CSS of the layout and of the resource, plus the layout's authored CSS (html_editor_css_precompiled_baseline(),html_editor_layout_css_autoral(),html_editor_css_precompiled_concatenar()). Changing the layout in the form reloads that cascade (html-editor-layout-css); -
templates (per target) to start a page;
-
@[[…]]@variables and widgets shown as boxes in the visual mode, with the real content rendered on demand; -
an AI assistant (ia.php), a SEO & Sharing tab for pages, and the HTML/CSS backup history to restore.
What the browser compiles goes to css_compiled on save, with the provenance signature (resources).
AJAX: html_editor_ajax_interface()
Called by interface.php when the library is among the module's. It first goes through ia_ajax_interface() and then dispatches by ajax-opcao:
| Option | Function | Does |
|---|---|---|
html-editor-templates-load |
html_editor_ajax_templates_load() |
Lists the target's templates (html-editor.templates.load.where filter) |
html-editor-widget-types, html-editor-widgets-list |
html_editor_ajax_widget_types(), html_editor_ajax_widgets_list() |
Widget types and instances to insert (html_editor_widgets_buscar()) |
html-editor-widget-render |
html_editor_ajax_widget_render() |
Renders a widget for the visual mode |
html-editor-render-vars |
html_editor_ajax_render_vars() |
Replaces the HTML's variables and widgets with visual boxes (html_editor_boxes_variaveis(), html_editor_boxes_widgets(), html_editor_resolver_variaveis(), html_editor_resolver_var(), html_editor_var_box(), html_editor_var_pattern(), html_editor_render_widget_signature()) |
html-editor-layout-css |
html_editor_ajax_layout_css() |
CSS of the chosen layout, split into precompiled and authored |
html-editor-ia-requests |
html_editor_ajax_ia_requests() |
Sends the request to the AI with HTML, CSS, mode and theme tokens |
Theme tokens for the AI
So the AI uses the site's colors and fonts instead of inventing them, the editor summarizes the project's Tailwind contract into a {{theme_tokens}} block of about 1.5 KB (2 KB hard cap), prioritizing color, font and spacing: html_editor_ia_tokens_tema_compilar(), with html_editor_ia_tokens_tema_limite(), html_editor_ia_tokens_tema_namespaces(), html_editor_ia_tokens_tema_valor_util(), html_editor_ia_tokens_tema_bloco(), html_editor_ia_tokens_tema_componentes(), html_editor_ia_css_classes_resumir() and html_editor_ia_extrair_tokens_tema(). The AI mode receives the block in its own marker (html_editor_ia_theme_tokens_marcador(), html_editor_ia_modo_theme_tokens_aplicar()).
Includes and filters
-
html_editor_include(['js_vars' => …])includes the visual editor and its dependencies; thehtml-editor.html_editor_include.projectJSandhtml-editor.html_editor_include.imagepickJSfilters (hooks) let the project replace the project JS and the image picker. -
html_editor_assets_registro()loads the external assets registry on demand. -
html_editor_tailwind_browser_contract()reads the project theme contract (contents/tailwindcss/browser-contract.css, which overrides the core one) handed to the in-browser Tailwind.
Functions
Generated from gestor/bibliotecas/html-editor.php · 37 functions
html_editor_publisher_controls
view source · line 26 ↗html_editor_publisher_controls(array $params = false)Publisher controles.
Parameters
$paramsarray- Parâmetros da função.
html_editor_tailwind_browser_version
view source · line 121 ↗html_editor_tailwind_browser_version(): stringVersão do @tailwindcss/browser usada pelos editores (req-117).
Returns
html_editor_assets_registro
view source · line 136 ↗html_editor_assets_registro(): arrayRegistro de assets externos, carregado sob demanda (req-156).
Returns
html_editor_tailwind_browser_contract
view source · line 156 ↗html_editor_tailwind_browser_contract(): stringContrato de tema entregue ao Tailwind Browser (req-114, extraído em req-117).
Returns
html_editor_ia_tokens_tema_limite
view source · line 181 ↗html_editor_ia_tokens_tema_limite(): intOrçamento de bytes do bloco {{theme_tokens}} (req-127).
Returns
html_editor_ia_tokens_tema_namespaces
view source · line 204 ↗html_editor_ia_tokens_tema_namespaces(): arrayNamespaces de tema do Tailwind v4 aceitos no bloco {{theme_tokens}} (req-127).
Returns
html_editor_ia_tokens_tema_valor_util
view source · line 233 ↗html_editor_ia_tokens_tema_valor_util(string $valor): boolDecide se o VALOR de uma declaração de tema cabe no prompt (req-127).
Parameters
$valorstring- valor da declaração, já sem o
;.
Returns
html_editor_ia_tokens_tema_bloco
view source · line 260 ↗html_editor_ia_tokens_tema_bloco(string $css): stringRecorta o conteúdo do primeiro bloco @theme / @theme static do contrato (req-127).
Parameters
$cssstring- CSS do contrato, já sem comentários.
Returns
@theme.html_editor_ia_tokens_tema_componentes
view source · line 294 ↗html_editor_ia_tokens_tema_componentes(string $css): arrayLista os nomes de classe declarados nos blocos @layer components do contrato (req-127).
Parameters
$cssstring- CSS do contrato, já sem comentários.
Returns
html_editor_ia_css_classes_resumir
view source · line 345 ↗html_editor_ia_css_classes_resumir(string $css, int|null $limiteBytes = null): stringResume um CSS qualquer na lista de nomes de classe que ele define (req-127).
Parameters
$cssstring- CSS a resumir.
$limiteBytesint|null- orçamento total;
nullusahtml_editor_ia_tokens_tema_limite().
Returns
html_editor_ia_tokens_tema_compilar
view source · line 387 ↗html_editor_ia_tokens_tema_compilar(string $css, int|null $limiteBytes = null): stringMonta o bloco {{theme_tokens}} a partir do CSS do contrato (req-127).
Parameters
$cssstring- conteúdo do
browser-contract.css. $limiteBytesint|null- orçamento total;
nullusahtml_editor_ia_tokens_tema_limite().
Returns
html_editor_ia_theme_tokens_marcador
view source · line 523 ↗html_editor_ia_theme_tokens_marcador(): stringMarcador do bloco condicional de tokens de tema nos .md dos modos de IA (req-127).
Returns
html_editor_ia_modo_theme_tokens_aplicar
view source · line 543 ↗html_editor_ia_modo_theme_tokens_aplicar(string $modo, string $theme_tokens): stringAplica (ou remove) a seção de tokens de tema no texto do modo de IA (req-127).
Parameters
$modostring- texto do modo de IA.
$theme_tokensstring- saída de
html_editor_ia_extrair_tokens_tema().
Returns
html_editor_ia_extrair_tokens_tema
view source · line 595 ↗html_editor_ia_extrair_tokens_tema(string|null $caminhoContrato = null, int|null $limiteBytes = null): stringExtrator semântico leve de tokens de tema para o Assistente de IA (req-127).
Parameters
$caminhoContratostring|null- caminho explícito do contrato;
nullresolve pelo projeto ativo. $limiteBytesint|null- orçamento total;
nullusahtml_editor_ia_tokens_tema_limite().
Returns
html_editor_css_precompiled_baseline
view source · line 632 ↗html_editor_css_precompiled_baseline(array $params = false): stringBaseline de CSS pré-compilado do editor (req-117).
Parameters
$paramsarray
Returns
html_editor_layout_css_autoral
view source · line 681 ↗html_editor_layout_css_autoral(string $layout_id): stringCSS AUTORAL do layout — a folha que o runtime serve e o editor não recebia (req-160).
Parameters
$layout_idstring- Layout da página.
Returns
html_editor_css_precompiled_concatenar
view source · line 714 ↗html_editor_css_precompiled_concatenar(string $layout, string $recurso): stringConcatena as camadas do baseline na ordem da cascata do runtime (req-117).
Parameters
$layoutstring- CSS pré-compilado do layout.
$recursostring- CSS pré-compilado do próprio recurso.
Returns
html_editor_componente
view source · line 744 ↗html_editor_componente($params = false)Componente Editor HTML.
Parameters
$params
html_editor_include
view source · line 1120 ↗html_editor_include($params = false)Incluir o editor HTML visual.
Parameters
$params
html_editor_ajax_interface
view source · line 1209 ↗html_editor_ajax_interface(array $params = false)AJAX Interface.
Parameters
$paramsarray- Parâmetros da função.
html_editor_ajax_layout_css
view source · line 1240 ↗html_editor_ajax_layout_css()CSS do layout escolhido no formulário (req-160).
html_editor_var_pattern
view source · line 1293 ↗html_editor_var_pattern()============================================================================ req-093 (BATCH-093) — Renderização de variáveis/widgets como caixas no Editor HTML Visual CLÁSSICO e no preview, espelhando a Editbar (Dashboard Site Toolbar).
html_editor_var_box
view source · line 1299 ↗html_editor_var_box($marker, $rendered, $tipo)Parameters
$marker$rendered$tipo
html_editor_render_widget_signature
view source · line 1306 ↗html_editor_render_widget_signature($signature)Parameters
$signature
html_editor_widget_renderizar
view source · line 1329 ↗html_editor_widget_renderizar($sig): arrayRenderiza um widget como a página publicada o entrega, para as prévias do editor.
Parameters
$sig
Returns
css são as tags <style> registradas na renderização.html_editor_widget_js_modulos
view source · line 1350 ↗html_editor_widget_js_modulos(): arrayMódulos que têm controlador público de widget (<modulo>.widget.js), pelo cadastro de widgets. A prévia do editor carrega o controlador dos widgets presentes na página; com uma lista fixa no JavaScript, widget de projeto ou de plugin ficava sem comportamento na prévia.
Returns
html_editor_resolver_var
view source · line 1371 ↗html_editor_resolver_var($id)Parameters
$id
html_editor_boxes_widgets
view source · line 1397 ↗html_editor_boxes_widgets($html)Parameters
$html
html_editor_resolver_variaveis
view source · line 1413 ↗html_editor_resolver_variaveis($html)Parameters
$html
html_editor_boxes_variaveis
view source · line 1424 ↗html_editor_boxes_variaveis($html)Parameters
$html
html_editor_ajax_render_vars
view source · line 1469 ↗html_editor_ajax_render_vars()AJAX — Recebe o HTML do editor (CodeMirror) e devolve duas versões renderizadas (req-093): - boxes: variáveis globais em caixas (.c2f-var-box + data-c2f-marker) + widgets renderizados entre comentários — para carregar no EDITOR VISUAL (átomos reversíveis no save). - values: variáveis globais resolvidas para valor puro (sem caixas) — para o PREVIEW iframe. As variáveis LOCAIS/de simulação (desconhecidas do backend) são preservadas para o frontend resolver.
html_editor_ajax_widget_render
view source · line 1493 ↗html_editor_ajax_widget_render()AJAX Widget Render.
html_editor_ajax_widget_types
view source · line 1534 ↗html_editor_ajax_widget_types()AJAX Widget Types.
html_editor_ajax_widgets_list
view source · line 1570 ↗html_editor_ajax_widgets_list()AJAX Widgets List.
html_editor_widgets_buscar
view source · line 1652 ↗html_editor_widgets_buscar(array $params = array()): arrayBusca paginada de itens de widget para o painel "+" do Live Editor (BATCH-081 §6).
Parameters
$paramsarray- { module?:string, busca?:string, pagina?:int, limite?:int }
Returns
$_GESTOR['ajax-json'].html_editor_ajax_templates_load
view source · line 1725 ↗html_editor_ajax_templates_load()AJAX Templates.
html_editor_ajax_ia_requests
view source · line 1844 ↗html_editor_ajax_ia_requests()AJAX IA Requests.
Widgets and responsive previews
html_editor_widget_renderizar renders a declared widget and returns an array with html and css; html_editor_widget_js_modulos returns a module => true map for active widgets with a .widget.js file. Dashboard callers collect the CSS, head and scripts registered during rendering, then restore temporary context. The visual editor uses viewport-based preview height, calc(100vh - 220px), in Tailwind edit/view modals. Widgets require their template, record and theme styles in the isolated preview. See Dashboard for stylesheet order.