Conn2Flow
Docs navigation

Reference / Libraries

html-editor.php library

The HTML and CSS editor of the page, layout, component, template, publication and widget CRUDs: code, visual, Tailwind preview, templates, variables, widgets and AI assistant.

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 iframe with 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; the html-editor.html_editor_include.projectJS and html-editor.html_editor_include.imagepickJS filters (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

37 of 37

html_editor_ia_tokens_tema_bloco

view source · line 260 ↗
html_editor_ia_tokens_tema_bloco(string $css): string

Recorta o conteúdo do primeiro bloco @theme / @theme static do contrato (req-127).

Parameters

$cssstring
CSS do contrato, já sem comentários.

Returns

string
conteúdo interno do bloco, ou string vazia quando não houver @theme.

html_editor_ia_tokens_tema_componentes

view source · line 294 ↗
html_editor_ia_tokens_tema_componentes(string $css): array

Lista os nomes de classe declarados nos blocos @layer components do contrato (req-127).

Parameters

$cssstring
CSS do contrato, já sem comentários.

Returns

array
lista de classes com o ponto, na ordem de aparição.

html_editor_ia_css_classes_resumir

view source · line 345 ↗
html_editor_ia_css_classes_resumir(string $css, int|null $limiteBytes = null): string

Resume um CSS qualquer na lista de nomes de classe que ele define (req-127).

Parameters

$cssstring
CSS a resumir.
$limiteBytesint|null
orçamento total; null usa html_editor_ia_tokens_tema_limite().

Returns

string
lista de classes separadas por espaço, ou string vazia.

html_editor_ia_tokens_tema_compilar

view source · line 387 ↗
html_editor_ia_tokens_tema_compilar(string $css, int|null $limiteBytes = null): string

Monta 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; null usa html_editor_ia_tokens_tema_limite().

Returns

string
bloco CSS compacto, ou string vazia quando não houver nada aproveitável.

html_editor_ia_modo_theme_tokens_aplicar

view source · line 543 ↗
html_editor_ia_modo_theme_tokens_aplicar(string $modo, string $theme_tokens): string

Aplica (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

string

html_editor_ia_extrair_tokens_tema

view source · line 595 ↗
html_editor_ia_extrair_tokens_tema(string|null $caminhoContrato = null, int|null $limiteBytes = null): string

Extrator semântico leve de tokens de tema para o Assistente de IA (req-127).

Parameters

$caminhoContratostring|null
caminho explícito do contrato; null resolve pelo projeto ativo.
$limiteBytesint|null
orçamento total; null usa html_editor_ia_tokens_tema_limite().

Returns

string
bloco CSS compacto, ou string vazia quando não houver contrato aproveitável.

html_editor_css_precompiled_concatenar

view source · line 714 ↗
html_editor_css_precompiled_concatenar(string $layout, string $recurso): string

Concatena 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

string

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_widget_renderizar

view source · line 1329 ↗
html_editor_widget_renderizar($sig): array

Renderiza um widget como a página publicada o entrega, para as prévias do editor.

Parameters

$sig

Returns

array
['html' => string, 'css' => string] css são as tags <style> registradas na renderização.

html_editor_widget_js_modulos

view source · line 1350 ↗
html_editor_widget_js_modulos(): array

Mó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

array
[modulo => true]

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_widgets_buscar

view source · line 1652 ↗
html_editor_widgets_buscar(array $params = array()): array

Busca 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

array
Estrutura de resposta pronta para $_GESTOR['ajax-json'].

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.

The Future is Hybrid: Human + AI.

Conn2Flow is the tool. If you need the Architect to design your company's strategy using this technology...

Hire Specialized Consulting