@molecule/app-editor-layout-angular

Feature · editor-layout · App (browser) · v1.1.3 · Apache-2.0

Editor scaffold: top bar with save/publish, main canvas, optional side panel

npm install @molecule/app-editor-layout-angular

npm · Source on GitHub

How it works

@molecule/app-editor-layout-angular is a ready-made editor-layout feature for the app (browser) side. It composes the core interfaces it needs, so it works with whichever providers your app has bonded.

import { Component } from '@angular/core'
import { EditorLayout } from '@molecule/app-editor-layout-angular'
import { EditorToolbar } from '@molecule/app-editor-toolbar-angular'
import { ArticleEditor } from './article-editor.component'
import { MetadataPanel } from './metadata-panel.component'

@Component({
  selector: 'app-editor',
  standalone: true,
  imports: [EditorLayout, EditorToolbar, ArticleEditor, MetadataPanel],
  template: `
    <div mol-editor-layout [sidePanelOpen]="true">
      <app-editor-toolbar slot="topBar" title="Untitled post" />
      <app-article-editor slot="canvas" />
      <app-metadata-panel slot="sidePanel" />
    </div>
  `,
})
export class Editor {}

Works with: @molecule/app-angular, @molecule/app-ui, @molecule/app-ui-angular

Reference

Angular editor layout scaffold.

Exports EditorLayout — sticky top bar + main canvas + optional side panel. It is the Angular counterpart of @molecule/app-editor-layout-react: the same props (React names) and the same DOM for the same input. Used for blog post editors, product editors, bot flow editors, etc.

Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit src/index.ts JSDoc, not this file.

Quick Start

import { Component } from '@angular/core'
import { EditorLayout } from '@molecule/app-editor-layout-angular'
import { EditorToolbar } from '@molecule/app-editor-toolbar-angular'
import { ArticleEditor } from './article-editor.component'
import { MetadataPanel } from './metadata-panel.component'

@Component({
  selector: 'app-editor',
  standalone: true,
  imports: [EditorLayout, EditorToolbar, ArticleEditor, MetadataPanel],
  template: `
    <div mol-editor-layout [sidePanelOpen]="true">
      <app-editor-toolbar slot="topBar" title="Untitled post" />
      <app-article-editor slot="canvas" />
      <app-metadata-panel slot="sidePanel" />
    </div>
  `,
})
export class Editor {}

Type

feature

Installation

npm install @molecule/app-editor-layout-angular @angular/common @angular/core @angular/platform-browser @molecule/app-angular @molecule/app-ui @molecule/app-ui-angular

API

Interfaces

EditorLayoutProps

Props accepted by EditorLayout — the same props @molecule/app-editor-layout-react accepts. Node props (topBar, canvas, sidePanel) are projected content in Angular (an input cannot carry a node), so they are typed unknown: pass them in the host template, not as values.

interface EditorLayoutProps {
  /**
   * Sticky top bar — typically title + save/publish buttons + status
   * indicator, projected as `[slot=topBar]` content.
   */
  topBar?: unknown
  /** Main editing canvas, projected as `[slot=canvas]` content. */
  canvas?: unknown
  /**
   * Optional right-side settings / metadata panel, projected as
   * `[slot=sidePanel]` content.
   */
  sidePanel?: unknown
  /** Side-panel position — defaults to `'right'`. */
  sidePanelPosition?: 'left' | 'right'
  /** Whether the side panel is currently visible. */
  sidePanelOpen?: boolean
  /** Extra classes. */
  className?: string
  /** `data-mol-id` for AI-agent selectors. */
  dataMolId?: string
}

Classes

EditorLayout

EditorLayout component.

Three-region editor scaffold: sticky top bar + main canvas + optional side panel. The host IS the outer <div> (div[mol-editor-layout]), matching React's root exactly. The top bar, canvas and side panel are projected slots ([slot=topBar], [slot=canvas], [slot=sidePanel]); the side panel renders before the <main> on the left and after it on the right.

Angular projection needs always-mounted <ng-content> capture points, so both side-panel wrappers live in the template unconditionally and EditorLayout.reconcile reconciles them against React's DOM.

