From 3245593c20c3f27c5963a0a91924645b5f824bad Mon Sep 17 00:00:00 2001 From: Sebastian Date: Sat, 21 May 2022 18:44:51 +0200 Subject: [PATCH] Improvements to templates and markdown editor. --- .../Apps/Editor.cs | 1 - .../StringReferenceExtractor.cs | 4 +-- .../Apps/Templates/StringLogger.cs | 3 +- .../Templates/TemplateCommandMiddleware.cs | 6 ++-- .../Squidex.Domain.Apps.Entities.csproj | 2 +- backend/src/Squidex/Squidex.csproj | 2 +- .../forms/markdown-editor.component.ts | 29 ++++++++++--------- 7 files changed, 26 insertions(+), 21 deletions(-) diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/Editor.cs b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/Editor.cs index 731b5ac30..5ec9ab71a 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Model/Apps/Editor.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Model/Apps/Editor.cs @@ -7,7 +7,6 @@ #pragma warning disable SA1313 // Parameter names should begin with lower-case letter - namespace Squidex.Domain.Apps.Core.Apps { public sealed record Editor(string Name, string Url) diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/StringReferenceExtractor.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/StringReferenceExtractor.cs index bd8f2a173..cc1ec4482 100644 --- a/backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/StringReferenceExtractor.cs +++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/StringReferenceExtractor.cs @@ -40,7 +40,7 @@ namespace Squidex.Domain.Apps.Core.ExtractReferenceIds baseUrl = Regex.Escape(baseUrl); - AddContentPattern(baseUrl + @"(.+)\/(.+)\/(?[a-z0-9\-_9]+)"); + AddContentPattern(baseUrl + @"([^\/]+)\/([^\/]+)\/(?[a-z0-9\-_9]+)"); } private void AddAssetUrlPatterns(string baseUrl) @@ -58,7 +58,7 @@ namespace Squidex.Domain.Apps.Core.ExtractReferenceIds baseUrl = Regex.Escape(baseUrl); AddAssetPattern(baseUrl + @"(?[a-z0-9\-_9]+)"); - AddAssetPattern(baseUrl + @"(.+)\/(?[a-z0-9\-_9]+)"); + AddAssetPattern(baseUrl + @"([^\/]+)\/(?[a-z0-9\-_9]+)"); } private void AddAssetPattern(string pattern) diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/StringLogger.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/StringLogger.cs index 4f61b8bbf..fde9c1f7e 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/StringLogger.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/StringLogger.cs @@ -21,10 +21,11 @@ namespace Squidex.Domain.Apps.Entities.Apps.Templates private readonly List errors = new List(); private string startedLine = string.Empty; + public bool CanWriteToSameLine => false; + public StringLogger(string template, ISemanticLog log) { this.template = template; - this.log = log; } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/TemplateCommandMiddleware.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/TemplateCommandMiddleware.cs index 717d5daef..538a17a21 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/TemplateCommandMiddleware.cs +++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/TemplateCommandMiddleware.cs @@ -11,8 +11,9 @@ using Squidex.CLI.Commands.Implementation; using Squidex.CLI.Commands.Implementation.FileSystem; using Squidex.CLI.Commands.Implementation.Sync; using Squidex.CLI.Commands.Implementation.Sync.App; -using Squidex.CLI.Commands.Implementation.Sync.AssertFolders; +using Squidex.CLI.Commands.Implementation.Sync.AssetFolders; using Squidex.CLI.Commands.Implementation.Sync.Assets; +using Squidex.CLI.Commands.Implementation.Sync.Contents; using Squidex.CLI.Commands.Implementation.Sync.Rules; using Squidex.CLI.Commands.Implementation.Sync.Schemas; using Squidex.CLI.Commands.Implementation.Sync.Workflows; @@ -85,9 +86,10 @@ namespace Squidex.Domain.Apps.Entities.Apps.Templates new RulesSynchronizer(cliLog), new SchemasSynchronizer(cliLog), new WorkflowsSynchronizer(cliLog), + new ContentsSynchronizer(cliLog) }; - foreach (var target in targets.OrderBy(x => x.Name)) + foreach (var target in targets) { await target.ImportAsync(syncService, syncOptions, session); } diff --git a/backend/src/Squidex.Domain.Apps.Entities/Squidex.Domain.Apps.Entities.csproj b/backend/src/Squidex.Domain.Apps.Entities/Squidex.Domain.Apps.Entities.csproj index 10e83dbbd..34625f0c0 100644 --- a/backend/src/Squidex.Domain.Apps.Entities/Squidex.Domain.Apps.Entities.csproj +++ b/backend/src/Squidex.Domain.Apps.Entities/Squidex.Domain.Apps.Entities.csproj @@ -34,7 +34,7 @@ - + diff --git a/backend/src/Squidex/Squidex.csproj b/backend/src/Squidex/Squidex.csproj index 1e9658992..91cf649e4 100644 --- a/backend/src/Squidex/Squidex.csproj +++ b/backend/src/Squidex/Squidex.csproj @@ -80,7 +80,7 @@ - + diff --git a/frontend/src/app/shared/components/forms/markdown-editor.component.ts b/frontend/src/app/shared/components/forms/markdown-editor.component.ts index cda460cf9..aa0f05252 100644 --- a/frontend/src/app/shared/components/forms/markdown-editor.component.ts +++ b/frontend/src/app/shared/components/forms/markdown-editor.component.ts @@ -112,7 +112,7 @@ export class MarkdownEditorComponent extends StatefulControlComponent { - this.simplemde = new SimpleMDE({ + const options = { previewRender: (text: string) => { return marked(text, { pedantic: true }); }, @@ -193,18 +193,21 @@ export class MarkdownEditorComponent extends StatefulControlComponent 0 ? - { - name: 'contents', - action: this.showContentsSelector, - className: 'icon-contents icon-bold', - title: 'Insert Contents', - } : null, + } ], element: this.editor.nativeElement, - }); + }; + + if (this.schemaIds && this.schemaIds.length > 0) { + options.toolbar.push({ + name: 'contents', + action: this.showContentsSelector, + className: 'icon-contents icon-bold', + title: 'Insert Contents', + }); + } + this.simplemde = new SimpleMDE(options); this.simplemde.value(this.value || ''); this.simplemde.codemirror.setOption('readOnly', this.snapshot.isDisabled); @@ -340,7 +343,7 @@ export class MarkdownEditorComponent extends StatefulControlComponent