Workflow Management Guide

November 30, 2025 ยท View on GitHub

Implement approval workflows, version control, and document lifecycle management.

Quick Setup

Basic Workflow

const editor = new ArmorEditor({
  container: '#editor',
  workflow: {
    enabled: true,
    stages: ['draft', 'review', 'approved', 'published']
  },
  versioning: {
    enabled: true,
    git: true
  }
});

Approval Workflows

Multi-Stage Approvals

const editor = new ArmorEditor({
  workflow: {
    enabled: true,
    stages: [
      {
        name: 'draft',
        role: 'author',
        actions: ['edit', 'submit']
      },
      {
        name: 'review',
        role: 'reviewer',
        actions: ['approve', 'reject', 'request_changes'],
        deadline: 48 // hours
      },
      {
        name: 'final_approval',
        role: 'manager',
        actions: ['approve', 'reject'],
        deadline: 24
      },
      {
        name: 'published',
        role: 'system',
        actions: ['archive']
      }
    ]
  }
});

Workflow Actions

// Submit for approval
await editor.submitForApproval('review');

// Approve document
editor.approveDocument('doc-123', {
  stage: 'review',
  comments: 'Looks good!',
  approver: 'reviewer-id'
});

// Reject document
editor.rejectDocument('doc-123', {
  stage: 'review',
  reason: 'Needs more data',
  rejector: 'reviewer-id'
});

// Get workflow status
const status = editor.getWorkflowStatus('doc-123');

Parallel Approvals

workflow: {
  stages: [
    {
      name: 'parallel_review',
      parallel: true,
      approvers: [
        { role: 'technical_reviewer', required: true },
        { role: 'business_reviewer', required: true },
        { role: 'legal_reviewer', required: false }
      ],
      consensus: 'majority' // 'all', 'majority', 'any'
    }
  ]
}

Version Control

Git-like Versioning

const editor = new ArmorEditor({
  versioning: {
    enabled: true,
    git: true,
    branches: true,
    autoSave: true,
    maxVersions: 100
  }
});

Version Operations

// Create version
const version = editor.createVersion('Added new section', {
  author: 'john.doe@company.com',
  tags: ['feature-addition']
});

// Get version history
const history = editor.getVersionHistory();

// Restore version
editor.restoreVersion('version-abc123');

// Compare versions
const diff = editor.compareVersions('v1', 'v2');

Branching and Merging

// Create branch
editor.createBranch('feature-new-section');

// Switch branch
editor.switchBranch('feature-new-section');

// Merge branch
editor.mergeBranch('feature-new-section', 'main', {
  strategy: 'auto',
  message: 'Merge feature into main'
});

// Delete branch
editor.deleteBranch('feature-new-section');

Document Templates

Template System

const editor = new ArmorEditor({
  templates: {
    enabled: true,
    categories: ['business', 'legal', 'technical'],
    customTemplates: true,
    variables: true
  }
});

Create Templates

// Create template
editor.createTemplate({
  id: 'project-proposal',
  name: 'Project Proposal',
  category: 'business',
  content: `
    <h1>Project Proposal: {{project_name}}</h1>
    <p><strong>Date:</strong> {{date}}</p>
    <p><strong>Author:</strong> {{author}}</p>
    
    <h2>Executive Summary</h2>
    <p>{{executive_summary}}</p>
    
    <h2>Budget</h2>
    <p>Total: ${{budget}}</p>
  `,
  variables: [
    { name: 'project_name', type: 'text', required: true },
    { name: 'date', type: 'date', default: 'today' },
    { name: 'author', type: 'user', default: 'current_user' },
    { name: 'executive_summary', type: 'textarea' },
    { name: 'budget', type: 'number', format: 'currency' }
  ]
});

// Use template
editor.useTemplate('project-proposal', {
  project_name: 'AI Integration',
  budget: 150000
});

Template Categories

templates: {
  categories: {
    business: ['proposal', 'memo', 'report'],
    legal: ['contract', 'agreement', 'policy'],
    technical: ['specification', 'documentation', 'readme'],
    marketing: ['campaign', 'content', 'social']
  }
}

Use Cases

Corporate Policy Workflow

const policyEditor = new ArmorEditor({
  container: '#policy-editor',
  workflow: {
    enabled: true,
    stages: [
      { name: 'draft', role: 'policy_author' },
      { name: 'department_review', role: 'department_head' },
      { name: 'legal_review', role: 'legal_team' },
      { name: 'executive_approval', role: 'executive' },
      { name: 'published', role: 'system' }
    ],
    notifications: {
      email: true,
      slack: true
    }
  },
  versioning: {
    enabled: true,
    auditTrail: true,
    digitalSignatures: true
  }
});

Marketing Content Workflow

const marketingEditor = new ArmorEditor({
  container: '#marketing-editor',
  workflow: {
    stages: [
      { name: 'draft', role: 'copywriter' },
      { name: 'creative_review', role: 'creative_director' },
      { name: 'brand_review', role: 'brand_manager' },
      { name: 'client_approval', role: 'client' },
      { name: 'published', role: 'system' }
    ],
    deadlines: {
      creative_review: 24,
      brand_review: 48,
      client_approval: 72
    }
  }
});

