How onlyoffice/sdkjs works
Main Project Components
• API & SDK Core: The central logic that exposes office document APIs. This is represented by common API files (e.g., in cell/api.js, common/apiBase.js, word/api.js, slide/api.js, visio/api.js) that provide the endpoints and definitions for the Office JavaScript APIs.
• Domain-Specific Modules: These are split into several key areas:
– Cell: For spreadsheet functionality. Contains modules for models, formulas, collaborative editing, views, CSS, and utilities.
– Word: For document editing. Contains modules for document editing, paragraph processing, drawing, styles, and more.
– Slide: For presentation editing. Contains drawing components, themes, API builders, and editor specifics.
– Visio: For diagramming/Visio-related functionality.
– PDF: For PDF annotations, drawing, form processing, and viewer interactions.
• Common/Shared Libraries: Components under “common” providing shared functionality such as drawing objects, chart rendering, collaborative editing base features, and utilities (e.g., geometry, text shaping, plugin APIs, etc.).
• Build & Deployment Tools: Files in the “build” directory, Makefile, Gruntfile.js, and related build scripts responsible for packaging, minification, and deployment.
• Testing & Quality Assurance: The “tests” directory contains a variety of test suites across modules (cell, word, slide, visio, pdf) ensuring functionality and performance.
• External Configurations and Vendor Code: Configuration files (under “configs”, .eslintrc.yaml, .codeclimate.yml, etc.) and vendor folder with external libraries, ensuring code quality and integration with third-party tools.
Relationships & Interactions
• The SDK core (API layer) acts as the foundation upon which domain-specific modules like cell, word, slide, and visio are built. These modules leverage shared utilities from the common layer.
• Build tools are used to combine, bundle, and optimize these components, enabling smooth integration into desktop editors and the Document Server.
• Test suites and CI/CD workflows (evident in the .github directories and workflows for CodeQL, dev and common checks) interact with both the build process and source files, enforcing code quality.
• The modules interact with external services and collaborative editing backend layers via defined APIs, as seen in files such as collaborative editing scripts in cell and common.
Important Architectural Patterns & Design Principles
• Modular Architecture: The codebase is clearly divided into independent modules (cell, word, slide, visio, pdf) that each encapsulate specific functionality.
• Layered Structure: There is a separation between the presentation/view layers (UI components like Editor, DrawingControllers), business logic (models, core API functions), and utility/common services (shared libraries, collaborative editing modules).
• Reusability & Plug-Ins: Shared components in the “common” directory suggest an emphasis on code reuse. The plugin files and extensible APIs hint at customizable, extensible design which is essential for SDK development.
• Build & Test Automation: The extensive presence of build scripts and a variety of tests indicates a continuous integration approach and automated deployment workflow.