Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: add api/modules docs #200

Merged
merged 2 commits into from
Jan 11, 2025
Merged

docs: add api/modules docs #200

merged 2 commits into from
Jan 11, 2025

Conversation

kagol
Copy link
Member

@kagol kagol commented Jan 11, 2025

PR

主要增加以下文档:

  • API 参考:配置项、Fluent Editor 实例、Fluent Editor 类
  • 模块生态:工具栏提示、标题列表

效果如下:

image

PR Checklist

Please check if your PR fulfills the following requirements:

  • The commit message follows our Commit Message Guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

  • Bugfix
  • Feature
  • Code style update (formatting, local variables)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • CI related changes
  • Documentation content changes
  • Other... Please describe:

What is the current behavior?

Issue Number: N/A

What is the new behavior?

Does this PR introduce a breaking change?

  • Yes
  • No

Other information

Summary by CodeRabbit

  • Documentation

    • Added comprehensive documentation for Fluent Editor
    • Introduced new sections for:
      • API references
      • Class methods
      • Instance methods
      • Configuration options
    • Added documentation for modules:
      • Header list
      • Toolbar tooltips
  • New Features

    • Expanded documentation for Fluent Editor's capabilities
    • Provided detailed usage instructions and code examples

@kagol kagol added the documentation Improvements or additions to documentation label Jan 11, 2025
Copy link

coderabbitai bot commented Jan 11, 2025

Warning

Rate limit exceeded

@kagol has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 18 minutes and 46 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 8ebe5eb and c9406f1.

📒 Files selected for processing (6)
  • packages/docs/fluent-editor/.vitepress/sidebar.ts (1 hunks)
  • packages/docs/fluent-editor/docs/api/fluent-editor-class.md (1 hunks)
  • packages/docs/fluent-editor/docs/api/fluent-editor-instance.md (1 hunks)
  • packages/docs/fluent-editor/docs/api/options.md (1 hunks)
  • packages/docs/fluent-editor/docs/modules/header-list.md (1 hunks)
  • packages/docs/fluent-editor/docs/modules/toolbar-tip.md (1 hunks)

Walkthrough

This pull request focuses on enhancing the documentation for the Fluent Editor package. The changes involve updating the sidebar configuration, adding comprehensive documentation for various modules and APIs, and reorganizing the documentation structure. New sections have been introduced for API references, module ecosystems, and detailed explanations of features like toolbar tips, header lists, internationalization, and screenshot functionality.

Changes

