Skip to content

Commit

Permalink
Merge pull request #477 from matrix-org/aringenbach/live_tree
Browse files Browse the repository at this point in the history
Enable live document tree and display it by default
  • Loading branch information
aringenbach authored Jan 13, 2023
2 parents b44a9b4 + 4303666 commit 8b12417
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 9 deletions.
10 changes: 5 additions & 5 deletions platforms/ios/example/Wysiwyg/Views/ContentView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import WysiwygComposer
struct ContentView: View {
/// A composer content "saved" and displayed upon hitting the send button.
@State private var sentMessage: WysiwygComposerContent?
@State private var tree: String?
@State private var showTree = true
/// View model for the composer.
@StateObject private var viewModel = WysiwygComposerViewModel(
minHeight: WysiwygSharedConstants.composerMinHeight,
Expand All @@ -48,13 +48,13 @@ struct ContentView: View {
}
.disabled(viewModel.isContentEmpty)
.accessibilityIdentifier(.sendButton)
Button("Show tree") {
tree = viewModel.treeRepresentation()
Button(showTree ? "Hide tree" : "Show tree") {
showTree.toggle()
}
.accessibilityIdentifier(.showTreeButton)
ScrollView {
if let tree = tree {
Text(tree)
if showTree {
Text(viewModel.treeRepresentation())
.accessibilityIdentifier(.treeText)
.font(.system(size: 11.0, weight: .regular, design: .monospaced))
.multilineTextAlignment(.leading)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ extension WysiwygUITests {
// FIXME: iOS automatically adds an extra line break even if not in the model
assertTextViewContent("​Some text\n")

button(.showTreeButton).tap()
assertTreeEquals(
"""
└>pre
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ extension WysiwygUITests {
// Bolding doesn't change text and we can't test text attributes from this context.
assertTextViewContent("Some bold text")

button(.showTreeButton).tap()
assertTreeEquals(
"""
├>"Some bold "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ extension WysiwygUITests {
// FIXME: iOS automatically adds an extra line break even if not in the model
assertTextViewContent("Some text\n")

button(.showTreeButton).tap()
assertTreeEquals(
"""
└>blockquote
Expand Down
2 changes: 1 addition & 1 deletion platforms/ios/example/WysiwygUITests/WysiwygUITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ internal extension WysiwygUITests {
///
/// - Parameter content: the tree content to assert, must be provided without newlines at the start and at the end.
func assertTreeEquals(_ content: String) {
button(.showTreeButton).tap()
sleep(1)
XCTAssertEqual(staticText(.treeText).label, "\n\(content)\n")
}
}
Expand Down

0 comments on commit 8b12417

Please sign in to comment.