-
-
Notifications
You must be signed in to change notification settings - Fork 234
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
10 changed files
with
282 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
src/Butil/Bit.Butil/Internals/JsInterops/DocumentJsInterop.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System.Threading.Tasks; | ||
using Microsoft.JSInterop; | ||
|
||
namespace Bit.Butil; | ||
|
||
internal static class DocumentJsInterop | ||
{ | ||
internal static async Task<string> DocumentGetCharacterSet(this IJSRuntime js) | ||
=> await js.InvokeAsync<string>("BitButil.document.characterSet"); | ||
|
||
internal static async Task<CompatMode> DocumentGetCompatMode(this IJSRuntime js) | ||
{ | ||
var mode = await js.InvokeAsync<string>("BitButil.document.compatMode"); | ||
return mode switch | ||
{ | ||
"BackCompat" => CompatMode.BackCompat, | ||
_ => CompatMode.CSS1Compat | ||
}; | ||
} | ||
|
||
internal static async Task<string> DocumentGetContentType(this IJSRuntime js) | ||
=> await js.InvokeAsync<string>("BitButil.document.contentType"); | ||
|
||
internal static async Task<string> DocumentGetDocumentURI(this IJSRuntime js) | ||
=> await js.InvokeAsync<string>("BitButil.document.documentURI"); | ||
|
||
internal static async Task<DesignMode> DocumentGetDesignMode(this IJSRuntime js) | ||
{ | ||
var mode = await js.InvokeAsync<string>("BitButil.document.getDesignMode"); | ||
return mode switch | ||
{ | ||
"on" => DesignMode.On, | ||
_ => DesignMode.Off | ||
}; | ||
} | ||
internal static async Task DocumentSetDesignMode(this IJSRuntime js, DesignMode mode) | ||
=> await js.InvokeVoidAsync("BitButil.document.setDesignMode", mode); | ||
|
||
internal static async Task<DocumentDir> DocumentGetDir(this IJSRuntime js) | ||
{ | ||
var mode = await js.InvokeAsync<string>("BitButil.document.getDir"); | ||
return mode switch | ||
{ | ||
"rtl" => DocumentDir.Rtl, | ||
_ => DocumentDir.Ltr | ||
}; | ||
} | ||
internal static async Task DocumentSetDir(this IJSRuntime js, DocumentDir dir) | ||
=> await js.InvokeVoidAsync("BitButil.document.setDir", dir); | ||
|
||
internal static async Task<string> DocumentGetReferrer(this IJSRuntime js) | ||
=> await js.InvokeAsync<string>("BitButil.document.referrer"); | ||
|
||
internal static async Task<string> DocumentGetTitle(this IJSRuntime js) | ||
=> await js.InvokeAsync<string>("BitButil.document.getTitle"); | ||
internal static async Task DocumentSetTitle(this IJSRuntime js, string title) | ||
=> await js.InvokeVoidAsync("BitButil.document.setTitle", title); | ||
|
||
internal static async Task<string> DocumentGetUrl(this IJSRuntime js) | ||
=> await js.InvokeAsync<string>("BitButil.document.URL"); | ||
|
||
internal static async Task DocumentExitFullscreen(this IJSRuntime js) | ||
=> await js.InvokeVoidAsync("BitButil.document.exitFullscreen"); | ||
|
||
internal static async Task DocumentExitPointerLock(this IJSRuntime js) | ||
=> await js.InvokeVoidAsync("BitButil.document.exitPointerLock"); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Bit.Butil; | ||
|
||
public enum CompatMode | ||
{ | ||
/// <summary> | ||
/// The document is in quirks mode. | ||
/// </summary> | ||
BackCompat, | ||
|
||
/// <summary> | ||
/// The document is in no-quirks (also known as "standards") mode or limited-quirks (also known as "almost standards") mode. | ||
/// </summary> | ||
CSS1Compat | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Bit.Butil; | ||
|
||
public enum DesignMode | ||
{ | ||
/// <summary> | ||
/// The document's design mode is off (default). | ||
/// </summary> | ||
Off, | ||
|
||
/// <summary> | ||
/// The document is in design mode and the entire document is editable. | ||
/// </summary> | ||
On | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
namespace Bit.Butil; | ||
|
||
public enum DocumentDir | ||
{ | ||
/// <summary> | ||
/// Left to right (default). | ||
/// </summary> | ||
Ltr, | ||
|
||
/// <summary> | ||
/// Right to left. | ||
/// </summary> | ||
Rtl | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/Butil/Bit.Butil/Publics/Element/Dir.cs → ...l/Bit.Butil/Publics/Element/ElementDir.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
namespace Bit.Butil; | ||
|
||
public enum Dir | ||
public enum ElementDir | ||
{ | ||
/// <summary> | ||
/// The dir value is not set. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
var BitButil = BitButil || {}; | ||
|
||
(function (butil: any) { | ||
const _handlers = {}; | ||
|
||
butil.document = { | ||
characterSet() { return document.characterSet }, | ||
compatMode() { return document.compatMode }, | ||
contentType() { return document.contentType }, | ||
documentURI() { return document.documentURI }, | ||
getDesignMode() { return document.designMode }, | ||
setDesignMode(value: string) { document.designMode = value }, | ||
getDir() { return document.dir }, | ||
setDir(value: string) { document.dir = value }, | ||
referrer() { return document.referrer }, | ||
getTitle() { return document.title }, | ||
URL() { return document.URL }, | ||
setTitle(value: string) { document.title = value }, | ||
exitFullscreen() { return document.exitFullscreen() }, | ||
exitPointerLock() { return document.exitPointerLock() }, | ||
|
||
}; | ||
}(BitButil)); |