File Change Summary
.vitepress/sidebar.ts Updated sidebar links with new /docs/demo/ prefix, added new sections "API 参考" and "模块生态"
docs/api/fluent-editor-class.md New documentation for FluentEditor class, detailing import() and register() static methods
docs/api/fluent-editor-instance.md Added instance API documentation with methods like getModule(), getContents(), and setContents()
docs/api/options.md Introduced FluentEditorOptions interface with detailed configuration options
docs/demo/* Updated documentation for format painter, header list, i18n, screenshot, and toolbar tip
docs/modules/header-list.md New documentation for quill-header-list module with configuration details
docs/modules/toolbar-tip.md New documentation for quill-toolbar-tip module with usage and configuration guide

Possibly related PRs

Poem

🐰 Docs dancing with grace,
Sidebar links find their place
Modules bloom, APIs shine bright
Fluent Editor's knowledge takes flight!
Rabbit's wisdom, clear and neat 📖✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Walkthrough

This pull request introduces new documentation for the API and modules of the Fluent Editor. It updates the sidebar links to point to new demo paths and adds detailed API references for Fluent Editor classes, instances, and configuration options.

Changes

File Summary
packages/docs/fluent-editor/.vitepress/sidebar.ts Updated sidebar links to new demo paths and added sections for API references and module ecosystem.
packages/docs/fluent-editor/docs/api/fluent-editor-class.md Added documentation for Fluent Editor class API, including import and register methods.
packages/docs/fluent-editor/docs/api/fluent-editor-instance.md Added documentation for Fluent Editor instance API, detailing methods like getModule, getContents, and setContents.
packages/docs/fluent-editor/docs/api/options.md Added documentation for Fluent Editor configuration options, extending Quill options.
packages/docs/fluent-editor/docs/demo/* Added new demo documentation files for various features like format painter, header list, i18n, screenshot, and toolbar tip.
packages/docs/fluent-editor/docs/modules/* Added new module documentation files for header list and toolbar tip.

],
},
{
text: '模块生态',

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ensure that the new links added to the sidebar are correctly pointing to the intended documentation paths. Incorrect links can lead to navigation issues.

@kagol kagol force-pushed the kagol/add-api-docs branch from 0c4f604 to 8ebe5eb Compare January 11, 2025 08:50
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Inline review comments failed to post. This is likely due to GitHub's limits when posting large numbers of comments.

Actionable comments posted: 7

🧹 Nitpick comments (8)
packages/docs/fluent-editor/.vitepress/sidebar.ts (1)

8-27: LGTM! Well-organized documentation structure.

The documentation sections are logically organized, with a clear progression from basic usage to advanced features. The consistent use of the /docs/demo/ prefix improves navigation predictability.

Consider adding English translations for the section titles to improve accessibility for non-Chinese users. For example:

-      text: '使用示例',
+      text: '使用示例 (Usage Examples)',
packages/docs/fluent-editor/docs/api/options.md (2)

46-56: Improve type definitions and documentation for upload options.

The upload configuration could benefit from more specific types and better documentation:

  uploadOption?: {
-    imageUpload?: ({ file, callback, editor }) => void
+    imageUpload?: (params: {
+      file: File;
+      callback: (url: string) => void;
+      editor: FluentEditor;
+    }) => void;
-    imageAccept?: Array<string>[] | string
+    imageAccept?: string[] | string;
-    fileAccept?: Array<string>[] | string
+    fileAccept?: string[] | string;
     fileUpload: ({ file, callback, editor }) => void
     isVideoPlay?: boolean
-    maxSize?: number
+    maxSize?: number; // Maximum file size in bytes
     success?: (file: File) => void
     fail?: (file: File) => void
     multiple?: boolean
  }

62-65: Document i18n configuration options.

Add more detailed descriptions for the internationalization options:

  i18n?: {
-    lang?: string
+    lang?: string; // Language code (e.g., 'en-US', 'zh-CN')
-    langText?: Record<string, string>
+    langText?: Record<string, string>; // Custom translation overrides
  }
packages/docs/fluent-editor/docs/modules/toolbar-tip.md (2)

15-43: Consider using TypeScript consistently in code examples

The code example uses TypeScript for imports but lacks type annotations for variables. Consider adding type annotations for better documentation:

-const QuillToolbarTipOption = {
+const QuillToolbarTipOption: Record<string, any> = {
   tipTextMap: defaultToolbarTip["en-US"],
 };

-const editor = new FluentEditor("#editor", {
+const editor: FluentEditor = new FluentEditor("#editor", {

120-124: Enhance configuration table with examples

Consider adding an "Example" column to the configuration table to provide concrete examples for each option.

packages/docs/fluent-editor/docs/demo/screenshot.md (2)

7-12: Add security and performance considerations

Consider adding sections about:

  1. Security implications of using screenshots (e.g., data privacy)
  2. Performance impact of html2canvas
  3. Browser compatibility matrix

21-21: Add error handling guidance

The documentation should include guidance on handling potential errors during screenshot creation and upload.

packages/docs/fluent-editor/docs/modules/header-list.md (1)

38-48: Add accessibility considerations

Consider adding documentation about:

  1. Keyboard navigation in the header list
  2. Screen reader compatibility
  3. ARIA attributes support
🛑 Comments failed to post (7)
packages/docs/fluent-editor/docs/api/fluent-editor-instance.md (3)

45-47: ⚠️ Potential issue

Fix TypeScript syntax error and improve return type documentation.

Add a semicolon and document the Delta type:

-getContents(index: number = 0, length: number = remaining): Delta
+getContents(index: number = 0, length: number = remaining): Delta;

Consider importing and documenting the Delta type:

import { Delta } from 'quill-delta';
🧰 Tools
🪛 GitHub Actions: autofix.ci

[error] 46-46: Parsing error: ',' expected


22-24: ⚠️ Potential issue

Fix TypeScript syntax error.

Add a semicolon to the type definition to resolve the parsing error:

-getModule(name: string): any
+getModule(name: string): any;
🧰 Tools
🪛 GitHub Actions: autofix.ci

[error] 23-23: Parsing error: ',' expected


67-69: ⚠️ Potential issue

Fix TypeScript syntax error and clarify source parameter.

Add a semicolon and document the source parameter options:

-setContents(delta: Delta, source: string = 'api'): Delta
+setContents(delta: Delta, source: 'user' | 'api' | 'silent' = 'api'): Delta;
🧰 Tools
🪛 GitHub Actions: autofix.ci

[error] 68-68: Parsing error: ',' expected

packages/docs/fluent-editor/docs/api/fluent-editor-class.md (2)

54-57: ⚠️ Potential issue

Fix TypeScript syntax errors in type definitions.

Add semicolons and improve type documentation:

-Quill.register(format: Attributor | BlotDefinintion, supressWarning: boolean = false)
-Quill.register(path: string, def: any, supressWarning: boolean = false)
-Quill.register(defs: { [path: string]: any }, supressWarning: boolean = false)
+Quill.register(format: Attributor | BlotDefinition, suppressWarning: boolean = false);
+Quill.register(path: string, def: any, suppressWarning: boolean = false);
+Quill.register(defs: { [path: string]: any }, suppressWarning: boolean = false);

Also note the typo corrections:

  • BlotDefinintionBlotDefinition
  • supressWarningsuppressWarning
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Quill.register(format: Attributor | BlotDefinition, suppressWarning: boolean = false);
Quill.register(path: string, def: any, suppressWarning: boolean = false);
Quill.register(defs: { [path: string]: any }, suppressWarning: boolean = false);
🧰 Tools
🪛 GitHub Actions: autofix.ci

[error] 54-54: Parsing error: ',' expected


38-40: ⚠️ Potential issue

Fix duplicate variable declaration and incorrect import.

There's a duplicate Mention variable declaration and an incorrect theme import:

const Toolbar = FluentEditor.import('modules/toolbar')
const Mention = FluentEditor.import('modules/mention')
-const Mention = FluentEditor.import('themes/snow')
+const Snow = FluentEditor.import('themes/snow')

Committable suggestion skipped: line range outside the PR's diff.

packages/docs/fluent-editor/docs/modules/header-list.md (2)

20-34: ⚠️ Potential issue

Address linting issues and add error handling

  1. The linting error "Do not use 'new' for side effects" should be addressed.
  2. Add error handling documentation for common scenarios.
-new FluentEditor('#editor', {
+const editor = new FluentEditor('#editor', {
   // ... configuration ...
 });

Also applies to: 54-70

🧰 Tools
🪛 GitHub Check: lint

[failure] 20-20:
Do not use 'new' for side effects

🪛 GitHub Actions: autofix.ci

[error] 20-20: Do not use 'new' for side effects (no-new)


62-62: 🛠️ Refactor suggestion

Add null check for querySelector

The current code might throw if the selector doesn't match any elements. Consider adding a more robust null check:

-const navOffset = document.querySelector('.fixed')?.getBoundingClientRect().height || 0
+const fixedElement = document.querySelector('.fixed')
+const navOffset = fixedElement ? fixedElement.getBoundingClientRect().height : 0
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

        const fixedElement = document.querySelector('.fixed')
        const navOffset = fixedElement ? fixedElement.getBoundingClientRect().height : 0

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🧹 Nitpick comments (1)
packages/docs/fluent-editor/docs/modules/header-list.md (1)

38-47: Improve table formatting for better readability

The table's column alignment and escape characters could be improved.

Apply these changes to the table:

-| 名称            | 类型                     | 描述                                                                                                                            | 默认值     | 是否必选 |
-| --------------- | ------------------------ | -------------------------------------------------------------------------------------------------------------------------------------- | ----------- | -------- |
+| 名称            | 类型                    | 描述                                                                | 默认值      | 是否必选  |
+| --------------- | ----------------------- | ------------------------------------------------------------------ | ----------- | --------- |
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0c4f604 and 8ebe5eb.

📒 Files selected for processing (6)
  • packages/docs/fluent-editor/.vitepress/sidebar.ts (1 hunks)
  • packages/docs/fluent-editor/docs/api/fluent-editor-class.md (1 hunks)
  • packages/docs/fluent-editor/docs/api/fluent-editor-instance.md (1 hunks)
  • packages/docs/fluent-editor/docs/api/options.md (1 hunks)
  • packages/docs/fluent-editor/docs/modules/header-list.md (1 hunks)
  • packages/docs/fluent-editor/docs/modules/toolbar-tip.md (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/docs/fluent-editor/docs/api/options.md
🧰 Additional context used
🪛 LanguageTool
packages/docs/fluent-editor/docs/api/fluent-editor-class.md

[uncategorized] ~61-~61: 您的意思是“"不"全”?
Context: ...false) ``` - 详细信息 注册格式只需要直接传入格式类,内部会自动补全 path。 注册模块和主题需要手动传入 path 和对应的模块类、主题类。...

(BU)

🪛 GitHub Actions: autofix.ci
packages/docs/fluent-editor/docs/api/fluent-editor-class.md

[error] 22-22: Parsing error: ';' expected


[error] 54-54: Parsing error: ',' expected

packages/docs/fluent-editor/docs/api/fluent-editor-instance.md

[error] 23-23: Parsing error: ',' expected


[error] 46-46: Parsing error: ',' expected


[error] 68-68: Parsing error: ',' expected

packages/docs/fluent-editor/docs/modules/header-list.md

[error] 20-20: Do not use 'new' for side effects (no-new)

🪛 GitHub Check: lint
packages/docs/fluent-editor/docs/modules/header-list.md

[failure] 20-20:
Do not use 'new' for side effects


[failure] 54-54:
Do not use 'new' for side effects

⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: test
🔇 Additional comments (2)
packages/docs/fluent-editor/.vitepress/sidebar.ts (1)

33-35: Verify the documentation paths

Ensure that all the new API reference paths (/docs/api/options, /docs/api/fluent-editor-instance, /docs/api/fluent-editor-class) exist and are accessible.

Run this script to verify the paths:

#!/bin/bash
# Description: Verify that all documentation files exist
fd -e md -p "docs/api/(options|fluent-editor-instance|fluent-editor-class).md$"
packages/docs/fluent-editor/docs/modules/toolbar-tip.md (1)

1-201: Documentation looks comprehensive and well-structured!

The documentation provides clear installation instructions, usage examples, and detailed configuration options. The code examples are accurate and helpful.

- 类型

```typescript
getModule(name: string): any
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix TypeScript syntax errors in type definitions

The TypeScript type definitions are missing commas at the end of parameter lists.

Apply these fixes:

-getModule(name: string): any
+getModule(name: string,): any

-getContents(index: number = 0, length: number = remaining): Delta
+getContents(index: number = 0, length: number = remaining,): Delta

-setContents(delta: Delta, source: string = 'api'): Delta
+setContents(delta: Delta, source: string = 'api',): Delta

Also applies to: 46-46, 68-68

🧰 Tools
🪛 GitHub Actions: autofix.ci

[error] 23-23: Parsing error: ',' expected

Comment on lines +32 to +35
```typescript
const toolbar = quill.getModule('toolbar')
const i18n = quill.getModule('i18n')
```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Incorrect variable name in code example

The example uses quill instead of editor which is inconsistent with the instance name shown in the initialization example.

Apply this fix:

-const toolbar = quill.getModule('toolbar')
-const i18n = quill.getModule('i18n')
+const toolbar = editor.getModule('toolbar')
+const i18n = editor.getModule('i18n')

Comment on lines +38 to +41
const Mention = FluentEditor.import('modules/mention')
const Mention = FluentEditor.import('themes/snow')
const Link = FluentEditor.import('formats/link')
```
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix duplicate variable declaration

The variable Mention is declared twice, with the second declaration actually being for the Snow theme.

Apply this fix:

const Toolbar = FluentEditor.import('modules/toolbar')
const Mention = FluentEditor.import('modules/mention')
-const Mention = FluentEditor.import('themes/snow')
+const Snow = FluentEditor.import('themes/snow')
const Link = FluentEditor.import('formats/link')
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const Mention = FluentEditor.import('modules/mention')
const Mention = FluentEditor.import('themes/snow')
const Link = FluentEditor.import('formats/link')
```
const Mention = FluentEditor.import('modules/mention')
const Snow = FluentEditor.import('themes/snow')
const Link = FluentEditor.import('formats/link')

@kagol kagol force-pushed the kagol/add-api-docs branch from 8ebe5eb to c9406f1 Compare January 11, 2025 09:03
@kagol kagol merged commit e9b8d04 into main Jan 11, 2025
0 of 2 checks passed
@coderabbitai coderabbitai bot mentioned this pull request Jan 15, 2025
13 tasks
kagol added a commit that referenced this pull request Jan 15, 2025
* docs: add api docs

* docs: add modules docs
@kagol kagol added the v3 label Jan 16, 2025
@kagol kagol deleted the kagol/add-api-docs branch January 17, 2025 03:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation v3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant