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

chore(edgeless): move templates to AFFiNE side #6156

Merged
merged 6 commits into from
Jan 31, 2024

Conversation

doouding
Copy link
Member

@doouding doouding commented Jan 30, 2024

  • Remove all built-in templates besides stickers template
  • Modify builtIn template to allow extension by user side

Extend template

import {
    type TemplateManager,
    type Template,
    EdgelessTemplatePanel
} from '@blocksuite/blocks';

// Implement your own template manager
const cutsomManager = {
    list(category: string): Promise<Template[]>  {
      // list the templates of given categories
    }
    categories(): Promise<string[]> {
      // list all the categories
    }
    search(keyword: string, category?: string): Promise<Template[]> {
      // search templates by keyword in the given category
    }
} satisfies TemplateManager;

// You can extend templates to retain built-in templates
EdgelessTemplatePanel.templates.extend(cutsomManager);

// Or you can just replace the built-in templates entirely
EdgelessTemplatePanel.templates = cutsomManager;

Copy link

vercel bot commented Jan 30, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
blocksuite ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jan 31, 2024 2:27am
1 Ignored Deployment
Name Status Preview Comments Updated (UTC)
blocksuite-docs ⬜️ Ignored (Inspect) Visit Preview Jan 31, 2024 2:27am

Copy link
Member

@doodlewind doodlewind left a comment

Choose a reason for hiding this comment

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

Can't wait to make this happen! Could you add a example about how to define custom template for third party developers in PR description? Thanks!

@doodlewind doodlewind merged commit 637fede into master Jan 31, 2024
22 checks passed
@doodlewind doodlewind deleted the chore/remove-templates branch January 31, 2024 02:38
Brooooooklyn pushed a commit to toeverything/AFFiNE that referenced this pull request Feb 21, 2024
Related to toeverything/blocksuite#6156

### Change
Move the edgeless templates to AFFiNE. All templates are stored as zip files. Run `node build-edgeless.mjs` in `@affine/templates` to generate JSON-format templates and importing script. The template will be generated automatically during building and dev (`yarn dev`).
Brooooooklyn pushed a commit to toeverything/AFFiNE that referenced this pull request Feb 21, 2024
Related to toeverything/blocksuite#6156

### Change
Move the edgeless templates to AFFiNE. All templates are stored as zip files. Run `node build-edgeless.mjs` in `@affine/templates` to generate JSON-format templates and importing script. The template will be generated automatically during building and dev (`yarn dev`).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants