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

feat(core): editor setting service #7956

Merged
merged 1 commit into from
Aug 26, 2024
Merged

Conversation

EYHN
Copy link
Member

@EYHN EYHN commented Aug 23, 2024

define editor setting schema in packages/frontend/core/src/modules/editor-settting/schema.ts

e.g.

const BSEditorSettingSchema = z.object({
  connector: z.object({
    stroke: z
      .union([
        z.string(),
        z.object({
          dark: z.string(),
          light: z.string(),
        }),
      ])
      .default('#000000'), // default is necessary
  }),
});

schema can be defined in a nested way. EditorSetting api is in flat way:

editorSetting api:

editorSetting.settings$ === {
  'connector.stroke': '#000000'
}
editorSetting.set('connector.stroke', '#000')

and use expandFlattenObject function can restore the flattened structure to a nested structure. nested structure is required by blocksuite

editorSetting.settings$.map(expandFlattenObject) === {
  connector: {
    stroke: '#000000'
  }
}

Copy link

graphite-app bot commented Aug 23, 2024

Your org has enabled the Graphite merge queue for merging into canary

Add the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

Copy link
Member Author

EYHN commented Aug 23, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @EYHN and the rest of your teammates on Graphite Graphite

@EYHN EYHN mentioned this pull request Aug 23, 2024
@github-actions github-actions bot added test Related to test cases app:core labels Aug 23, 2024
@EYHN EYHN force-pushed the eyhn/editor-setting-service branch from f286f1d to dc3d6d3 Compare August 23, 2024 06:02
@EYHN EYHN changed the base branch from eyhn/user-db to canary August 23, 2024 06:03
@EYHN EYHN marked this pull request as ready for review August 23, 2024 06:03
Copy link

nx-cloud bot commented Aug 23, 2024

@EYHN EYHN assigned JimmFly and akumatus and unassigned akumatus and JimmFly Aug 23, 2024
@EYHN EYHN requested a review from akumatus August 23, 2024 06:04
Copy link

codecov bot commented Aug 23, 2024

Codecov Report

Attention: Patch coverage is 97.91667% with 1 line in your changes missing coverage. Please review.

Project coverage is 55.27%. Comparing base (3c37006) to head (bc86f0a).
Report is 1 commits behind head on canary.

Files Patch % Lines
...ckages/frontend/core/src/utils/unflatten-object.ts 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           canary    #7956      +/-   ##
==========================================
+ Coverage   55.18%   55.27%   +0.08%     
==========================================
  Files        1053     1060       +7     
  Lines       44677    44725      +48     
  Branches     5262     5272      +10     
==========================================
+ Hits        24656    24722      +66     
+ Misses      19643    19624      -19     
- Partials      378      379       +1     
Flag Coverage Δ
server-test 77.68% <ø> (+0.07%) ⬆️
unittest 27.13% <97.91%> (+0.17%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@EYHN EYHN force-pushed the eyhn/editor-setting-service branch from fea3451 to 8982886 Compare August 26, 2024 08:00
Copy link

graphite-app bot commented Aug 26, 2024

Merge activity

define editor setting schema in `packages/frontend/core/src/modules/editor-settting/schema.ts`

e.g.

```ts
const BSEditorSettingSchema = z.object({
  connector: z.object({
    stroke: z
      .union([
        z.string(),
        z.object({
          dark: z.string(),
          light: z.string(),
        }),
      ])
      .default('#000000'), // default is necessary
  }),
});
```

schema can be defined in a nested way. EditorSetting api is in flat way:

editorSetting api:

```ts
editorSetting.settings$ === {
  'connector.stroke': '#000000'
}
editorSetting.set('connector.stroke', '#000')
```

and use `expandFlattenObject` function can restore the flattened structure to a nested structure. nested structure is required by blocksuite

```ts
editorSetting.settings$.map(expandFlattenObject) === {
  connector: {
    stroke: '#000000'
  }
}
```
@EYHN EYHN force-pushed the eyhn/editor-setting-service branch from 8982886 to bc86f0a Compare August 26, 2024 08:19
@graphite-app graphite-app bot merged commit bc86f0a into canary Aug 26, 2024
33 checks passed
@graphite-app graphite-app bot deleted the eyhn/editor-setting-service branch August 26, 2024 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
app:core test Related to test cases
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

4 participants