# ScriptDocument(ロブロックス クラス) > Represents the ephemeral state of an open document in the Studio Script Editor, providing APIs for reading and editing code. - URL:https://roblox.minecraft-okinawa.com/reference/classes/ScriptDocument/ - 公式:https://create.roblox.com/docs/reference/engine/classes/ScriptDocument - 受け継いでいるクラス:Instance ## メソッド - `ScriptDocument:AddReadOnlyReasonsAsync(reasons: Array): ()`:Adds reasons for the Script Editor UI to be read-only. Yields the current thread until the editor acknowledges the change. - `ScriptDocument:CloseAsync(): Tuple`:Requests that the editor associated with this document close. Yields the current thread until the editor responds to the request. - `ScriptDocument:EditTextAsync(newText: string, startLine: int, startCharacter: int, endLine: int, endCharacter: int): Tuple`:Replaces the text in the specified range from (startLine, startColumn) to (endLine, endColumn) with newText. - `ScriptDocument:ForceSetSelectionAsync(cursorLine: int, cursorCharacter: int, anchorLine: int?, anchorCharacter: int?): Tuple`:Asks the editor to set its cursor selection to the argument values. - `ScriptDocument:GetLine(lineIndex: int?): string`:Returns the text of the specified line. When no argument is provided, returns the line of the current cursor position. - `ScriptDocument:GetLineCount(): int`:Returns the number of lines in the document. - `ScriptDocument:GetReadOnlyReasons(): List`:Returns the reasons the Script Editor UI is currently read-only. - `ScriptDocument:GetScript(): LuaSourceContainer`:Returns the underlying LuaSourceContainer instance, if one exists, otherwise nil. - `ScriptDocument:GetSelectedText(): string`:Gets the text selected in the editor, or an empty string if there is no selection. - `ScriptDocument:GetSelection(): Tuple`:Returns the last known selection of the Script Editor in the format: CursorLine, CursorChar, AnchorLine, AnchorChar. If the Script Editor has no selection, CursorLine == AnchorLine and CursorChar == AnchorChar. - `ScriptDocument:GetSelectionEnd(): Tuple`:Gets the larger of the cursor position and anchor. If the editor has no selection, they are the same value. - `ScriptDocument:GetSelectionStart(): Tuple`:Gets the smaller of the cursor position and anchor. If the editor has no selection, they are the same value. - `ScriptDocument:GetText(startLine: int?, startCharacter: int?, endLine: int?, endCharacter: int?): string`:Returns text from the open editor. - `ScriptDocument:GetViewport(): Tuple`:Returns the currently displayed line numbers in the editor change. - `ScriptDocument:HasSelectedText(): boolean`:Returns whether or not the editor has any text selected. - `ScriptDocument:IsCommandBar(): boolean`:Returns true if the ScriptDocument represents the Command bar. - `ScriptDocument:IsReadOnly(): boolean`:Returns true if the Script Editor UI is currently read-only. - `ScriptDocument:MultiEditTextAsync(edits: Array): Tuple`:Applies a batch of text edits to the document as a single atomic operation. Yields the current thread until the editor responds. - `ScriptDocument:RemoveReadOnlyReasonsAsync(reasons: Array): ()`:Removes reasons for the Script Editor UI to be read-only. Yields the current thread until the editor acknowledges the change. - `ScriptDocument:RequestSetSelectionAsync(cursorLine: int, cursorCharacter: int, anchorLine: int?, anchorCharacter: int?): Tuple`:Asks the editor to set its cursor selection to the argument values. - `ScriptDocument:ReviewableTextEditsAsync(changes: Array): Tuple`:Applies a batch of line-based text edits that appear in the editor as reviewable inline diffs, allowing users to accept or reject each change. ## イベント - `ScriptDocument.SelectionChanged(positionLine: int64, positionCharacter: int64, anchorLine: int64, anchorCharacter: int64)`:Fires when the ScriptDocument changes, including immediately after a text change. - `ScriptDocument.ViewportChanged(startLine: int64, endLine: int64)`:Fires when the displayed line numbers in the editor change. 英語の説明とメンバー一覧:Roblox Creator Documentation(CC BY 4.0)。日本語の解説はこのサイト独自のものです。 執筆:鈴木孝昌(現役プロジェクトマネージャー/プログラミング講師)/運営:沖縄マイクラ部 プログラミングスクール「クロスウェーブ」(https://minecraft-okinawa.com/)