Skip to content

Commit

Permalink
refactor(codemirror): minor
Browse files Browse the repository at this point in the history
  • Loading branch information
exuanbo committed Sep 18, 2024
1 parent c6c1b9c commit d82bb67
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/features/editor/codemirror/annotations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ const StringAnnotation = Annotation.define<string>()

export const withStringAnnotation =
(value: string) =>
(spec: TransactionSpec): TransactionSpec => {
const annotations = [spec.annotations ?? []].flat()
(transaction: TransactionSpec): TransactionSpec => {
const { annotations = [] } = transaction
return {
...spec,
annotations: [...annotations, StringAnnotation.of(value)],
...transaction,
annotations: [...[annotations].flat(), StringAnnotation.of(value)],
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/features/editor/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ const syncInputFromState = defineViewEffect((view) => {
setEditorInput$.pipe(
filter(({ value }) => value !== view.state.doc.toString()),
map(({ value }) => replaceContent(view.state, value)),
map((spec) => syncFromState(spec)),
map((transaction) => syncFromState(transaction)),
),
(transaction) => view.dispatch(transaction),
)
Expand Down

0 comments on commit d82bb67

Please sign in to comment.