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

reference-node external configuration #8765

Closed
xiaofeiniuuu opened this issue Nov 20, 2024 · 4 comments
Closed

reference-node external configuration #8765

xiaofeiniuuu opened this issue Nov 20, 2024 · 4 comments

Comments

@xiaofeiniuuu
Copy link

How to update the config value of
const config = provider.getOptional(ReferenceNodeConfigIdentifier) ​​?? {}; after upgrading
Do I need to use ReferenceNodeConfigExtension? How to use it?
I see that affine-paragraph no longer has referenceNodeConfig

@xiaofeiniuuu
Copy link
Author

image
How to update this value externally

@xiaofeiniuuu
Copy link
Author

xiaofeiniuuu commented Nov 20, 2024

image

This is what I'm doing now. Is this correct?

@L-Sun
Copy link
Contributor

L-Sun commented Nov 20, 2024

You can add a ConfigExtension to editor.pageSpecs and editor.edgelessSpecs. For example, in the setup stage of playground editor:

  • Before
    const refNodeSlotsExtension = RefNodeSlotsExtension();
    editor.pageSpecs = patchPageRootSpec([
    refNodeSlotsExtension,
    ...specs.pageModeSpecs,
    ]);
    editor.edgelessSpecs = patchPageRootSpec([
    refNodeSlotsExtension,
    ...specs.edgelessModeSpecs,
    ]);
  • After
    const referenceNodeConfigExtension : ExtensionType = {
      setup: di => {
        const prev = di.getFactory(ReferenceNodeConfigIdentifier);
        di.override(ReferenceNodeConfigIdentifier, provider => {
          return {
            ...prev?.(provider), // If you wan to fully control the configs, remove this line
            // Your configs put here
          } satisfies ReferenceNodeConfig;
        });
      }
    } 
    
    editor.pageSpecs = patchPageRootSpec([
      refNodeSlotsExtension,
      ...specs.pageModeSpecs,
      referenceNodeConfigExtension,
    ]);
    editor.edgelessSpecs = patchPageRootSpec([
      refNodeSlotsExtension,
      ...specs.edgelessModeSpecs,
     referenceNodeConfigExtension,
    ]);

@L-Sun
Copy link
Contributor

L-Sun commented Nov 20, 2024

image

This is what I'm doing now. Is this correct?

Basically correct if there is no other reference node configuration. More precisely,

  • you also need to push the extension to EdgelessEditorBlockSpecs
  • you can override the configuration in this way,
  • or partially modify the configuration by following the instructions in the my comments above.

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

No branches or pull requests

2 participants