mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
feat(editor): gfx template package (#11480)
This commit is contained in:
@@ -39,6 +39,7 @@
|
|||||||
"@blocksuite/affine-gfx-mindmap": "workspace:*",
|
"@blocksuite/affine-gfx-mindmap": "workspace:*",
|
||||||
"@blocksuite/affine-gfx-note": "workspace:*",
|
"@blocksuite/affine-gfx-note": "workspace:*",
|
||||||
"@blocksuite/affine-gfx-shape": "workspace:*",
|
"@blocksuite/affine-gfx-shape": "workspace:*",
|
||||||
|
"@blocksuite/affine-gfx-template": "workspace:*",
|
||||||
"@blocksuite/affine-gfx-text": "workspace:*",
|
"@blocksuite/affine-gfx-text": "workspace:*",
|
||||||
"@blocksuite/affine-gfx-turbo-renderer": "workspace:*",
|
"@blocksuite/affine-gfx-turbo-renderer": "workspace:*",
|
||||||
"@blocksuite/affine-inline-footnote": "workspace:*",
|
"@blocksuite/affine-inline-footnote": "workspace:*",
|
||||||
@@ -128,6 +129,7 @@
|
|||||||
"./gfx/mindmap": "./src/gfx/mindmap.ts",
|
"./gfx/mindmap": "./src/gfx/mindmap.ts",
|
||||||
"./gfx/connector": "./src/gfx/connector.ts",
|
"./gfx/connector": "./src/gfx/connector.ts",
|
||||||
"./gfx/group": "./src/gfx/group.ts",
|
"./gfx/group": "./src/gfx/group.ts",
|
||||||
|
"./gfx/template": "./src/gfx/template.ts",
|
||||||
"./gfx/turbo-renderer": "./src/gfx/turbo-renderer.ts",
|
"./gfx/turbo-renderer": "./src/gfx/turbo-renderer.ts",
|
||||||
"./components/block-selection": "./src/components/block-selection.ts",
|
"./components/block-selection": "./src/components/block-selection.ts",
|
||||||
"./components/block-zero-width": "./src/components/block-zero-width.ts",
|
"./components/block-zero-width": "./src/components/block-zero-width.ts",
|
||||||
|
|||||||
1
blocksuite/affine/all/src/gfx/template.ts
Normal file
1
blocksuite/affine/all/src/gfx/template.ts
Normal file
@@ -0,0 +1 @@
|
|||||||
|
export * from '@blocksuite/affine-gfx-template';
|
||||||
@@ -36,6 +36,7 @@
|
|||||||
{ "path": "../gfx/mindmap" },
|
{ "path": "../gfx/mindmap" },
|
||||||
{ "path": "../gfx/note" },
|
{ "path": "../gfx/note" },
|
||||||
{ "path": "../gfx/shape" },
|
{ "path": "../gfx/shape" },
|
||||||
|
{ "path": "../gfx/template" },
|
||||||
{ "path": "../gfx/text" },
|
{ "path": "../gfx/text" },
|
||||||
{ "path": "../gfx/turbo-renderer" },
|
{ "path": "../gfx/turbo-renderer" },
|
||||||
{ "path": "../inlines/footnote" },
|
{ "path": "../inlines/footnote" },
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
"@blocksuite/affine-gfx-mindmap": "workspace:*",
|
"@blocksuite/affine-gfx-mindmap": "workspace:*",
|
||||||
"@blocksuite/affine-gfx-note": "workspace:*",
|
"@blocksuite/affine-gfx-note": "workspace:*",
|
||||||
"@blocksuite/affine-gfx-shape": "workspace:*",
|
"@blocksuite/affine-gfx-shape": "workspace:*",
|
||||||
|
"@blocksuite/affine-gfx-template": "workspace:*",
|
||||||
"@blocksuite/affine-gfx-text": "workspace:*",
|
"@blocksuite/affine-gfx-text": "workspace:*",
|
||||||
"@blocksuite/affine-inline-latex": "workspace:*",
|
"@blocksuite/affine-inline-latex": "workspace:*",
|
||||||
"@blocksuite/affine-inline-link": "workspace:*",
|
"@blocksuite/affine-inline-link": "workspace:*",
|
||||||
|
|||||||
@@ -4,10 +4,8 @@ import { connectorQuickTool } from '@blocksuite/affine-gfx-connector';
|
|||||||
import { mindMapSeniorTool } from '@blocksuite/affine-gfx-mindmap';
|
import { mindMapSeniorTool } from '@blocksuite/affine-gfx-mindmap';
|
||||||
import { noteSeniorTool } from '@blocksuite/affine-gfx-note';
|
import { noteSeniorTool } from '@blocksuite/affine-gfx-note';
|
||||||
import { shapeSeniorTool } from '@blocksuite/affine-gfx-shape';
|
import { shapeSeniorTool } from '@blocksuite/affine-gfx-shape';
|
||||||
import {
|
import { templateSeniorTool } from '@blocksuite/affine-gfx-template';
|
||||||
QuickToolExtension,
|
import { QuickToolExtension } from '@blocksuite/affine-widget-edgeless-toolbar';
|
||||||
SeniorToolExtension,
|
|
||||||
} from '@blocksuite/affine-widget-edgeless-toolbar';
|
|
||||||
import { html } from 'lit';
|
import { html } from 'lit';
|
||||||
|
|
||||||
import { buildLinkDenseMenu } from './link/link-dense-menu.js';
|
import { buildLinkDenseMenu } from './link/link-dense-menu.js';
|
||||||
@@ -30,14 +28,6 @@ const linkQuickTool = QuickToolExtension('link', ({ block, gfx }) => {
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
const templateSeniorTool = SeniorToolExtension('template', ({ block }) => {
|
|
||||||
return {
|
|
||||||
name: 'Template',
|
|
||||||
content: html`<edgeless-template-button .edgeless=${block}>
|
|
||||||
</edgeless-template-button>`,
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
export const quickTools = [
|
export const quickTools = [
|
||||||
defaultQuickTool,
|
defaultQuickTool,
|
||||||
frameQuickTool,
|
frameQuickTool,
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import {
|
|||||||
type SurfaceBlockModel,
|
type SurfaceBlockModel,
|
||||||
type SurfaceContext,
|
type SurfaceContext,
|
||||||
} from '@blocksuite/affine-block-surface';
|
} from '@blocksuite/affine-block-surface';
|
||||||
|
import { TemplateJob } from '@blocksuite/affine-gfx-template';
|
||||||
import {
|
import {
|
||||||
type ConnectorElementModel,
|
type ConnectorElementModel,
|
||||||
RootBlockSchema,
|
RootBlockSchema,
|
||||||
@@ -31,7 +32,6 @@ import { effect } from '@preact/signals-core';
|
|||||||
import clamp from 'lodash-es/clamp';
|
import clamp from 'lodash-es/clamp';
|
||||||
|
|
||||||
import { RootService } from '../root-service.js';
|
import { RootService } from '../root-service.js';
|
||||||
import { TemplateJob } from './services/template.js';
|
|
||||||
import { getCursorMode } from './utils/query.js';
|
import { getCursorMode } from './utils/query.js';
|
||||||
|
|
||||||
export class EdgelessRootService extends RootService implements SurfaceContext {
|
export class EdgelessRootService extends RootService implements SurfaceContext {
|
||||||
|
|||||||
@@ -1,12 +1,9 @@
|
|||||||
export * from './clipboard/clipboard';
|
export * from './clipboard/clipboard';
|
||||||
export * from './clipboard/command';
|
export * from './clipboard/command';
|
||||||
export { EdgelessTemplatePanel } from './components/toolbar/template/template-panel.js';
|
|
||||||
export * from './components/toolbar/template/template-type.js';
|
|
||||||
export * from './edgeless-root-block.js';
|
export * from './edgeless-root-block.js';
|
||||||
export { EdgelessRootPreviewBlockComponent } from './edgeless-root-preview-block.js';
|
export { EdgelessRootPreviewBlockComponent } from './edgeless-root-preview-block.js';
|
||||||
export { EdgelessRootService } from './edgeless-root-service.js';
|
export { EdgelessRootService } from './edgeless-root-service.js';
|
||||||
export * from './gfx-tool';
|
export * from './gfx-tool';
|
||||||
export * from './services/template.js';
|
|
||||||
export * from './utils/clipboard-utils.js';
|
export * from './utils/clipboard-utils.js';
|
||||||
export { sortEdgelessElements } from './utils/clone-utils.js';
|
export { sortEdgelessElements } from './utils/clone-utils.js';
|
||||||
export { isCanvasElement } from './utils/query.js';
|
export { isCanvasElement } from './utils/query.js';
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { effects as gfxGroupEffects } from '@blocksuite/affine-gfx-group/effects
|
|||||||
import { effects as gfxMindmapEffects } from '@blocksuite/affine-gfx-mindmap/effects';
|
import { effects as gfxMindmapEffects } from '@blocksuite/affine-gfx-mindmap/effects';
|
||||||
import { effects as gfxNoteEffects } from '@blocksuite/affine-gfx-note/effects';
|
import { effects as gfxNoteEffects } from '@blocksuite/affine-gfx-note/effects';
|
||||||
import { effects as gfxShapeEffects } from '@blocksuite/affine-gfx-shape/effects';
|
import { effects as gfxShapeEffects } from '@blocksuite/affine-gfx-shape/effects';
|
||||||
|
import { effects as gfxTemplateEffects } from '@blocksuite/affine-gfx-template/effects';
|
||||||
import { effects as gfxCanvasTextEffects } from '@blocksuite/affine-gfx-text/effects';
|
import { effects as gfxCanvasTextEffects } from '@blocksuite/affine-gfx-text/effects';
|
||||||
import { effects as widgetEdgelessToolbarEffects } from '@blocksuite/affine-widget-edgeless-toolbar/effects';
|
import { effects as widgetEdgelessToolbarEffects } from '@blocksuite/affine-widget-edgeless-toolbar/effects';
|
||||||
|
|
||||||
@@ -26,10 +27,6 @@ import { ToolbarArrowUpIcon } from './edgeless/components/toolbar/common/toolbar
|
|||||||
import { EdgelessDefaultToolButton } from './edgeless/components/toolbar/default/default-tool-button.js';
|
import { EdgelessDefaultToolButton } from './edgeless/components/toolbar/default/default-tool-button.js';
|
||||||
import { EdgelessLassoToolButton } from './edgeless/components/toolbar/lasso/lasso-tool-button.js';
|
import { EdgelessLassoToolButton } from './edgeless/components/toolbar/lasso/lasso-tool-button.js';
|
||||||
import { EdgelessLinkToolButton } from './edgeless/components/toolbar/link/link-tool-button.js';
|
import { EdgelessLinkToolButton } from './edgeless/components/toolbar/link/link-tool-button.js';
|
||||||
import { OverlayScrollbar } from './edgeless/components/toolbar/template/overlay-scrollbar.js';
|
|
||||||
import { AffineTemplateLoading } from './edgeless/components/toolbar/template/template-loading.js';
|
|
||||||
import { EdgelessTemplatePanel } from './edgeless/components/toolbar/template/template-panel.js';
|
|
||||||
import { EdgelessTemplateButton } from './edgeless/components/toolbar/template/template-tool-button.js';
|
|
||||||
import {
|
import {
|
||||||
AffineModalWidget,
|
AffineModalWidget,
|
||||||
EdgelessRootBlockComponent,
|
EdgelessRootBlockComponent,
|
||||||
@@ -97,6 +94,7 @@ function registerGfxEffects() {
|
|||||||
gfxMindmapEffects();
|
gfxMindmapEffects();
|
||||||
gfxGroupEffects();
|
gfxGroupEffects();
|
||||||
gfxBrushEffects();
|
gfxBrushEffects();
|
||||||
|
gfxTemplateEffects();
|
||||||
}
|
}
|
||||||
|
|
||||||
function registerWidgets() {
|
function registerWidgets() {
|
||||||
@@ -124,7 +122,6 @@ function registerEdgelessToolbarComponents() {
|
|||||||
);
|
);
|
||||||
customElements.define('edgeless-link-tool-button', EdgelessLinkToolButton);
|
customElements.define('edgeless-link-tool-button', EdgelessLinkToolButton);
|
||||||
customElements.define('edgeless-lasso-tool-button', EdgelessLassoToolButton);
|
customElements.define('edgeless-lasso-tool-button', EdgelessLassoToolButton);
|
||||||
customElements.define('edgeless-template-button', EdgelessTemplateButton);
|
|
||||||
|
|
||||||
// Menus
|
// Menus
|
||||||
customElements.define('edgeless-slide-menu', EdgelessSlideMenu);
|
customElements.define('edgeless-slide-menu', EdgelessSlideMenu);
|
||||||
@@ -139,12 +136,10 @@ function registerMiscComponents() {
|
|||||||
|
|
||||||
// Loading and preview components
|
// Loading and preview components
|
||||||
customElements.define('loader-element', Loader);
|
customElements.define('loader-element', Loader);
|
||||||
customElements.define('affine-template-loading', AffineTemplateLoading);
|
|
||||||
|
|
||||||
// Toolbar and UI components
|
// Toolbar and UI components
|
||||||
customElements.define('edgeless-zoom-toolbar', EdgelessZoomToolbar);
|
customElements.define('edgeless-zoom-toolbar', EdgelessZoomToolbar);
|
||||||
customElements.define('zoom-bar-toggle-button', ZoomBarToggleButton);
|
customElements.define('zoom-bar-toggle-button', ZoomBarToggleButton);
|
||||||
customElements.define('overlay-scrollbar', OverlayScrollbar);
|
|
||||||
|
|
||||||
// Auto-complete components
|
// Auto-complete components
|
||||||
customElements.define(
|
customElements.define(
|
||||||
@@ -155,7 +150,6 @@ function registerMiscComponents() {
|
|||||||
|
|
||||||
// Note and template components
|
// Note and template components
|
||||||
customElements.define(NOTE_SLICER_WIDGET, NoteSlicer);
|
customElements.define(NOTE_SLICER_WIDGET, NoteSlicer);
|
||||||
customElements.define('edgeless-templates-panel', EdgelessTemplatePanel);
|
|
||||||
|
|
||||||
// Navigation components
|
// Navigation components
|
||||||
customElements.define(
|
customElements.define(
|
||||||
@@ -189,9 +183,6 @@ declare global {
|
|||||||
'edgeless-default-tool-button': EdgelessDefaultToolButton;
|
'edgeless-default-tool-button': EdgelessDefaultToolButton;
|
||||||
'edgeless-lasso-tool-button': EdgelessLassoToolButton;
|
'edgeless-lasso-tool-button': EdgelessLassoToolButton;
|
||||||
'edgeless-link-tool-button': EdgelessLinkToolButton;
|
'edgeless-link-tool-button': EdgelessLinkToolButton;
|
||||||
'overlay-scrollbar': OverlayScrollbar;
|
|
||||||
'affine-template-loading': AffineTemplateLoading;
|
|
||||||
'edgeless-templates-panel': EdgelessTemplatePanel;
|
|
||||||
'affine-page-root': PageRootBlockComponent;
|
'affine-page-root': PageRootBlockComponent;
|
||||||
'zoom-bar-toggle-button': ZoomBarToggleButton;
|
'zoom-bar-toggle-button': ZoomBarToggleButton;
|
||||||
'edgeless-zoom-toolbar': EdgelessZoomToolbar;
|
'edgeless-zoom-toolbar': EdgelessZoomToolbar;
|
||||||
|
|||||||
@@ -4,8 +4,6 @@ export * from './common-specs/index.js';
|
|||||||
export * from './edgeless/edgeless-builtin-spec.js';
|
export * from './edgeless/edgeless-builtin-spec.js';
|
||||||
export * from './edgeless/edgeless-root-spec.js';
|
export * from './edgeless/edgeless-root-spec.js';
|
||||||
export * from './edgeless/index.js';
|
export * from './edgeless/index.js';
|
||||||
export { TemplateJob } from './edgeless/services/template.js';
|
|
||||||
export * as TemplateMiddlewares from './edgeless/services/template-middlewares.js';
|
|
||||||
export * from './page/page-root-block.js';
|
export * from './page/page-root-block.js';
|
||||||
export { PageRootService } from './page/page-root-service.js';
|
export { PageRootService } from './page/page-root-service.js';
|
||||||
export * from './page/page-root-spec.js';
|
export * from './page/page-root-spec.js';
|
||||||
|
|||||||
@@ -30,6 +30,7 @@
|
|||||||
{ "path": "../../gfx/mindmap" },
|
{ "path": "../../gfx/mindmap" },
|
||||||
{ "path": "../../gfx/note" },
|
{ "path": "../../gfx/note" },
|
||||||
{ "path": "../../gfx/shape" },
|
{ "path": "../../gfx/shape" },
|
||||||
|
{ "path": "../../gfx/template" },
|
||||||
{ "path": "../../gfx/text" },
|
{ "path": "../../gfx/text" },
|
||||||
{ "path": "../../inlines/latex" },
|
{ "path": "../../inlines/latex" },
|
||||||
{ "path": "../../inlines/link" },
|
{ "path": "../../inlines/link" },
|
||||||
|
|||||||
47
blocksuite/affine/gfx/template/package.json
Normal file
47
blocksuite/affine/gfx/template/package.json
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
{
|
||||||
|
"name": "@blocksuite/affine-gfx-template",
|
||||||
|
"description": "Gfx template for BlockSuite.",
|
||||||
|
"type": "module",
|
||||||
|
"scripts": {
|
||||||
|
"build": "tsc"
|
||||||
|
},
|
||||||
|
"sideEffects": false,
|
||||||
|
"keywords": [],
|
||||||
|
"author": "toeverything",
|
||||||
|
"license": "MIT",
|
||||||
|
"dependencies": {
|
||||||
|
"@blocksuite/affine-block-surface": "workspace:*",
|
||||||
|
"@blocksuite/affine-components": "workspace:*",
|
||||||
|
"@blocksuite/affine-gfx-text": "workspace:*",
|
||||||
|
"@blocksuite/affine-model": "workspace:*",
|
||||||
|
"@blocksuite/affine-rich-text": "workspace:*",
|
||||||
|
"@blocksuite/affine-shared": "workspace:*",
|
||||||
|
"@blocksuite/affine-widget-edgeless-toolbar": "workspace:*",
|
||||||
|
"@blocksuite/global": "workspace:*",
|
||||||
|
"@blocksuite/icons": "^2.2.10",
|
||||||
|
"@blocksuite/std": "workspace:*",
|
||||||
|
"@blocksuite/store": "workspace:*",
|
||||||
|
"@floating-ui/dom": "^1.6.13",
|
||||||
|
"@lit/context": "^1.1.2",
|
||||||
|
"@preact/signals-core": "^1.8.0",
|
||||||
|
"@toeverything/theme": "^1.1.12",
|
||||||
|
"@types/lodash-es": "^4.17.12",
|
||||||
|
"lit": "^3.2.0",
|
||||||
|
"lodash-es": "^4.17.21",
|
||||||
|
"minimatch": "^10.0.1",
|
||||||
|
"rxjs": "^7.8.1",
|
||||||
|
"yjs": "^13.6.21",
|
||||||
|
"zod": "^3.23.8"
|
||||||
|
},
|
||||||
|
"exports": {
|
||||||
|
".": "./src/index.ts",
|
||||||
|
"./effects": "./src/effects.ts"
|
||||||
|
},
|
||||||
|
"files": [
|
||||||
|
"src",
|
||||||
|
"dist",
|
||||||
|
"!src/__tests__",
|
||||||
|
"!dist/__tests__"
|
||||||
|
],
|
||||||
|
"version": "0.20.0"
|
||||||
|
}
|
||||||
20
blocksuite/affine/gfx/template/src/effects.ts
Normal file
20
blocksuite/affine/gfx/template/src/effects.ts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import { OverlayScrollbar } from './toolbar/overlay-scrollbar';
|
||||||
|
import { AffineTemplateLoading } from './toolbar/template-loading';
|
||||||
|
import { EdgelessTemplatePanel } from './toolbar/template-panel';
|
||||||
|
import { EdgelessTemplateButton } from './toolbar/template-tool-button';
|
||||||
|
|
||||||
|
export function effects() {
|
||||||
|
customElements.define('edgeless-templates-panel', EdgelessTemplatePanel);
|
||||||
|
customElements.define('overlay-scrollbar', OverlayScrollbar);
|
||||||
|
customElements.define('edgeless-template-button', EdgelessTemplateButton);
|
||||||
|
customElements.define('affine-template-loading', AffineTemplateLoading);
|
||||||
|
}
|
||||||
|
|
||||||
|
declare global {
|
||||||
|
interface HTMLElementTagNameMap {
|
||||||
|
'edgeless-templates-panel': EdgelessTemplatePanel;
|
||||||
|
'overlay-scrollbar': OverlayScrollbar;
|
||||||
|
'edgeless-template-button': EdgelessTemplateButton;
|
||||||
|
'affine-template-loading': AffineTemplateLoading;
|
||||||
|
}
|
||||||
|
}
|
||||||
5
blocksuite/affine/gfx/template/src/index.ts
Normal file
5
blocksuite/affine/gfx/template/src/index.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
export * from './services/template.js';
|
||||||
|
export * from './template-tool.js';
|
||||||
|
export * from './toolbar/senior-tool.js';
|
||||||
|
export * from './toolbar/template-panel.js';
|
||||||
|
export * from './toolbar/template-type.js';
|
||||||
11
blocksuite/affine/gfx/template/src/template-tool.ts
Normal file
11
blocksuite/affine/gfx/template/src/template-tool.ts
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import { BaseTool } from '@blocksuite/std/gfx';
|
||||||
|
|
||||||
|
export class TemplateTool extends BaseTool {
|
||||||
|
static override toolName: string = 'template';
|
||||||
|
}
|
||||||
|
|
||||||
|
declare module '@blocksuite/std/gfx' {
|
||||||
|
interface GfxToolsMap {
|
||||||
|
template: TemplateTool;
|
||||||
|
}
|
||||||
|
}
|
||||||
13
blocksuite/affine/gfx/template/src/toolbar/senior-tool.ts
Normal file
13
blocksuite/affine/gfx/template/src/toolbar/senior-tool.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import { SeniorToolExtension } from '@blocksuite/affine-widget-edgeless-toolbar';
|
||||||
|
import { html } from 'lit';
|
||||||
|
|
||||||
|
export const templateSeniorTool = SeniorToolExtension(
|
||||||
|
'template',
|
||||||
|
({ block }) => {
|
||||||
|
return {
|
||||||
|
name: 'Template',
|
||||||
|
content: html`<edgeless-template-button .edgeless=${block}>
|
||||||
|
</edgeless-template-button>`,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
);
|
||||||
@@ -22,8 +22,7 @@ import { repeat } from 'lit/directives/repeat.js';
|
|||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
|
import { unsafeSVG } from 'lit/directives/unsafe-svg.js';
|
||||||
|
|
||||||
import { EdgelessRootService } from '../../../edgeless-root-service.js';
|
import { createTemplateJob } from '../services/template.js';
|
||||||
import { createTemplateJob } from '../../../services/template.js';
|
|
||||||
import { builtInTemplates } from './builtin-templates.js';
|
import { builtInTemplates } from './builtin-templates.js';
|
||||||
import { defaultPreview, Triangle } from './cards.js';
|
import { defaultPreview, Triangle } from './cards.js';
|
||||||
import type { Template } from './template-type.js';
|
import type { Template } from './template-type.js';
|
||||||
@@ -271,10 +270,6 @@ export class EdgelessTemplatePanel extends WithDisposable(LitElement) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
get service() {
|
|
||||||
return this.edgeless.std.get(EdgelessRootService);
|
|
||||||
}
|
|
||||||
|
|
||||||
get gfx() {
|
get gfx() {
|
||||||
return this.edgeless.std.get(GfxControllerIdentifier);
|
return this.edgeless.std.get(GfxControllerIdentifier);
|
||||||
}
|
}
|
||||||
@@ -319,6 +314,7 @@ export class EdgelessTemplatePanel extends WithDisposable(LitElement) {
|
|||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
this._loadingTemplate = null;
|
this._loadingTemplate = null;
|
||||||
|
// @ts-expect-error FIXME: resolve after gfx tool refactor
|
||||||
this.gfx.tool.setTool('default');
|
this.gfx.tool.setTool('default');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -138,6 +138,7 @@ export class EdgelessTemplateButton extends EdgelessToolbarToolMixin(
|
|||||||
this.setEdgelessTool(this._prevTool);
|
this.setEdgelessTool(this._prevTool);
|
||||||
this._prevTool = null;
|
this._prevTool = null;
|
||||||
} else {
|
} else {
|
||||||
|
// @ts-expect-error FIXME: resolve after gfx tool refactor
|
||||||
this.setEdgelessTool('default');
|
this.setEdgelessTool('default');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
21
blocksuite/affine/gfx/template/tsconfig.json
Normal file
21
blocksuite/affine/gfx/template/tsconfig.json
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
"extends": "../../../tsconfig.json",
|
||||||
|
"compilerOptions": {
|
||||||
|
"rootDir": "./src",
|
||||||
|
"outDir": "./dist",
|
||||||
|
"tsBuildInfoFile": "./dist/tsconfig.tsbuildinfo"
|
||||||
|
},
|
||||||
|
"include": ["./src"],
|
||||||
|
"references": [
|
||||||
|
{ "path": "../../blocks/block-surface" },
|
||||||
|
{ "path": "../../components" },
|
||||||
|
{ "path": "../text" },
|
||||||
|
{ "path": "../../model" },
|
||||||
|
{ "path": "../../rich-text" },
|
||||||
|
{ "path": "../../shared" },
|
||||||
|
{ "path": "../../widgets/widget-edgeless-toolbar" },
|
||||||
|
{ "path": "../../../framework/global" },
|
||||||
|
{ "path": "../../../framework/std" },
|
||||||
|
{ "path": "../../../framework/store" }
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -2,7 +2,7 @@ import {
|
|||||||
EdgelessTemplatePanel,
|
EdgelessTemplatePanel,
|
||||||
type Template,
|
type Template,
|
||||||
type TemplateManager,
|
type TemplateManager,
|
||||||
} from '@blocksuite/affine/blocks/root';
|
} from '@blocksuite/affine/gfx/template';
|
||||||
import { beforeEach, expect, test } from 'vitest';
|
import { beforeEach, expect, test } from 'vitest';
|
||||||
|
|
||||||
import { setupEditor } from '../utils/setup.js';
|
import { setupEditor } from '../utils/setup.js';
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ import type {
|
|||||||
Template,
|
Template,
|
||||||
TemplateCategory,
|
TemplateCategory,
|
||||||
TemplateManager,
|
TemplateManager,
|
||||||
} from '@blocksuite/affine/blocks/root';
|
} from '@blocksuite/affine/gfx/template';
|
||||||
import { EdgelessTemplatePanel } from '@blocksuite/affine/blocks/root';
|
import { EdgelessTemplatePanel } from '@blocksuite/affine/gfx/template';
|
||||||
|
|
||||||
export function setupEdgelessTemplate() {
|
export function setupEdgelessTemplate() {
|
||||||
const playgroundTemplates = [
|
const playgroundTemplates = [
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import { addImages } from '@blocksuite/affine/blocks/image';
|
import { addImages } from '@blocksuite/affine/blocks/image';
|
||||||
import { createTemplateJob } from '@blocksuite/affine/blocks/root';
|
|
||||||
import { getSurfaceBlock } from '@blocksuite/affine/blocks/surface';
|
import { getSurfaceBlock } from '@blocksuite/affine/blocks/surface';
|
||||||
import { LightLoadingIcon } from '@blocksuite/affine/components/icons';
|
import { LightLoadingIcon } from '@blocksuite/affine/components/icons';
|
||||||
import { addTree } from '@blocksuite/affine/gfx/mindmap';
|
import { addTree } from '@blocksuite/affine/gfx/mindmap';
|
||||||
import { fitContent } from '@blocksuite/affine/gfx/shape';
|
import { fitContent } from '@blocksuite/affine/gfx/shape';
|
||||||
|
import { createTemplateJob } from '@blocksuite/affine/gfx/template';
|
||||||
import { Bound } from '@blocksuite/affine/global/gfx';
|
import { Bound } from '@blocksuite/affine/global/gfx';
|
||||||
import type {
|
import type {
|
||||||
MindmapElementModel,
|
MindmapElementModel,
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import { uploadBlobForImage } from '@blocksuite/affine/blocks/image';
|
import { uploadBlobForImage } from '@blocksuite/affine/blocks/image';
|
||||||
import { createTemplateJob } from '@blocksuite/affine/blocks/root';
|
|
||||||
import {
|
import {
|
||||||
getSurfaceBlock,
|
getSurfaceBlock,
|
||||||
SurfaceBlockModel,
|
SurfaceBlockModel,
|
||||||
} from '@blocksuite/affine/blocks/surface';
|
} from '@blocksuite/affine/blocks/surface';
|
||||||
import { fitContent } from '@blocksuite/affine/gfx/shape';
|
import { fitContent } from '@blocksuite/affine/gfx/shape';
|
||||||
|
import { createTemplateJob } from '@blocksuite/affine/gfx/template';
|
||||||
import { Bound, getCommonBound } from '@blocksuite/affine/global/gfx';
|
import { Bound, getCommonBound } from '@blocksuite/affine/global/gfx';
|
||||||
import type {
|
import type {
|
||||||
MindmapElementModel,
|
MindmapElementModel,
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import { createTemplateJob } from '@blocksuite/affine/blocks/root';
|
import { createTemplateJob } from '@blocksuite/affine/gfx/template';
|
||||||
import type { EditorHost } from '@blocksuite/affine/std';
|
import type { EditorHost } from '@blocksuite/affine/std';
|
||||||
import { GfxControllerIdentifier } from '@blocksuite/affine/std/gfx';
|
import { GfxControllerIdentifier } from '@blocksuite/affine/std/gfx';
|
||||||
import type { BlockSnapshot } from '@blocksuite/affine/store';
|
import type { BlockSnapshot } from '@blocksuite/affine/store';
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { builtInTemplates as builtInStickersTemplates } from '@affine/templates/
|
|||||||
import {
|
import {
|
||||||
EdgelessTemplatePanel,
|
EdgelessTemplatePanel,
|
||||||
type TemplateManager,
|
type TemplateManager,
|
||||||
} from '@blocksuite/affine/blocks/root';
|
} from '@blocksuite/affine/gfx/template';
|
||||||
|
|
||||||
export function registerTemplates() {
|
export function registerTemplates() {
|
||||||
EdgelessTemplatePanel.templates.extend(
|
EdgelessTemplatePanel.templates.extend(
|
||||||
|
|||||||
@@ -34,6 +34,7 @@ export const PackageList = [
|
|||||||
'blocksuite/affine/gfx/mindmap',
|
'blocksuite/affine/gfx/mindmap',
|
||||||
'blocksuite/affine/gfx/note',
|
'blocksuite/affine/gfx/note',
|
||||||
'blocksuite/affine/gfx/shape',
|
'blocksuite/affine/gfx/shape',
|
||||||
|
'blocksuite/affine/gfx/template',
|
||||||
'blocksuite/affine/gfx/text',
|
'blocksuite/affine/gfx/text',
|
||||||
'blocksuite/affine/gfx/turbo-renderer',
|
'blocksuite/affine/gfx/turbo-renderer',
|
||||||
'blocksuite/affine/inlines/footnote',
|
'blocksuite/affine/inlines/footnote',
|
||||||
@@ -321,6 +322,7 @@ export const PackageList = [
|
|||||||
'blocksuite/affine/gfx/mindmap',
|
'blocksuite/affine/gfx/mindmap',
|
||||||
'blocksuite/affine/gfx/note',
|
'blocksuite/affine/gfx/note',
|
||||||
'blocksuite/affine/gfx/shape',
|
'blocksuite/affine/gfx/shape',
|
||||||
|
'blocksuite/affine/gfx/template',
|
||||||
'blocksuite/affine/gfx/text',
|
'blocksuite/affine/gfx/text',
|
||||||
'blocksuite/affine/inlines/latex',
|
'blocksuite/affine/inlines/latex',
|
||||||
'blocksuite/affine/inlines/link',
|
'blocksuite/affine/inlines/link',
|
||||||
@@ -557,6 +559,22 @@ export const PackageList = [
|
|||||||
'blocksuite/framework/store',
|
'blocksuite/framework/store',
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
location: 'blocksuite/affine/gfx/template',
|
||||||
|
name: '@blocksuite/affine-gfx-template',
|
||||||
|
workspaceDependencies: [
|
||||||
|
'blocksuite/affine/blocks/block-surface',
|
||||||
|
'blocksuite/affine/components',
|
||||||
|
'blocksuite/affine/gfx/text',
|
||||||
|
'blocksuite/affine/model',
|
||||||
|
'blocksuite/affine/rich-text',
|
||||||
|
'blocksuite/affine/shared',
|
||||||
|
'blocksuite/affine/widgets/widget-edgeless-toolbar',
|
||||||
|
'blocksuite/framework/global',
|
||||||
|
'blocksuite/framework/std',
|
||||||
|
'blocksuite/framework/store',
|
||||||
|
],
|
||||||
|
},
|
||||||
{
|
{
|
||||||
location: 'blocksuite/affine/gfx/text',
|
location: 'blocksuite/affine/gfx/text',
|
||||||
name: '@blocksuite/affine-gfx-text',
|
name: '@blocksuite/affine-gfx-text',
|
||||||
@@ -1184,6 +1202,7 @@ export type PackageName =
|
|||||||
| '@blocksuite/affine-gfx-mindmap'
|
| '@blocksuite/affine-gfx-mindmap'
|
||||||
| '@blocksuite/affine-gfx-note'
|
| '@blocksuite/affine-gfx-note'
|
||||||
| '@blocksuite/affine-gfx-shape'
|
| '@blocksuite/affine-gfx-shape'
|
||||||
|
| '@blocksuite/affine-gfx-template'
|
||||||
| '@blocksuite/affine-gfx-text'
|
| '@blocksuite/affine-gfx-text'
|
||||||
| '@blocksuite/affine-gfx-turbo-renderer'
|
| '@blocksuite/affine-gfx-turbo-renderer'
|
||||||
| '@blocksuite/affine-inline-footnote'
|
| '@blocksuite/affine-inline-footnote'
|
||||||
|
|||||||
@@ -81,6 +81,7 @@
|
|||||||
{ "path": "./blocksuite/affine/gfx/mindmap" },
|
{ "path": "./blocksuite/affine/gfx/mindmap" },
|
||||||
{ "path": "./blocksuite/affine/gfx/note" },
|
{ "path": "./blocksuite/affine/gfx/note" },
|
||||||
{ "path": "./blocksuite/affine/gfx/shape" },
|
{ "path": "./blocksuite/affine/gfx/shape" },
|
||||||
|
{ "path": "./blocksuite/affine/gfx/template" },
|
||||||
{ "path": "./blocksuite/affine/gfx/text" },
|
{ "path": "./blocksuite/affine/gfx/text" },
|
||||||
{ "path": "./blocksuite/affine/gfx/turbo-renderer" },
|
{ "path": "./blocksuite/affine/gfx/turbo-renderer" },
|
||||||
{ "path": "./blocksuite/affine/inlines/footnote" },
|
{ "path": "./blocksuite/affine/inlines/footnote" },
|
||||||
|
|||||||
31
yarn.lock
31
yarn.lock
@@ -2782,6 +2782,7 @@ __metadata:
|
|||||||
"@blocksuite/affine-gfx-mindmap": "workspace:*"
|
"@blocksuite/affine-gfx-mindmap": "workspace:*"
|
||||||
"@blocksuite/affine-gfx-note": "workspace:*"
|
"@blocksuite/affine-gfx-note": "workspace:*"
|
||||||
"@blocksuite/affine-gfx-shape": "workspace:*"
|
"@blocksuite/affine-gfx-shape": "workspace:*"
|
||||||
|
"@blocksuite/affine-gfx-template": "workspace:*"
|
||||||
"@blocksuite/affine-gfx-text": "workspace:*"
|
"@blocksuite/affine-gfx-text": "workspace:*"
|
||||||
"@blocksuite/affine-inline-latex": "workspace:*"
|
"@blocksuite/affine-inline-latex": "workspace:*"
|
||||||
"@blocksuite/affine-inline-link": "workspace:*"
|
"@blocksuite/affine-inline-link": "workspace:*"
|
||||||
@@ -3192,6 +3193,35 @@ __metadata:
|
|||||||
languageName: unknown
|
languageName: unknown
|
||||||
linkType: soft
|
linkType: soft
|
||||||
|
|
||||||
|
"@blocksuite/affine-gfx-template@workspace:*, @blocksuite/affine-gfx-template@workspace:blocksuite/affine/gfx/template":
|
||||||
|
version: 0.0.0-use.local
|
||||||
|
resolution: "@blocksuite/affine-gfx-template@workspace:blocksuite/affine/gfx/template"
|
||||||
|
dependencies:
|
||||||
|
"@blocksuite/affine-block-surface": "workspace:*"
|
||||||
|
"@blocksuite/affine-components": "workspace:*"
|
||||||
|
"@blocksuite/affine-gfx-text": "workspace:*"
|
||||||
|
"@blocksuite/affine-model": "workspace:*"
|
||||||
|
"@blocksuite/affine-rich-text": "workspace:*"
|
||||||
|
"@blocksuite/affine-shared": "workspace:*"
|
||||||
|
"@blocksuite/affine-widget-edgeless-toolbar": "workspace:*"
|
||||||
|
"@blocksuite/global": "workspace:*"
|
||||||
|
"@blocksuite/icons": "npm:^2.2.10"
|
||||||
|
"@blocksuite/std": "workspace:*"
|
||||||
|
"@blocksuite/store": "workspace:*"
|
||||||
|
"@floating-ui/dom": "npm:^1.6.13"
|
||||||
|
"@lit/context": "npm:^1.1.2"
|
||||||
|
"@preact/signals-core": "npm:^1.8.0"
|
||||||
|
"@toeverything/theme": "npm:^1.1.12"
|
||||||
|
"@types/lodash-es": "npm:^4.17.12"
|
||||||
|
lit: "npm:^3.2.0"
|
||||||
|
lodash-es: "npm:^4.17.21"
|
||||||
|
minimatch: "npm:^10.0.1"
|
||||||
|
rxjs: "npm:^7.8.1"
|
||||||
|
yjs: "npm:^13.6.21"
|
||||||
|
zod: "npm:^3.23.8"
|
||||||
|
languageName: unknown
|
||||||
|
linkType: soft
|
||||||
|
|
||||||
"@blocksuite/affine-gfx-text@workspace:*, @blocksuite/affine-gfx-text@workspace:blocksuite/affine/gfx/text":
|
"@blocksuite/affine-gfx-text@workspace:*, @blocksuite/affine-gfx-text@workspace:blocksuite/affine/gfx/text":
|
||||||
version: 0.0.0-use.local
|
version: 0.0.0-use.local
|
||||||
resolution: "@blocksuite/affine-gfx-text@workspace:blocksuite/affine/gfx/text"
|
resolution: "@blocksuite/affine-gfx-text@workspace:blocksuite/affine/gfx/text"
|
||||||
@@ -3709,6 +3739,7 @@ __metadata:
|
|||||||
"@blocksuite/affine-gfx-mindmap": "workspace:*"
|
"@blocksuite/affine-gfx-mindmap": "workspace:*"
|
||||||
"@blocksuite/affine-gfx-note": "workspace:*"
|
"@blocksuite/affine-gfx-note": "workspace:*"
|
||||||
"@blocksuite/affine-gfx-shape": "workspace:*"
|
"@blocksuite/affine-gfx-shape": "workspace:*"
|
||||||
|
"@blocksuite/affine-gfx-template": "workspace:*"
|
||||||
"@blocksuite/affine-gfx-text": "workspace:*"
|
"@blocksuite/affine-gfx-text": "workspace:*"
|
||||||
"@blocksuite/affine-gfx-turbo-renderer": "workspace:*"
|
"@blocksuite/affine-gfx-turbo-renderer": "workspace:*"
|
||||||
"@blocksuite/affine-inline-footnote": "workspace:*"
|
"@blocksuite/affine-inline-footnote": "workspace:*"
|
||||||
|
|||||||
Reference in New Issue
Block a user