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

Implement Tree.RemoveStyle #171

Merged
merged 2 commits into from
Apr 16, 2024
Merged

Implement Tree.RemoveStyle #171

merged 2 commits into from
Apr 16, 2024

Conversation

7hong13
Copy link
Contributor

@7hong13 7hong13 commented Apr 15, 2024

What this PR does / why we need it?

Implement JsonTree.removeStyle().

Any background context you want to provide?

What are the relevant tickets?

Checklist

  • Added relevant tests or not required
  • Didn't break anything

@7hong13 7hong13 added this to the 0.4.16 milestone Apr 15, 2024
@7hong13 7hong13 self-assigned this Apr 15, 2024
Comment on lines +34 to +59
return when {
attributes?.isNotEmpty() == true -> {
tree.style(fromPos to toPos, attributes, executedAt).map {
TreeStyleOpInfo(
it.from,
it.to,
it.fromPath,
it.attributes.orEmpty(),
path = root.createPath(parentCreatedAt),
)
}
}

attributesToRemove?.isNotEmpty() == true -> {
tree.removeStyle(fromPos to toPos, attributesToRemove, executedAt).map {
TreeStyleOpInfo(
it.from,
it.to,
it.fromPath,
attributesToRemove = it.attributesToRemove.orEmpty(),
path = root.createPath(parentCreatedAt),
)
}
}

else -> emptyList()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it assured that only one of attributes or attributesToRemove will be set?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the current interface, style() can only set attributes, and removeStyle() can only set attributesToRemove. So I think it is logically assured that only one of them will be set.

@7hong13 7hong13 merged commit 1760113 into main Apr 16, 2024
5 of 6 checks passed
@7hong13 7hong13 deleted the tree_remove_style branch April 16, 2024 04:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants