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: refactor KeySelection and ValueSelection #463

Merged
merged 3 commits into from
Jul 15, 2024

Conversation

josdejong
Copy link
Owner

For reference, see #460, #454

This PR changes:

export interface KeySelection {
  type: SelectionType.key
  path: JSONPath
  edit?: boolean
}

export type ValueSelection = {
  type: SelectionType.value
  path: JSONPath
  edit?: boolean
}

into:

export interface KeySelection {
  type: SelectionType.key
  path: JSONPath
}

export interface EditKeySelection extends KeySelection {
  type: SelectionType.key
  path: JSONPath
  edit: true
  initialValue?: string
}

export type ValueSelection = {
  type: SelectionType.value
  path: JSONPath
}

export interface EditValueSelection extends ValueSelection {
  type: SelectionType.value
  path: JSONPath
  edit: true
  initialValue?: string
}

Breaking changes:

  • the types of KeySelection and ValueSelection are changed
  • the helper functions createKeySelection and createValueSelection are changed (argument edit is removed), and two new helper functions are added: createEditKeySelection and createEditValueSelection
  • the API of the component EditableValue is changed

Motivation:

  • Get rid of some internal workarounds to initialize the value of a key or value when starting to edit it: insertActiveElementContents, tick2, refreshEditableDiv, attaching a .refresh() method to the editable div.
  • Make the types more explicit (no optional boolean edit), make use of the commonly used helper functions createKeySelection and createValueSelection more compact.

…ouple of internal workarounds

BREAKING CHANGE:
The API's of `KeySelection`, `ValueSelection`, `createKeySelection`, `createValueSelection`,
and `EditableValue` changed.
@josdejong josdejong merged commit c807600 into v1 Jul 15, 2024
3 checks passed
@josdejong josdejong deleted the chore/refactor-oninsert branch July 15, 2024 10:52
@josdejong josdejong mentioned this pull request Jul 30, 2024
Merged
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant