Updated rich text parser interfaces to support context cache. (#15220)

This commit is contained in:
Andy Butland
2023-11-16 06:33:36 +01:00
committed by GitHub
parent 6f139ced53
commit ead7741ee2
3 changed files with 91 additions and 0 deletions

View File

@@ -12,13 +12,38 @@ public interface IImageSourceParser
/// <param name="dependencies">A list of dependencies.</param>
/// <returns>The parsed value.</returns>
/// <remarks>Turns src="/media/..." into src="umb://media/..." and adds the corresponding udi to the dependencies.</remarks>
[Obsolete("Please use the overload taking all parameters. This method will be removed in Umbraco 14.")]
string ToArtifact(string value, ICollection<Udi> dependencies);
/// <summary>
/// Parses an Umbraco property value and produces an artifact property value.
/// </summary>
/// <param name="value">The property value.</param>
/// <param name="dependencies">A list of dependencies.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>The parsed value.</returns>
/// <remarks>Turns src="/media/..." into src="umb://media/..." and adds the corresponding udi to the dependencies.</remarks>
#pragma warning disable CS0618 // Type or member is obsolete
string ToArtifact(string value, ICollection<Udi> dependencies, IContextCache contextCache) => ToArtifact(value, dependencies);
#pragma warning restore CS0618 // Type or member is obsolete
/// <summary>
/// Parses an artifact property value and produces an Umbraco property value.
/// </summary>
/// <param name="value">The artifact property value.</param>
/// <returns>The parsed value.</returns>
/// <remarks>Turns umb://media/... into /media/....</remarks>
[Obsolete("Please use the overload taking all parameters. This method will be removed in Umbraco 14.")]
string FromArtifact(string value);
/// <summary>
/// Parses an artifact property value and produces an Umbraco property value.
/// </summary>
/// <param name="value">The artifact property value.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>The parsed value.</returns>
/// <remarks>Turns umb://media/... into /media/....</remarks>
#pragma warning disable CS0618 // Type or member is obsolete
string FromArtifact(string value, IContextCache contextCache) => FromArtifact(value);
#pragma warning restore CS0618 // Type or member is obsolete
}

View File

@@ -15,13 +15,41 @@ public interface ILocalLinkParser
/// Turns {{localLink:1234}} into {{localLink:umb://{type}/{id}}} and adds the corresponding udi to the
/// dependencies.
/// </remarks>
[Obsolete("Please use the overload taking all parameters. This method will be removed in Umbraco 14.")]
string ToArtifact(string value, ICollection<Udi> dependencies);
/// <summary>
/// Parses an Umbraco property value and produces an artifact property value.
/// </summary>
/// <param name="value">The property value.</param>
/// <param name="dependencies">A list of dependencies.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>The parsed value.</returns>
/// <remarks>
/// Turns {{localLink:1234}} into {{localLink:umb://{type}/{id}}} and adds the corresponding udi to the
/// dependencies.
/// </remarks>
#pragma warning disable CS0618 // Type or member is obsolete
string ToArtifact(string value, ICollection<Udi> dependencies, IContextCache contextCache) => ToArtifact(value, dependencies);
#pragma warning restore CS0618 // Type or member is obsolete
/// <summary>
/// Parses an artifact property value and produces an Umbraco property value.
/// </summary>
/// <param name="value">The artifact property value.</param>
/// <returns>The parsed value.</returns>
/// <remarks>Turns {{localLink:umb://{type}/{id}}} into {{localLink:1234}}.</remarks>
[Obsolete("Please use the overload taking all parameters. This method will be removed in Umbraco 14.")]
string FromArtifact(string value);
/// <summary>
/// Parses an artifact property value and produces an Umbraco property value.
/// </summary>
/// <param name="value">The artifact property value.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>The parsed value.</returns>
/// <remarks>Turns {{localLink:umb://{type}/{id}}} into {{localLink:1234}}.</remarks>
#pragma warning disable CS0618 // Type or member is obsolete
string FromArtifact(string value, IContextCache contextCache) => FromArtifact(value);
#pragma warning restore CS0618 // Type or member is obsolete
}

View File

@@ -8,15 +8,38 @@ public interface IMacroParser
/// <param name="value">Property value.</param>
/// <param name="dependencies">A list of dependencies.</param>
/// <returns>Parsed value.</returns>
[Obsolete("Please use the overload taking all parameters. This method will be removed in Umbraco 14.")]
string ToArtifact(string value, ICollection<Udi> dependencies);
/// <summary>
/// Parses an Umbraco property value and produces an artifact property value.
/// </summary>
/// <param name="value">Property value.</param>
/// <param name="dependencies">A list of dependencies.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>Parsed value.</returns>
#pragma warning disable CS0618 // Type or member is obsolete
string ToArtifact(string value, ICollection<Udi> dependencies, IContextCache contextCache) => ToArtifact(value, dependencies);
#pragma warning restore CS0618 // Type or member is obsolete
/// <summary>
/// Parses an artifact property value and produces an Umbraco property value.
/// </summary>
/// <param name="value">Artifact property value.</param>
/// <returns>Parsed value.</returns>
[Obsolete("Please use the overload taking all parameters. This method will be removed in Umbraco 14.")]
string FromArtifact(string value);
/// <summary>
/// Parses an artifact property value and produces an Umbraco property value.
/// </summary>
/// <param name="value">Artifact property value.</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>Parsed value.</returns>
#pragma warning disable CS0618 // Type or member is obsolete
string FromArtifact(string value, IContextCache contextCache) => FromArtifact(value);
#pragma warning restore CS0618 // Type or member is obsolete
/// <summary>
/// Tries to replace the value of the attribute/parameter with a value containing a converted identifier.
/// </summary>
@@ -25,5 +48,20 @@ public interface IMacroParser
/// <param name="dependencies">Collection to add dependencies to when performing ToArtifact</param>
/// <param name="direction">Indicates which action is being performed (to or from artifact)</param>
/// <returns>Value with converted identifiers</returns>
[Obsolete("Please use the overload taking all parameters. This method will be removed in Umbraco 14.")]
string ReplaceAttributeValue(string value, string editorAlias, ICollection<Udi> dependencies, Direction direction);
/// <summary>
/// Tries to replace the value of the attribute/parameter with a value containing a converted identifier.
/// </summary>
/// <param name="value">Value to attempt to convert</param>
/// <param name="editorAlias">Alias of the editor used for the parameter</param>
/// <param name="dependencies">Collection to add dependencies to when performing ToArtifact</param>
/// <param name="direction">Indicates which action is being performed (to or from artifact)</param>
/// <param name="contextCache">The context cache.</param>
/// <returns>Value with converted identifiers</returns>
string ReplaceAttributeValue(string value, string editorAlias, ICollection<Udi> dependencies, Direction direction, IContextCache contextCache)
#pragma warning disable CS0618 // Type or member is obsolete
=> ReplaceAttributeValue(value, editorAlias, dependencies, direction);
#pragma warning restore CS0618 // Type or member is obsolete
}