Browse Source

Improvements to templates and markdown editor.

pull/881/head
Sebastian 4 years ago
parent
commit
3245593c20
  1. 1
      backend/src/Squidex.Domain.Apps.Core.Model/Apps/Editor.cs
  2. 4
      backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/StringReferenceExtractor.cs
  3. 3
      backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/StringLogger.cs
  4. 6
      backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/TemplateCommandMiddleware.cs
  5. 2
      backend/src/Squidex.Domain.Apps.Entities/Squidex.Domain.Apps.Entities.csproj
  6. 2
      backend/src/Squidex/Squidex.csproj
  7. 23
      frontend/src/app/shared/components/forms/markdown-editor.component.ts

1
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 #pragma warning disable SA1313 // Parameter names should begin with lower-case letter
namespace Squidex.Domain.Apps.Core.Apps namespace Squidex.Domain.Apps.Core.Apps
{ {
public sealed record Editor(string Name, string Url) public sealed record Editor(string Name, string Url)

4
backend/src/Squidex.Domain.Apps.Core.Operations/ExtractReferenceIds/StringReferenceExtractor.cs

@ -40,7 +40,7 @@ namespace Squidex.Domain.Apps.Core.ExtractReferenceIds
baseUrl = Regex.Escape(baseUrl); baseUrl = Regex.Escape(baseUrl);
AddContentPattern(baseUrl + @"(.+)\/(.+)\/(?<Id>[a-z0-9\-_9]+)"); AddContentPattern(baseUrl + @"([^\/]+)\/([^\/]+)\/(?<Id>[a-z0-9\-_9]+)");
} }
private void AddAssetUrlPatterns(string baseUrl) private void AddAssetUrlPatterns(string baseUrl)
@ -58,7 +58,7 @@ namespace Squidex.Domain.Apps.Core.ExtractReferenceIds
baseUrl = Regex.Escape(baseUrl); baseUrl = Regex.Escape(baseUrl);
AddAssetPattern(baseUrl + @"(?<Id>[a-z0-9\-_9]+)"); AddAssetPattern(baseUrl + @"(?<Id>[a-z0-9\-_9]+)");
AddAssetPattern(baseUrl + @"(.+)\/(?<Id>[a-z0-9\-_9]+)"); AddAssetPattern(baseUrl + @"([^\/]+)\/(?<Id>[a-z0-9\-_9]+)");
} }
private void AddAssetPattern(string pattern) private void AddAssetPattern(string pattern)

3
backend/src/Squidex.Domain.Apps.Entities/Apps/Templates/StringLogger.cs

@ -21,10 +21,11 @@ namespace Squidex.Domain.Apps.Entities.Apps.Templates
private readonly List<string> errors = new List<string>(); private readonly List<string> errors = new List<string>();
private string startedLine = string.Empty; private string startedLine = string.Empty;
public bool CanWriteToSameLine => false;
public StringLogger(string template, ISemanticLog log) public StringLogger(string template, ISemanticLog log)
{ {
this.template = template; this.template = template;
this.log = log; this.log = log;
} }

6
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.FileSystem;
using Squidex.CLI.Commands.Implementation.Sync; using Squidex.CLI.Commands.Implementation.Sync;
using Squidex.CLI.Commands.Implementation.Sync.App; 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.Assets;
using Squidex.CLI.Commands.Implementation.Sync.Contents;
using Squidex.CLI.Commands.Implementation.Sync.Rules; using Squidex.CLI.Commands.Implementation.Sync.Rules;
using Squidex.CLI.Commands.Implementation.Sync.Schemas; using Squidex.CLI.Commands.Implementation.Sync.Schemas;
using Squidex.CLI.Commands.Implementation.Sync.Workflows; using Squidex.CLI.Commands.Implementation.Sync.Workflows;
@ -85,9 +86,10 @@ namespace Squidex.Domain.Apps.Entities.Apps.Templates
new RulesSynchronizer(cliLog), new RulesSynchronizer(cliLog),
new SchemasSynchronizer(cliLog), new SchemasSynchronizer(cliLog),
new WorkflowsSynchronizer(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); await target.ImportAsync(syncService, syncOptions, session);
} }

2
backend/src/Squidex.Domain.Apps.Entities/Squidex.Domain.Apps.Entities.csproj

@ -34,7 +34,7 @@
<PackageReference Include="Microsoft.Orleans.Core" Version="3.6.0" /> <PackageReference Include="Microsoft.Orleans.Core" Version="3.6.0" />
<PackageReference Include="Notifo.SDK" Version="1.0.1" /> <PackageReference Include="Notifo.SDK" Version="1.0.1" />
<PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" /> <PackageReference Include="RefactoringEssentials" Version="5.6.0" PrivateAssets="all" />
<PackageReference Include="Squidex.CLI.Core" Version="8.11.0" /> <PackageReference Include="Squidex.CLI.Core" Version="8.16.0" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />
<PackageReference Include="System.Collections.Immutable" Version="6.0.0" /> <PackageReference Include="System.Collections.Immutable" Version="6.0.0" />
<PackageReference Include="System.ValueTuple" Version="4.5.0" /> <PackageReference Include="System.ValueTuple" Version="4.5.0" />

