-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from mattbegent/feature/embed-tool
Add embed tool
- Loading branch information
Showing
6 changed files
with
147 additions
and
2 deletions.
There are no files selected for viewing
76 changes: 76 additions & 0 deletions
76
Umbraco.Community.Skrivlet/Converters/EmbedBlockDataConverter.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,76 @@ | ||
using System.Text.Json; | ||
|
||
namespace Umbraco.Community.SkrivLet.Converters | ||
{ | ||
public class EmbedBlockDataConverter : IBlockDataConverter | ||
{ | ||
public bool CanConvert(string type) | ||
{ | ||
return type.Equals("embed"); | ||
} | ||
|
||
public SkrivLetBlockBase Convert(ref Utf8JsonReader reader, string id, string type) | ||
{ | ||
if (reader.TokenType != JsonTokenType.StartObject) | ||
{ | ||
throw new JsonException(); | ||
} | ||
|
||
var block = new SkrivLetBlock<EmbedBlockData>(id, type); | ||
block.Data = new EmbedBlockData(); | ||
while (reader.Read()) | ||
{ | ||
if (reader.TokenType == JsonTokenType.EndObject) | ||
{ | ||
return block; | ||
} | ||
|
||
// Get the key. | ||
if (reader.TokenType != JsonTokenType.PropertyName) | ||
{ | ||
throw new JsonException(); | ||
} | ||
|
||
string? propertyName = reader.GetString() ?? ""; | ||
switch (propertyName.ToLower()) | ||
{ | ||
case "service": | ||
reader.Read(); | ||
block.Data.Service = reader.GetString() ?? ""; | ||
break; | ||
case "source": | ||
reader.Read(); | ||
block.Data.Source = reader.GetString() ?? ""; | ||
break; | ||
case "embed": | ||
reader.Read(); | ||
block.Data.Embed = reader.GetString() ?? ""; | ||
break; | ||
case "width": | ||
reader.Read(); | ||
block.Data.Width = reader.GetInt16(); | ||
break; | ||
case "height": | ||
reader.Read(); | ||
block.Data.Height = reader.GetInt16(); | ||
break; | ||
case "caption": | ||
reader.Read(); | ||
block.Data.Caption = reader.GetString() ?? ""; | ||
break; | ||
} | ||
} | ||
return block; | ||
} | ||
} | ||
|
||
public class EmbedBlockData | ||
{ | ||
public string Service { get; set; } | ||
public string Source { get; set; } | ||
public string Embed { get; set; } | ||
public int Height { get; set; } | ||
public int Width { get; set; } | ||
public string Caption { get; 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
4 changes: 4 additions & 0 deletions
4
Umbraco.Community.Skrivlet/Views/Partials/SkrivLet/Embed.cshtml
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,4 @@ | ||
@model Umbraco.Community.SkrivLet.SkrivLetBlock<Umbraco.Community.SkrivLet.Converters.EmbedBlockData> | ||
<div class="sl-embed sl-embed--@Model.Data.Service"> | ||
<iframe title="@Model.Data.Caption" src="@Model.Data.Embed" width="@Model.Data.Width" height="@Model.Data.Height" frameborder="0" allowfullscreen></iframe> | ||
</div> |
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 |
---|---|---|
|
@@ -34,6 +34,10 @@ | |
max-width: 800px; | ||
} | ||
|
||
.cdx-label { | ||
font-weight: 700; | ||
} | ||
|
||
/* Image */ | ||
.simple-image { | ||
padding: 20px 0; | ||
|