Browse Source

Fix editor bugs.

pull/1067/head
Sebastian Stehle 2 years ago
parent
commit
b127d5f546
  1. 2
      backend/src/Squidex.Domain.Apps.Core.Model/Contents/RichTextNode.cs
  2. 42
      backend/src/Squidex.Web/ApiExceptionConverter.cs
  3. 204
      backend/src/Squidex/wwwroot/editor/squidex-editor.js
  4. 10
      frontend/src/app/framework/angular/forms/error-validator.ts

2
backend/src/Squidex.Domain.Apps.Core.Model/Contents/RichTextNode.cs

@ -127,6 +127,8 @@ public sealed class RichTextNode : INode
}
}
currentState = state;
return isValid;
}

42
backend/src/Squidex.Web/ApiExceptionConverter.cs

@ -164,48 +164,16 @@ public static class ApiExceptionConverter
public static IEnumerable<string> ToErrors(IEnumerable<ValidationError> errors)
{
static string FixPropertyName(string property)
{
property = property.Trim();
if (property.Length == 0)
{
return property;
}
var prevChar = 0;
var builder = new StringBuilder(property.Length);
builder.Append(char.ToLowerInvariant(property[0]));
foreach (var character in property.Skip(1))
{
if (prevChar == '.')
{
builder.Append(char.ToLowerInvariant(character));
}
else
{
builder.Append(character);
}
prevChar = character;
}
return builder.ToString();
}
return errors.Select(e =>
{
var message = e.Message;
if (e.PropertyNames?.Any() == true)
{
return $"{string.Join(", ", e.PropertyNames.Select(FixPropertyName))}: {e.Message}";
}
else
{
return e.Message;
message = $"{string.Join(", ", e.PropertyNames)}: {message}";
}
return message;
});
}
}

204
backend/src/Squidex/wwwroot/editor/squidex-editor.js

File diff suppressed because one or more lines are too long

10
frontend/src/app/framework/angular/forms/error-validator.ts

@ -11,10 +11,10 @@ import { getControlPath } from './forms-helper';
export class ErrorValidator {
private errorsCache: { [path: string]: { value: any } } = {};
private error: ErrorDto | undefined | null;
private errorSource: ErrorDto | undefined | null;
public validator: ValidatorFn = control => {
if (!this.error) {
if (!this.errorSource) {
return null;
}
@ -35,8 +35,8 @@ export class ErrorValidator {
const errors: string[] = [];
if (this.error.details) {
for (const details of this.error.details) {
if (this.errorSource.details) {
for (const details of this.errorSource.details) {
for (const property of details.properties) {
if (property.startsWith(path)) {
const subProperty = property.substring(path.length);
@ -73,6 +73,6 @@ export class ErrorValidator {
public setError(error: ErrorDto | undefined | null) {
this.errorsCache = {};
this.error = error;
this.errorSource = error;
}
}

Loading…
Cancel
Save