# OneEditor Integration Profile

UnifiedWriter is a file-processing Control package. It keeps its own `writer.file.*` commands, file capabilities, and EditorControl state. OneEditor is an integrated Host profile that may render its own File menu and route file actions to the active package after New/Open resolves the file type.

This profile is intentionally not a universal Host rule. WorkbenchControl and ordinary page-embedded usage may display UnifiedWriter's package File menu directly.

## Recommended OneEditor flow

```text
New / Open in OneEditor
  -> determine file type or template
  -> load UnifiedWriter package
  -> create EditorControl({ mode: 'edit', hostProfile: 'oneEditor' })
  -> read commands, menu contributions, toolbar contributions, file capabilities
  -> compose OneEditor UI
  -> delegate File actions to writer.file.* commands
```

## Creation example

```javascript
require(['UnifiedWriter/main'], function(UnifiedWriter){
  var control = UnifiedWriter.createEditorControl({
    container: '#editorFrame',
    mode: 'edit',
    hostProfile: 'oneEditor',
    OpenFile: hostOpenFile,
    SaveFile: hostSaveFile
  });

  var commands = control.getCommandRegistry({ mode: 'edit' });
  var menus = control.getMenuContributions({ mode: 'edit', surface: 'oneEditor' });
  var toolbars = control.getToolbarContributions({ mode: 'edit', surface: 'oneEditor' });
  var files = control.getFileCapabilities();
});
```

## View / OneViewer mode

OneViewer should not request a separate ViewerControl. It should create the same EditorControl in view/read-only mode.

```javascript
var viewer = UnifiedWriter.createEditorControl({
  container: '#viewerFrame',
  mode: 'view',
  readOnly: true,
  hostProfile: 'oneViewer'
});
```

In view mode, mutation commands such as `writer.format.bold`, `writer.insert.image`, `writer.review.trackChanges.toggle`, and legacy actions such as `bold` are filtered from contributions and guarded at the public `exec()` boundary.

## Capability API

`getFileCapabilities()` returns machine-readable format information for New/Open/Save/Export integration.

```javascript
{
  readableFormats: [{ id:'uwpsx', extensions:['.uwpsx'] }, { id:'docx', extensions:['.docx'] }],
  writableFormats: [{ id:'uwpsx', extensions:['.uwpsx'], native:true }],
  exportFormats: [{ id:'pdf', extensions:['.pdf'] }],
  templates: [{ id:'blank', command:'writer.file.newDocument' }]
}
```

## Surface ownership summary

| Surface | WorkbenchControl | OneEditor / OneViewer profile |
|---|---|---|
| File menu UI | May render package File menu | May render Host File menu and delegate |
| File commands | `writer.file.*` | `writer.file.*` after active package is known |
| Storage provider UI | Host callback / adapter / Demo shell | Host callback / adapter |
| Edit/View/Insert/Format menus | Rendered from package menu definitions | Composed from package contributions |
| Toolbar | Rendered by Workbench shell | Composed from package contributions |


## v5.66.1 UnifiedControl requirement

OneEditor must load UnifiedControl before UnifiedWriter and configure both AMD aliases.  UnifiedWriter no longer exposes only a plain wrapper object; `createEditorControl()` returns an instance of `UnifiedWriter.EditorControl`, which inherits `UnifiedControl.Control`.

```javascript
require.config({
  paths: {
    'UnifiedControl': unifiedControlRoot + '/scripts',
    'UnifiedWriter': unifiedWriterRoot + '/scripts'
  }
});

require(['UnifiedWriter/main'], function (UnifiedWriter) {
  var control = UnifiedWriter.createEditorControl({
    container: editorFrame,
    mode: 'edit',
    hostProfile: 'oneEditor'
  });
});
```

OneEditor may continue to obtain menu, toolbar and file capabilities from the same methods: `getCommandRegistry()`, `getMenuContributions()`, `getToolbarContributions()`, `getContextMenuContributions()` and `getFileCapabilities()`.


## v5.67.0 OneEditor file payload flow

After package routing, OneEditor should create `EditorControl` and call `control.openFile(HostFilePayload/v1, context)`. Save / Save As / Export should call `control.saveFile`, `control.saveAsFile`, or `control.exportFile`, then pass the returned `HostSavePayload/v1` to the OneEditor save adapter.
