# UnifiedSpread OneEditor Integration Profile

UnifiedSpread dev-31.0.6 supports the single-file processing package policy v1.2 and the general policy v1.8 contribution model.

## Public creation APIs

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

- `createEditorControl(options)` creates the spreadsheet editing surface for Host-composed UI. Package menu / toolbar chrome is hidden by default.
- `createWorkbenchControl(options)` creates the composite workbench with package menu, toolbar, formula bar and status bar.

## Command ID policy

The public command prefix is `spread`.

Examples:

- `spread.file.open`
- `spread.file.save`
- `spread.edit.undo`
- `spread.insert.chart`
- `spread.format.bold`
- `spread.data.filter.apply`

Unprefixed historical IDs such as `file.open` and `format.bold` are rejected by `control.exec()` and `CommandRegistry.get()`.

## Contribution APIs

```javascript
var commands = editor.getCommandDescriptors();
var menus = editor.getMenuContributions({ surface: 'oneEditor', hostProfile: 'oneEditor' });
var toolbars = editor.getToolbarContributions({ surface: 'oneEditor', hostProfile: 'oneEditor' });
var contextMenus = editor.getContextMenuContributions();
var fileCapabilities = editor.getFileCapabilities();
```

The contribution descriptors are declarative. They reference command IDs and do not contain DOM.

## File menu ownership

OneEditor owns its File menu UI. Therefore `getMenuContributions({ surface: 'oneEditor' })` omits the package File menu by default. The File commands remain available as `spread.file.*` and can be called by OneEditor after it resolves the active file package.

For normal Workbench use, `getMenuContributions({ surface: 'workbench' })` includes the File menu and `createWorkbenchControl()` renders it.

## File capability contract

`getFileCapabilities()` returns readable / writable / export formats and template entries. UnifiedSpread uses `.uspdx` as the native re-editable work file. `.xlsx`, `.xlsm`, and `.csv` can be written through Save As or Export according to the File I/O policy.

## Demo

Open `demo/oneeditor-integration.html` over an HTTP server. The page simulates a Host shell that owns the top menu, creates `createEditorControl()`, and displays the descriptors returned by the control.


## Single File Policy v1.3 Flow

OneEditor should create `createEditorControl({ hostProfile: 'oneEditor' })`, load CSS from `PACKAGE_MANIFEST.json`, then pass an acquired `HostFilePayload/v1` to `control.openFile(payload, context)`.

For Save / Save As / Export, OneEditor should call `control.saveFile`, `control.saveAsFile`, or `control.exportFile`, then write the returned `HostSavePayload/v1.data` through its own storage workflow.
