Skip to content

Configuration

This page lists the configuration points reviewers should inspect when checking a docx_editor integration.

Syncfusion Editor Configuration

dart
const config = DocxSyncfusionConfig(
  licenseKey: syncfusionLicenseKey,
  trustedOrigin: 'https://app.example.com',
  toolbarMode: DocxToolbarMode.ribbon,
);
FieldRequiredPurpose
licenseKeyYesSyncfusion EJ2 license key.
serviceUrlNoOptional Syncfusion service endpoint for service-backed editor features. Normal conversion is pure Dart.
cdnVersionNoSyncfusion EJ2 CDN version. Defaults to the package-pinned version.
trustedOriginRecommendedOrigin used by the editor iframe when posting messages back to the Flutter app.
toolbarModeNoribbon for Word-style tabs or toolbar for a compact action toolbar.

Widget Configuration

dart
SyncfusionDocxEditor(
  document: pickedDocument,
  syncfusionConfig: config,
  controller: controller,
  conversionService: const VyuhDocxConversionService(),
  showToolbar: true,
  onReady: () {},
  onContentChanged: () {},
);
FieldPurpose
documentHost-resolved source, capabilities, lifecycle, lock, and metadata for the session.
syncfusionConfigSyncfusion license, iframe origin, CDN, and toolbar mode.
controllerOptional but expected in regulated flows. Enforces save/export/sign/print policy.
conversionServiceOptional override. Defaults to the pure-Dart vyuh_docx bridge where used.
heightOptional editor height.
showToolbarShows or hides editor actions. Hiding the toolbar does not grant or remove capabilities.
toolbarItemsOptional toolbar item filter for toolbar mode.
onReadyCalled when the editor is ready.
onContentChangedCalled when the editor marks content changed.

Document Source Configuration

Openable source data lives in DocxSource. Business context lives in DocxPickedDocument.

FactoryUse case
DocxSource.docxBase64The host already has base64 DOCX content.
DocxSource.docxBytesThe host has raw DOCX bytes.
DocxSource.sfdtStringThe host has SFDT JSON text.
DocxSource.sfdtJsonThe host has decoded SFDT.
DocxSource.blankDocumentStart a new editable blank document.
DocxSource.storageReferenceThe editor must ask host storage to resolve the document.
Picked document factoryUse case
DocxPickedDocument.localBytesLocal file pick, validated as .docx.
DocxPickedDocument.networkBytesNetwork-loaded file with URL metadata.
DocxPickedDocument.serverDocumentHost document record with source id, optional version id, capabilities, lock, hash, and metadata.

Use expectedSha256 and verifyIntegrity() when opening controlled bytes from a known host version.

Controller Configuration

dart
final controller = DocxController(
  capabilities: DocxCapabilities.fromGrants(
    const {DocumentGrant.read, DocumentGrant.review, DocumentGrant.edit},
    singleEditorLockRequired: true,
  ),
  storageAdapter: storage,
  trustedClock: trustedClock,
  actor: actor,
  lifecycleState: lifecycleState,
  requireResolvedCommentsForSign: true,
  signingVocabulary: signingVocabulary,
  onAuditEvent: audit.write,
);
FieldPurpose
capabilitiesAction gates for the current actor and document.
storageAdapterHost implementation for open, save draft, create version, and download URL.
trustedClockServer-authoritative UTC time for audit and signatures.
onAuditEventDurable audit sink callback.
actorAuthenticated user. Used for audit attribution and Syncfusion comment/revision authorship.
lifecycleStateOptional document lifecycle guard. Released states cannot use editable presets.
requireResolvedCommentsForSignBlocks signing while open review threads remain.
signingVocabularyAllowed signature meanings for the document type.

Lifecycle Configuration

Use DocxLifecycleBinding.resolve before opening controlled documents.

Lifecycle stateDefault posture
draftEditable by default.
inReviewRevision review by default.
approvedView only.
effectiveView only.
supersededView only.

The controller also has a package-level guard: if a released state is paired with editable capabilities, it throws instead of letting the document open editable.

Capability Configuration

Named presets are available for common roles:

PresetUse case
DocxCapabilities.fromGrants(grants)Preferred host-facing API. Expands read, review, and edit document grants into editor action gates.
DocxCapabilities.viewOnly()Open and search/read a document.
DocxCapabilities.commentOnly()Add comments and view review state without editing source.
DocxCapabilities.revisionReview()Accept or reject tracked changes.
DocxCapabilities.fullEdit()Full authoring, optionally requiring track changes.
DocxCapabilities.editWithLock()Full authoring that also requires a backend-owned edit lock.

DocxCapability.eSign is intentionally not included in the edit presets. Add it only when the lifecycle step permits sign-off and the controller has an actor and signing vocabulary.

Document Grants

Use Set<DocumentGrant> as the simple host-facing access model:

GrantMeaning
DocumentGrant.readOpen and search/read.
DocumentGrant.reviewComment, view review state, accept/reject revisions, and export/print review output.
DocumentGrant.editFull authoring, save, review actions, export, and print.

If the host grants an empty set, the resulting capability set is empty. That is intentional: access decisions fail closed.

Edit Lock Configuration

Lock factoryMeaning
DocxEditLock.notRequired()No lock is needed for mutation.
DocxEditLock.ownedByCurrentSession(...)The current session owns the backend lock and may mutate.
DocxEditLock.ownedByOther(...)Another session owns the lock; mutation is blocked.

Use editWithLock() or singleEditorLockRequired only when the host can create, renew, and release backend locks.

Conversion Configuration

Configuration pointPurpose
conversionService on SyncfusionDocxEditorOverride the conversion implementation.
VyuhDocxConversionServiceDefault pure-Dart DOCX/SFDT/PDF bridge backed by vyuh_docx.
Custom DocxConversionServiceIntegrate another conversion backend while keeping controller policy unchanged.

Review Widget Configuration

WidgetRequired inputsCallback configuration
DocxCompareViewDocxDiffResult or base/revised documentsinitialMode, title.
DocxReviewPanelcomment threadsreply, reply-and-resolve, status, resolve, reopen, navigate, create-comment, refresh callbacks.
DocxReviewViewdiff or base/revised documentsnavigate, comment, suggest, apply suggestion, reject suggestion callbacks.

The widgets are presentational. Persisting comments, statuses, suggestions, and revision decisions remains the host/controller responsibility.

Signing Configuration

Signing requires:

RequirementWhy
DocxCapability.eSignExplicit lifecycle permission to sign.
DocxActorSignature attribution.
DocxCredentialVerifierFresh reauthentication ceremony.
DocxSigningVocabularyControlled allowed meanings.
requireResolvedCommentsForSign when neededDocument type can block approval while comments remain open.

Controlled Print Configuration

ControlledPrintService is configured separately from the editor widget:

dart
final printService = ControlledPrintService(
  policy: policy,
  allocator: allocator,
  clock: clock,
  register: register,
  audit: audit,
);
ContractHost responsibility
PrintPolicyDecide whether the actor may issue the requested copy class.
CopyAllocatorAtomically allocate copy numbers and issuance codes.
TrustedClockProvide the authoritative issue time.
PrintRegisterPersist the issuance record.
AuditSinkPersist immutable print audit events.

Controlled print belongs in docx_editor because it is a workflow operation, not just a PDF rendering operation.