Academic Paper Workflow

const academicEditor = new ArmorEditor({
  container: '#academic-editor',
  workflow: {
    stages: [
      { name: 'draft', role: 'researcher' },
      { name: 'peer_review', role: 'peer_reviewer', parallel: true },
      { name: 'supervisor_review', role: 'supervisor' },
      { name: 'journal_submission', role: 'journal_editor' },
      { name: 'published', role: 'system' }
    ]
  },
  versioning: {
    enabled: true,
    branches: true,
    compareVersions: true
  }
});

Automation

Workflow Automation

// Create automation rule
editor.createAutomationRule({
  name: 'Auto-assign reviewers',
  trigger: 'stage_changed',
  condition: 'stage === "review"',
  actions: [
    {
      type: 'assign_reviewer',
      reviewer: 'department_head'
    },
    {
      type: 'send_notification',
      template: 'review_required'
    },
    {
      type: 'set_deadline',
      hours: 48
    }
  ]
});

Scheduled Operations

// Quarterly report generation
editor.createAutomationRule({
  name: 'Quarterly reports',
  trigger: 'schedule',
  schedule: '0 0 1 */3 *', // First day of quarter
  actions: [
    {
      type: 'create_document',
      template: 'quarterly-report'
    },
    {
      type: 'assign_workflow',
      workflow: 'quarterly-approval'
    }
  ]
});

API Methods

Workflow Control

// Start workflow
const workflowId = editor.startWorkflow('approval-process', 'doc-123');

// Submit for approval
await editor.submitForApproval('review');

// Approve/reject
editor.approveDocument(documentId, options);
editor.rejectDocument(documentId, reason);

// Get status
const status = editor.getWorkflowStatus(documentId);

Version Control

// Version management
const version = editor.createVersion(message, author);
editor.restoreVersion(versionId);
const history = editor.getVersionHistory();

// Branching
editor.createBranch(branchName);
editor.switchBranch(branchName);
editor.mergeBranch(source, target);

Templates

// Template management
editor.createTemplate(template);
editor.useTemplate(templateId, variables);
const templates = editor.getTemplates(category);
editor.deleteTemplate(templateId);

Configuration Options

Workflow Options

OptionTypeDefaultDescription
enabledbooleanfalseEnable workflows
stagesarray[]Workflow stages
approvalsbooleantrueRequire approvals
notificationsobject{}Notification settings
deadlinesbooleanfalseSet deadlines
escalationobject{}Escalation rules

Versioning Options

OptionTypeDefaultDescription
enabledbooleanfalseEnable versioning
gitbooleanfalseGit-like features
branchesbooleanfalseBranch support
autoSavebooleantrueAuto-save versions
maxVersionsnumber50Max versions to keep
compressionbooleantrueCompress versions

Template Options

OptionTypeDefaultDescription
enabledbooleanfalseEnable templates
categoriesarray[]Template categories
customTemplatesbooleantrueAllow custom templates
variablesbooleantrueVariable substitution
sharingbooleanfalseShare templates

External Integrations

JIRA Integration

workflow: {
  integrations: {
    jira: {
      enabled: true,
      createTicket: true,
      updateStatus: true,
      apiKey: process.env.JIRA_API_KEY
    }
  }
}

Slack Integration

workflow: {
  integrations: {
    slack: {
      enabled: true,
      channels: ['#approvals', '#notifications'],
      webhook: process.env.SLACK_WEBHOOK
    }
  }
}

Salesforce Integration

workflow: {
  integrations: {
    salesforce: {
      enabled: true,
      updateRecords: true,
      apiKey: process.env.SALESFORCE_API_KEY
    }
  }
}

Performance

Large Document Workflows

workflow: {
  performance: {
    caching: true,
    batchProcessing: true,
    asyncOperations: true,
    maxConcurrentWorkflows: 100
  }
}

Database Integration

workflow: {
  storage: {
    type: 'database',
    connection: {
      host: 'workflow-db.company.com',
      database: 'workflows'
    }
  }
}

Monitoring

Workflow Analytics

workflow: {
  analytics: {
    enabled: true,
    metrics: ['completion_time', 'bottlenecks', 'approval_rates'],
    dashboard: true,
    alerts: {
      stalled_workflows: 24,
      overdue_approvals: 48
    }
  }
}

// Get analytics
const analytics = editor.getWorkflowAnalytics();
console.log('Avg completion time:', analytics.avgCompletionTime);
console.log('Bottlenecks:', analytics.bottlenecks);

Troubleshooting

Workflow Issues

// Handle workflow errors
editor.on('workflowError', (error) => {
  console.error('Workflow error:', error);
  
  if (error.type === 'APPROVAL_TIMEOUT') {
    // Handle timeout
    editor.escalateApproval(error.documentId);
  }
});

Version Control Issues

// Handle merge conflicts
editor.on('mergeConflict', (conflict) => {
  // Show conflict resolution UI
  showConflictResolution(conflict);
});

Examples