2
backend/src/Squidex/Squidex.csproj

@ -80,7 +80,7 @@
<PackageReference Include="Squidex.Assets.S3" Version="3.0.0" /> <PackageReference Include="Squidex.Assets.S3" Version="3.0.0" />
<PackageReference Include="Squidex.Assets.TusAdapter" Version="3.0.0" /> <PackageReference Include="Squidex.Assets.TusAdapter" Version="3.0.0" />
<PackageReference Include="Squidex.Caching.Orleans" Version="1.9.0" /> <PackageReference Include="Squidex.Caching.Orleans" Version="1.9.0" />
<PackageReference Include="Squidex.ClientLibrary" Version="8.18.0" /> <PackageReference Include="Squidex.ClientLibrary" Version="8.21.0" />
<PackageReference Include="Squidex.Hosting" Version="2.13.0" /> <PackageReference Include="Squidex.Hosting" Version="2.13.0" />
<PackageReference Include="Squidex.OpenIddict.MongoDb" Version="4.0.1-dev" /> <PackageReference Include="Squidex.OpenIddict.MongoDb" Version="4.0.1-dev" />
<PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" /> <PackageReference Include="StyleCop.Analyzers" Version="1.1.118" PrivateAssets="all" />

23
frontend/src/app/shared/components/forms/markdown-editor.component.ts

@ -112,7 +112,7 @@ export class MarkdownEditorComponent extends StatefulControlComponent<State, str
this.resourceLoader.loadLocalStyle('dependencies/font-awesome/css/font-awesome.min.css'), this.resourceLoader.loadLocalStyle('dependencies/font-awesome/css/font-awesome.min.css'),
this.resourceLoader.loadLocalScript('dependencies/simplemde/simplemde.min.js'), this.resourceLoader.loadLocalScript('dependencies/simplemde/simplemde.min.js'),
]).then(() => { ]).then(() => {
this.simplemde = new SimpleMDE({ const options = {
previewRender: (text: string) => { previewRender: (text: string) => {
return marked(text, { pedantic: true }); return marked(text, { pedantic: true });
}, },
@ -193,18 +193,21 @@ export class MarkdownEditorComponent extends StatefulControlComponent<State, str
action: this.showAssetSelector, action: this.showAssetSelector,
className: 'icon-assets icon-bold', className: 'icon-assets icon-bold',
title: 'Insert Assets', title: 'Insert Assets',
}, }
this.schemaIds && this.schemaIds.length > 0 ? ],
{ element: this.editor.nativeElement,
};
if (this.schemaIds && this.schemaIds.length > 0) {
options.toolbar.push({
name: 'contents', name: 'contents',
action: this.showContentsSelector, action: this.showContentsSelector,
className: 'icon-contents icon-bold', className: 'icon-contents icon-bold',
title: 'Insert Contents', title: 'Insert Contents',
} : null,
],
element: this.editor.nativeElement,
}); });
}
this.simplemde = new SimpleMDE(options);
this.simplemde.value(this.value || ''); this.simplemde.value(this.value || '');
this.simplemde.codemirror.setOption('readOnly', this.snapshot.isDisabled); this.simplemde.codemirror.setOption('readOnly', this.snapshot.isDisabled);
@ -340,7 +343,7 @@ export class MarkdownEditorComponent extends StatefulControlComponent<State, str
.join(', ') .join(', ')
|| 'content'; || 'content';
return `[${name}](${this.apiUrl.buildUrl(content._links['self'].href)}')`; return `[${name}](${this.apiUrl.buildUrl(content._links['self'].href)})`;
} }
private buildAssetMarkup(asset: AssetDto) { private buildAssetMarkup(asset: AssetDto) {
@ -349,9 +352,9 @@ export class MarkdownEditorComponent extends StatefulControlComponent<State, str
if (asset.type === 'Image' || asset.mimeType === 'image/svg+xml' || asset.fileName.endsWith('.svg')) { if (asset.type === 'Image' || asset.mimeType === 'image/svg+xml' || asset.fileName.endsWith('.svg')) {
return `![${name}](${asset.fullUrl(this.apiUrl)} '${name}')`; return `![${name}](${asset.fullUrl(this.apiUrl)} '${name}')`;
} else if (asset.type === 'Video') { } else if (asset.type === 'Video') {
return `[${name}](${asset.fullUrl(this.apiUrl)}')`; return `[${name}](${asset.fullUrl(this.apiUrl)})`;
} else { } else {
return `[${name}](${asset.fullUrl(this.apiUrl)}')`; return `[${name}](${asset.fullUrl(this.apiUrl)})`;
} }
} }
} }

Loading…
Cancel
Save