@Component({
  selector: 'div[mol-editor-layout]',
  standalone: true,
  hostDirectives: [MolPlacement],
  imports: [],
  inputs: ['sidePanelPosition', 'sidePanelOpen', 'className', 'dataMolId'],
  host: {
    '[class]': 'classes()',
    '[attr.data-mol-id]': 'dataMolId ?? null',
  },
  template: `<div #bar [style.position]="'sticky'" [style.top]="'0px'" [style.z-index]="'10'">
      <ng-content select="[slot=topBar]"></ng-content>
    </div>
    <div [class]="rowClasses()">
      <aside #leftPanel [class]="panelClasses()">
        <ng-content select="[slot=sidePanel]"></ng-content>
      </aside>
      <main [class]="canvasClasses()">
        <ng-content select="[slot=canvas]"></ng-content>
      </main>
      <aside #rightPanel [class]="panelClasses()">
        <ng-content select="[slot=sidePanel]"></ng-content>
      </aside>
    </div>`,
})
export class EditorLayout {
  /** Side-panel position (defaults to `'right'` at read time). */
  sidePanelPosition?: 'left' | 'right'
  /** Whether the side panel is currently visible (defaults to `true`). */
  sidePanelOpen?: boolean
  /** Extra classes. */
  className?: string
  /** `data-mol-id` for AI-agent selectors. */
  dataMolId?: string

  /** The sticky top-bar container. */
  @ViewChild('bar') bar?: ElementRef<HTMLElement>
  /** The left side-panel capture wrapper (before the `<main>`). */
  @ViewChild('leftPanel') leftPanel?: ElementRef<HTMLElement>
  /** The right side-panel capture wrapper (after the `<main>`). */
  @ViewChild('rightPanel') rightPanel?: ElementRef<HTMLElement>

  constructor() {
    usePlacement((hasContent) => this.reconcile(hasContent))
  }

  /**
   * The current class map.
   * @returns The UIClassMap.
   */
  cm(): UIClassMap {
    return getClassMap()
  }

  /**
   * Computes the wrapper class list (`cm.flex({ direction: 'col' })` +
   * `cm.h('screen')` + `className`).
   * @returns The class string.
   */
  classes(): string {
    return this.cm().cn(this.cm().flex({ direction: 'col' }), this.cm().h('screen'), this.className)
  }

  /**
   * Computes the panel/canvas row class (`cm.flex({ align: 'stretch' })` + `cm.flex1`).
   * @returns The class string.
   */
  rowClasses(): string {
    return this.cm().cn(this.cm().flex({ align: 'stretch' }), this.cm().flex1)
  }

  /**
   * Computes the side-panel class (`cm.shrink0`).
   * @returns The class string.
   */
  panelClasses(): string {
    return this.cm().cn(this.cm().shrink0)
  }

  /**
   * Computes the canvas class (`cm.flex1`).
   * @returns The class string.
   */
  canvasClasses(): string {
    return this.cm().cn(this.cm().flex1)
  }

  /**
   * Applies React's conditions: with a projected side panel and
   * `sidePanelOpen` (default true), exactly one `<aside class="shrink0">`
   * wraps it — before the `<main>` on the left, after it on the right;
   * otherwise no `<aside>` renders.
   *
   * @param hasContent - Reads whether a slot has content.
   */
  private reconcile(hasContent: SlotReader): void {
    const left = this.leftPanel?.nativeElement
    const right = this.rightPanel?.nativeElement
    if (!left || !right) return
    const hasPanel = hasContent(left) || hasContent(right)
    const showPanel = hasPanel && (this.sidePanelOpen ?? true)
    const target = this.sidePanelPosition === 'left' ? left : right
    const other = target === left ? right : left
    // Angular projected the consumer's side-panel content into the first capture
    // point; render it in the shown side, or back in the capture when hidden.
    placeContent(left, target === left ? null : target)
    setElementPresent(target, showPanel)
    setElementPresent(other, false)
  }
}

Injection Notes

Requirements

Peer dependencies:

  • @angular/common ^22.0.0
  • @angular/core ^22.0.0
  • @angular/platform-browser ^22.0.0
  • @molecule/app-angular ^3.13.0 || ^4.0.0
  • @molecule/app-ui ^1.0.1
  • @molecule/app-ui-angular ^1.1.0

Runtime Dependencies

  • @angular/common

  • @angular/core

  • @angular/platform-browser

  • @molecule/app-angular

  • @molecule/app-ui

  • @molecule/app-ui-angular

  • The scaffold claims the FULL viewport height (h-screen flex column). Render it as the page root; nesting it below another fixed-height app shell produces double scrollbars.

  • The side panel container sets flex-shrink 0 but NO width — your sidePanel content must define its own width.

  • topBar is wrapped in a sticky container by the layout itself (unlike <DetailPageLayout>); the slot does not need its own stickiness, but should bring a surface background.

  • The node props are projected content: topBar and canvas are selected by [slot=topBar] / [slot=canvas], the side panel by [slot=sidePanel].

  • ArticleEditor and MetadataPanel above are your own components.

  • Styling resolves through getClassMap() — requires a wired ClassMap bond (standard molecule app setup). No text of its own.