How 10play/10tap-editor works
Project Type and Purpose
• This is an open-source React Native library (“@10play/tentap-editor”) that wraps a rich-text editor powered by Tiptap/ProseMirror and exposes native toolbar/keyboard support on Android and iOS.
• It includes:
• Native code (Android + iOS) for view managers and custom keyboards.
• JavaScript/TypeScript wrapper exposing a RichText component, Toolbar, hooks, and bridges for editor state.
• Example/demo apps demonstrating usage.
• A Docusaurus-based website hosting docs and examples.
• Build tooling (babel, TypeScript, yarn workspaces, GitHub Actions).
File Structure
• Top-level folders:
• android/ & ios/ → Native modules (view managers, packages).
• src/ → Core JS/TS library (RichText, Toolbar, bridges, hooks, utilities).
• example/ & example76/ → Demo React Native apps (Android + iOS projects) consuming the package.
• website/ → Documentation site (Docusaurus).
• scripts/ → Build-time helper (e.g., buildEditor.js).
• Configuration: babel.config.js, tsconfig.json, vite.config.ts, turbo.json, GitHub workflows.
• Patterns:
• React Native module pattern (JS ↔ Native via Bridge).
• ProseMirror plugin pattern (“bridges” folder).
• Web‐editor submodule (simpleWebEditor, webEditorUtils) bundled into a WebView.
Key README Insights
• Core features and tech stack: React Native, React + TypeScript + Tiptap/ProseMirror + react-native-webview.
• Native toolbar & custom keyboards (Android & iOS view managers).
• Supports both Classic and New RN Architecture.
• Docs and examples hosted separately via website/.
Main Components & Their Interactions
a. React Native App (Host)
• Imports @10play/tentap-editor.
• Renders <RichText> and <Toolbar> components.
b. JS Core Library (src/)
• RichText.tsx, Toolbar.tsx: UI wrappers.
• Hooks: useEditorBridge(), useEditorContent(), useBridgeState().
• Bridges folder: ProseMirror node/mark extensions (bold, link, lists, etc.).
• Utilities & Themes.
c. Native Module Layer
• Android: TenTapPackage.kt, TenTapViewManager.kt, native spec files.
• iOS: RCTBridgeProvider.m, TenTapViewManager.mm, TenTapViewImpl.mm, helper utils.
• Exposes a Native UI component to JS (via ReactNativeViewManager).
d. WebView Editor Engine
• simpleWebEditor + webEditorUtils: Bundles a React + Tiptap editor UI in a webpage.
• Communicates with JS Core via postMessage/AsyncMessages.ts.
e. Messaging Bridge
• AsyncMessages.ts, useEditorBridge.tsx: bidirectional message dispatch between JS ↔ WebView ↔ Native.
f. Demo Applications
• example/, example76/: full RN apps integrating the library, showing Classic vs. New architecture.
g. Documentation Site
• website/: Docusaurus app serving docs (setup, API, examples).
h. Build & CI/CD
• scripts/buildEditor.js: compiles web editor bundle.
• GitHub Actions / workflows: CI tests, CD to npm & documentation site.
Architectural Patterns & Principles
• Layered architecture:
1. App Layer (React Native host)
2. Presentation Layer (RichText UI + Toolbar UI)
3. Domain Layer (Editor logic, ProseMirror plugins, state hooks)
4. Infrastructure Layer (Native view manager + WebView engine + messaging)
• Bridge Pattern: JS ↔ Native ↔ WebView.
• Plugin Pattern: ProseMirror extensions in src/bridges.
• Module separation: core library vs. examples vs. docs.
• Monorepo workspace (yarn, turbo.json).
Final Checklist
• Each component clearly labeled.
• Annotations of major frameworks and file-tree pointers (e.g., “android/ → TenTapPackage.kt”).
• A title and version note (e.g., “TenTap Editor vX – System Architecture”).