Skip to content

Commit

Permalink
Adjust commands documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsaidi committed Feb 14, 2024
1 parent 012803a commit a702cac
Show file tree
Hide file tree
Showing 10 changed files with 46 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ import SwiftUI
public extension RichTextCommand {

/**
This button can be used to trigger any ``RichTextAction``
from a main menu command item.
This button can trigger any ``RichTextAction`` from the
main menu.
This button gets ``RichTextContext`` as a focused value.
It will be nil if no view has focus, which will disable
the button altogether.
This view requires that a ``RichTextContext`` is set as
a focused value, otherwise it will be disabled.
*/
struct ActionButton: View {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ import SwiftUI
public extension RichTextCommand {

/**
This view can be used to render a collection of actions
as main menu command items.
This view can add list of ``RichTextAction`` buttons to
the main menu.
This view requires that a ``RichTextContext`` is set as
a focused value, otherwise it will be disabled.
*/
struct ActionButtonGroup: View {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import SwiftUI
public extension RichTextCommand {

/**
This view renders ``RichTextAlignment`` command options.
This view can add list of text alignment options to the
main menu, using an ``RichTextCommand/ActionButtonGroup``.
This view requires that a ``RichTextContext`` is set as
a focused value, otherwise it will be disabled.
*/
struct AlignmentOptionsGroup: View {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import SwiftUI
public extension RichTextCommand {

/**
This view renders font size command options.
This view can add list of font size options to the main
menu, using an ``RichTextCommand/ActionButtonGroup``.
This view requires that a ``RichTextContext`` is set as
a focused value, otherwise it will be disabled.
*/
struct FontSizeOptionsGroup: View {

Expand Down
7 changes: 5 additions & 2 deletions Sources/RichTextKit/Commands/RichTextCommand+FormatMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ import SwiftUI
public extension RichTextCommand {

/**
This menu can be used to add format-specific options to
the main menu bar.
This menu view can add a list of text format options to
the main menu.
This view requires that a ``RichTextContext`` is set as
a focused value, otherwise it will be disabled.
*/
struct FormatMenu: Commands {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import SwiftUI
public extension RichTextCommand {

/**
This view renders ``RichTextIndent`` command options.
This group can add a list of text indent options to the
main menu, using an ``RichTextCommand/ActionButtonGroup``.
This view requires that a ``RichTextContext`` is set as
a focused value, otherwise it will be disabled.
*/
struct IndentOptionsGroup: View {

Expand Down
11 changes: 6 additions & 5 deletions Sources/RichTextKit/Commands/RichTextCommand+ShareMenu.swift
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import SwiftUI
public extension RichTextCommand {

/**
This menu can be used to add sharing-related options to
the main menu bar.
This menu view can add a list of sharing options to the
main menu.
The menu will try to add options for share, export, and
print, if applicable to the current platform. Selecting
Expand All @@ -23,14 +23,14 @@ public extension RichTextCommand {
return a share url, after which a command takes care of
the sharing. Also note that the `formatNSSharingAction`
and `pdfNSSharingAction` will only have effect on macOS,
where they will add ``RichTextNSSharingMenu`` options.
where they add ``RichTextNSSharingMenu`` options.
Note that a pdf action menu will only be included if it
has a corresponding action. Also note that you must use
`isEnabled: false` to disable the menu, since you can't
add `.disabled` to the command menu.
Setting any action to nil removes a corrsponding option
Setting actions to `nil` removes a corresponding option
from the menu.
*/
struct ShareMenu: Commands {
Expand Down Expand Up @@ -118,7 +118,8 @@ private extension RichTextCommand.ShareMenu {
if let action = printAction {
Button(action: action) {
Label(RTKL10n.menuPrint.text, .richTextActionPrint)
}.keyboardShortcut(for: .print)
}
.keyboardShortcut(for: .print)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import SwiftUI
public extension RichTextCommand {

/**
This view renders ``RichTextStyle`` command options.
This view can add a list of styling options to the main
menu, using an ``RichTextCommand/ActionButtonGroup``.
This view requires that a ``RichTextContext`` is set as
a focused value, otherwise it will be disabled.
*/
struct StyleOptionsGroup: View {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ import SwiftUI
public extension RichTextCommand {

/**
This view renders superscript command options.
This group can add a list of superscript options to the
main menu, using an ``RichTextCommand/ActionButtonGroup``.
This view requires that a ``RichTextContext`` is set as
a focused value, otherwise it will be disabled.
*/
struct SuperscriptOptionsGroup: View {

Expand Down
3 changes: 1 addition & 2 deletions Sources/RichTextKit/Commands/RichTextCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import Foundation
like views that are to be added to the main menu bar.
> Important: Most rich text commands require that there's a
focused ``RichTextContext`` value in the view hierarchy. If
not, they will be disabled.
focused ``RichTextContext`` value in the view hierarchy.
*/
public struct RichTextCommand {}

0 comments on commit a702cac

Please sign in to comment.