diff --git a/src/Limbo.Umbraco.YouTube/PropertyEditors/YouTubeConfiguration.cs b/src/Limbo.Umbraco.YouTube/PropertyEditors/YouTubeConfiguration.cs new file mode 100644 index 0000000..e9bec99 --- /dev/null +++ b/src/Limbo.Umbraco.YouTube/PropertyEditors/YouTubeConfiguration.cs @@ -0,0 +1,16 @@ +using Newtonsoft.Json; +using Umbraco.Cms.Core.PropertyEditors; + +#pragma warning disable CS1591 + +namespace Limbo.Umbraco.YouTube.PropertyEditors { + + public class YouTubeConfiguration { + + [ConfigurationField("hideLabel", "Hide label", "boolean", Description = "Select whether the label and description of properties using this data type should be hidden.

Hiding the label and description can be useful in some cases - eg. to give the video picker a bit more horizontal space.")] + [JsonProperty("hideLabel")] + public bool HideLabel { get; set; } + + } + +} \ No newline at end of file diff --git a/src/Limbo.Umbraco.YouTube/PropertyEditors/YouTubeConfigurationEditor.cs b/src/Limbo.Umbraco.YouTube/PropertyEditors/YouTubeConfigurationEditor.cs new file mode 100644 index 0000000..c3497e1 --- /dev/null +++ b/src/Limbo.Umbraco.YouTube/PropertyEditors/YouTubeConfigurationEditor.cs @@ -0,0 +1,15 @@ +using Umbraco.Cms.Core.IO; +using Umbraco.Cms.Core.PropertyEditors; +using Umbraco.Cms.Core.Services; + +#pragma warning disable CS1591 + +namespace Limbo.Umbraco.YouTube.PropertyEditors { + + public class YouTubeConfigurationEditor : ConfigurationEditor { + + public YouTubeConfigurationEditor(IIOHelper ioHelper, IEditorConfigurationParser editorConfigurationParser) : base(ioHelper, editorConfigurationParser) { } + + } + +} \ No newline at end of file diff --git a/src/Limbo.Umbraco.YouTube/PropertyEditors/YouTubeEditor.cs b/src/Limbo.Umbraco.YouTube/PropertyEditors/YouTubeEditor.cs index 28213bc..7a5a4a7 100644 --- a/src/Limbo.Umbraco.YouTube/PropertyEditors/YouTubeEditor.cs +++ b/src/Limbo.Umbraco.YouTube/PropertyEditors/YouTubeEditor.cs @@ -1,4 +1,7 @@ -using Umbraco.Cms.Core.PropertyEditors; +using Umbraco.Cms.Core.IO; +using Umbraco.Cms.Core.Models; +using Umbraco.Cms.Core.PropertyEditors; +using Umbraco.Cms.Core.Services; #pragma warning disable 1591 @@ -10,6 +13,9 @@ namespace Limbo.Umbraco.YouTube.PropertyEditors { [DataEditor(EditorAlias, EditorName, EditorView, ValueType = ValueTypes.Json, Group = "Limbo", Icon = EditorIcon)] public class YouTubeEditor : DataEditor { + private readonly IIOHelper _ioHelper; + private readonly IEditorConfigurationParser _editorConfigurationParser; + #region Constants internal const string EditorAlias = "Limbo.Umbraco.YouTube"; @@ -24,7 +30,24 @@ public class YouTubeEditor : DataEditor { #region Constructors - public YouTubeEditor(IDataValueEditorFactory dataValueEditorFactory) : base(dataValueEditorFactory) { } + public YouTubeEditor(IIOHelper ioHelper, IEditorConfigurationParser editorConfigurationParser, IDataValueEditorFactory dataValueEditorFactory) : base(dataValueEditorFactory) { + _ioHelper = ioHelper; + _editorConfigurationParser = editorConfigurationParser; + } + + #endregion + + #region Member methods + + public override IDataValueEditor GetValueEditor(object? configuration) { + IDataValueEditor editor = base.GetValueEditor(configuration); + if (editor is DataValueEditor dve) dve.View += $"?v={YouTubePackage.InformationalVersion}"; + return editor; + } + + protected override IConfigurationEditor CreateConfigurationEditor() { + return new YouTubeConfigurationEditor(_ioHelper, _editorConfigurationParser); + } #endregion diff --git a/src/Limbo.Umbraco.YouTube/wwwroot/Scripts/Controllers/Video.js b/src/Limbo.Umbraco.YouTube/wwwroot/Scripts/Controllers/Video.js index f9fb8e2..99cd6bf 100644 --- a/src/Limbo.Umbraco.YouTube/wwwroot/Scripts/Controllers/Video.js +++ b/src/Limbo.Umbraco.YouTube/wwwroot/Scripts/Controllers/Video.js @@ -85,7 +85,7 @@ }, 20); } } - + if (!rawVideoData) { vm.videoId = null; vm.title = null, @@ -103,6 +103,9 @@ function init() { + if (!$scope.model.config) $scope.model.config = {}; + $scope.model.hideLabel = $scope.model.config.hideLabel === true; + if (!$scope.model.value || $scope.model.value === "null") { $scope.model.value = null; return;