diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml
index 21bf11225..181948a6b 100644
--- a/.github/workflows/dev.yml
+++ b/.github/workflows/dev.yml
@@ -25,7 +25,7 @@ jobs:
uses: docker/setup-qemu-action@v3.0.0
- name: Prepare - Setup Docker Buildx
- uses: docker/setup-buildx-action@v3.1.0
+ uses: docker/setup-buildx-action@v3.2.0
- name: Prepare - Setup Node
uses: actions/setup-node@v4.0.2
@@ -33,7 +33,7 @@ jobs:
node-version: 18
- name: Build - BUILD
- uses: docker/build-push-action@v5.2.0
+ uses: docker/build-push-action@v5.3.0
with:
load: true
build-args: "SQUIDEX__RUNTIME__VERSION=7.0.0-dev-${{ env.BUILD_NUMBER }}"
@@ -130,7 +130,7 @@ jobs:
- name: Publish - Login to Docker Hub
if: github.event_name != 'pull_request'
- uses: docker/login-action@v3.0.0
+ uses: docker/login-action@v3.1.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
diff --git a/.github/workflows/make-screenshots.yml b/.github/workflows/make-screenshots.yml
index f5cfc7d0a..0232ebd55 100644
--- a/.github/workflows/make-screenshots.yml
+++ b/.github/workflows/make-screenshots.yml
@@ -15,7 +15,7 @@ jobs:
uses: docker/setup-qemu-action@v3.0.0
- name: Prepare - Setup Docker Buildx
- uses: docker/setup-buildx-action@v3.1.0
+ uses: docker/setup-buildx-action@v3.2.0
- name: Prepare - Setup Node
uses: actions/setup-node@v4.0.2
@@ -23,7 +23,7 @@ jobs:
node-version: 18
- name: Build - BUILD
- uses: docker/build-push-action@v5.2.0
+ uses: docker/build-push-action@v5.3.0
with:
load: true
cache-from: type=gha
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index cd593d635..26d814f02 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -20,7 +20,7 @@ jobs:
uses: docker/setup-qemu-action@v3.0.0
- name: Prepare - Setup Docker Buildx
- uses: docker/setup-buildx-action@v3.1.0
+ uses: docker/setup-buildx-action@v3.2.0
- name: Prepare - Setup Node
uses: actions/setup-node@v4.0.2
@@ -28,7 +28,7 @@ jobs:
node-version: 18
- name: Build - BUILD
- uses: docker/build-push-action@v5.2.0
+ uses: docker/build-push-action@v5.3.0
with:
load: true
build-args: "SQUIDEX__BUILD__VERSION=${{ env.GITHUB_REF_SLUG }},SQUIDEX__RUNTIME__VERSION=${{ env.GITHUB_REF_SLUG }}"
@@ -131,7 +131,7 @@ jobs:
fi
- name: Publish - Login to Docker Hub
- uses: docker/login-action@v3.0.0
+ uses: docker/login-action@v3.1.0
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
@@ -167,7 +167,7 @@ jobs:
- name: Release - Get Changelog Entry
id: changelog_reader
- uses: mindsers/changelog-reader-action@v2.2.2
+ uses: mindsers/changelog-reader-action@v2.2.3
with:
version: ${{ env.GITHUB_REF_SLUG }}
path: ./CHANGELOG.md
diff --git a/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj b/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj
index 674e6bb5a..b5f0f9942 100644
--- a/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj
+++ b/backend/extensions/Squidex.Extensions/Squidex.Extensions.csproj
@@ -16,10 +16,10 @@
-
+
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/backend/src/Migrations/Migrations.csproj b/backend/src/Migrations/Migrations.csproj
index 8fc18e7dc..2aff5d219 100644
--- a/backend/src/Migrations/Migrations.csproj
+++ b/backend/src/Migrations/Migrations.csproj
@@ -6,7 +6,7 @@
enable
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj b/backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj
index 32743858a..1702a34ed 100644
--- a/backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj
+++ b/backend/src/Squidex.Domain.Apps.Core.Model/Squidex.Domain.Apps.Core.Model.csproj
@@ -12,7 +12,7 @@
True
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/UpdateValues.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/UpdateValues.cs
new file mode 100644
index 000000000..00ba891cf
--- /dev/null
+++ b/backend/src/Squidex.Domain.Apps.Core.Operations/ConvertContent/UpdateValues.cs
@@ -0,0 +1,56 @@
+// ==========================================================================
+// Squidex Headless CMS
+// ==========================================================================
+// Copyright (c) Squidex UG (haftungsbeschraenkt)
+// All rights reserved. Licensed under the MIT license.
+// ==========================================================================
+
+using Squidex.Domain.Apps.Core.Contents;
+using Squidex.Domain.Apps.Core.Schemas;
+using Squidex.Domain.Apps.Core.Scripting;
+using Squidex.Infrastructure.Json.Objects;
+
+namespace Squidex.Domain.Apps.Core.ConvertContent;
+
+public sealed class UpdateValues : IContentValueConverter
+{
+ private readonly ContentData existingData;
+ private readonly IScriptEngine scriptEngine;
+ private ScriptVars? vars;
+
+ public UpdateValues(ContentData existingData, IScriptEngine scriptEngine)
+ {
+ this.existingData = existingData;
+ this.scriptEngine = scriptEngine;
+ }
+
+ public (bool Remove, JsonValue) ConvertValue(IField field, JsonValue source, IField? parent)
+ {
+ if (source.Value is not JsonObject jsonObject)
+ {
+ return (false, source);
+ }
+
+ if (jsonObject.TryGetValue("$unset", out var value1) && !Equals(value1.Value, false))
+ {
+ return (true, source);
+ }
+
+ if (!jsonObject.TryGetValue("$update", out var value2) || value2.Value is not string update)
+ {
+ return (false, source);
+ }
+
+ var options = new ScriptOptions { Readonly = true };
+
+ vars ??= new ScriptVars
+ {
+ ["$data"] = existingData,
+ ["$self"] = jsonObject
+ };
+
+ var result = scriptEngine.Execute(vars, update, options);
+
+ return (false, result);
+ }
+}
diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentFieldProperty.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentFieldProperty.cs
index cb5627085..452d5f888 100644
--- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentFieldProperty.cs
+++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/ContentFieldProperty.cs
@@ -7,6 +7,7 @@
using System.Diagnostics;
using Jint.Native;
+using Squidex.Domain.Apps.Core.Scripting.Internal;
using Squidex.Infrastructure.Json.Objects;
namespace Squidex.Domain.Apps.Core.Scripting.ContentWrapper;
diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Extensions/StringAsyncJintExtension.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Extensions/StringAsyncJintExtension.cs
index 11214ae30..86dfe41f0 100644
--- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Extensions/StringAsyncJintExtension.cs
+++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Extensions/StringAsyncJintExtension.cs
@@ -7,8 +7,8 @@
using Jint.Native;
using Jint.Runtime;
+using Squidex.AI;
using Squidex.Domain.Apps.Core.Properties;
-using Squidex.Text.ChatBots;
using Squidex.Text.Translations;
#pragma warning disable CA1826 // Do not use Enumerable methods on indexable collections
@@ -61,17 +61,9 @@ public sealed class StringAsyncJintExtension : IJintExtension, IScriptDescriptor
return;
}
- var conversationId = Guid.NewGuid().ToString();
- try
- {
- var result = await chatAgent.PromptAsync(conversationId, prompt, ct);
+ var result = await chatAgent.PromptAsync(prompt, ct: ct);
- scheduler.Run(callback, JsValue.FromObject(context.Engine, result.Text));
- }
- finally
- {
- await chatAgent.StopConversationAsync(conversationId);
- }
+ scheduler.Run(callback, JsValue.FromObject(context.Engine, result.Text));
}
catch (Exception ex)
{
diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/JintObjectConverter.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/JintObjectConverter.cs
index df6981dd5..e7a5d8019 100644
--- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/JintObjectConverter.cs
+++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/JintObjectConverter.cs
@@ -14,6 +14,7 @@ using NodaTime;
using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Core.Scripting.ContentWrapper;
using Squidex.Infrastructure;
+using Squidex.Infrastructure.Json.Objects;
using Squidex.Shared.Users;
namespace Squidex.Domain.Apps.Core.Scripting.Internal;
@@ -44,6 +45,9 @@ public sealed class JintObjectConverter : IObjectConverter
case ClaimsPrincipal principal:
result = JintUser.Create(engine, principal);
return true;
+ case JsonValue jsonValue:
+ result = JsonMapper.Map(jsonValue, engine);
+ return true;
case DomainId domainId:
result = domainId.ToString();
return true;
diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/JsonMapper.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/JsonMapper.cs
similarity index 98%
rename from backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/JsonMapper.cs
rename to backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/JsonMapper.cs
index e2799033a..5bf3ee5fc 100644
--- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ContentWrapper/JsonMapper.cs
+++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/Internal/JsonMapper.cs
@@ -14,7 +14,7 @@ using Jint.Runtime.Interop;
using Squidex.Infrastructure;
using Squidex.Infrastructure.Json.Objects;
-namespace Squidex.Domain.Apps.Core.Scripting.ContentWrapper;
+namespace Squidex.Domain.Apps.Core.Scripting.Internal;
public static class JsonMapper
{
diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs
index 82081437a..69027bacd 100644
--- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs
+++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/JintScriptEngine.cs
@@ -152,8 +152,9 @@ public sealed class JintScriptEngine : IScriptEngine, IScriptDescriptor
var engine = new Engine(engineOptions =>
{
- engineOptions.SetTypeConverter(engine => new CustomClrConverter(engine));
engineOptions.AddObjectConverter(JintObjectConverter.Instance);
+ engineOptions.AllowClrWrite(!options.Readonly);
+ engineOptions.SetTypeConverter(engine => new CustomClrConverter(engine));
engineOptions.SetReferencesResolver(NullPropagation.Instance);
engineOptions.Strict();
diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ScriptOptions.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ScriptOptions.cs
index 58d0d46d9..2bbcb80f6 100644
--- a/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ScriptOptions.cs
+++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Scripting/ScriptOptions.cs
@@ -14,4 +14,6 @@ public record struct ScriptOptions
public bool CanDisallow { get; set; }
public bool AsContext { get; set; }
+
+ public bool Readonly { get; set; }
}
diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj b/backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj
index 4803fe9d3..0da4877ec 100644
--- a/backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj
+++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Squidex.Domain.Apps.Core.Operations.csproj
@@ -18,17 +18,18 @@
-
+
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
+
diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/AssetSubscription.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/AssetSubscription.cs
index bdd31a1f6..109331a8d 100644
--- a/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/AssetSubscription.cs
+++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/AssetSubscription.cs
@@ -7,15 +7,15 @@
using Squidex.Domain.Apps.Core.Rules.EnrichedEvents;
using Squidex.Domain.Apps.Events.Assets;
-using Squidex.Shared;
+using Squidex.Messaging.Subscriptions;
namespace Squidex.Domain.Apps.Core.Subscriptions;
-public sealed class AssetSubscription : AppSubscription
+public sealed class AssetSubscription : ISubscription
{
- public EnrichedAssetEventType? Type { get; set; }
+ public EnrichedAssetEventType? Type { get; init; }
- public override ValueTask ShouldHandle(object message)
+ public ValueTask ShouldHandle(object message)
{
return new ValueTask(ShouldHandleCore(message));
}
@@ -25,24 +25,14 @@ public sealed class AssetSubscription : AppSubscription
switch (message)
{
case EnrichedAssetEvent enrichedAssetEvent:
- return ShouldHandle(enrichedAssetEvent);
+ return CheckType(enrichedAssetEvent);
case AssetEvent assetEvent:
- return ShouldHandle(assetEvent);
+ return CheckType(assetEvent);
default:
return false;
}
}
- private bool ShouldHandle(EnrichedAssetEvent @event)
- {
- return CheckType(@event) && CheckPermission(@event.AppId.Name);
- }
-
- private bool ShouldHandle(AssetEvent @event)
- {
- return CheckType(@event) && CheckPermission(@event.AppId.Name);
- }
-
private bool CheckType(EnrichedAssetEvent @event)
{
return Type == null || Type.Value == @event.Type;
@@ -64,11 +54,4 @@ public sealed class AssetSubscription : AppSubscription
return true;
}
}
-
- private bool CheckPermission(string appName)
- {
- var permission = PermissionIds.ForApp(PermissionIds.AppAssetsRead, appName);
-
- return Permissions.Includes(permission);
- }
}
diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/ContentSubscription.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/ContentSubscription.cs
index 052527d70..be8367885 100644
--- a/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/ContentSubscription.cs
+++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/ContentSubscription.cs
@@ -7,17 +7,21 @@
using Squidex.Domain.Apps.Core.Rules.EnrichedEvents;
using Squidex.Domain.Apps.Events.Contents;
+using Squidex.Infrastructure.Security;
+using Squidex.Messaging.Subscriptions;
using Squidex.Shared;
namespace Squidex.Domain.Apps.Core.Subscriptions;
-public sealed class ContentSubscription : AppSubscription
+public sealed class ContentSubscription : ISubscription
{
+ public PermissionSet Permissions { get; set; }
+
public string? SchemaName { get; set; }
public EnrichedContentEventType? Type { get; set; }
- public override ValueTask ShouldHandle(object message)
+ public ValueTask ShouldHandle(object message)
{
return new ValueTask(ShouldHandleCore(message));
}
diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/EventMessageEvaluator.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/EventMessageEvaluator.cs
deleted file mode 100644
index cc641d3c0..000000000
--- a/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/EventMessageEvaluator.cs
+++ /dev/null
@@ -1,86 +0,0 @@
-// ==========================================================================
-// Squidex Headless CMS
-// ==========================================================================
-// Copyright (c) Squidex UG (haftungsbeschraenkt)
-// All rights reserved. Licensed under the MIT license.
-// ==========================================================================
-
-using Squidex.Domain.Apps.Events;
-using Squidex.Infrastructure;
-using Squidex.Messaging.Subscriptions;
-
-namespace Squidex.Domain.Apps.Core.Subscriptions;
-
-public sealed class EventMessageEvaluator : IMessageEvaluator
-{
- private readonly Dictionary> subscriptions = [];
- private readonly ReaderWriterLockSlim readerWriterLock = new ReaderWriterLockSlim();
-
- public async ValueTask> GetSubscriptionsAsync(object message)
- {
- if (message is not AppEvent appEvent)
- {
- return Enumerable.Empty();
- }
-
- readerWriterLock.EnterReadLock();
- try
- {
- List? result = null;
-
- if (subscriptions.TryGetValue(appEvent.AppId.Id, out var appSubscriptions))
- {
- foreach (var (id, subscription) in appSubscriptions)
- {
- if (await subscription.ShouldHandle(appEvent))
- {
- result ??= [];
- result.Add(id);
- }
- }
- }
-
- return result ?? Enumerable.Empty();
- }
- finally
- {
- readerWriterLock.ExitReadLock();
- }
- }
-
- public void SubscriptionAdded(Guid id, ISubscription subscription)
- {
- if (subscription is not AppSubscription appSubscription)
- {
- return;
- }
-
- readerWriterLock.EnterWriteLock();
- try
- {
- subscriptions.GetOrAddNew(appSubscription.AppId)[id] = appSubscription;
- }
- finally
- {
- readerWriterLock.ExitWriteLock();
- }
- }
-
- public void SubscriptionRemoved(Guid id, ISubscription subscription)
- {
- if (subscription is not AppSubscription appSubscription)
- {
- return;
- }
-
- readerWriterLock.EnterWriteLock();
- try
- {
- subscriptions.GetOrAddDefault(appSubscription.AppId)?.Remove(id);
- }
- finally
- {
- readerWriterLock.ExitWriteLock();
- }
- }
-}
diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/EventMessageWrapper.cs b/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/EventMessageWrapper.cs
index 0afc04bba..a97c124a8 100644
--- a/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/EventMessageWrapper.cs
+++ b/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/EventMessageWrapper.cs
@@ -13,31 +13,29 @@ namespace Squidex.Domain.Apps.Core.Subscriptions;
public sealed class EventMessageWrapper : IPayloadWrapper
{
- private readonly IEnumerable subscriptionEventCreators;
+ private readonly IEnumerable creators;
public Envelope Event { get; }
object IPayloadWrapper.Message => Event.Payload;
- public EventMessageWrapper(Envelope @event, IEnumerable subscriptionEventCreators)
+ public EventMessageWrapper(Envelope @event, IEnumerable creators)
{
Event = @event;
- this.subscriptionEventCreators = subscriptionEventCreators;
+ this.creators = creators;
}
public async ValueTask
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/AppSubscription.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/AppCacheOptions.cs
similarity index 50%
rename from backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/AppSubscription.cs
rename to backend/src/Squidex.Domain.Apps.Entities/Apps/AppCacheOptions.cs
index 838094e17..3a2cc07c8 100644
--- a/backend/src/Squidex.Domain.Apps.Core.Operations/Subscriptions/AppSubscription.cs
+++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/AppCacheOptions.cs
@@ -5,17 +5,9 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
-using Squidex.Infrastructure;
-using Squidex.Infrastructure.Security;
-using Squidex.Messaging.Subscriptions;
+namespace Squidex.Domain.Apps.Entities.Apps;
-namespace Squidex.Domain.Apps.Core.Subscriptions;
-
-public abstract class AppSubscription : ISubscription
+public sealed class AppCacheOptions
{
- public DomainId AppId { get; set; }
-
- public PermissionSet Permissions { get; set; }
-
- public abstract ValueTask ShouldHandle(object message);
+ public TimeSpan CacheDuration { get; set; }
}
diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/AppPermanentDeleter.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/AppPermanentDeleter.cs
index 496ccd2e9..0aa18acbc 100644
--- a/backend/src/Squidex.Domain.Apps.Entities/Apps/AppPermanentDeleter.cs
+++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/AppPermanentDeleter.cs
@@ -35,9 +35,9 @@ public sealed class AppPermanentDeleter : IEventConsumer
];
}
- public bool Handles(StoredEvent @event)
+ public ValueTask HandlesAsync(StoredEvent @event)
{
- return consumingTypes.Contains(@event.Data.Type);
+ return new ValueTask(consumingTypes.Contains(@event.Data.Type));
}
public async Task On(Envelope @event)
diff --git a/backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs b/backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs
index d22e1be54..a0074ef0d 100644
--- a/backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs
+++ b/backend/src/Squidex.Domain.Apps.Entities/Apps/Indexes/AppsIndex.cs
@@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
+using Microsoft.Extensions.Options;
using Squidex.Caching;
using Squidex.Domain.Apps.Core.Apps;
using Squidex.Domain.Apps.Entities.Apps.Commands;
@@ -22,16 +23,18 @@ namespace Squidex.Domain.Apps.Entities.Apps.Indexes;
public sealed class AppsIndex : IAppsIndex, ICommandMiddleware, IInitializable
{
- private static readonly TimeSpan CacheDuration = TimeSpan.FromMinutes(5);
private readonly IAppRepository appRepository;
private readonly IReplicatedCache appCache;
+ private readonly AppCacheOptions options;
private readonly NameReservationState namesState;
public AppsIndex(IAppRepository appRepository, IReplicatedCache appCache,
- IPersistenceFactory persistenceFactory)
+ IPersistenceFactory persistenceFactory,
+ IOptions options)
{
this.appRepository = appRepository;
this.appCache = appCache;
+ this.options = options.Value;
namesState = new NameReservationState(persistenceFactory, "Apps");
}
@@ -180,12 +183,8 @@ public sealed class AppsIndex : IAppsIndex, ICommandMiddleware, IInitializable
private async Task CheckAppAsync(CreateApp command,
CancellationToken ct)
{
- var token = await ReserveAsync(command.AppId, command.Name, ct);
-
- if (token == null)
- {
- throw new ValidationException(T.Get("apps.nameAlreadyExists"));
- }
+ var token = await ReserveAsync(command.AppId, command.Name, ct)
+ ?? throw new ValidationException(T.Get("apps.nameAlreadyExists"));
return token;
}
@@ -222,18 +221,28 @@ public sealed class AppsIndex : IAppsIndex, ICommandMiddleware, IInitializable
private async Task PrepareAsync(App app)
{
+ if (options.CacheDuration <= TimeSpan.Zero)
+ {
+ return app;
+ }
+
// Do not use cancellation here as we already so far.
await appCache.AddAsync(new[]
{
new KeyValuePair(GetCacheKey(app.Id), app),
new KeyValuePair(GetCacheKey(app.Name), app),
- }, CacheDuration);
+ }, options.CacheDuration);
return app;
}
private Task InvalidateItAsync(DomainId id, string name)
{
+ if (options.CacheDuration <= TimeSpan.Zero)
+ {
+ return Task.CompletedTask;
+ }
+
// Do not use cancellation here as we already so far.
return appCache.RemoveAsync(new[]
{
diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetPermanentDeleter.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetPermanentDeleter.cs
index 6e58fa73b..1c75db846 100644
--- a/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetPermanentDeleter.cs
+++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetPermanentDeleter.cs
@@ -30,9 +30,9 @@ public sealed class AssetPermanentDeleter : IEventConsumer
];
}
- public bool Handles(StoredEvent @event)
+ public ValueTask HandlesAsync(StoredEvent @event)
{
- return consumingTypes.Contains(@event.Data.Type);
+ return new ValueTask(consumingTypes.Contains(@event.Data.Type));
}
public async Task On(Envelope @event)
diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetsJintExtension.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetsJintExtension.cs
index 8dfc74c5c..2d8169483 100644
--- a/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetsJintExtension.cs
+++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/AssetsJintExtension.cs
@@ -17,7 +17,6 @@ using Squidex.Domain.Apps.Core.Apps;
using Squidex.Domain.Apps.Core.Assets;
using Squidex.Domain.Apps.Core.Rules.EnrichedEvents;
using Squidex.Domain.Apps.Core.Scripting;
-using Squidex.Domain.Apps.Core.Scripting.ContentWrapper;
using Squidex.Domain.Apps.Core.Scripting.Internal;
using Squidex.Domain.Apps.Entities.Assets.Commands;
using Squidex.Domain.Apps.Entities.Properties;
diff --git a/backend/src/Squidex.Domain.Apps.Entities/Assets/RecursiveDeleter.cs b/backend/src/Squidex.Domain.Apps.Entities/Assets/RecursiveDeleter.cs
index 802134333..4731ef86d 100644
--- a/backend/src/Squidex.Domain.Apps.Entities/Assets/RecursiveDeleter.cs
+++ b/backend/src/Squidex.Domain.Apps.Entities/Assets/RecursiveDeleter.cs
@@ -45,9 +45,9 @@ public sealed class RecursiveDeleter : IEventConsumer
];
}
- public bool Handles(StoredEvent @event)
+ public ValueTask HandlesAsync(StoredEvent @event)
{
- return consumingTypes.Contains(@event.Data.Type);
+ return new ValueTask(consumingTypes.Contains(@event.Data.Type));
}
public async Task On(Envelope @event)
diff --git a/backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreJob.cs b/backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreJob.cs
index 497e00562..96298ab5c 100644
--- a/backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreJob.cs
+++ b/backend/src/Squidex.Domain.Apps.Entities/Backup/RestoreJob.cs
@@ -286,7 +286,7 @@ public sealed class RestoreJob : IJobRunner
await eventStore.AppendUnsafeAsync(commits, ct);
// Just in case we use parallel inserts later.
- Interlocked.Increment(ref handled);
+ Interlocked.Add(ref handled, batch.Count);
await run.LogAsync($"Reading {state.Reader.ReadEvents}/{handled} events and {state.Reader.ReadAttachments} attachments completed.", true);
});
diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentDomainObject.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentDomainObject.cs
index e24c9defc..c11f47310 100644
--- a/backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentDomainObject.cs
+++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/ContentDomainObject.cs
@@ -322,9 +322,11 @@ public partial class ContentDomainObject : DomainObject
operation.MustHavePermission(PermissionIds.AppContentsUpdate);
operation.MustHaveData(c.Data);
+ var newData = operation.InvokeUpdates(c.Data, Snapshot.EditingData);
+
if (!c.DoNotValidate)
{
- await operation.ValidateInputAsync(c.Data, c.OptimizeValidation, Snapshot.IsPublished, ct);
+ await operation.ValidateInputAsync(newData, c.OptimizeValidation, Snapshot.IsPublished, ct);
}
if (!c.DoNotValidateWorkflow)
@@ -332,8 +334,6 @@ public partial class ContentDomainObject : DomainObject
await operation.CheckUpdateAsync();
}
- var newData = c.Data;
-
if (c.EnrichDefaults)
{
newData = operation.GenerateDefaultValues(newData);
@@ -363,6 +363,8 @@ public partial class ContentDomainObject : DomainObject
operation.MustHavePermission(PermissionIds.AppContentsUpdate);
operation.MustHaveData(c.Data);
+ c.Data = operation.InvokeUpdates(c.Data, Snapshot.EditingData);
+
if (!c.DoNotValidate)
{
await operation.ValidateInputPartialAsync(c.Data, c.OptimizeValidation, Snapshot.IsPublished, ct);
diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/Guards/ValidationExtensions.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/Guards/ValidationExtensions.cs
index 711bec438..e8cb501c3 100644
--- a/backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/Guards/ValidationExtensions.cs
+++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/DomainObject/Guards/ValidationExtensions.cs
@@ -9,6 +9,7 @@ using Squidex.Domain.Apps.Core;
using Squidex.Domain.Apps.Core.Apps;
using Squidex.Domain.Apps.Core.Contents;
using Squidex.Domain.Apps.Core.ConvertContent;
+using Squidex.Domain.Apps.Core.Scripting;
using Squidex.Domain.Apps.Core.ValidateContent;
using Squidex.Domain.Apps.Entities.Contents.Repositories;
using Squidex.Infrastructure;
@@ -97,6 +98,17 @@ public static class ValidationExtensions
return converter.Convert(data);
}
+ public static ContentData InvokeUpdates(this ContentOperation operation, ContentData data, ContentData currentData)
+ {
+ var converter =
+ new ContentConverter(
+ operation.Components,
+ operation.Schema);
+ converter.Add(new UpdateValues(currentData, operation.Resolve()));
+
+ return converter.Convert(data);
+ }
+
public static async Task CheckReferrersAsync(this ContentOperation operation,
CancellationToken ct)
{
diff --git a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetActions.cs b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetActions.cs
index 7779117bd..a5cfe3527 100644
--- a/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetActions.cs
+++ b/backend/src/Squidex.Domain.Apps.Entities/Contents/GraphQL/Types/Assets/AssetActions.cs
@@ -5,6 +5,7 @@
// All rights reserved. Licensed under the MIT license.
// ==========================================================================
+using System.Reactive.Linq;
using GraphQL;
using GraphQL.Resolvers;
using GraphQL.Types;
@@ -13,6 +14,8 @@ using Squidex.Domain.Apps.Core.Rules.EnrichedEvents;
using Squidex.Domain.Apps.Core.Subscriptions;
using Squidex.Domain.Apps.Entities.Assets;
using Squidex.Infrastructure;
+using Squidex.Infrastructure.Translations;
+using Squidex.Messaging.Subscriptions;
using Squidex.Shared;
namespace Squidex.Domain.Apps.Entities.Contents.GraphQL.Types.Assets;
@@ -129,13 +132,29 @@ internal static class AssetActions
},
];
- public static readonly ISourceStreamResolver Resolver = Resolvers.Stream(PermissionIds.AppAssetsRead, c =>
+ public static readonly ISourceStreamResolver Resolver = new SourceStreamResolver
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/backend/src/Squidex.Domain.Users.MongoDb/Squidex.Domain.Users.MongoDb.csproj b/backend/src/Squidex.Domain.Users.MongoDb/Squidex.Domain.Users.MongoDb.csproj
index dcdfa3328..7d5dbd4e2 100644
--- a/backend/src/Squidex.Domain.Users.MongoDb/Squidex.Domain.Users.MongoDb.csproj
+++ b/backend/src/Squidex.Domain.Users.MongoDb/Squidex.Domain.Users.MongoDb.csproj
@@ -19,7 +19,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj b/backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj
index 8e355d2fc..05455182f 100644
--- a/backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj
+++ b/backend/src/Squidex.Domain.Users/Squidex.Domain.Users.csproj
@@ -18,13 +18,13 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
-
+
diff --git a/backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj b/backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj
index c808539d7..2ac186a70 100644
--- a/backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj
+++ b/backend/src/Squidex.Infrastructure.GetEventStore/Squidex.Infrastructure.GetEventStore.csproj
@@ -11,11 +11,11 @@
True
-
-
-
+
+
+
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj b/backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj
index 29ac5948d..09f675aaf 100644
--- a/backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj
+++ b/backend/src/Squidex.Infrastructure.MongoDb/Squidex.Infrastructure.MongoDb.csproj
@@ -14,7 +14,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/backend/src/Squidex.Infrastructure/Commands/DefaultDomainObjectCache.cs b/backend/src/Squidex.Infrastructure/Commands/DefaultDomainObjectCache.cs
index 2f10f7052..dc2f8df94 100644
--- a/backend/src/Squidex.Infrastructure/Commands/DefaultDomainObjectCache.cs
+++ b/backend/src/Squidex.Infrastructure/Commands/DefaultDomainObjectCache.cs
@@ -15,7 +15,7 @@ namespace Squidex.Infrastructure.Commands;
public sealed class DefaultDomainObjectCache : IDomainObjectCache
{
- private readonly DistributedCacheEntryOptions cacheOptions;
+ private readonly DistributedCacheEntryOptions cacheOptions = new DistributedCacheEntryOptions();
private readonly IMemoryCache cache;
private readonly IJsonSerializer serializer;
private readonly IDistributedCache distributedCache;
@@ -27,15 +27,20 @@ public sealed class DefaultDomainObjectCache : IDomainObjectCache
this.serializer = serializer;
this.distributedCache = distributedCache;
- cacheOptions = new DistributedCacheEntryOptions
+ if (options.Value.CacheDuration > TimeSpan.Zero)
{
- AbsoluteExpirationRelativeToNow = options.Value.CacheDuration
- };
+ cacheOptions.AbsoluteExpirationRelativeToNow = options.Value.CacheDuration;
+ }
}
public async Task GetAsync(DomainId id, long version,
CancellationToken ct = default)
{
+ if (cacheOptions.AbsoluteExpirationRelativeToNow == null)
+ {
+ return default!;
+ }
+
var cacheKey = CacheKey(id, version);
if (cache.TryGetValue(cacheKey, out var found) && found is T typed)
@@ -68,10 +73,14 @@ public sealed class DefaultDomainObjectCache : IDomainObjectCache
public async Task SetAsync(DomainId id, long version, T snapshot,
CancellationToken ct = default)
{
+ if (cacheOptions.AbsoluteExpirationRelativeToNow == null)
+ {
+ return;
+ }
+
var cacheKey = CacheKey(id, version);
cache.Set(cacheKey, snapshot, cacheOptions.AbsoluteExpirationRelativeToNow!.Value);
-
try
{
using (var stream = DefaultPools.MemoryStream.GetStream())
diff --git a/backend/src/Squidex.Infrastructure/DomainId.cs b/backend/src/Squidex.Infrastructure/DomainId.cs
index d9746aa58..ef56b7fdc 100644
--- a/backend/src/Squidex.Infrastructure/DomainId.cs
+++ b/backend/src/Squidex.Infrastructure/DomainId.cs
@@ -10,7 +10,7 @@ using System.ComponentModel;
namespace Squidex.Infrastructure;
[TypeConverter(typeof(DomainIdTypeConverter))]
-public readonly struct DomainId : IEquatable, IComparable
+public readonly struct DomainId : IEquatable, IComparable, IDeterministicHashCode
{
private static readonly string EmptyString = Guid.Empty.ToString();
@@ -74,6 +74,32 @@ public readonly struct DomainId : IEquatable, IComparable
return id ?? EmptyString;
}
+ public int GetDeterministicHashCode()
+ {
+ unchecked
+ {
+ int hash1 = (5381 << 16) + 5381;
+ int hash2 = hash1;
+
+ if (id != null)
+ {
+ for (int i = 0; i < id.Length; i += 2)
+ {
+ hash1 = ((hash1 << 5) + hash1) ^ id[i];
+
+ if (i == id.Length - 1)
+ {
+ break;
+ }
+
+ hash2 = ((hash2 << 5) + hash2) ^ id[i + 1];
+ }
+ }
+
+ return hash1 + (hash2 * 1566083941);
+ }
+ }
+
public int CompareTo(DomainId other)
{
return string.Compare(ToString(), other.ToString(), StringComparison.Ordinal);
diff --git a/backend/src/Squidex.Infrastructure/EventSourcing/Consume/ParseSubscription.cs b/backend/src/Squidex.Infrastructure/EventSourcing/Consume/ParseSubscription.cs
index a75380ec7..64c33bcf1 100644
--- a/backend/src/Squidex.Infrastructure/EventSourcing/Consume/ParseSubscription.cs
+++ b/backend/src/Squidex.Infrastructure/EventSourcing/Consume/ParseSubscription.cs
@@ -53,7 +53,7 @@ internal sealed class ParseSubscription : IEventSubscriber, IEventS
{
Envelope? @event = null;
- if (eventConsumer.Handles(storedEvent))
+ if (await eventConsumer.HandlesAsync(storedEvent))
{
@event = eventFormatter.ParseIfKnown(storedEvent);
}
diff --git a/backend/src/Squidex.Infrastructure/EventSourcing/Envelope{T}.cs b/backend/src/Squidex.Infrastructure/EventSourcing/Envelope{T}.cs
index 1296fcecf..80b097429 100644
--- a/backend/src/Squidex.Infrastructure/EventSourcing/Envelope{T}.cs
+++ b/backend/src/Squidex.Infrastructure/EventSourcing/Envelope{T}.cs
@@ -7,37 +7,19 @@
namespace Squidex.Infrastructure.EventSourcing;
-public class Envelope where T : class, IEvent
+public sealed class Envelope(T payload, EnvelopeHeaders? headers = null) where T : class, IEvent
{
- private readonly EnvelopeHeaders headers;
- private readonly T payload;
+ public EnvelopeHeaders Headers { get; } = headers ?? [];
- public EnvelopeHeaders Headers
- {
- get => headers;
- }
-
- public T Payload
- {
- get => payload;
- }
-
- public Envelope(T payload, EnvelopeHeaders? headers = null)
- {
- Guard.NotNull(payload);
-
- this.payload = payload;
-
- this.headers = headers ?? [];
- }
+ public T Payload { get; } = Guard.NotNull(payload);
public Envelope To() where TOther : class, IEvent
{
- return new Envelope((payload as TOther)!, headers.CloneHeaders());
+ return new Envelope((payload as TOther)!, Headers.CloneHeaders());
}
public static implicit operator Envelope(Envelope source)
{
- return source == null ? source! : new Envelope(source.payload, source.headers);
+ return source == null ? source! : new Envelope(source.Payload, source.Headers);
}
}
diff --git a/backend/src/Squidex.Infrastructure/EventSourcing/IEventConsumer.cs b/backend/src/Squidex.Infrastructure/EventSourcing/IEventConsumer.cs
index 78331f763..f3a412627 100644
--- a/backend/src/Squidex.Infrastructure/EventSourcing/IEventConsumer.cs
+++ b/backend/src/Squidex.Infrastructure/EventSourcing/IEventConsumer.cs
@@ -21,9 +21,9 @@ public interface IEventConsumer
bool CanClear => true;
- bool Handles(StoredEvent @event)
+ ValueTask HandlesAsync(StoredEvent @event)
{
- return true;
+ return new ValueTask(true);
}
Task ClearAsync()
diff --git a/backend/src/Squidex.Infrastructure/IDeterministicHashCode.cs b/backend/src/Squidex.Infrastructure/IDeterministicHashCode.cs
new file mode 100644
index 000000000..1507a9fbc
--- /dev/null
+++ b/backend/src/Squidex.Infrastructure/IDeterministicHashCode.cs
@@ -0,0 +1,13 @@
+// ==========================================================================
+// Squidex Headless CMS
+// ==========================================================================
+// Copyright (c) Squidex UG (haftungsbeschraenkt)
+// All rights reserved. Licensed under the MIT license.
+// ==========================================================================
+
+namespace Squidex.Infrastructure;
+
+public interface IDeterministicHashCode
+{
+ int GetDeterministicHashCode();
+}
diff --git a/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj b/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj
index 3d5701f1f..cbba05e56 100644
--- a/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj
+++ b/backend/src/Squidex.Infrastructure/Squidex.Infrastructure.csproj
@@ -13,23 +13,23 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
+
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/backend/src/Squidex.Infrastructure/States/ShardedService.cs b/backend/src/Squidex.Infrastructure/States/ShardedService.cs
index ac2bc79f9..40fa79c07 100644
--- a/backend/src/Squidex.Infrastructure/States/ShardedService.cs
+++ b/backend/src/Squidex.Infrastructure/States/ShardedService.cs
@@ -9,7 +9,7 @@ using Squidex.Hosting;
namespace Squidex.Infrastructure.States;
-public abstract class ShardedService : IInitializable where TKey : notnull
+public abstract class ShardedService : IInitializable where TKey : notnull, IDeterministicHashCode
{
private readonly Dictionary shards = [];
private readonly IShardingStrategy sharding;
diff --git a/backend/src/Squidex.Infrastructure/States/Sharding.cs b/backend/src/Squidex.Infrastructure/States/Sharding.cs
index 028e63394..ef7e7e750 100644
--- a/backend/src/Squidex.Infrastructure/States/Sharding.cs
+++ b/backend/src/Squidex.Infrastructure/States/Sharding.cs
@@ -11,7 +11,7 @@ namespace Squidex.Infrastructure.States;
public interface IShardingStrategy
{
- string GetShardKey(T key) where T : notnull;
+ string GetShardKey(T key) where T : notnull, IDeterministicHashCode;
IEnumerable GetShardKeys();
}
@@ -24,7 +24,7 @@ public sealed class SingleSharding : IShardingStrategy
{
}
- public string GetShardKey(T key) where T : notnull
+ public string GetShardKey(T key) where T : notnull, IDeterministicHashCode
{
return string.Empty;
}
@@ -44,9 +44,9 @@ public sealed class PartitionedSharding : IShardingStrategy
this.numPartitions = numPartitions;
}
- public string GetShardKey(T key) where T : notnull
+ public string GetShardKey(T key) where T : notnull, IDeterministicHashCode
{
- var partition = Math.Abs(key.GetHashCode()) % numPartitions;
+ var partition = Math.Abs(key.GetDeterministicHashCode()) % numPartitions;
return GetShardKey(partition);
}
diff --git a/backend/src/Squidex.Shared/Squidex.Shared.csproj b/backend/src/Squidex.Shared/Squidex.Shared.csproj
index 53a791d99..a07d24137 100644
--- a/backend/src/Squidex.Shared/Squidex.Shared.csproj
+++ b/backend/src/Squidex.Shared/Squidex.Shared.csproj
@@ -10,7 +10,7 @@
True
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/backend/src/Squidex.Web/Pipeline/SetupMiddleware.cs b/backend/src/Squidex.Web/Pipeline/SetupMiddleware.cs
index dc3bb5dc7..a8069a8ff 100644
--- a/backend/src/Squidex.Web/Pipeline/SetupMiddleware.cs
+++ b/backend/src/Squidex.Web/Pipeline/SetupMiddleware.cs
@@ -37,7 +37,6 @@ public sealed class SetupMiddleware
else
{
isUserFound = true;
-
await next(context);
}
}
diff --git a/backend/src/Squidex.Web/Squidex.Web.csproj b/backend/src/Squidex.Web/Squidex.Web.csproj
index bb7daafc4..cb1bd7205 100644
--- a/backend/src/Squidex.Web/Squidex.Web.csproj
+++ b/backend/src/Squidex.Web/Squidex.Web.csproj
@@ -16,7 +16,7 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
diff --git a/backend/src/Squidex/Areas/Api/Config/OpenApi/OpenApiServices.cs b/backend/src/Squidex/Areas/Api/Config/OpenApi/OpenApiServices.cs
index 695941d98..10bc25ff0 100644
--- a/backend/src/Squidex/Areas/Api/Config/OpenApi/OpenApiServices.cs
+++ b/backend/src/Squidex/Areas/Api/Config/OpenApi/OpenApiServices.cs
@@ -6,8 +6,6 @@
// ==========================================================================
using System.Text.Json;
-using Newtonsoft.Json;
-using Newtonsoft.Json.Serialization;
using NJsonSchema;
using NJsonSchema.Generation;
using NJsonSchema.Generation.TypeMappers;
diff --git a/backend/src/Squidex/Areas/Api/Controllers/Translations/Models/AskDto.cs b/backend/src/Squidex/Areas/Api/Controllers/Translations/Models/AskDto.cs
index dc3a510d7..ca2cd7df1 100644
--- a/backend/src/Squidex/Areas/Api/Controllers/Translations/Models/AskDto.cs
+++ b/backend/src/Squidex/Areas/Api/Controllers/Translations/Models/AskDto.cs
@@ -13,6 +13,11 @@ namespace Squidex.Areas.Api.Controllers.Translations.Models;
[OpenApiRequest]
public sealed class AskDto
{
+ ///
+ /// Optional conversation ID.
+ ///
+ public string? ConversationId { get; set; }
+
///
/// The text to ask.
///
diff --git a/backend/src/Squidex/Areas/Api/Controllers/Translations/TranslationsController.cs b/backend/src/Squidex/Areas/Api/Controllers/Translations/TranslationsController.cs
index bc6bc23a8..979f96b12 100644
--- a/backend/src/Squidex/Areas/Api/Controllers/Translations/TranslationsController.cs
+++ b/backend/src/Squidex/Areas/Api/Controllers/Translations/TranslationsController.cs
@@ -6,10 +6,10 @@
// ==========================================================================
using Microsoft.AspNetCore.Mvc;
+using Squidex.AI;
using Squidex.Areas.Api.Controllers.Translations.Models;
using Squidex.Infrastructure.Commands;
using Squidex.Shared;
-using Squidex.Text.ChatBots;
using Squidex.Text.Translations;
using Squidex.Web;
@@ -64,17 +64,9 @@ public sealed class TranslationsController : ApiController
[ApiCosts(10)]
public async Task PostQuestion(string app, [FromBody] AskDto request)
{
- var conversationId = Guid.NewGuid().ToString();
- try
- {
- var result = await chatAgent.PromptAsync(conversationId, request.Prompt, HttpContext.RequestAborted);
- var response = new string[] { result.Text };
+ var result = await chatAgent.PromptAsync(request.Prompt, request.ConversationId, HttpContext.RequestAborted);
+ var response = new string[] { result.Text };
- return Ok(response);
- }
- finally
- {
- await chatAgent.StopConversationAsync(conversationId, default);
- }
+ return Ok(response);
}
}
diff --git a/backend/src/Squidex/Config/Domain/CommandsServices.cs b/backend/src/Squidex/Config/Domain/CommandsServices.cs
index e0c3ace16..3e0e902e2 100644
--- a/backend/src/Squidex/Config/Domain/CommandsServices.cs
+++ b/backend/src/Squidex/Config/Domain/CommandsServices.cs
@@ -40,9 +40,17 @@ public static class CommandsServices
services.Configure(config,
"usage");
+ services.Configure(config,
+ "caching:apps");
+
services.Configure(config,
"caching:domainObjects");
+ services.Configure(config,
+ "caching:schemas");
+
+ services.ConfigureForObsoleteReplicatedCacheSetting(config);
+
services.AddSingletonAs()
.As();
@@ -139,4 +147,25 @@ public static class CommandsServices
services.AddSingletonAs()
.As();
}
+
+ private static void ConfigureForObsoleteReplicatedCacheSetting(this IServiceCollection services, IConfiguration config)
+ {
+ var isCaching = config.GetValue("caching:replicated:enable");
+
+ services.Configure(options =>
+ {
+ if (options.CacheDuration == default && isCaching)
+ {
+ options.CacheDuration = TimeSpan.FromMinutes(5);
+ }
+ });
+
+ services.Configure(options =>
+ {
+ if (options.CacheDuration == default && isCaching)
+ {
+ options.CacheDuration = TimeSpan.FromMinutes(5);
+ }
+ });
+ }
}
diff --git a/backend/src/Squidex/Config/Domain/FontendServices.cs b/backend/src/Squidex/Config/Domain/FontendServices.cs
index 02085dd09..c0a296d31 100644
--- a/backend/src/Squidex/Config/Domain/FontendServices.cs
+++ b/backend/src/Squidex/Config/Domain/FontendServices.cs
@@ -7,10 +7,10 @@
using System.Text.Json;
using Microsoft.Extensions.Options;
+using Squidex.AI;
using Squidex.Areas.Api.Controllers.UI;
using Squidex.Domain.Apps.Entities.History;
using Squidex.Hosting;
-using Squidex.Text.ChatBots;
using Squidex.Text.Translations;
using Squidex.Web;
diff --git a/backend/src/Squidex/Config/Domain/InfrastructureServices.cs b/backend/src/Squidex/Config/Domain/InfrastructureServices.cs
index d9d33e812..72593d7c9 100644
--- a/backend/src/Squidex/Config/Domain/InfrastructureServices.cs
+++ b/backend/src/Squidex/Config/Domain/InfrastructureServices.cs
@@ -6,12 +6,12 @@
// ==========================================================================
using Microsoft.Extensions.Caching.Memory;
+using Microsoft.SemanticKernel;
using NodaTime;
using Squidex.Areas.Api.Controllers.Contents.Generator;
using Squidex.Areas.Api.Controllers.News;
using Squidex.Areas.Api.Controllers.News.Service;
using Squidex.Areas.Api.Controllers.UI;
-using Squidex.Caching;
using Squidex.Domain.Apps.Core.Scripting;
using Squidex.Domain.Apps.Core.Scripting.Extensions;
using Squidex.Domain.Apps.Core.Tags;
@@ -38,9 +38,6 @@ public static class InfrastructureServices
services.Configure(config,
"exposedConfiguration");
- services.Configure(config,
- "caching:replicated");
-
services.Configure(config,
"scripting");
@@ -133,6 +130,16 @@ public static class InfrastructureServices
services.AddSingletonAs()
.AsSelf();
+ var kernel = services.AddKernel();
+
+ var openAiKey = config["chatBot:openAi:apiKey"];
+ var openAiModel = config["chatBot:openAi:model"] ?? "gpt-3.5-turbo-0125";
+
+ if (!string.IsNullOrWhiteSpace(openAiKey))
+ {
+ kernel.AddOpenAIChatCompletion(openAiModel, openAiKey);
+ }
+
services.AddDeepLTranslations(config);
services.AddGoogleCloudTranslations(config);
services.AddOpenAIChatAgent(config);
diff --git a/backend/src/Squidex/Config/Domain/StoreServices.cs b/backend/src/Squidex/Config/Domain/StoreServices.cs
index b1796cbb4..3ea946e3f 100644
--- a/backend/src/Squidex/Config/Domain/StoreServices.cs
+++ b/backend/src/Squidex/Config/Domain/StoreServices.cs
@@ -75,6 +75,15 @@ public static class StoreServices
options.DatabaseName = mongoDatabaseName;
});
+ services.AddKernel()
+ .AddMongoChatStore(config, options =>
+ {
+ options.CollectionName = "Chat";
+ });
+
+ services.AddMessaging()
+ .AddMongoDataStore(config);
+
services.AddSingletonAs(c => GetMongoClient(mongoConfiguration))
.As();
diff --git a/backend/src/Squidex/Config/Messaging/MessagingServices.cs b/backend/src/Squidex/Config/Messaging/MessagingServices.cs
index 035c518d2..f0a9a7e59 100644
--- a/backend/src/Squidex/Config/Messaging/MessagingServices.cs
+++ b/backend/src/Squidex/Config/Messaging/MessagingServices.cs
@@ -22,7 +22,6 @@ using Squidex.Messaging;
using Squidex.Messaging.Implementation;
using Squidex.Messaging.Implementation.Null;
using Squidex.Messaging.Implementation.Scheduler;
-using Squidex.Messaging.Subscriptions;
namespace Squidex.Config.Messaging;
@@ -30,11 +29,14 @@ public static class MessagingServices
{
public static void AddSquidexMessaging(this IServiceCollection services, IConfiguration config)
{
+ services.Configure(config,
+ "messaging");
+
var channelBackupRestore = new ChannelName("backup.restore");
var channelBackupStart = new ChannelName("backup.start");
var channelFallback = new ChannelName("default");
var channelRules = new ChannelName("rules.run");
- var isCaching = config.GetValue("caching:replicated:enable");
+ var isRandomName = config.GetValue("clustering:randomName");
var isWorker = config.GetValue("clustering:worker");
if (isWorker)
@@ -59,16 +61,22 @@ public static class MessagingServices
services.AddSingletonAs()
.AsSelf().As();
+ }
- services.AddSingletonAs()
- .As();
+ if (isRandomName)
+ {
+ services.AddSingletonAs()
+ .As();
+ }
- services.AddSingletonAs()
- .As();
+ services.AddSingletonAs()
+ .As();
- services.AddSingletonAs()
- .As();
- }
+ services.AddSingletonAs()
+ .As();
+
+ services.AddSingletonAs()
+ .As();
services.AddSingleton(c =>
new SystemTextJsonMessagingSerializer(c.GetRequiredService()));
@@ -76,55 +84,43 @@ public static class MessagingServices
services.AddSingletonAs()
.As();
- services.AddSingletonAs()
- .As();
-
services.AddSingletonAs()
.As().As();
- services.AddReplicatedCacheMessaging(isCaching, options =>
- {
- options.TransportSelector = (transport, _) => transport.First(x => x is NullTransport != isCaching);
- });
-
- services.Configure(options =>
- {
- options.SendMessagesToSelf = false;
- });
-
- services.AddMessagingSubscriptions();
- services.AddMessagingTransport(config);
- services.AddMessaging(options =>
- {
- options.Routing.Add(m => m is JobStart r && r.Request.TaskName == BackupJob.TaskName, channelBackupStart);
- options.Routing.Add(m => m is JobStart r && r.Request.TaskName == RestoreJob.TaskName, channelBackupRestore);
- options.Routing.Add(m => m is JobStart r && r.Request.TaskName == RuleRunnerJob.TaskName, channelRules);
- options.Routing.AddFallback(channelFallback);
- });
-
- services.AddMessaging(channelBackupStart, isWorker, options =>
- {
- options.Timeout = TimeSpan.FromHours(4);
- options.Scheduler = new ParallelScheduler(4);
- options.LogMessage = x => true;
- });
-
- services.AddMessaging(channelBackupRestore, isWorker, options =>
- {
- options.Timeout = TimeSpan.FromHours(24);
- options.Scheduler = InlineScheduler.Instance;
- options.LogMessage = x => true;
- });
-
- services.AddMessaging(channelRules, isWorker, options =>
- {
- options.Scheduler = new ParallelScheduler(4);
- options.LogMessage = x => true;
- });
-
- services.AddMessaging(channelFallback, isWorker, options =>
- {
- options.Scheduler = InlineScheduler.Instance;
- });
+ services.AddMessaging()
+ .AddTransport(config)
+ .AddSubscriptions(!isWorker)
+ .AddReplicatedCache(true, options =>
+ {
+ options.TransportSelector = (transport, _) => transport.First(x => x is not NullTransport);
+ })
+ .Configure(options =>
+ {
+ options.Routing.Add(m => m is JobStart r && r.Request.TaskName == BackupJob.TaskName, channelBackupStart);
+ options.Routing.Add(m => m is JobStart r && r.Request.TaskName == RestoreJob.TaskName, channelBackupRestore);
+ options.Routing.Add(m => m is JobStart r && r.Request.TaskName == RuleRunnerJob.TaskName, channelRules);
+ options.Routing.AddFallback(channelFallback);
+ })
+ .AddChannel(channelBackupStart, isWorker, options =>
+ {
+ options.Timeout = TimeSpan.FromHours(4);
+ options.Scheduler = new ParallelScheduler(4);
+ options.LogMessage = x => true;
+ })
+ .AddChannel(channelBackupRestore, isWorker, options =>
+ {
+ options.Timeout = TimeSpan.FromHours(24);
+ options.Scheduler = InlineScheduler.Instance;
+ options.LogMessage = x => true;
+ })
+ .AddChannel(channelRules, isWorker, options =>
+ {
+ options.Scheduler = new ParallelScheduler(4);
+ options.LogMessage = x => true;
+ })
+ .AddChannel(channelFallback, isWorker, options =>
+ {
+ options.Scheduler = InlineScheduler.Instance;
+ });
}
}
diff --git a/backend/src/Squidex/Squidex.csproj b/backend/src/Squidex/Squidex.csproj
index 187984883..a2efa1645 100644
--- a/backend/src/Squidex/Squidex.csproj
+++ b/backend/src/Squidex/Squidex.csproj
@@ -38,44 +38,44 @@
-
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
+
+
+
+
+
-
+
-
-
+
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
diff --git a/backend/src/Squidex/appsettings.json b/backend/src/Squidex/appsettings.json
index 21124e74f..2f9db6842 100644
--- a/backend/src/Squidex/appsettings.json
+++ b/backend/src/Squidex/appsettings.json
@@ -73,10 +73,26 @@
"maxSurrogateKeysSize": 0,
"replicated": {
+ // OBSOLETE
// Set to true to enable a replicated cache for app, schemas and rules. Increases performance but reduces consistency.
+ //
+ // This setting is obsolete and has been replaced with
+ // * caching:apps:cacheDuration
+ // * caching:schemas:cacheDuration
+ //
"enable": true
},
+ "apps": {
+ // The cache duration for apps.
+ "cacheDuration": "00:00:00"
+ },
+
+ "schemas": {
+ // The cache duration for schemas.
+ "cacheDuration": "00:00:00"
+ },
+
"domainObjects": {
// The cache duration for domain objects.
"cacheDuration": "00:10:00"
@@ -663,7 +679,10 @@
"chatbot": {
"openai": {
// The OpenAI API Key.
- "apiKey": ""
+ "apiKey": "",
+
+ // The chat model.
+ "model": "gpt-3.5-turbo-0125"
}
},
diff --git a/backend/src/Squidex/wwwroot/editor/squidex-editor.css b/backend/src/Squidex/wwwroot/editor/squidex-editor.css
index 12703f300..793f54e79 100644
--- a/backend/src/Squidex/wwwroot/editor/squidex-editor.css
+++ b/backend/src/Squidex/wwwroot/editor/squidex-editor.css
@@ -1 +1 @@
-.remirror-theme{width:100%}.remirror-theme{position:relative}.remirror-theme *{box-sizing:border-box}.remirror-theme .ProseMirror p{margin-bottom:1rem!important}.remirror-editor{min-height:300px!important;max-height:500px}.MuiStack-root>.MuiBox-root{margin-right:5px}.MuiBox-root>.MuiButtonBase-root{border-color:#dedfe3!important;border-radius:0}.MuiBox-root>.MuiButtonBase-root{border-left-width:0!important}.MuiBox-root>.MuiBox-root:first-child>.MuiButtonBase-root{border-left-width:1px!important}.MuiStack-root>.MuiBox-root>.MuiButtonBase-root:first-child{border-left-width:1px!important}.MuiButtonBase-root.Mui-selected:hover{background-color:#3284f4!important}.remirror-editor-wrapper{padding-top:0!important}.custom-icon path{fill:#0000008a}.remirror-theme div.ProseMirror{border:1px solid #dedfe3!important;border-radius:0!important;box-shadow:none!important}.MuiTooltip-popper>div{background-color:#1a2129;border-radius:0;font-size:85%;font-weight:400;padding:.5rem}.MuiMenu-paper{transform:none!important}.squidex-editor-disabled{pointer-events:none}.squidex-editor-menu{border:1px solid #dedfe3;border-bottom:0;padding:5px}.squidex-editor-menu fieldset{border-radius:0;border:0;display:flex;outline:0;padding:0}.squidex-editor-menu fieldset:disabled,.squidex-editor-menu fieldset.disabled{pointer-events:none}.squidex-editor-menu fieldset:disabled,.squidex-editor-menu fieldset.disabled{opacity:.5}.squidex-editor-counter{border:1px solid #dedfe3;border-top:0;font-size:85%;font-weight:400;opacity:.8;padding:4px 10px 4px 4px;text-align:right}.squidex-editor-image-view{border:1px solid #dedfe3;border-radius:0;display:inline-block;margin-top:15px;margin-bottom:15px;overflow:hidden}.squidex-editor-image-buttons{bottom:10px;left:10px;position:absolute}.squidex-editor-image-element{display:block;max-width:400px;max-height:400px}.squidex-editor-image-info{left:10px;top:10px;position:absolute;background-color:#3284f4;color:#fff;font-size:85%;font-weight:400;padding:2px 6px}.squidex-editor-main{position:relative}.squidex-editor-main .ace_editor{bottom:0;left:0;right:0;top:0;position:absolute;border:1px solid #dedfe3}.squidex-editor-content-link{align-items:center;border-radius:2px;border:1px solid #dedfe3;padding:10px;display:flex;flex-direction:row;flex-wrap:nowrap;margin-top:10px;margin-bottom:10px}.squidex-editor-content-schema{display:block;overflow-x:hidden;overflow-y:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%;min-width:0;width:auto;border-right:1px solid #c2c4cc;color:#8b8f9d;flex-shrink:0;padding-left:10px;padding-right:10px;width:200px}.squidex-editor-content-name{display:block;overflow-x:hidden;overflow-y:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%;min-width:0;width:auto;padding-left:10px;padding-right:0}.squidex-editor-html{margin-bottom:10px;margin-top:10px;position:relative}.squidex-editor-html-label{left:6px;top:0;position:absolute;color:#8b8f9d;font-size:85%;font-weight:400}.squidex-editor-html textarea{font-family:monospace;padding:30px 20px 20px}.squidex-editor-button{align-items:center;background-color:#fff;border-radius:0;border:1px solid #dedfe3;bottom:10px;display:inline-flex;font-size:85%;font-weight:400;margin-right:5px;padding:6px 12px}.squidex-editor-button:hover{background-color:#f5f5f5}.squidex-editor-input{border:1px solid #dedfe3;border-radius:0;box-sizing:border-box;height:30px;margin-left:0;margin-right:5px;outline:none;padding:6px 12px}.squidex-editor-input:active{border-color:#3284f4}.squidex-editor-floating{border:1px solid #dedfe3}.squidex-editor-floating .MuiBox-root{margin-right:0!important}.squidex-editor-floating .MuiButtonBase-root{height:30px}.squidex-editor-modal-wrapper,.squidex-editor-modal-backdrop{bottom:0;left:0;right:0;top:0;position:absolute}.squidex-editor-modal-backdrop{background-color:#00000003}.squidex-editor-modal-window{left:50%;top:50%;background-color:#fff;border:0;border-radius:.25rem;box-sizing:border-box;box-shadow:0 3px 16px #0003;margin-top:-50px;margin-left:-150px;position:absolute;width:350px}.squidex-editor-modal-body{display:flex;flex-direction:row;flex-grow:1;padding-top:0!important}.squidex-editor-modal-body,.squidex-editor-modal-title{padding:15px}.squidex-editor-modal-title{font-size:85%}.squidex-editor-modal-window input{flex-grow:1}.b:before{content:"";font-family:monospace;font-size:90%}.b:after{content:"";font-family:monospace;font-size:90%}
+.remirror-theme{width:100%}.remirror-theme{position:relative}.remirror-theme *{box-sizing:border-box}.remirror-theme .ProseMirror p{margin-bottom:1rem!important}.remirror-editor{min-height:300px!important;max-height:500px}.MuiStack-root>.MuiBox-root{margin-right:5px}.MuiBox-root>.MuiButtonBase-root{border-color:#dedfe3!important;border-radius:0}.MuiBox-root>.MuiButtonBase-root{border-left-width:0!important}.MuiBox-root>.MuiBox-root:first-child>.MuiButtonBase-root{border-left-width:1px!important}.MuiStack-root>.MuiBox-root>.MuiButtonBase-root:first-child{border-left-width:1px!important}.MuiButtonBase-root.Mui-selected:hover{background-color:#3284f4!important}.remirror-editor-wrapper{padding-top:0!important}.custom-icon path{fill:#0000008a}.remirror-theme div.ProseMirror{border:1px solid #dedfe3!important;border-radius:0!important;box-shadow:none!important}.MuiTooltip-popper>div{background-color:#1a2129;border-radius:0;font-size:85%;font-weight:400;padding:.5rem}.MuiMenu-paper{transform:none!important}.squidex-editor-disabled{pointer-events:none}.squidex-editor-menu{border:1px solid #dedfe3;border-bottom:0;padding:5px}.squidex-editor-menu fieldset{border-radius:0;border:0;display:flex;outline:0;padding:0}.squidex-editor-menu fieldset:disabled,.squidex-editor-menu fieldset.disabled{pointer-events:none}.squidex-editor-menu fieldset:disabled,.squidex-editor-menu fieldset.disabled{opacity:.5}.squidex-editor-counter{border:1px solid #dedfe3;border-top:0;font-size:85%;font-weight:400;opacity:.8;padding:4px 10px 4px 4px;text-align:right}.squidex-editor-image-view{border:1px solid #dedfe3;border-radius:0;display:inline-block;margin-top:15px;margin-bottom:15px;overflow:hidden}.squidex-editor-image-buttons{bottom:10px;left:10px;position:absolute}.squidex-editor-image-element{display:block;max-width:400px;max-height:400px}.squidex-editor-image-info{left:10px;top:10px;position:absolute;background-color:#3284f4;color:#fff;font-size:85%;font-weight:400;padding:2px 6px}.squidex-editor-main{position:relative}.squidex-editor-main .ace_editor{bottom:0;left:0;right:0;top:0;position:absolute;border:1px solid #dedfe3}.squidex-editor-content-link{align-items:center;border-radius:2px;border:1px solid #dedfe3;padding:10px;display:flex;flex-direction:row;flex-wrap:nowrap;margin-top:10px;margin-bottom:10px}.squidex-editor-content-schema{display:block;overflow-x:hidden;overflow-y:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%;min-width:0;width:auto;border-right:1px solid #c2c4cc;color:#8b8f9d;flex-shrink:0;padding-left:10px;padding-right:10px;width:200px}.squidex-editor-content-name{display:block;overflow-x:hidden;overflow-y:hidden;text-overflow:ellipsis;white-space:nowrap;max-width:100%;min-width:0;width:auto;padding-left:10px;padding-right:0}.squidex-editor-html{margin-bottom:10px;margin-top:10px;position:relative}.squidex-editor-html-label{left:6px;top:0;position:absolute;color:#8b8f9d;font-size:85%;font-weight:400}.squidex-editor-html textarea{border:1px solid #dedfe3;font-family:monospace;font-size:inherit;height:100px;outline:none;overflow-x:hidden;overflow-y:auto;padding:30px 14px 14px;resize:vertical;width:100%}.squidex-editor-button{align-items:center;background-color:#fff;border-radius:0;border:1px solid #dedfe3;bottom:10px;display:inline-flex;font-size:85%;font-weight:400;margin-right:5px;padding:6px 12px}.squidex-editor-button:hover{background-color:#f5f5f5}.squidex-editor-input{border:1px solid #dedfe3;border-radius:0;box-sizing:border-box;height:30px;margin-left:0;margin-right:5px;outline:none;padding:6px 12px}.squidex-editor-input:active{border-color:#3284f4}.squidex-editor-floating{border:1px solid #dedfe3}.squidex-editor-floating .MuiBox-root{margin-right:0!important}.squidex-editor-floating .MuiButtonBase-root{height:30px}.squidex-editor-modal-wrapper,.squidex-editor-modal-backdrop{bottom:0;left:0;right:0;top:0;position:absolute}.squidex-editor-modal-backdrop{background-color:#00000003}.squidex-editor-modal-window{left:50%;top:50%;background-color:#fff;border:0;border-radius:.25rem;box-sizing:border-box;box-shadow:0 3px 16px #0003;margin-top:-50px;margin-left:-150px;position:absolute;width:350px}.squidex-editor-modal-body{display:flex;flex-direction:row;flex-grow:1;padding-top:0!important}.squidex-editor-modal-body,.squidex-editor-modal-title{padding:15px}.squidex-editor-modal-title{font-size:85%}.squidex-editor-modal-window input{flex-grow:1}.b:before{content:"";font-family:monospace;font-size:90%}.b:after{content:"";font-family:monospace;font-size:90%}
diff --git a/backend/src/Squidex/wwwroot/editor/squidex-editor.js b/backend/src/Squidex/wwwroot/editor/squidex-editor.js
index 922d91ab4..dba399264 100644
--- a/backend/src/Squidex/wwwroot/editor/squidex-editor.js
+++ b/backend/src/Squidex/wwwroot/editor/squidex-editor.js
@@ -1,4 +1,4 @@
-var g4=Object.defineProperty;var m4=(t,e,n)=>e in t?g4(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var dt=(t,e,n)=>(m4(t,typeof e!="symbol"?e+"":e,n),n),v4=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var Gv=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)};var Af=(t,e,n)=>(v4(t,e,"access private method"),n);function y4(t,e){for(var n=0;nr[o]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var ht=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ko(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var J_={exports:{}},am={},eR={exports:{}},je={};/**
+var M4=Object.defineProperty;var O4=(t,e,n)=>e in t?M4(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n;var lt=(t,e,n)=>(O4(t,typeof e!="symbol"?e+"":e,n),n),I4=(t,e,n)=>{if(!e.has(t))throw TypeError("Cannot "+n)};var qv=(t,e,n)=>{if(e.has(t))throw TypeError("Cannot add the same private member more than once");e instanceof WeakSet?e.add(t):e.set(t,n)};var Of=(t,e,n)=>(I4(t,e,"access private method"),n);function L4(t,e){for(var n=0;nr[o]})}}}return Object.freeze(Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}))}var ct=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function jo(t){return t&&t.__esModule&&Object.prototype.hasOwnProperty.call(t,"default")?t.default:t}var uR={exports:{}},dm={},dR={exports:{}},We={};/**
* @license React
* react.production.min.js
*
@@ -6,7 +6,7 @@ var g4=Object.defineProperty;var m4=(t,e,n)=>e in t?g4(t,e,{enumerable:!0,config
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
- */var Bh=Symbol.for("react.element"),b4=Symbol.for("react.portal"),w4=Symbol.for("react.fragment"),x4=Symbol.for("react.strict_mode"),k4=Symbol.for("react.profiler"),E4=Symbol.for("react.provider"),S4=Symbol.for("react.context"),C4=Symbol.for("react.forward_ref"),T4=Symbol.for("react.suspense"),A4=Symbol.for("react.memo"),_4=Symbol.for("react.lazy"),eS=Symbol.iterator;function R4(t){return t===null||typeof t!="object"?null:(t=eS&&t[eS]||t["@@iterator"],typeof t=="function"?t:null)}var tR={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},nR=Object.assign,rR={};function lu(t,e,n){this.props=t,this.context=e,this.refs=rR,this.updater=n||tR}lu.prototype.isReactComponent={};lu.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};lu.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function oR(){}oR.prototype=lu.prototype;function cb(t,e,n){this.props=t,this.context=e,this.refs=rR,this.updater=n||tR}var ub=cb.prototype=new oR;ub.constructor=cb;nR(ub,lu.prototype);ub.isPureReactComponent=!0;var tS=Array.isArray,iR=Object.prototype.hasOwnProperty,db={current:null},sR={key:!0,ref:!0,__self:!0,__source:!0};function aR(t,e,n){var r,o={},i=null,s=null;if(e!=null)for(r in e.ref!==void 0&&(s=e.ref),e.key!==void 0&&(i=""+e.key),e)iR.call(e,r)&&!sR.hasOwnProperty(r)&&(o[r]=e[r]);var l=arguments.length-2;if(l===1)o.children=n;else if(1e in t?g4(t,e,{enumerable:!0,config
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
- */var N4=D,$4=Symbol.for("react.element"),D4=Symbol.for("react.fragment"),P4=Object.prototype.hasOwnProperty,z4=N4.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,F4={key:!0,ref:!0,__self:!0,__source:!0};function lR(t,e,n){var r,o={},i=null,s=null;n!==void 0&&(i=""+n),e.key!==void 0&&(i=""+e.key),e.ref!==void 0&&(s=e.ref);for(r in e)P4.call(e,r)&&!F4.hasOwnProperty(r)&&(o[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)o[r]===void 0&&(o[r]=e[r]);return{$$typeof:$4,type:t,key:i,ref:s,props:o,_owner:z4.current}}am.Fragment=D4;am.jsx=lR;am.jsxs=lR;J_.exports=am;var V=J_.exports,f0={exports:{}};(function(t,e){var n=typeof Reflect<"u"?Reflect.construct:void 0,r=Object.defineProperty,o=Error.captureStackTrace;o===void 0&&(o=function(u){var c=new Error;r(u,"stack",{configurable:!0,get:function(){var h=c.stack;return r(this,"stack",{configurable:!0,value:h,writable:!0}),h},set:function(h){r(u,"stack",{configurable:!0,value:h,writable:!0})}})});function i(a){a!==void 0&&r(this,"message",{configurable:!0,value:a,writable:!0});var u=this.constructor.name;u!==void 0&&u!==this.name&&r(this,"name",{configurable:!0,value:u,writable:!0}),o(this,this.constructor)}i.prototype=Object.create(Error.prototype,{constructor:{configurable:!0,value:i,writable:!0}});var s=function(){function a(c,d){return r(c,"name",{configurable:!0,value:d})}try{var u=function(){};if(a(u,"foo"),u.name==="foo")return a}catch{}}();function l(a,u){if(u==null||u===Error)u=i;else if(typeof u!="function")throw new TypeError("super_ should be a function");var c;if(typeof a=="string")c=a,a=n!==void 0?function(){return n(u,arguments,this.constructor)}:function(){u.apply(this,arguments)},s!==void 0&&(s(a,c),c=void 0);else if(typeof a!="function")throw new TypeError("constructor should be either a string or a function");a.super_=a.super=u;var d={constructor:{configurable:!0,value:a,writable:!0}};return c!==void 0&&(d.name={configurable:!0,value:c,writable:!0}),a.prototype=Object.create(u.prototype,d),a}e=t.exports=l,e.BaseError=i})(f0,f0.exports);var cR=f0.exports,rS="ProseMirror-selectednode",fb="",Es="\0",oS="__state_override__",B4={LastNodeCompatible:"lastNodeCompatible",FormattingMark:"formattingMark",FormattingNode:"formattingNode",NodeCursor:"nodeCursor",FontStyle:"fontStyle",Link:"link",Color:"color",Alignment:"alignment",Indentation:"indentation",Behavior:"behavior",Code:"code",InlineNode:"inline",ListContainerNode:"listContainer",ListItemNode:"listItemNode",Block:"block",BlockNode:"block",TextBlock:"textBlock",ExcludeInputRules:"excludeFromInputRules",PreventExits:"preventsExits",Media:"media"},ke=B4,Ui=Symbol.for("__remirror__"),wn=(t=>(t.PlainExtension="RemirrorPlainExtension",t.NodeExtension="RemirrorNodeExtension",t.MarkExtension="RemirrorMarkExtension",t.PlainExtensionConstructor="RemirrorPlainExtensionConstructor",t.NodeExtensionConstructor="RemirrorNodeExtensionConstructor",t.MarkExtensionConstructor="RemirrorMarkExtensionConstructor",t.Manager="RemirrorManager",t.Preset="RemirrorPreset",t.PresetConstructor="RemirrorPresetConstructor",t))(wn||{}),st=(t=>(t[t.Critical=1e6]="Critical",t[t.Highest=1e5]="Highest",t[t.High=1e4]="High",t[t.Medium=1e3]="Medium",t[t.Default=100]="Default",t[t.Low=10]="Low",t[t.Lowest=0]="Lowest",t))(st||{}),yr=(t=>(t[t.None=0]="None",t[t.Create=1]="Create",t[t.EditorView=2]="EditorView",t[t.Runtime=3]="Runtime",t[t.Destroy=4]="Destroy",t))(yr||{}),oe=(t=>(t.Undo="_|undo|_",t.Redo="_|redo|_",t.Bold="_|bold|_",t.Italic="_|italic|_",t.Underline="_|underline|_",t.Strike="_|strike|_",t.Code="_|code|_",t.Paragraph="_|paragraph|_",t.H1="_|h1|_",t.H2="_|h2|_",t.H3="_|h3|_",t.H4="_|h4|_",t.H5="_|h5|_",t.H6="_|h6|_",t.TaskList="_|task|_",t.BulletList="_|bullet|_",t.OrderedList="_|number|_",t.Quote="_|quote|_",t.Divider="_|divider|_",t.Codeblock="_|codeblock|_",t.ClearFormatting="_|clear|_",t.Superscript="_|sup|_",t.Subscript="_|sub|_",t.LeftAlignment="_|left-align|_",t.CenterAlignment="_|center-align|_",t.RightAlignment="_|right-align|_",t.JustifyAlignment="_|justify-align|_",t.InsertLink="_|link|_",t.Find="_|find|_",t.FindBackwards="_|find-backwards|_",t.FindReplace="_|find-replace|_",t.AddFootnote="_|footnote|_",t.AddComment="_|comment|_",t.ContextMenu="_|context-menu|_",t.IncreaseFontSize="_|inc-font-size|_",t.DecreaseFontSize="_|dec-font-size|_",t.IncreaseIndent="_|indent|_",t.DecreaseIndent="_|dedent|_",t.Shortcuts="_|shortcuts|_",t.Copy="_|copy|_",t.Cut="_|cut|_",t.Paste="_|paste|_",t.PastePlain="_|paste-plain|_",t.SelectAll="_|select-all|_",t.Format="_|format|_",t))(oe||{}),re=(t=>(t.PROD="RMR0000",t.UNKNOWN="RMR0001",t.INVALID_COMMAND_ARGUMENTS="RMR0002",t.CUSTOM="RMR0003",t.CORE_HELPERS="RMR0004",t.MUTATION="RMR0005",t.INTERNAL="RMR0006",t.MISSING_REQUIRED_EXTENSION="RMR0007",t.MANAGER_PHASE_ERROR="RMR0008",t.INVALID_GET_EXTENSION="RMR0010",t.INVALID_MANAGER_ARGUMENTS="RMR0011",t.SCHEMA="RMR0012",t.HELPERS_CALLED_IN_OUTER_SCOPE="RMR0013",t.INVALID_MANAGER_EXTENSION="RMR0014",t.DUPLICATE_COMMAND_NAMES="RMR0016",t.DUPLICATE_HELPER_NAMES="RMR0017",t.NON_CHAINABLE_COMMAND="RMR0018",t.INVALID_EXTENSION="RMR0019",t.INVALID_CONTENT="RMR0021",t.INVALID_NAME="RMR0050",t.EXTENSION="RMR0100",t.EXTENSION_SPEC="RMR0101",t.EXTENSION_EXTRA_ATTRIBUTES="RMR0102",t.INVALID_SET_EXTENSION_OPTIONS="RMR0103",t.REACT_PROVIDER_CONTEXT="RMR0200",t.REACT_GET_ROOT_PROPS="RMR0201",t.REACT_EDITOR_VIEW="RMR0202",t.REACT_CONTROLLED="RMR0203",t.REACT_NODE_VIEW="RMR0204",t.REACT_GET_CONTEXT="RMR0205",t.REACT_COMPONENTS="RMR0206",t.REACT_HOOKS="RMR0207",t.I18N_CONTEXT="RMR0300",t))(re||{}),H4=function(e){return U4(e)&&!W4(e)};function U4(t){return!!t&&typeof t=="object"}function W4(t){var e=Object.prototype.toString.call(t);return e==="[object RegExp]"||e==="[object Date]"||G4(t)}var V4=typeof Symbol=="function"&&Symbol.for,j4=V4?Symbol.for("react.element"):60103;function G4(t){return t.$$typeof===j4}function K4(t){return Array.isArray(t)?[]:{}}function Ud(t,e){return e.clone!==!1&&e.isMergeableObject(t)?Oc(K4(t),t,e):t}function Y4(t,e,n){return t.concat(e).map(function(r){return Ud(r,n)})}function X4(t,e){if(!e.customMerge)return Oc;var n=e.customMerge(t);return typeof n=="function"?n:Oc}function q4(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(e){return Object.propertyIsEnumerable.call(t,e)}):[]}function iS(t){return Object.keys(t).concat(q4(t))}function uR(t,e){try{return e in t}catch{return!1}}function Z4(t,e){return uR(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))}function Q4(t,e,n){var r={};return n.isMergeableObject(t)&&iS(t).forEach(function(o){r[o]=Ud(t[o],n)}),iS(e).forEach(function(o){Z4(t,o)||(uR(t,o)&&n.isMergeableObject(e[o])?r[o]=X4(o,n)(t[o],e[o],n):r[o]=Ud(e[o],n))}),r}function Oc(t,e,n){n=n||{},n.arrayMerge=n.arrayMerge||Y4,n.isMergeableObject=n.isMergeableObject||H4,n.cloneUnlessOtherwiseSpecified=Ud;var r=Array.isArray(e),o=Array.isArray(t),i=r===o;return i?r?n.arrayMerge(t,e,n):Q4(t,e,n):Ud(e,n)}Oc.all=function(e,n){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(r,o){return Oc(r,o,n)},{})};var J4=Oc,eD=J4;const tD=Ko(eD);var nD=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,o,i;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!t(e[o],n[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;o--!==0;){var s=i[o];if(!t(e[s],n[s]))return!1}return!0}return e!==e&&n!==n};const rD=Ko(nD);/*!
+ */var X4=D,q4=Symbol.for("react.element"),Z4=Symbol.for("react.fragment"),Q4=Object.prototype.hasOwnProperty,J4=X4.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,eD={key:!0,ref:!0,__self:!0,__source:!0};function bR(t,e,n){var r,o={},i=null,s=null;n!==void 0&&(i=""+n),e.key!==void 0&&(i=""+e.key),e.ref!==void 0&&(s=e.ref);for(r in e)Q4.call(e,r)&&!eD.hasOwnProperty(r)&&(o[r]=e[r]);if(t&&t.defaultProps)for(r in e=t.defaultProps,e)o[r]===void 0&&(o[r]=e[r]);return{$$typeof:q4,type:t,key:i,ref:s,props:o,_owner:J4.current}}dm.Fragment=Z4;dm.jsx=bR;dm.jsxs=bR;uR.exports=dm;var V=uR.exports,v0={exports:{}};(function(t,e){var n=typeof Reflect<"u"?Reflect.construct:void 0,r=Object.defineProperty,o=Error.captureStackTrace;o===void 0&&(o=function(u){var c=new Error;r(u,"stack",{configurable:!0,get:function(){var h=c.stack;return r(this,"stack",{configurable:!0,value:h,writable:!0}),h},set:function(h){r(u,"stack",{configurable:!0,value:h,writable:!0})}})});function i(a){a!==void 0&&r(this,"message",{configurable:!0,value:a,writable:!0});var u=this.constructor.name;u!==void 0&&u!==this.name&&r(this,"name",{configurable:!0,value:u,writable:!0}),o(this,this.constructor)}i.prototype=Object.create(Error.prototype,{constructor:{configurable:!0,value:i,writable:!0}});var s=function(){function a(c,d){return r(c,"name",{configurable:!0,value:d})}try{var u=function(){};if(a(u,"foo"),u.name==="foo")return a}catch{}}();function l(a,u){if(u==null||u===Error)u=i;else if(typeof u!="function")throw new TypeError("super_ should be a function");var c;if(typeof a=="string")c=a,a=n!==void 0?function(){return n(u,arguments,this.constructor)}:function(){u.apply(this,arguments)},s!==void 0&&(s(a,c),c=void 0);else if(typeof a!="function")throw new TypeError("constructor should be either a string or a function");a.super_=a.super=u;var d={constructor:{configurable:!0,value:a,writable:!0}};return c!==void 0&&(d.name={configurable:!0,value:c,writable:!0}),a.prototype=Object.create(u.prototype,d),a}e=t.exports=l,e.BaseError=i})(v0,v0.exports);var wR=v0.exports,fS="ProseMirror-selectednode",yb="",xs="\0",pS="__state_override__",tD={LastNodeCompatible:"lastNodeCompatible",FormattingMark:"formattingMark",FormattingNode:"formattingNode",NodeCursor:"nodeCursor",FontStyle:"fontStyle",Link:"link",Color:"color",Alignment:"alignment",Indentation:"indentation",Behavior:"behavior",Code:"code",InlineNode:"inline",ListContainerNode:"listContainer",ListItemNode:"listItemNode",Block:"block",BlockNode:"block",TextBlock:"textBlock",ExcludeInputRules:"excludeFromInputRules",PreventExits:"preventsExits",Media:"media"},ke=tD,Bi=Symbol.for("__remirror__"),yn=(t=>(t.PlainExtension="RemirrorPlainExtension",t.NodeExtension="RemirrorNodeExtension",t.MarkExtension="RemirrorMarkExtension",t.PlainExtensionConstructor="RemirrorPlainExtensionConstructor",t.NodeExtensionConstructor="RemirrorNodeExtensionConstructor",t.MarkExtensionConstructor="RemirrorMarkExtensionConstructor",t.Manager="RemirrorManager",t.Preset="RemirrorPreset",t.PresetConstructor="RemirrorPresetConstructor",t))(yn||{}),ot=(t=>(t[t.Critical=1e6]="Critical",t[t.Highest=1e5]="Highest",t[t.High=1e4]="High",t[t.Medium=1e3]="Medium",t[t.Default=100]="Default",t[t.Low=10]="Low",t[t.Lowest=0]="Lowest",t))(ot||{}),mr=(t=>(t[t.None=0]="None",t[t.Create=1]="Create",t[t.EditorView=2]="EditorView",t[t.Runtime=3]="Runtime",t[t.Destroy=4]="Destroy",t))(mr||{}),oe=(t=>(t.Undo="_|undo|_",t.Redo="_|redo|_",t.Bold="_|bold|_",t.Italic="_|italic|_",t.Underline="_|underline|_",t.Strike="_|strike|_",t.Code="_|code|_",t.Paragraph="_|paragraph|_",t.H1="_|h1|_",t.H2="_|h2|_",t.H3="_|h3|_",t.H4="_|h4|_",t.H5="_|h5|_",t.H6="_|h6|_",t.TaskList="_|task|_",t.BulletList="_|bullet|_",t.OrderedList="_|number|_",t.Quote="_|quote|_",t.Divider="_|divider|_",t.Codeblock="_|codeblock|_",t.ClearFormatting="_|clear|_",t.Superscript="_|sup|_",t.Subscript="_|sub|_",t.LeftAlignment="_|left-align|_",t.CenterAlignment="_|center-align|_",t.RightAlignment="_|right-align|_",t.JustifyAlignment="_|justify-align|_",t.InsertLink="_|link|_",t.Find="_|find|_",t.FindBackwards="_|find-backwards|_",t.FindReplace="_|find-replace|_",t.AddFootnote="_|footnote|_",t.AddComment="_|comment|_",t.ContextMenu="_|context-menu|_",t.IncreaseFontSize="_|inc-font-size|_",t.DecreaseFontSize="_|dec-font-size|_",t.IncreaseIndent="_|indent|_",t.DecreaseIndent="_|dedent|_",t.Shortcuts="_|shortcuts|_",t.Copy="_|copy|_",t.Cut="_|cut|_",t.Paste="_|paste|_",t.PastePlain="_|paste-plain|_",t.SelectAll="_|select-all|_",t.Format="_|format|_",t))(oe||{}),re=(t=>(t.PROD="RMR0000",t.UNKNOWN="RMR0001",t.INVALID_COMMAND_ARGUMENTS="RMR0002",t.CUSTOM="RMR0003",t.CORE_HELPERS="RMR0004",t.MUTATION="RMR0005",t.INTERNAL="RMR0006",t.MISSING_REQUIRED_EXTENSION="RMR0007",t.MANAGER_PHASE_ERROR="RMR0008",t.INVALID_GET_EXTENSION="RMR0010",t.INVALID_MANAGER_ARGUMENTS="RMR0011",t.SCHEMA="RMR0012",t.HELPERS_CALLED_IN_OUTER_SCOPE="RMR0013",t.INVALID_MANAGER_EXTENSION="RMR0014",t.DUPLICATE_COMMAND_NAMES="RMR0016",t.DUPLICATE_HELPER_NAMES="RMR0017",t.NON_CHAINABLE_COMMAND="RMR0018",t.INVALID_EXTENSION="RMR0019",t.INVALID_CONTENT="RMR0021",t.INVALID_NAME="RMR0050",t.EXTENSION="RMR0100",t.EXTENSION_SPEC="RMR0101",t.EXTENSION_EXTRA_ATTRIBUTES="RMR0102",t.INVALID_SET_EXTENSION_OPTIONS="RMR0103",t.REACT_PROVIDER_CONTEXT="RMR0200",t.REACT_GET_ROOT_PROPS="RMR0201",t.REACT_EDITOR_VIEW="RMR0202",t.REACT_CONTROLLED="RMR0203",t.REACT_NODE_VIEW="RMR0204",t.REACT_GET_CONTEXT="RMR0205",t.REACT_COMPONENTS="RMR0206",t.REACT_HOOKS="RMR0207",t.I18N_CONTEXT="RMR0300",t))(re||{}),nD=function(e){return rD(e)&&!oD(e)};function rD(t){return!!t&&typeof t=="object"}function oD(t){var e=Object.prototype.toString.call(t);return e==="[object RegExp]"||e==="[object Date]"||aD(t)}var iD=typeof Symbol=="function"&&Symbol.for,sD=iD?Symbol.for("react.element"):60103;function aD(t){return t.$$typeof===sD}function lD(t){return Array.isArray(t)?[]:{}}function Wd(t,e){return e.clone!==!1&&e.isMergeableObject(t)?Rc(lD(t),t,e):t}function cD(t,e,n){return t.concat(e).map(function(r){return Wd(r,n)})}function uD(t,e){if(!e.customMerge)return Rc;var n=e.customMerge(t);return typeof n=="function"?n:Rc}function dD(t){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(t).filter(function(e){return Object.propertyIsEnumerable.call(t,e)}):[]}function gS(t){return Object.keys(t).concat(dD(t))}function xR(t,e){try{return e in t}catch{return!1}}function hD(t,e){return xR(t,e)&&!(Object.hasOwnProperty.call(t,e)&&Object.propertyIsEnumerable.call(t,e))}function fD(t,e,n){var r={};return n.isMergeableObject(t)&&gS(t).forEach(function(o){r[o]=Wd(t[o],n)}),gS(e).forEach(function(o){hD(t,o)||(xR(t,o)&&n.isMergeableObject(e[o])?r[o]=uD(o,n)(t[o],e[o],n):r[o]=Wd(e[o],n))}),r}function Rc(t,e,n){n=n||{},n.arrayMerge=n.arrayMerge||cD,n.isMergeableObject=n.isMergeableObject||nD,n.cloneUnlessOtherwiseSpecified=Wd;var r=Array.isArray(e),o=Array.isArray(t),i=r===o;return i?r?n.arrayMerge(t,e,n):fD(t,e,n):Wd(e,n)}Rc.all=function(e,n){if(!Array.isArray(e))throw new Error("first argument should be an array");return e.reduce(function(r,o){return Rc(r,o,n)},{})};var pD=Rc,gD=pD;const mD=jo(gD);var vD=function t(e,n){if(e===n)return!0;if(e&&n&&typeof e=="object"&&typeof n=="object"){if(e.constructor!==n.constructor)return!1;var r,o,i;if(Array.isArray(e)){if(r=e.length,r!=n.length)return!1;for(o=r;o--!==0;)if(!t(e[o],n[o]))return!1;return!0}if(e.constructor===RegExp)return e.source===n.source&&e.flags===n.flags;if(e.valueOf!==Object.prototype.valueOf)return e.valueOf()===n.valueOf();if(e.toString!==Object.prototype.toString)return e.toString()===n.toString();if(i=Object.keys(e),r=i.length,r!==Object.keys(n).length)return!1;for(o=r;o--!==0;)if(!Object.prototype.hasOwnProperty.call(n,i[o]))return!1;for(o=r;o--!==0;){var s=i[o];if(!t(e[s],n[s]))return!1}return!0}return e!==e&&n!==n};const yD=jo(vD);/*!
* isobject
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
- */var dR=function(e){return e!=null&&typeof e=="object"&&Array.isArray(e)===!1};/*!
+ */var kR=function(e){return e!=null&&typeof e=="object"&&Array.isArray(e)===!1};/*!
* is-plain-object
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
- */var oD=dR;function sS(t){return oD(t)===!0&&Object.prototype.toString.call(t)==="[object Object]"}var iD=function(e){var n,r;return!(sS(e)===!1||(n=e.constructor,typeof n!="function")||(r=n.prototype,sS(r)===!1)||r.hasOwnProperty("isPrototypeOf")===!1)};/*!
+ */var bD=kR;function mS(t){return bD(t)===!0&&Object.prototype.toString.call(t)==="[object Object]"}var wD=function(e){var n,r;return!(mS(e)===!1||(n=e.constructor,typeof n!="function")||(r=n.prototype,mS(r)===!1)||r.hasOwnProperty("isPrototypeOf")===!1)};/*!
* is-extendable
*
* Copyright (c) 2015-2017, Jon Schlinkert.
* Released under the MIT License.
- */var sD=iD,aD=function(e){return sD(e)||typeof e=="function"||Array.isArray(e)};/*!
+ */var xD=wD,kD=function(e){return xD(e)||typeof e=="function"||Array.isArray(e)};/*!
* object.omit
*
* Copyright (c) 2014-2017, Jon Schlinkert.
* Released under the MIT License.
- */var lD=aD,cD=function(e,n,r){if(!lD(e))return{};typeof n=="function"&&(r=n,n=[]),typeof n=="string"&&(n=[n]);for(var o=typeof r=="function",i=Object.keys(e),s={},l=0;l
*
* Copyright (c) 2014-2015 Jon Schlinkert, contributors.
* Licensed under the MIT License
- */var uD=dR,dD=function(e,n){if(!uD(e)&&typeof e!="function")return{};var r={};if(typeof n=="string")return n in e&&(r[n]=e[n]),r;for(var o=n.length,i=-1;++i{let d=a.prefixes[c]||"",h=u;return n===!1&&(r&&(h=h.normalize("NFD").replace(new RegExp(`[^a-zA-ZØßø0-9${r.join("")}]`,"g"),"")),r||(h=h.normalize("NFD").replace(/[^a-zA-ZØßø0-9]/g,""),d="")),r&&(d=d.replace(new RegExp(`[^${r.join("")}]`,"g"),"")),c===0?d+h:!d&&!h?"":s&&!d&&o.match(/\s/)?" "+h:(d||o)+h}).filter(Boolean)}function pD(t){const e=t.matchAll(hR).next().value,n=e?e.index:0;return t.slice(0,n+1).toUpperCase()+t.slice(n+1).toLowerCase()}function pR(t,e){return fR(t,e).reduce((n,r)=>n+pD(r),"")}function aS(t,e){return fR(t,{...e,prefix:"-"}).join("").toLowerCase()}function g0(t,e,n,r){var o,i=!1,s=0;function l(){o&&clearTimeout(o)}function a(){l(),i=!0}typeof e!="boolean"&&(r=n,n=e,e=void 0);function u(){for(var c=arguments.length,d=new Array(c),h=0;ht?g():e!==!0&&(o=setTimeout(r?m:g,r===void 0?t-p:t))}return u.cancel=a,u}function gR(t,e,n){return n===void 0?g0(t,e,!1):g0(t,n,e!==!1)}function It(t,e,n){const r=t[e];return gb(!lm(r),n),r}function gb(t,e){if(!t)throw new gD(e)}var gD=class extends cR.BaseError{constructor(){super(...arguments),this.name="AssertionError"}};function cn(t){return Object.entries(t)}function Wd(t){return Object.keys(t)}function Hh(t){return Object.values(t)}function ar(t,e,n){return t.includes(e,n)}function be(t){return Object.assign(Object.create(null),t)}function mR(t){return Object.prototype.toString.call(t)}function vR(t){return mR(t).slice(8,-1)}function Uh(t,e){return n=>typeof n!==t?!1:e?e(n):!0}function mb(t){return e=>vR(e)===t}var lm=Uh("undefined"),Ee=Uh("string"),Zr=Uh("number",t=>!Number.isNaN(t)),tt=Uh("function");function mD(t){return t===null}function m0(t){return t===!0||t===!1}function ta(t){if(vR(t)!=="Object")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.getPrototypeOf({})}function vD(t){return t==null||/^[bns]/.test(typeof t)}function Us(t){return mD(t)||lm(t)}function Pn(t){return!Us(t)&&(tt(t)||Uh("object")(t))}var yD=mb("RegExp");function bD(t){return mb("Map")(t)}function wD(t){return mb("Set")(t)}function Vd(t){return Pn(t)&&!bD(t)&&!wD(t)&&Object.keys(t).length===0}var Bt=Array.isArray;function Ws(t){return Bt(t)&&t.length===0}function lS(t){return Bt(t)&&t.length>0}function xD(t){return t.charAt(0).toUpperCase()+t.slice(1)}function cu(t,e,n=r=>!!r){e.lastIndex=0;const r=[],o=e.flags;let i;o.includes("g")||(e=new RegExp(e.source,`g${o}`));do i=e.exec(t),i&&r.push(i);while(n(i));return e.lastIndex=0,r}function Wp(){const t=Date.now(),e=Wp.last||t;return Wp.last=t>e?t:e+1}Wp.last=0;function Ic(t=""){return`${t}${Wp().toString(36)}`}function yR(t){return pb(t,e=>!lm(e))}function kD(t){if(!ta(t))throw new Error("An invalid value was passed into this clone utility. Expected a plain object");return{...t}}var bR=rD;function Lc(t,e=!1){const n=e?[...t].reverse():t,r=new Set(n);return e?[...r].reverse():[...r]}function wR(t){const e=[];for(const n of t){const r=Bt(n)?wR(n):[n];e.push(...r)}return e}function xR(){}function kR(...t){return tD.all(t,{isMergeableObject:ta})}function ED({min:t,max:e,value:n}){return ne?e:n}function SD(t){return t[t.length-1]}function Vs(t,e){return[...t].map((n,r)=>({value:n,index:r})).sort((n,r)=>e(n.value,r.value)||n.index-r.index).map(({value:n})=>n)}function CD(t,e,n){try{if(Ee(e)&&e in t)return t[e];Bt(e)&&(e=`['${e.join("']['")}']`);let r=t;return e.replace(/\[\s*(["'])(.*?)\1\s*]|^\s*(\w+)\s*(?=\.|\[|$)|\.\s*(\w*)\s*(?=\.|\[|$)|\[\s*(-?\d+)\s*]/g,(o,i,s,l,a,u)=>(r=r[s||l||a||u],"")),r===void 0?n:r}catch{return n}}function TD(t,e){const n=kD(e);let r=n;for(const[o,i]of t.entries()){const s=o>=t.length-1;let l=r[i];if(s){if(Bt(r)){const a=Number.parseInt(i.toString(),10);Zr(a)&&r.splice(a,1)}else Reflect.deleteProperty(r,i);return n}if(vD(l))return n;l=Bt(l)?[...l]:{...l},r[i]=l,r=l}return n}function AD(t){return e=>CD(e,t)}function vb(t,e,n=!1){const r=[],o=new Set,i=tt(e)?e:AD(e),s=n?[...t].reverse():t;for(const l of s){const a=i(l);o.has(a)||(o.add(a),r.push(l))}return n?r.reverse():r}function yb(t,e){const n=Bt(t)?t[0]:t;return Zr(e)?n<=e?Array.from({length:e+1-n},(r,o)=>o+n):Array.from({length:n+1-e},(r,o)=>-1*o+n):Array.from({length:Math.abs(n)},(r,o)=>(n<0?-1:1)*o)}function ii(t,...e){const n=e.filter(Zr);return t>=Math.min(...n)&&t<=Math.max(...n)}function ER(t){return tt(t)?t():t}var SR="https://remirror.io/docs/errors",_D={[re.UNKNOWN]:"An error occurred but we're not quite sure why. 🧐",[re.INVALID_COMMAND_ARGUMENTS]:"The arguments passed to the command method were invalid.",[re.CUSTOM]:"This is a custom error, possibly thrown by an external library.",[re.CORE_HELPERS]:"An error occurred in a function called from the `@remirror/core-helpers` library.",[re.MUTATION]:"Mutation of immutable value detected.",[re.INTERNAL]:"This is an error which should not occur and is internal to the remirror codebase.",[re.MISSING_REQUIRED_EXTENSION]:"Your editor is missing a required extension.",[re.MANAGER_PHASE_ERROR]:"This occurs when accessing a method or property before it is available.",[re.INVALID_GET_EXTENSION]:"The user requested an invalid extension from the getExtensions method. Please check the `createExtensions` return method is returning an extension with the defined constructor.",[re.INVALID_MANAGER_ARGUMENTS]:"Invalid value(s) passed into `Manager` constructor. Only `Presets` and `Extensions` are supported.",[re.SCHEMA]:"There is a problem with the schema or you are trying to access a node / mark that doesn't exists.",[re.HELPERS_CALLED_IN_OUTER_SCOPE]:"The `helpers` method which is passed into the ``create*` method should only be called within returned method since it relies on an active view (not present in the outer scope).",[re.INVALID_MANAGER_EXTENSION]:"You requested an invalid extension from the manager.",[re.DUPLICATE_COMMAND_NAMES]:"Command method names must be unique within the editor.",[re.DUPLICATE_HELPER_NAMES]:"Helper method names must be unique within the editor.",[re.NON_CHAINABLE_COMMAND]:"Attempted to chain a non chainable command.",[re.INVALID_EXTENSION]:"The provided extension is invalid.",[re.INVALID_CONTENT]:"The content provided to the editor is not supported.",[re.INVALID_NAME]:"An invalid name was used for the extension.",[re.EXTENSION]:"An error occurred within an extension. More details should be made available.",[re.EXTENSION_SPEC]:"The spec was defined without calling the `defaults`, `parse` or `dom` methods.",[re.EXTENSION_EXTRA_ATTRIBUTES]:"Extra attributes must either be a string or an object.",[re.INVALID_SET_EXTENSION_OPTIONS]:"A call to `extension.setOptions` was made with invalid keys.",[re.REACT_PROVIDER_CONTEXT]:"`useRemirrorContext` was called outside of the `remirror` context. It can only be used within an active remirror context created by the ``.",[re.REACT_GET_ROOT_PROPS]:"`getRootProps` has been attached to the DOM more than once. It should only be attached to the dom once per editor.",[re.REACT_EDITOR_VIEW]:"A problem occurred adding the editor view to the dom.",[re.REACT_CONTROLLED]:"There is a problem with your controlled editor setup.",[re.REACT_NODE_VIEW]:"Something went wrong with your custom ReactNodeView Component.",[re.REACT_GET_CONTEXT]:"You attempted to call `getContext` provided by the `useRemirror` prop during the first render of the editor. This is not possible and should only be after the editor first mounts.",[re.REACT_COMPONENTS]:"An error occurred within a remirror component.",[re.REACT_HOOKS]:"An error occurred within a remirror hook.",[re.I18N_CONTEXT]:"You called `useI18n()` outside of an `I18nProvider` context."};function RD(t){return Ee(t)&&ar(Hh(re),t)}function MD(t,e){const n=_D[t],r=n?`${n}
+ */var CD=kR,TD=function(e,n){if(!CD(e)&&typeof e!="function")return{};var r={};if(typeof n=="string")return n in e&&(r[n]=e[n]),r;for(var o=n.length,i=-1;++i{let d=a.prefixes[c]||"",h=u;return n===!1&&(r&&(h=h.normalize("NFD").replace(new RegExp(`[^a-zA-ZØßø0-9${r.join("")}]`,"g"),"")),r||(h=h.normalize("NFD").replace(/[^a-zA-ZØßø0-9]/g,""),d="")),r&&(d=d.replace(new RegExp(`[^${r.join("")}]`,"g"),"")),c===0?d+h:!d&&!h?"":s&&!d&&o.match(/\s/)?" "+h:(d||o)+h}).filter(Boolean)}function RD(t){const e=t.matchAll(ER).next().value,n=e?e.index:0;return t.slice(0,n+1).toUpperCase()+t.slice(n+1).toLowerCase()}function CR(t,e){return SR(t,e).reduce((n,r)=>n+RD(r),"")}function vS(t,e){return SR(t,{...e,prefix:"-"}).join("").toLowerCase()}function b0(t,e,n,r){var o,i=!1,s=0;function l(){o&&clearTimeout(o)}function a(){l(),i=!0}typeof e!="boolean"&&(r=n,n=e,e=void 0);function u(){for(var c=arguments.length,d=new Array(c),h=0;ht?g():e!==!0&&(o=setTimeout(r?m:g,r===void 0?t-p:t))}return u.cancel=a,u}function TR(t,e,n){return n===void 0?b0(t,e,!1):b0(t,n,e!==!1)}function Mt(t,e,n){const r=t[e];return wb(!hm(r),n),r}function wb(t,e){if(!t)throw new MD(e)}var MD=class extends wR.BaseError{constructor(){super(...arguments),this.name="AssertionError"}};function an(t){return Object.entries(t)}function Vd(t){return Object.keys(t)}function Uh(t){return Object.values(t)}function ir(t,e,n){return t.includes(e,n)}function ye(t){return Object.assign(Object.create(null),t)}function AR(t){return Object.prototype.toString.call(t)}function _R(t){return AR(t).slice(8,-1)}function Wh(t,e){return n=>typeof n!==t?!1:e?e(n):!0}function xb(t){return e=>_R(e)===t}var hm=Wh("undefined"),Ee=Wh("string"),Xr=Wh("number",t=>!Number.isNaN(t)),Je=Wh("function");function OD(t){return t===null}function w0(t){return t===!0||t===!1}function Js(t){if(_R(t)!=="Object")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.getPrototypeOf({})}function ID(t){return t==null||/^[bns]/.test(typeof t)}function Bs(t){return OD(t)||hm(t)}function $n(t){return!Bs(t)&&(Je(t)||Wh("object")(t))}var LD=xb("RegExp");function ND(t){return xb("Map")(t)}function $D(t){return xb("Set")(t)}function jd(t){return $n(t)&&!ND(t)&&!$D(t)&&Object.keys(t).length===0}var Pt=Array.isArray;function Hs(t){return Pt(t)&&t.length===0}function yS(t){return Pt(t)&&t.length>0}function DD(t){return t.charAt(0).toUpperCase()+t.slice(1)}function lu(t,e,n=r=>!!r){e.lastIndex=0;const r=[],o=e.flags;let i;o.includes("g")||(e=new RegExp(e.source,`g${o}`));do i=e.exec(t),i&&r.push(i);while(n(i));return e.lastIndex=0,r}function Yp(){const t=Date.now(),e=Yp.last||t;return Yp.last=t>e?t:e+1}Yp.last=0;function Mc(t=""){return`${t}${Yp().toString(36)}`}function RR(t){return bb(t,e=>!hm(e))}function PD(t){if(!Js(t))throw new Error("An invalid value was passed into this clone utility. Expected a plain object");return{...t}}var MR=yD;function Oc(t,e=!1){const n=e?[...t].reverse():t,r=new Set(n);return e?[...r].reverse():[...r]}function OR(t){const e=[];for(const n of t){const r=Pt(n)?OR(n):[n];e.push(...r)}return e}function IR(){}function LR(...t){return mD.all(t,{isMergeableObject:Js})}function zD({min:t,max:e,value:n}){return ne?e:n}function FD(t){return t[t.length-1]}function Us(t,e){return[...t].map((n,r)=>({value:n,index:r})).sort((n,r)=>e(n.value,r.value)||n.index-r.index).map(({value:n})=>n)}function BD(t,e,n){try{if(Ee(e)&&e in t)return t[e];Pt(e)&&(e=`['${e.join("']['")}']`);let r=t;return e.replace(/\[\s*(["'])(.*?)\1\s*]|^\s*(\w+)\s*(?=\.|\[|$)|\.\s*(\w*)\s*(?=\.|\[|$)|\[\s*(-?\d+)\s*]/g,(o,i,s,l,a,u)=>(r=r[s||l||a||u],"")),r===void 0?n:r}catch{return n}}function HD(t,e){const n=PD(e);let r=n;for(const[o,i]of t.entries()){const s=o>=t.length-1;let l=r[i];if(s){if(Pt(r)){const a=Number.parseInt(i.toString(),10);Xr(a)&&r.splice(a,1)}else Reflect.deleteProperty(r,i);return n}if(ID(l))return n;l=Pt(l)?[...l]:{...l},r[i]=l,r=l}return n}function UD(t){return e=>BD(e,t)}function kb(t,e,n=!1){const r=[],o=new Set,i=Je(e)?e:UD(e),s=n?[...t].reverse():t;for(const l of s){const a=i(l);o.has(a)||(o.add(a),r.push(l))}return n?r.reverse():r}function Eb(t,e){const n=Pt(t)?t[0]:t;return Xr(e)?n<=e?Array.from({length:e+1-n},(r,o)=>o+n):Array.from({length:n+1-e},(r,o)=>-1*o+n):Array.from({length:Math.abs(n)},(r,o)=>(n<0?-1:1)*o)}function ri(t,...e){const n=e.filter(Xr);return t>=Math.min(...n)&&t<=Math.max(...n)}function NR(t){return Je(t)?t():t}var $R="https://remirror.io/docs/errors",WD={[re.UNKNOWN]:"An error occurred but we're not quite sure why. 🧐",[re.INVALID_COMMAND_ARGUMENTS]:"The arguments passed to the command method were invalid.",[re.CUSTOM]:"This is a custom error, possibly thrown by an external library.",[re.CORE_HELPERS]:"An error occurred in a function called from the `@remirror/core-helpers` library.",[re.MUTATION]:"Mutation of immutable value detected.",[re.INTERNAL]:"This is an error which should not occur and is internal to the remirror codebase.",[re.MISSING_REQUIRED_EXTENSION]:"Your editor is missing a required extension.",[re.MANAGER_PHASE_ERROR]:"This occurs when accessing a method or property before it is available.",[re.INVALID_GET_EXTENSION]:"The user requested an invalid extension from the getExtensions method. Please check the `createExtensions` return method is returning an extension with the defined constructor.",[re.INVALID_MANAGER_ARGUMENTS]:"Invalid value(s) passed into `Manager` constructor. Only `Presets` and `Extensions` are supported.",[re.SCHEMA]:"There is a problem with the schema or you are trying to access a node / mark that doesn't exists.",[re.HELPERS_CALLED_IN_OUTER_SCOPE]:"The `helpers` method which is passed into the ``create*` method should only be called within returned method since it relies on an active view (not present in the outer scope).",[re.INVALID_MANAGER_EXTENSION]:"You requested an invalid extension from the manager.",[re.DUPLICATE_COMMAND_NAMES]:"Command method names must be unique within the editor.",[re.DUPLICATE_HELPER_NAMES]:"Helper method names must be unique within the editor.",[re.NON_CHAINABLE_COMMAND]:"Attempted to chain a non chainable command.",[re.INVALID_EXTENSION]:"The provided extension is invalid.",[re.INVALID_CONTENT]:"The content provided to the editor is not supported.",[re.INVALID_NAME]:"An invalid name was used for the extension.",[re.EXTENSION]:"An error occurred within an extension. More details should be made available.",[re.EXTENSION_SPEC]:"The spec was defined without calling the `defaults`, `parse` or `dom` methods.",[re.EXTENSION_EXTRA_ATTRIBUTES]:"Extra attributes must either be a string or an object.",[re.INVALID_SET_EXTENSION_OPTIONS]:"A call to `extension.setOptions` was made with invalid keys.",[re.REACT_PROVIDER_CONTEXT]:"`useRemirrorContext` was called outside of the `remirror` context. It can only be used within an active remirror context created by the ``.",[re.REACT_GET_ROOT_PROPS]:"`getRootProps` has been attached to the DOM more than once. It should only be attached to the dom once per editor.",[re.REACT_EDITOR_VIEW]:"A problem occurred adding the editor view to the dom.",[re.REACT_CONTROLLED]:"There is a problem with your controlled editor setup.",[re.REACT_NODE_VIEW]:"Something went wrong with your custom ReactNodeView Component.",[re.REACT_GET_CONTEXT]:"You attempted to call `getContext` provided by the `useRemirror` prop during the first render of the editor. This is not possible and should only be after the editor first mounts.",[re.REACT_COMPONENTS]:"An error occurred within a remirror component.",[re.REACT_HOOKS]:"An error occurred within a remirror hook.",[re.I18N_CONTEXT]:"You called `useI18n()` outside of an `I18nProvider` context."};function VD(t){return Ee(t)&&ir(Uh(re),t)}function jD(t,e){const n=WD[t],r=n?`${n}
`:"",o=e?`${e}
-`:"";return`${r}${o}For more information visit ${SR}#${t.toLowerCase()}`}var CR=class extends cR.BaseError{constructor({code:t,message:e,disableLogging:n=!1}={}){const r=RD(t)?t:re.CUSTOM;super(MD(r,e)),this.errorCode=r,this.url=`${SR}#${r.toLowerCase()}`,n||console.error(this.message)}static create(t={}){return new CR(t)}};function we(t,e){if(!t)throw CR.create(e)}function cm(t){if(typeof t!="object"||t===null)return t;const e=Symbol.toStringTag in t&&t[Symbol.toStringTag]==="Module"?t.default??t:t;return e&&typeof t=="object"&&"__esModule"in e&&e.__esModule&&e.default!==void 0?e.default:e}function $a(t,e={}){return t}function Mn(t){this.content=t}Mn.prototype={constructor:Mn,find:function(t){for(var e=0;e>1}};Mn.from=function(t){if(t instanceof Mn)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new Mn(e)};function TR(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let o=t.child(r),i=e.child(r);if(o==i){n+=o.nodeSize;continue}if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)n++;return n}if(o.content.size||i.content.size){let s=TR(o.content,i.content,n+1);if(s!=null)return s}n+=o.nodeSize}}function AR(t,e,n,r){for(let o=t.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:n,b:r};let s=t.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let u=0,c=Math.min(s.text.length,l.text.length);for(;ue&&r(a,o+l,i||null,s)!==!1&&a.content.size){let c=l+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,n-c),r,o+c)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,o){let i="",s=!0;return this.nodesBetween(e,n,(l,a)=>{l.isText?(i+=l.text.slice(Math.max(e,a)-a,n-a),s=!r):l.isLeaf?(o?i+=typeof o=="function"?o(l):o:l.type.spec.leafText&&(i+=l.type.spec.leafText(l)),s=!r):!s&&l.isBlock&&(i+=r,s=!0)},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),i=1);ie)for(let i=0,s=0;se&&((sn)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),o+=l.nodeSize),s=a}return new Q(r,o)}cutByIndex(e,n){return e==n?Q.empty:e==0&&n==this.content.length?this:new Q(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[e]=n,new Q(o,i)}addToStart(e){return new Q([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Q(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,o=0;;r++){let i=this.child(r),s=o+i.nodeSize;if(s>=e)return s==e||n>0?Rf(r+1,s):Rf(r,o);o=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return Q.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Q(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Q.empty;let n,r=0;for(let o=0;othis.type.rank&&(n||(n=e.slice(0,o)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-o.type.rank),n}}Ke.none=[];class jp extends Error{}class ae{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=RR(this.content,e+this.openStart,n);return r&&new ae(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ae(_R(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ae.empty;let r=n.openStart||0,o=n.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ae(Q.fromJSON(e,n.content),r,o)}static maxOpen(e,n=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)o++;return new ae(e,r,o)}}ae.empty=new ae(Q.empty,0,0);function _R(t,e,n){let{index:r,offset:o}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(o==e||i.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(_R(i.content,e-o-1,n-o-1)))}function RR(t,e,n,r){let{index:o,offset:i}=t.findIndex(e),s=t.maybeChild(o);if(i==e||s.isText)return r&&!r.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=RR(s.content,e-i-1,n);return l&&t.replaceChild(o,s.copy(l))}function OD(t,e,n){if(n.openStart>t.depth)throw new jp("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new jp("Inconsistent open depths");return MR(t,e,n,0)}function MR(t,e,n,r){let o=t.index(r),i=t.node(r);if(o==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Ed(t,e,n,r){let o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Va(t.nodeAfter,r),i++));for(let l=i;lo&&v0(t,e,o+1),s=r.depth>o&&v0(n,r,o+1),l=[];return Ed(null,t,o,l),i&&s&&e.index(o)==n.index(o)?(OR(i,s),Va(ja(i,IR(t,e,n,r,o+1)),l)):(i&&Va(ja(i,Gp(t,e,o+1)),l),Ed(e,n,o,l),s&&Va(ja(s,Gp(n,r,o+1)),l)),Ed(r,null,o,l),new Q(l)}function Gp(t,e,n){let r=[];if(Ed(null,t,n,r),t.depth>n){let o=v0(t,e,n+1);Va(ja(o,Gp(t,e,n+1)),r)}return Ed(e,null,n,r),new Q(r)}function ID(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)o=e.node(i).copy(Q.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}class Nc{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(n);return r?e.child(n).cut(r):o}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],o=n==0?0:this.path[n*3-1]+1;for(let i=0;i0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Za(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],o=0,i=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),u=i-a;if(r.push(s,l,o+a),!u||(s=s.child(l),s.isText))break;i=u-1,o+=a+1}return new Nc(n,r,i)}static resolveCached(e,n){for(let o=0;oe&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),LR(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=Q.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=o;an.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let o=Q.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,o,r)}};Rs.prototype.text=void 0;class Kp extends Rs{constructor(e,n,r,o){if(super(e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):LR(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Kp(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Kp(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function LR(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class Qa{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new $D(e,n);if(r.next==null)return Qa.empty;let o=NR(r);r.next&&r.err("Unexpected trailing text");let i=UD(HD(o));return WD(i,r),i}matchType(e){for(let n=0;nu.createAndFill()));for(let u=0;u=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let o=0;o{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return i}).join(`
-`)}}Qa.empty=new Qa(!0);class $D{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function NR(t){let e=[];do e.push(DD(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function DD(t){let e=[];do e.push(PD(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function PD(t){let e=BD(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=zD(t,e);else break;return e}function cS(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function zD(t,e){let n=cS(t),r=n;return t.eat(",")&&(t.next!="}"?r=cS(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function FD(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let i in n){let s=n[i];s.groups.indexOf(e)>-1&&o.push(s)}return o.length==0&&t.err("No node type or group '"+e+"' found"),o}function BD(t){if(t.eat("(")){let e=NR(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=FD(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function HD(t){let e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let u={term:a,to:l};return e[s].push(u),u}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,u)=>a.concat(i(u,l)),[]);if(s.type=="seq")for(let a=0;;a++){let u=i(s.exprs[a],l);if(a==s.exprs.length-1)return u;o(u,l=n())}else if(s.type=="star"){let a=n();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=n();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let u=0;u{t[s].forEach(({term:l,to:a})=>{if(!l)return;let u;for(let c=0;c{u||o.push([l,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let i=e[r.join(",")]=new Qa(r.indexOf(t.length-1)>-1);for(let s=0;s-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[i]=new FR(i,n,s));let o=n.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class VD{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class Wh{constructor(e,n,r,o){this.name=e,this.rank=n,this.schema=r,this.spec=o,this.attrs=zR(o.attrs),this.excluded=null;let i=DR(this.attrs);this.instance=i?new Ke(this,i):null}create(e=null){return!e&&this.instance?this.instance:new Ke(this,PR(this.attrs,e))}static compile(e,n){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new Wh(i,o++,n,s)),r}removeFromSet(e){for(var n=0;n-1}}let jD=class{constructor(e){this.cached=Object.create(null);let n=this.spec={};for(let o in e)n[o]=e[o];n.nodes=Mn.from(e.nodes),n.marks=Mn.from(e.marks||{}),this.nodes=b0.compile(this.spec.nodes,this),this.marks=Wh.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;i.contentMatch=r[s]||(r[s]=Qa.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet=l=="_"?null:l?dS(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:dS(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof b0){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,o)}text(e,n){let r=this.nodes.text;return new Kp(r,r.defaultAttrs,e,Ke.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeFromJSON(e){return Rs.fromJSON(this,e)}markFromJSON(e){return Ke.fromJSON(this,e)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function dS(t,e){let n=[];for(let r=0;r-1)&&n.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}let bb=class w0{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[],n.forEach(r=>{r.tag?this.tags.push(r):r.style&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let o=e.nodes[r.node];return o.contentMatch.matchType(o)})}parse(e,n={}){let r=new fS(this,n,!1);return r.addAll(e,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new fS(this,n,!0);return r.addAll(e,n.from,n.to),ae.maxOpen(r.finish())}matchTag(e,n,r){for(let o=r?this.tags.indexOf(r)+1:0;oe.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s{r(s=pS(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=pS(s)),s.node||s.ignore||s.mark||(s.node=o)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new w0(e,w0.schemaRules(e)))}};const BR={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},GD={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},HR={ol:!0,ul:!0},Yp=1,Xp=2,Sd=4;function hS(t,e,n){return e!=null?(e?Yp:0)|(e==="full"?Xp:0):t&&t.whitespace=="pre"?Yp|Xp:n&~Sd}class Mf{constructor(e,n,r,o,i,s,l){this.type=e,this.attrs=n,this.marks=r,this.pendingMarks=o,this.solid=i,this.options=l,this.content=[],this.activeMarks=Ke.none,this.stashMarks=[],this.match=s||(l&Sd?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Q.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Yp)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let n=Q.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Q.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}popFromStashMark(e){for(let n=this.stashMarks.length-1;n>=0;n--)if(e.eq(this.stashMarks[n]))return this.stashMarks.splice(n,1)[0]}applyPending(e){for(let n=0,r=this.pendingMarks;nthis.addAll(e)),s&&this.sync(l),this.needsBlock=a}else this.withStyleRules(e,()=>{this.addElementByRule(e,i,i.consuming===!1?o:void 0)})}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
-`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let n=Ke.none,r=Ke.none;for(let o=0;o{s.clearMark(l)&&(r=l.addToSet(r))}):n=this.parser.schema.marks[s.mark].create(s.attrs).addToSet(n),s.consuming===!1)i=s;else break}return[n,r]}addElementByRule(e,n,r){let o,i,s;n.node?(i=this.parser.schema.nodes[n.node],i.isLeaf?this.insertNode(i.create(n.attrs))||this.leafFallback(e):o=this.enter(i,n.attrs||null,n.preserveWhitespace)):(s=this.parser.schema.marks[n.mark].create(n.attrs),this.addPendingMark(s));let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a)}o&&this.sync(l)&&this.open--,s&&this.removePendingMark(s,l)}addAll(e,n,r){let o=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=r==null?null:e.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i);this.findAtPoint(e,o)}findPlace(e){let n,r;for(let o=this.open;o>=0;o--){let i=this.nodes[o],s=i.findWrapping(e);if(s&&(!n||n.length>s.length)&&(n=s,r=i,!s.length)||i.solid)break}if(!n)return!1;this.sync(r);for(let o=0;othis.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let n=this.open;n>=0;n--)if(this.nodes[n]==e)return this.open=n,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let c=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!c||c.name!=u&&c.groups.indexOf(u)==-1)return!1;a--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let n=ZD(e,this.top.pendingMarks);n&&this.top.stashMarks.push(n),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,n){for(let r=this.open;r>=0;r--){let o=this.nodes[r];if(o.pendingMarks.lastIndexOf(e)>-1)o.pendingMarks=e.removeFromSet(o.pendingMarks);else{o.activeMarks=e.removeFromSet(o.activeMarks);let s=o.popFromStashMark(e);s&&o.type&&o.type.allowsMarkType(s.type)&&(o.activeMarks=s.addToSet(o.activeMarks))}if(o==n)break}}}function KD(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&HR.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function YD(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function XD(t){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,n,r=[];for(;n=e.exec(t);)r.push(n[1],n[2].trim());return r}function pS(t){let e={};for(let n in t)e[n]=t[n];return e}function qD(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let i=[],s=l=>{i.push(l);for(let a=0;a{if(i.length||s.marks.length){let l=0,a=0;for(;l=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let o=this.marks[e.type.name];return o&&jr.renderSpec(Zv(r),o(e,n))}static renderSpec(e,n,r=null){if(typeof n=="string")return{dom:e.createTextNode(n)};if(n.nodeType!=null)return{dom:n};if(n.dom&&n.dom.nodeType!=null)return n;let o=n[0],i=o.indexOf(" ");i>0&&(r=o.slice(0,i),o=o.slice(i+1));let s,l=r?e.createElementNS(r,o):e.createElement(o),a=n[1],u=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){u=2;for(let c in a)if(a[c]!=null){let d=c.indexOf(" ");d>0?l.setAttributeNS(c.slice(0,d),c.slice(d+1),a[c]):l.setAttribute(c,a[c])}}for(let c=u;cu)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:h,contentDOM:f}=jr.renderSpec(e,d,r);if(l.appendChild(h),f){if(s)throw new RangeError("Multiple content holes");s=f}}}return{dom:l,contentDOM:s}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new jr(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=gS(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return gS(e.marks)}}function gS(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function Zv(t){return t.document||window.document}const UR=65535,WR=Math.pow(2,16);function QD(t,e){return t+e*WR}function mS(t){return t&UR}function JD(t){return(t-(t&UR))/WR}const VR=1,jR=2,up=4,GR=8;class x0{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&GR)>0}get deletedBefore(){return(this.delInfo&(VR|up))>0}get deletedAfter(){return(this.delInfo&(jR|up))>0}get deletedAcross(){return(this.delInfo&up)>0}}class Wr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Wr.empty)return Wr.empty}recover(e){let n=0,r=mS(e);if(!this.inverted)for(let o=0;oe)break;let u=this.ranges[l+i],c=this.ranges[l+s],d=a+u;if(e<=d){let h=u?e==a?-1:e==d?1:n:n,f=a+o+(h<0?0:c);if(r)return f;let p=e==(n<0?a:d)?null:QD(l/3,e-a),g=e==a?jR:e==d?VR:up;return(n<0?e!=a:e!=d)&&(g|=GR),new x0(f,g,p)}o+=c-u}return r?e+o:new x0(e+o,0,null)}touches(e,n){let r=0,o=mS(n),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+i],c=a+u;if(e<=c&&l==o*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o=0;n--){let o=e.getMirror(n);this.appendMap(e.maps[n].invert(),o!=null&&o>n?r-o-1:void 0)}}invert(){let e=new vc;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ri&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),n.openStart,n.openEnd);return Xt.fromReplace(e,this.from,this.to,i)}invert(){return new Fo(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Ni(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ni&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ni(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ni(n.from,n.to,e.markFromJSON(n.mark))}}dn.jsonID("addMark",Ni);class Fo extends dn{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new ae(wb(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),n.openStart,n.openEnd);return Xt.fromReplace(e,this.from,this.to,r)}invert(){return new Ni(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Fo(n.pos,r.pos,this.mark)}merge(e){return e instanceof Fo&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Fo(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Fo(n.from,n.to,e.markFromJSON(n.mark))}}dn.jsonID("removeMark",Fo);class Ss extends dn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Xt.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Xt.fromReplace(e,this.pos,this.pos+1,new ae(Q.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let o=0;or.pos?null:new qt(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new qt(n.from,n.to,n.gapFrom,n.gapTo,ae.fromJSON(e,n.slice),n.insert,!!n.structure)}}dn.jsonID("replaceAround",qt);function k0(t,e,n){let r=t.resolve(e),o=n-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function eP(t,e,n,r){let o=[],i=[],s,l;t.doc.nodesBetween(e,n,(a,u,c)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let h=Math.max(u,e),f=Math.min(u+a.nodeSize,n),p=r.addToSet(d);for(let g=0;gt.step(a)),i.forEach(a=>t.step(a))}function tP(t,e,n,r){let o=[],i=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;i++;let a=null;if(r instanceof Wh){let u=s.marks,c;for(;c=r.isInSet(u);)(a||(a=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let u=Math.min(l+s.nodeSize,n);for(let c=0;ct.step(new Fo(s.from,s.to,s.style)))}function nP(t,e,n,r=n.contentMatch){let o=t.doc.nodeAt(e),i=[],s=e+1;for(let l=0;l=0;l--)t.step(i[l])}function rP(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function uu(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let o=t.$from.node(r),i=t.$from.index(r),s=t.$to.indexAfter(r);if(rn;p--)g||r.index(p)>0?(g=!0,c=Q.from(r.node(p).copy(c)),d++):a--;let h=Q.empty,f=0;for(let p=i,g=!1;p>n;p--)g||o.after(p+1)=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Q.from(n[s].type.create(n[s].attrs,r))}let o=e.start,i=e.end;t.step(new qt(o,i,o,i,new ae(r,0,0),n.length,!0))}function lP(t,e,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{if(s.isTextblock&&!s.hasMarkup(r,o)&&cP(t.doc,t.mapping.slice(i).map(l),r)){t.clearIncompatible(t.mapping.slice(i).map(l,1),r);let a=t.mapping.slice(i),u=a.map(l,1),c=a.map(l+s.nodeSize,1);return t.step(new qt(u,c,u+1,c-1,new ae(Q.from(r.create(o,null,s.marks)),0,0),1,!0)),!1}})}function cP(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function uP(t,e,n,r,o){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new qt(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new ae(Q.from(s),0,0),1,!0))}function yc(t,e,n=1,r){let o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let u=o.depth-1,c=n-2;u>i;u--,c--){let d=o.node(u),h=o.index(u);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(h,d.childCount),p=r&&r[c+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[c]||d;if(!d.canReplace(h+1,d.childCount)||!g.type.validContent(f))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function dP(t,e,n=1,r){let o=t.doc.resolve(e),i=Q.empty,s=Q.empty;for(let l=o.depth,a=o.depth-n,u=n-1;l>a;l--,u--){i=Q.from(o.node(l).copy(i));let c=r&&r[u];s=Q.from(c?c.type.create(c.attrs,s):o.node(l).copy(s))}t.step(new bn(e,e,new ae(i.append(s),n,n),!0))}function Vh(t,e){let n=t.resolve(e),r=n.index();return hP(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function hP(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}function fP(t,e,n){let r=new bn(e-n,e+n,ae.empty,!0);t.step(r)}function KR(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,n))return r.after(o+1);if(i=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),u=r.node(s),c=!1;if(i==1)c=u.canReplace(a,a,o);else{let d=u.contentMatchAt(a).findWrapping(o.firstChild.type);c=d&&u.canReplaceWith(a,a,d[0])}if(c)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function kb(t,e,n=e,r=ae.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),i=t.resolve(n);return YR(o,i,r)?new bn(e,n,r):new gP(o,i,r).fit()}function YR(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class gP{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Q.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=Q.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new ae(i,s,l);return e>-1?new qt(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new bn(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,o=this.unplaced.openEnd;r1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=Jv(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:u}=this.frontier[l],c,d=null;if(n==1&&(s?u.matchType(s.type)||(d=u.fillBefore(Q.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(n==2&&s&&(c=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:c};if(i&&u.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=Jv(e,n);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new ae(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=Jv(e,n);if(o.childCount<=1&&n>0){let i=e.size-n<=n+o.size;this.unplaced=new ae(Uu(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new ae(Uu(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:o,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let g=0;g1||a==0||g.content.size)&&(d=m,c.push(XR(g.mark(h.allowedMarks(g.marks)),u==1?a:0,u==l.childCount?f:-1)))}let p=u==l.childCount;p||(f=-1),this.placed=Wu(this.placed,n,Q.from(c)),this.frontier[n].match=d,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,m=l;g1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],i=n=0;l--){let{match:a,type:u}=this.frontier[l],c=e1(e,l,u,a,!0);if(!c||c.childCount)continue e}return{depth:n,fit:s,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Wu(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Wu(this.placed,this.depth,Q.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Q.empty,!0);n.childCount&&(this.placed=Wu(this.placed,this.frontier.length,n))}}function Uu(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Uu(t.firstChild.content,e-1,n)))}function Wu(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Wu(t.lastChild.content,e-1,n)))}function Jv(t,e){for(let n=0;n1&&(r=r.replaceChild(0,XR(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(Q.empty,!0)))),t.copy(r)}function e1(t,e,n,r,o){let i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!mP(n,i.content,s)?l:null}function mP(t,e,n){for(let r=n;r0;h--,f--){let p=o.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(h)>-1?l=h:o.before(h)==f&&s.splice(1,0,-h)}let a=s.indexOf(l),u=[],c=r.openStart;for(let h=r.content,f=0;;f++){let p=h.firstChild;if(u.push(p),f==r.openStart)break;h=p.content}for(let h=c-1;h>=0;h--){let f=u[h],p=vP(f.type);if(p&&!f.sameMarkup(o.node(Math.abs(l)-1)))c=h;else if(p||!f.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let f=(h+c+1)%(r.openStart+1),p=u[f];if(p)for(let g=0;g=0&&(t.replace(e,n,r),!(t.steps.length>d));h--){let f=s[h];f<0||(e=o.before(f),n=i.after(f))}}function qR(t,e,n,r,o){if(er){let i=o.contentMatchAt(0),s=i.fillBefore(t).append(t);t=s.append(i.matchFragment(s).fillBefore(Q.empty,!0))}return t}function bP(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=KR(t.doc,e,r.type);o!=null&&(e=n=o)}t.replaceRange(e,n,new ae(Q.from(r),0,0))}function wP(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n),i=ZR(r,o);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return t.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&o.end(s)-n!=o.depth-s)return t.delete(r.before(s),n);t.delete(e,n)}function ZR(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let o=r;o>=0;o--){let i=t.start(o);if(ie.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&n.push(o)}return n}class bc extends dn{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Xt.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return Xt.fromReplace(e,this.pos,this.pos+1,new ae(Q.from(o),0,n.isLeaf?0:1))}getMap(){return Wr.empty}invert(e){return new bc(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new bc(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new bc(n.pos,n.attr,n.value)}}dn.jsonID("attr",bc);class jd extends dn{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let o in e.attrs)n[o]=e.attrs[o];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Xt.ok(r)}getMap(){return Wr.empty}invert(e){return new jd(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new jd(n.attr,n.value)}}dn.jsonID("docAttr",jd);let Dc=class extends Error{};Dc=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};Dc.prototype=Object.create(Error.prototype);Dc.prototype.constructor=Dc;Dc.prototype.name="TransformError";class xP{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new vc}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new Dc(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=ae.empty){let o=kb(this.doc,e,n,r);return o&&this.step(o),this}replaceWith(e,n,r){return this.replace(e,n,new ae(Q.from(r),0,0))}delete(e,n){return this.replace(e,n,ae.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return yP(this,e,n,r),this}replaceRangeWith(e,n,r){return bP(this,e,n,r),this}deleteRange(e,n){return wP(this,e,n),this}lift(e,n){return oP(this,e,n),this}join(e,n=1){return fP(this,e,n),this}wrap(e,n){return aP(this,e,n),this}setBlockType(e,n=e,r,o=null){return lP(this,e,n,r,o),this}setNodeMarkup(e,n,r=null,o){return uP(this,e,n,r,o),this}setNodeAttribute(e,n,r){return this.step(new bc(e,n,r)),this}setDocAttribute(e,n){return this.step(new jd(e,n)),this}addNodeMark(e,n){return this.step(new Ss(e,n)),this}removeNodeMark(e,n){if(!(n instanceof Ke)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n=n.isInSet(r.marks),!n)return this}return this.step(new $c(e,n)),this}split(e,n=1,r){return dP(this,e,n,r),this}addMark(e,n,r){return eP(this,e,n,r),this}removeMark(e,n,r){return tP(this,e,n,r),this}clearIncompatible(e,n,r){return nP(this,e,n,r),this}}const t1=Object.create(null);class Ue{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new kP(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n=0;i--){let s=n<0?Kl(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):Kl(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new ir(e.node(0))}static atStart(e){return Kl(e,e,0,0,1)||new ir(e)}static atEnd(e){return Kl(e,e,e.content.size,e.childCount,-1)||new ir(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=t1[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in t1)throw new RangeError("Duplicate use of selection JSON ID "+e);return t1[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Ie.between(this.$anchor,this.$head).getBookmark()}}Ue.prototype.visible=!0;class kP{constructor(e,n){this.$from=e,this.$to=n}}let yS=!1;function bS(t){!yS&&!t.parent.inlineContent&&(yS=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Ie extends Ue{constructor(e,n=e){bS(e),bS(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Ue.near(r);let o=e.resolve(n.map(this.anchor));return new Ie(o.parent.inlineContent?o:r,r)}replace(e,n=ae.empty){if(super.replace(e,n),n==ae.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Ie&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new um(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Ie(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let o=e.resolve(n);return new this(o,r==n?o:e.resolve(r))}static between(e,n,r){let o=e.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let i=Ue.findFrom(n,r,!0)||Ue.findFrom(n,-r,!0);if(i)n=i.$head;else return Ue.near(n,r)}return e.parent.inlineContent||(o==0?e=n:(e=(Ue.findFrom(e,-r,!0)||Ue.findFrom(e,r,!0)).$anchor,e.pos0?0:1);o>0?s=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&Le.isSelectable(l))return Le.create(t,n-(o<0?l.nodeSize:0))}else{let a=Kl(t,l,n+o,o<0?l.childCount:0,o,i);if(a)return a}n+=l.nodeSize*o}return null}function wS(t,e,n){let r=t.steps.length-1;if(r{s==null&&(s=c)}),t.setSelection(Ue.near(t.doc.resolve(s),n))}const xS=1,Of=2,kS=4;class SP extends xP{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=Of,this}ensureMarks(e){return Ke.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&Of)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~Of,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||Ke.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let o=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),r=r??n,!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(n);i=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,o.text(e,i)),this.selection.empty||this.setSelection(Ue.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=kS,this}get scrolledIntoView(){return(this.updated&kS)>0}}function ES(t,e){return!e||!t?t:t.bind(e)}class Vu{constructor(e,n,r){this.name=e,this.init=ES(n.init,r),this.apply=ES(n.apply,r)}}const CP=[new Vu("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Vu("selection",{init(t,e){return t.selection||Ue.atStart(e.doc)},apply(t){return t.selection}}),new Vu("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Vu("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class n1{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=CP.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Vu(r.key,r.spec.state,r))})}}class Da{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(o,this[o.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new n1(e.schema,e.plugins),i=new Da(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=Rs.fromJSON(e.schema,n.doc);else if(s.name=="selection")i.selection=Ue.fromJSON(i.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],u=a.spec.state;if(a.key==s.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[s.name]=u.fromJSON.call(a,e,n[l],i);return}}i[s.name]=s.init(e,i)}}),i}}function QR(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=QR(o,e,{})),n[r]=o}return n}class yi{constructor(e){this.spec=e,this.props={},e.props&&QR(e.props,this,this.props),this.key=e.key?e.key.key:JR("plugin")}getState(e){return e[this.key]}}const r1=Object.create(null);function JR(t){return t in r1?t+"$"+ ++r1[t]:(r1[t]=0,t+"$")}class yl{constructor(e="key"){this.key=JR(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}var TP=/[A-Z]/g,AP=/^ms-/,o1={};function _P(t){return"-"+t.toLowerCase()}function RP(t){if(o1.hasOwnProperty(t))return o1[t];var e=t.replace(TP,_P);return o1[t]=AP.test(e)?"-"+e:e}function MP(t){return RP(t)}function OP(t,e){return MP(t)+":"+e}function IP(t){var e="";for(var n in t){var r=t[n];typeof r!="string"&&typeof r!="number"||(e&&(e+=";"),e+=OP(n,r))}return e}function LP(){return typeof document<"u"?document:null}var e2=LP;function t2(t,e){if(typeof t!="string")return[t];var n=[t];typeof e=="string"||Array.isArray(e)?e={brackets:e}:e||(e={});var r=e.brackets?Array.isArray(e.brackets)?e.brackets:[e.brackets]:["{}","[]","()"],o=e.escape||"___",i=!!e.flat;r.forEach(function(a){var u=new RegExp(["\\",a[0],"[^\\",a[0],"\\",a[1],"]*\\",a[1]].join("")),c=[];function d(h,f,p){var g=n.push(h.slice(a[0].length,-a[1].length))-1;return c.push(g),o+g+o}n.forEach(function(h,f){for(var p,g=0;h!=p;)if(p=h,h=h.replace(u,d),g++>1e4)throw Error("References have circular dependency. Please, check them.");n[f]=h}),c=c.reverse(),n=n.map(function(h){return c.forEach(function(f){h=h.replace(new RegExp("(\\"+o+f+"\\"+o+")","g"),a[0]+"$1"+a[1])}),h})});var s=new RegExp("\\"+o+"([0-9]+)\\"+o);function l(a,u,c){for(var d=[],h,f=0;h=s.exec(a);){if(f++>1e4)throw Error("Circular references in parenthesis");d.push(a.slice(0,h.index)),d.push(l(u[h[1]],u)),a=a.slice(h.index+h[0].length)}return d.push(a),d}return i?n:l(n[0],n)}function n2(t,e){if(e&&e.flat){var n=e&&e.escape||"___",r=t[0],o;if(!r)return"";for(var i=new RegExp("\\"+n+"([0-9]+)\\"+n),s=0;r!=o;){if(s++>1e4)throw Error("Circular references in "+t);o=r,r=r.replace(i,l)}return r}return t.reduce(function a(u,c){return Array.isArray(c)&&(c=c.reduce(a,"")),u+c},"");function l(a,u){if(t[u]==null)throw Error("Reference "+u+"is undefined");return t[u]}}function r2(t,e){return Array.isArray(t)?n2(t,e):t2(t,e)}r2.parse=t2;r2.stringify=n2;const NP={id:"extension.command.copy.label",message:"Copy",comment:"Label for copy command."},$P={id:"extension.command.copy.description",message:"Copy the selected text",comment:"Description for copy command."},DP={id:"extension.command.cut.label",message:"Cut",comment:"Label for cut command."},PP={id:"extension.command.cut.description",message:"Cut the selected text",comment:"Description for cut command."},zP={id:"extension.command.paste.label",message:"Paste",comment:"Label for paste command."},FP={id:"extension.command.paste.description",message:"Paste content into the editor",comment:"Description for paste command."},BP={id:"extension.command.select-all.label",message:"Select all",comment:"Label for select all command."},HP={id:"extension.command.select-all.description",message:"Select all content within the editor",comment:"Description for select all command."};var js=Object.freeze({__proto__:null,COPY_DESCRIPTION:$P,COPY_LABEL:NP,CUT_DESCRIPTION:PP,CUT_LABEL:DP,PASTE_DESCRIPTION:FP,PASTE_LABEL:zP,SELECT_ALL_DESCRIPTION:HP,SELECT_ALL_LABEL:BP});const UP={id:"keyboard.shortcut.escape",message:"Enter",comment:"Label for escape key in shortcuts."},WP={id:"keyboard.shortcut.command",message:"Command",comment:"Label for command key in shortcuts."},VP={id:"keyboard.shortcut.control",message:"Control",comment:"Label for control key in shortcuts."},jP={id:"keyboard.shortcut.enter",message:"Enter",comment:"Label for enter key in shortcuts."},GP={id:"keyboard.shortcut.shift",message:"Shift",comment:"Label for shift key in shortcuts."},KP={id:"keyboard.shortcut.alt",message:"Alt",comment:"Label for alt key in shortcuts."},YP={id:"keyboard.shortcut.capsLock",message:"Caps Lock",comment:"Label for caps lock key in shortcuts."},XP={id:"keyboard.shortcut.backspace",message:"Backspace",comment:"Label for backspace key in shortcuts."},qP={id:"keyboard.shortcut.tab",message:"Tab",comment:"Label for tab key in shortcuts."},ZP={id:"keyboard.shortcut.space",message:"Space",comment:"Label for space key in shortcuts."},QP={id:"keyboard.shortcut.delete",message:"Delete",comment:"Label for delete key in shortcuts."},JP={id:"keyboard.shortcut.pageUp",message:"Page Up",comment:"Label for page up key in shortcuts."},e5={id:"keyboard.shortcut.pageDown",message:"Page Down",comment:"Label for page down key in shortcuts."},t5={id:"keyboard.shortcut.home",message:"Home",comment:"Label for home key in shortcuts."},n5={id:"keyboard.shortcut.end",message:"End",comment:"Label for end key in shortcuts."},r5={id:"keyboard.shortcut.arrowLeft",message:"Arrow Left",comment:"Label for arrow left key in shortcuts."},o5={id:"keyboard.shortcut.arrowRight",message:"Arrow Right",comment:"Label for arrow right key in shortcuts."},i5={id:"keyboard.shortcut.arrowUp",message:"Arrow Up",comment:"Label for arrow up key in shortcuts."},s5={id:"keyboard.shortcut.arrowDown",message:"Arrow Down",comment:"Label for arrowDown key in shortcuts."};var on=Object.freeze({__proto__:null,ALT_KEY:KP,ARROW_DOWN_KEY:s5,ARROW_LEFT_KEY:r5,ARROW_RIGHT_KEY:o5,ARROW_UP_KEY:i5,BACKSPACE_KEY:XP,CAPS_LOCK_KEY:YP,COMMAND_KEY:WP,CONTROL_KEY:VP,DELETE_KEY:QP,END_KEY:n5,ENTER_KEY:jP,ESCAPE_KEY:UP,HOME_KEY:t5,PAGE_DOWN_KEY:e5,PAGE_UP_KEY:JP,SHIFT_KEY:GP,SPACE_KEY:ZP,TAB_KEY:qP});const a5={id:"extension.command.toggle-blockquote.label",message:"Blockquote",comment:"Label for blockquote formatting command."},l5={id:"extension.command.toggle-blockquote.description",message:"Add blockquote formatting to the selected text",comment:"Description for blockquote formatting command."};var SS=Object.freeze({__proto__:null,DESCRIPTION:l5,LABEL:a5});const c5={id:"extension.command.toggle-bold.label",message:"Bold",comment:"Label for bold formatting command."},u5={id:"extension.command.toggle-bold.description",message:"Add bold formatting to the selected text",comment:"Description for bold formatting command."};var CS=Object.freeze({__proto__:null,DESCRIPTION:u5,LABEL:c5});const d5={id:"extension.command.toggle-code-block.label",message:"Codeblock",comment:"Label for the code block command."},h5={id:"extension.command.toggle-code-block.description",message:"Add a code block",comment:"Description for the code block command."};var f5=Object.freeze({__proto__:null,DESCRIPTION:h5,LABEL:d5});const p5={id:"extension.command.toggle-code.label",message:"Code",comment:"Label for the inline code formatting."},g5={id:"extension.command.toggle-code.description",message:"Add inline code formatting to the selected text",comment:"Description for the inline code formatting command."};var m5=Object.freeze({__proto__:null,DESCRIPTION:g5,LABEL:p5});const v5={id:"extension.command.toggle-heading.label",message:`{level, select, 1 {Heading 1}
+`:"";return`${r}${o}For more information visit ${$R}#${t.toLowerCase()}`}var DR=class extends wR.BaseError{constructor({code:t,message:e,disableLogging:n=!1}={}){const r=VD(t)?t:re.CUSTOM;super(jD(r,e)),this.errorCode=r,this.url=`${$R}#${r.toLowerCase()}`,n||console.error(this.message)}static create(t={}){return new DR(t)}};function we(t,e){if(!t)throw DR.create(e)}function fm(t){if(typeof t!="object"||t===null)return t;const e=Symbol.toStringTag in t&&t[Symbol.toStringTag]==="Module"?t.default??t:t;return e&&typeof t=="object"&&"__esModule"in e&&e.__esModule&&e.default!==void 0?e.default:e}function La(t,e={}){return t}function _n(t){this.content=t}_n.prototype={constructor:_n,find:function(t){for(var e=0;e>1}};_n.from=function(t){if(t instanceof _n)return t;var e=[];if(t)for(var n in t)e.push(n,t[n]);return new _n(e)};function PR(t,e,n){for(let r=0;;r++){if(r==t.childCount||r==e.childCount)return t.childCount==e.childCount?null:n;let o=t.child(r),i=e.child(r);if(o==i){n+=o.nodeSize;continue}if(!o.sameMarkup(i))return n;if(o.isText&&o.text!=i.text){for(let s=0;o.text[s]==i.text[s];s++)n++;return n}if(o.content.size||i.content.size){let s=PR(o.content,i.content,n+1);if(s!=null)return s}n+=o.nodeSize}}function zR(t,e,n,r){for(let o=t.childCount,i=e.childCount;;){if(o==0||i==0)return o==i?null:{a:n,b:r};let s=t.child(--o),l=e.child(--i),a=s.nodeSize;if(s==l){n-=a,r-=a;continue}if(!s.sameMarkup(l))return{a:n,b:r};if(s.isText&&s.text!=l.text){let u=0,c=Math.min(s.text.length,l.text.length);for(;ue&&r(a,o+l,i||null,s)!==!1&&a.content.size){let c=l+1;a.nodesBetween(Math.max(0,e-c),Math.min(a.content.size,n-c),r,o+c)}l=u}}descendants(e){this.nodesBetween(0,this.size,e)}textBetween(e,n,r,o){let i="",s=!0;return this.nodesBetween(e,n,(l,a)=>{l.isText?(i+=l.text.slice(Math.max(e,a)-a,n-a),s=!r):l.isLeaf?(o?i+=typeof o=="function"?o(l):o:l.type.spec.leafText&&(i+=l.type.spec.leafText(l)),s=!r):!s&&l.isBlock&&(i+=r,s=!0)},0),i}append(e){if(!e.size)return this;if(!this.size)return e;let n=this.lastChild,r=e.firstChild,o=this.content.slice(),i=0;for(n.isText&&n.sameMarkup(r)&&(o[o.length-1]=n.withText(n.text+r.text),i=1);ie)for(let i=0,s=0;se&&((sn)&&(l.isText?l=l.cut(Math.max(0,e-s),Math.min(l.text.length,n-s)):l=l.cut(Math.max(0,e-s-1),Math.min(l.content.size,n-s-1))),r.push(l),o+=l.nodeSize),s=a}return new Q(r,o)}cutByIndex(e,n){return e==n?Q.empty:e==0&&n==this.content.length?this:new Q(this.content.slice(e,n))}replaceChild(e,n){let r=this.content[e];if(r==n)return this;let o=this.content.slice(),i=this.size+n.nodeSize-r.nodeSize;return o[e]=n,new Q(o,i)}addToStart(e){return new Q([e].concat(this.content),this.size+e.nodeSize)}addToEnd(e){return new Q(this.content.concat(e),this.size+e.nodeSize)}eq(e){if(this.content.length!=e.content.length)return!1;for(let n=0;nthis.size||e<0)throw new RangeError(`Position ${e} outside of fragment (${this})`);for(let r=0,o=0;;r++){let i=this.child(r),s=o+i.nodeSize;if(s>=e)return s==e||n>0?Lf(r+1,s):Lf(r,o);o=s}}toString(){return"<"+this.toStringInner()+">"}toStringInner(){return this.content.join(", ")}toJSON(){return this.content.length?this.content.map(e=>e.toJSON()):null}static fromJSON(e,n){if(!n)return Q.empty;if(!Array.isArray(n))throw new RangeError("Invalid input for Fragment.fromJSON");return new Q(n.map(e.nodeFromJSON))}static fromArray(e){if(!e.length)return Q.empty;let n,r=0;for(let o=0;othis.type.rank&&(n||(n=e.slice(0,o)),n.push(this),r=!0),n&&n.push(i)}}return n||(n=e.slice()),r||n.push(this),n}removeFromSet(e){for(let n=0;nr.type.rank-o.type.rank),n}}je.none=[];class qp extends Error{}class ae{constructor(e,n,r){this.content=e,this.openStart=n,this.openEnd=r}get size(){return this.content.size-this.openStart-this.openEnd}insertAt(e,n){let r=BR(this.content,e+this.openStart,n);return r&&new ae(r,this.openStart,this.openEnd)}removeBetween(e,n){return new ae(FR(this.content,e+this.openStart,n+this.openStart),this.openStart,this.openEnd)}eq(e){return this.content.eq(e.content)&&this.openStart==e.openStart&&this.openEnd==e.openEnd}toString(){return this.content+"("+this.openStart+","+this.openEnd+")"}toJSON(){if(!this.content.size)return null;let e={content:this.content.toJSON()};return this.openStart>0&&(e.openStart=this.openStart),this.openEnd>0&&(e.openEnd=this.openEnd),e}static fromJSON(e,n){if(!n)return ae.empty;let r=n.openStart||0,o=n.openEnd||0;if(typeof r!="number"||typeof o!="number")throw new RangeError("Invalid input for Slice.fromJSON");return new ae(Q.fromJSON(e,n.content),r,o)}static maxOpen(e,n=!0){let r=0,o=0;for(let i=e.firstChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.firstChild)r++;for(let i=e.lastChild;i&&!i.isLeaf&&(n||!i.type.spec.isolating);i=i.lastChild)o++;return new ae(e,r,o)}}ae.empty=new ae(Q.empty,0,0);function FR(t,e,n){let{index:r,offset:o}=t.findIndex(e),i=t.maybeChild(r),{index:s,offset:l}=t.findIndex(n);if(o==e||i.isText){if(l!=n&&!t.child(s).isText)throw new RangeError("Removing non-flat range");return t.cut(0,e).append(t.cut(n))}if(r!=s)throw new RangeError("Removing non-flat range");return t.replaceChild(r,i.copy(FR(i.content,e-o-1,n-o-1)))}function BR(t,e,n,r){let{index:o,offset:i}=t.findIndex(e),s=t.maybeChild(o);if(i==e||s.isText)return r&&!r.canReplace(o,o,n)?null:t.cut(0,e).append(n).append(t.cut(e));let l=BR(s.content,e-i-1,n);return l&&t.replaceChild(o,s.copy(l))}function GD(t,e,n){if(n.openStart>t.depth)throw new qp("Inserted content deeper than insertion position");if(t.depth-n.openStart!=e.depth-n.openEnd)throw new qp("Inconsistent open depths");return HR(t,e,n,0)}function HR(t,e,n,r){let o=t.index(r),i=t.node(r);if(o==e.index(r)&&r=0&&t.isText&&t.sameMarkup(e[n])?e[n]=t.withText(e[n].text+t.text):e.push(t)}function Ed(t,e,n,r){let o=(e||t).node(n),i=0,s=e?e.index(n):o.childCount;t&&(i=t.index(n),t.depth>n?i++:t.textOffset&&(Ua(t.nodeAfter,r),i++));for(let l=i;lo&&x0(t,e,o+1),s=r.depth>o&&x0(n,r,o+1),l=[];return Ed(null,t,o,l),i&&s&&e.index(o)==n.index(o)?(UR(i,s),Ua(Wa(i,WR(t,e,n,r,o+1)),l)):(i&&Ua(Wa(i,Zp(t,e,o+1)),l),Ed(e,n,o,l),s&&Ua(Wa(s,Zp(n,r,o+1)),l)),Ed(r,null,o,l),new Q(l)}function Zp(t,e,n){let r=[];if(Ed(null,t,n,r),t.depth>n){let o=x0(t,e,n+1);Ua(Wa(o,Zp(t,e,n+1)),r)}return Ed(e,null,n,r),new Q(r)}function KD(t,e){let n=e.depth-t.openStart,o=e.node(n).copy(t.content);for(let i=n-1;i>=0;i--)o=e.node(i).copy(Q.from(o));return{start:o.resolveNoCache(t.openStart+n),end:o.resolveNoCache(o.content.size-t.openEnd-n)}}class Ic{constructor(e,n,r){this.pos=e,this.path=n,this.parentOffset=r,this.depth=n.length/3-1}resolveDepth(e){return e==null?this.depth:e<0?this.depth+e:e}get parent(){return this.node(this.depth)}get doc(){return this.node(0)}node(e){return this.path[this.resolveDepth(e)*3]}index(e){return this.path[this.resolveDepth(e)*3+1]}indexAfter(e){return e=this.resolveDepth(e),this.index(e)+(e==this.depth&&!this.textOffset?0:1)}start(e){return e=this.resolveDepth(e),e==0?0:this.path[e*3-1]+1}end(e){return e=this.resolveDepth(e),this.start(e)+this.node(e).content.size}before(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position before the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]}after(e){if(e=this.resolveDepth(e),!e)throw new RangeError("There is no position after the top-level node");return e==this.depth+1?this.pos:this.path[e*3-1]+this.path[e*3].nodeSize}get textOffset(){return this.pos-this.path[this.path.length-1]}get nodeAfter(){let e=this.parent,n=this.index(this.depth);if(n==e.childCount)return null;let r=this.pos-this.path[this.path.length-1],o=e.child(n);return r?e.child(n).cut(r):o}get nodeBefore(){let e=this.index(this.depth),n=this.pos-this.path[this.path.length-1];return n?this.parent.child(e).cut(0,n):e==0?null:this.parent.child(e-1)}posAtIndex(e,n){n=this.resolveDepth(n);let r=this.path[n*3],o=n==0?0:this.path[n*3-1]+1;for(let i=0;i0;n--)if(this.start(n)<=e&&this.end(n)>=e)return n;return 0}blockRange(e=this,n){if(e.pos=0;r--)if(e.pos<=this.end(r)&&(!n||n(this.node(r))))return new Xa(this,e,r);return null}sameParent(e){return this.pos-this.parentOffset==e.pos-e.parentOffset}max(e){return e.pos>this.pos?e:this}min(e){return e.pos=0&&n<=e.content.size))throw new RangeError("Position "+n+" out of range");let r=[],o=0,i=n;for(let s=e;;){let{index:l,offset:a}=s.content.findIndex(i),u=i-a;if(r.push(s,l,o+a),!u||(s=s.child(l),s.isText))break;i=u-1,o+=a+1}return new Ic(n,r,i)}static resolveCached(e,n){for(let o=0;oe&&this.nodesBetween(e,n,i=>(r.isInSet(i.marks)&&(o=!0),!o)),o}get isBlock(){return this.type.isBlock}get isTextblock(){return this.type.isTextblock}get inlineContent(){return this.type.inlineContent}get isInline(){return this.type.isInline}get isText(){return this.type.isText}get isLeaf(){return this.type.isLeaf}get isAtom(){return this.type.isAtom}toString(){if(this.type.spec.toDebugString)return this.type.spec.toDebugString(this);let e=this.type.name;return this.content.size&&(e+="("+this.content.toStringInner()+")"),VR(this.marks,e)}contentMatchAt(e){let n=this.type.contentMatch.matchFragment(this.content,0,e);if(!n)throw new Error("Called contentMatchAt on a node with invalid content");return n}canReplace(e,n,r=Q.empty,o=0,i=r.childCount){let s=this.contentMatchAt(e).matchFragment(r,o,i),l=s&&s.matchFragment(this.content,n);if(!l||!l.validEnd)return!1;for(let a=o;an.type.name)}`);this.content.forEach(n=>n.check())}toJSON(){let e={type:this.type.name};for(let n in this.attrs){e.attrs=this.attrs;break}return this.content.size&&(e.content=this.content.toJSON()),this.marks.length&&(e.marks=this.marks.map(n=>n.toJSON())),e}static fromJSON(e,n){if(!n)throw new RangeError("Invalid input for Node.fromJSON");let r=null;if(n.marks){if(!Array.isArray(n.marks))throw new RangeError("Invalid mark data for Node.fromJSON");r=n.marks.map(e.markFromJSON)}if(n.type=="text"){if(typeof n.text!="string")throw new RangeError("Invalid text node in JSON");return e.text(n.text,r)}let o=Q.fromJSON(e,n.content);return e.nodeType(n.type).create(n.attrs,o,r)}};As.prototype.text=void 0;class Qp extends As{constructor(e,n,r,o){if(super(e,n,null,o),!r)throw new RangeError("Empty text nodes are not allowed");this.text=r}toString(){return this.type.spec.toDebugString?this.type.spec.toDebugString(this):VR(this.marks,JSON.stringify(this.text))}get textContent(){return this.text}textBetween(e,n){return this.text.slice(e,n)}get nodeSize(){return this.text.length}mark(e){return e==this.marks?this:new Qp(this.type,this.attrs,this.text,e)}withText(e){return e==this.text?this:new Qp(this.type,this.attrs,e,this.marks)}cut(e=0,n=this.text.length){return e==0&&n==this.text.length?this:this.withText(this.text.slice(e,n))}eq(e){return this.sameMarkup(e)&&this.text==e.text}toJSON(){let e=super.toJSON();return e.text=this.text,e}}function VR(t,e){for(let n=t.length-1;n>=0;n--)e=t[n].type.name+"("+e+")";return e}class qa{constructor(e){this.validEnd=e,this.next=[],this.wrapCache=[]}static parse(e,n){let r=new qD(e,n);if(r.next==null)return qa.empty;let o=jR(r);r.next&&r.err("Unexpected trailing text");let i=rP(nP(o));return oP(i,r),i}matchType(e){for(let n=0;nu.createAndFill()));for(let u=0;u=this.next.length)throw new RangeError(`There's no ${e}th edge in this content match`);return this.next[e]}toString(){let e=[];function n(r){e.push(r);for(let o=0;o{let i=o+(r.validEnd?"*":" ")+" ";for(let s=0;s"+e.indexOf(r.next[s].next);return i}).join(`
+`)}}qa.empty=new qa(!0);class qD{constructor(e,n){this.string=e,this.nodeTypes=n,this.inline=null,this.pos=0,this.tokens=e.split(/\s*(?=\b|\W|$)/),this.tokens[this.tokens.length-1]==""&&this.tokens.pop(),this.tokens[0]==""&&this.tokens.shift()}get next(){return this.tokens[this.pos]}eat(e){return this.next==e&&(this.pos++||!0)}err(e){throw new SyntaxError(e+" (in content expression '"+this.string+"')")}}function jR(t){let e=[];do e.push(ZD(t));while(t.eat("|"));return e.length==1?e[0]:{type:"choice",exprs:e}}function ZD(t){let e=[];do e.push(QD(t));while(t.next&&t.next!=")"&&t.next!="|");return e.length==1?e[0]:{type:"seq",exprs:e}}function QD(t){let e=tP(t);for(;;)if(t.eat("+"))e={type:"plus",expr:e};else if(t.eat("*"))e={type:"star",expr:e};else if(t.eat("?"))e={type:"opt",expr:e};else if(t.eat("{"))e=JD(t,e);else break;return e}function bS(t){/\D/.test(t.next)&&t.err("Expected number, got '"+t.next+"'");let e=Number(t.next);return t.pos++,e}function JD(t,e){let n=bS(t),r=n;return t.eat(",")&&(t.next!="}"?r=bS(t):r=-1),t.eat("}")||t.err("Unclosed braced range"),{type:"range",min:n,max:r,expr:e}}function eP(t,e){let n=t.nodeTypes,r=n[e];if(r)return[r];let o=[];for(let i in n){let s=n[i];s.groups.indexOf(e)>-1&&o.push(s)}return o.length==0&&t.err("No node type or group '"+e+"' found"),o}function tP(t){if(t.eat("(")){let e=jR(t);return t.eat(")")||t.err("Missing closing paren"),e}else if(/\W/.test(t.next))t.err("Unexpected token '"+t.next+"'");else{let e=eP(t,t.next).map(n=>(t.inline==null?t.inline=n.isInline:t.inline!=n.isInline&&t.err("Mixing inline and block content"),{type:"name",value:n}));return t.pos++,e.length==1?e[0]:{type:"choice",exprs:e}}}function nP(t){let e=[[]];return o(i(t,0),n()),e;function n(){return e.push([])-1}function r(s,l,a){let u={term:a,to:l};return e[s].push(u),u}function o(s,l){s.forEach(a=>a.to=l)}function i(s,l){if(s.type=="choice")return s.exprs.reduce((a,u)=>a.concat(i(u,l)),[]);if(s.type=="seq")for(let a=0;;a++){let u=i(s.exprs[a],l);if(a==s.exprs.length-1)return u;o(u,l=n())}else if(s.type=="star"){let a=n();return r(l,a),o(i(s.expr,a),a),[r(a)]}else if(s.type=="plus"){let a=n();return o(i(s.expr,l),a),o(i(s.expr,a),a),[r(a)]}else{if(s.type=="opt")return[r(l)].concat(i(s.expr,l));if(s.type=="range"){let a=l;for(let u=0;u{t[s].forEach(({term:l,to:a})=>{if(!l)return;let u;for(let c=0;c{u||o.push([l,u=[]]),u.indexOf(c)==-1&&u.push(c)})})});let i=e[r.join(",")]=new qa(r.indexOf(t.length-1)>-1);for(let s=0;s-1}allowsMarks(e){if(this.markSet==null)return!0;for(let n=0;nr[i]=new qR(i,n,s));let o=n.spec.topNode||"doc";if(!r[o])throw new RangeError("Schema is missing its top node type ('"+o+"')");if(!r.text)throw new RangeError("Every schema needs a 'text' type");for(let i in r.text.attrs)throw new RangeError("The text node type should not have attributes");return r}};class iP{constructor(e){this.hasDefault=Object.prototype.hasOwnProperty.call(e,"default"),this.default=e.default}get isRequired(){return!this.hasDefault}}class Vh{constructor(e,n,r,o){this.name=e,this.rank=n,this.schema=r,this.spec=o,this.attrs=XR(o.attrs),this.excluded=null;let i=KR(this.attrs);this.instance=i?new je(this,i):null}create(e=null){return!e&&this.instance?this.instance:new je(this,YR(this.attrs,e))}static compile(e,n){let r=Object.create(null),o=0;return e.forEach((i,s)=>r[i]=new Vh(i,o++,n,s)),r}removeFromSet(e){for(var n=0;n-1}}let sP=class{constructor(e){this.cached=Object.create(null);let n=this.spec={};for(let o in e)n[o]=e[o];n.nodes=_n.from(e.nodes),n.marks=_n.from(e.marks||{}),this.nodes=E0.compile(this.spec.nodes,this),this.marks=Vh.compile(this.spec.marks,this);let r=Object.create(null);for(let o in this.nodes){if(o in this.marks)throw new RangeError(o+" can not be both a node and a mark");let i=this.nodes[o],s=i.spec.content||"",l=i.spec.marks;i.contentMatch=r[s]||(r[s]=qa.parse(s,this.nodes)),i.inlineContent=i.contentMatch.inlineContent,i.markSet=l=="_"?null:l?xS(this,l.split(" ")):l==""||!i.inlineContent?[]:null}for(let o in this.marks){let i=this.marks[o],s=i.spec.excludes;i.excluded=s==null?[i]:s==""?[]:xS(this,s.split(" "))}this.nodeFromJSON=this.nodeFromJSON.bind(this),this.markFromJSON=this.markFromJSON.bind(this),this.topNodeType=this.nodes[this.spec.topNode||"doc"],this.cached.wrappings=Object.create(null)}node(e,n=null,r,o){if(typeof e=="string")e=this.nodeType(e);else if(e instanceof E0){if(e.schema!=this)throw new RangeError("Node type from different schema used ("+e.name+")")}else throw new RangeError("Invalid node type: "+e);return e.createChecked(n,r,o)}text(e,n){let r=this.nodes.text;return new Qp(r,r.defaultAttrs,e,je.setFrom(n))}mark(e,n){return typeof e=="string"&&(e=this.marks[e]),e.create(n)}nodeFromJSON(e){return As.fromJSON(this,e)}markFromJSON(e){return je.fromJSON(this,e)}nodeType(e){let n=this.nodes[e];if(!n)throw new RangeError("Unknown node type: "+e);return n}};function xS(t,e){let n=[];for(let r=0;r-1)&&n.push(s=a)}if(!s)throw new SyntaxError("Unknown mark type: '"+e[r]+"'")}return n}class Lc{constructor(e,n){this.schema=e,this.rules=n,this.tags=[],this.styles=[],n.forEach(r=>{r.tag?this.tags.push(r):r.style&&this.styles.push(r)}),this.normalizeLists=!this.tags.some(r=>{if(!/^(ul|ol)\b/.test(r.tag)||!r.node)return!1;let o=e.nodes[r.node];return o.contentMatch.matchType(o)})}parse(e,n={}){let r=new ES(this,n,!1);return r.addAll(e,n.from,n.to),r.finish()}parseSlice(e,n={}){let r=new ES(this,n,!0);return r.addAll(e,n.from,n.to),ae.maxOpen(r.finish())}matchTag(e,n,r){for(let o=r?this.tags.indexOf(r)+1:0;oe.length&&(l.charCodeAt(e.length)!=61||l.slice(e.length+1)!=n))){if(s.getAttrs){let a=s.getAttrs(n);if(a===!1)continue;s.attrs=a||void 0}return s}}}static schemaRules(e){let n=[];function r(o){let i=o.priority==null?50:o.priority,s=0;for(;s{r(s=SS(s)),s.mark||s.ignore||s.clearMark||(s.mark=o)})}for(let o in e.nodes){let i=e.nodes[o].spec.parseDOM;i&&i.forEach(s=>{r(s=SS(s)),s.node||s.ignore||s.mark||(s.node=o)})}return n}static fromSchema(e){return e.cached.domParser||(e.cached.domParser=new Lc(e,Lc.schemaRules(e)))}}const ZR={address:!0,article:!0,aside:!0,blockquote:!0,canvas:!0,dd:!0,div:!0,dl:!0,fieldset:!0,figcaption:!0,figure:!0,footer:!0,form:!0,h1:!0,h2:!0,h3:!0,h4:!0,h5:!0,h6:!0,header:!0,hgroup:!0,hr:!0,li:!0,noscript:!0,ol:!0,output:!0,p:!0,pre:!0,section:!0,table:!0,tfoot:!0,ul:!0},aP={head:!0,noscript:!0,object:!0,script:!0,style:!0,title:!0},QR={ol:!0,ul:!0},Jp=1,eg=2,Sd=4;function kS(t,e,n){return e!=null?(e?Jp:0)|(e==="full"?eg:0):t&&t.whitespace=="pre"?Jp|eg:n&~Sd}class Nf{constructor(e,n,r,o,i,s,l){this.type=e,this.attrs=n,this.marks=r,this.pendingMarks=o,this.solid=i,this.options=l,this.content=[],this.activeMarks=je.none,this.stashMarks=[],this.match=s||(l&Sd?null:e.contentMatch)}findWrapping(e){if(!this.match){if(!this.type)return[];let n=this.type.contentMatch.fillBefore(Q.from(e));if(n)this.match=this.type.contentMatch.matchFragment(n);else{let r=this.type.contentMatch,o;return(o=r.findWrapping(e.type))?(this.match=r,o):null}}return this.match.findWrapping(e.type)}finish(e){if(!(this.options&Jp)){let r=this.content[this.content.length-1],o;if(r&&r.isText&&(o=/[ \t\r\n\u000c]+$/.exec(r.text))){let i=r;r.text.length==o[0].length?this.content.pop():this.content[this.content.length-1]=i.withText(i.text.slice(0,i.text.length-o[0].length))}}let n=Q.from(this.content);return!e&&this.match&&(n=n.append(this.match.fillBefore(Q.empty,!0))),this.type?this.type.create(this.attrs,n,this.marks):n}popFromStashMark(e){for(let n=this.stashMarks.length-1;n>=0;n--)if(e.eq(this.stashMarks[n]))return this.stashMarks.splice(n,1)[0]}applyPending(e){for(let n=0,r=this.pendingMarks;nthis.addAll(e)),s&&this.sync(l),this.needsBlock=a}else this.withStyleRules(e,()=>{this.addElementByRule(e,i,i.consuming===!1?o:void 0)})}leafFallback(e){e.nodeName=="BR"&&this.top.type&&this.top.type.inlineContent&&this.addTextNode(e.ownerDocument.createTextNode(`
+`))}ignoreFallback(e){e.nodeName=="BR"&&(!this.top.type||!this.top.type.inlineContent)&&this.findPlace(this.parser.schema.text("-"))}readStyles(e){let n=je.none,r=je.none;for(let o=0;o{s.clearMark(l)&&(r=l.addToSet(r))}):n=this.parser.schema.marks[s.mark].create(s.attrs).addToSet(n),s.consuming===!1)i=s;else break}return[n,r]}addElementByRule(e,n,r){let o,i,s;n.node?(i=this.parser.schema.nodes[n.node],i.isLeaf?this.insertNode(i.create(n.attrs))||this.leafFallback(e):o=this.enter(i,n.attrs||null,n.preserveWhitespace)):(s=this.parser.schema.marks[n.mark].create(n.attrs),this.addPendingMark(s));let l=this.top;if(i&&i.isLeaf)this.findInside(e);else if(r)this.addElement(e,r);else if(n.getContent)this.findInside(e),n.getContent(e,this.parser.schema).forEach(a=>this.insertNode(a));else{let a=e;typeof n.contentElement=="string"?a=e.querySelector(n.contentElement):typeof n.contentElement=="function"?a=n.contentElement(e):n.contentElement&&(a=n.contentElement),this.findAround(e,a,!0),this.addAll(a)}o&&this.sync(l)&&this.open--,s&&this.removePendingMark(s,l)}addAll(e,n,r){let o=n||0;for(let i=n?e.childNodes[n]:e.firstChild,s=r==null?null:e.childNodes[r];i!=s;i=i.nextSibling,++o)this.findAtPoint(e,o),this.addDOM(i);this.findAtPoint(e,o)}findPlace(e){let n,r;for(let o=this.open;o>=0;o--){let i=this.nodes[o],s=i.findWrapping(e);if(s&&(!n||n.length>s.length)&&(n=s,r=i,!s.length)||i.solid)break}if(!n)return!1;this.sync(r);for(let o=0;othis.open){for(;n>this.open;n--)this.nodes[n-1].content.push(this.nodes[n].finish(e));this.nodes.length=this.open+1}}finish(){return this.open=0,this.closeExtra(this.isOpen),this.nodes[0].finish(this.isOpen||this.options.topOpen)}sync(e){for(let n=this.open;n>=0;n--)if(this.nodes[n]==e)return this.open=n,!0;return!1}get currentPos(){this.closeExtra();let e=0;for(let n=this.open;n>=0;n--){let r=this.nodes[n].content;for(let o=r.length-1;o>=0;o--)e+=r[o].nodeSize;n&&e++}return e}findAtPoint(e,n){if(this.find)for(let r=0;r-1)return e.split(/\s*\|\s*/).some(this.matchesContext,this);let n=e.split("/"),r=this.options.context,o=!this.isOpen&&(!r||r.parent.type==this.nodes[0].type),i=-(r?r.depth+1:0)+(o?0:1),s=(l,a)=>{for(;l>=0;l--){let u=n[l];if(u==""){if(l==n.length-1||l==0)continue;for(;a>=i;a--)if(s(l-1,a))return!0;return!1}else{let c=a>0||a==0&&o?this.nodes[a].type:r&&a>=i?r.node(a-i).type:null;if(!c||c.name!=u&&c.groups.indexOf(u)==-1)return!1;a--}}return!0};return s(n.length-1,this.open)}textblockFromContext(){let e=this.options.context;if(e)for(let n=e.depth;n>=0;n--){let r=e.node(n).contentMatchAt(e.indexAfter(n)).defaultType;if(r&&r.isTextblock&&r.defaultAttrs)return r}for(let n in this.parser.schema.nodes){let r=this.parser.schema.nodes[n];if(r.isTextblock&&r.defaultAttrs)return r}}addPendingMark(e){let n=hP(e,this.top.pendingMarks);n&&this.top.stashMarks.push(n),this.top.pendingMarks=e.addToSet(this.top.pendingMarks)}removePendingMark(e,n){for(let r=this.open;r>=0;r--){let o=this.nodes[r];if(o.pendingMarks.lastIndexOf(e)>-1)o.pendingMarks=e.removeFromSet(o.pendingMarks);else{o.activeMarks=e.removeFromSet(o.activeMarks);let s=o.popFromStashMark(e);s&&o.type&&o.type.allowsMarkType(s.type)&&(o.activeMarks=s.addToSet(o.activeMarks))}if(o==n)break}}}function lP(t){for(let e=t.firstChild,n=null;e;e=e.nextSibling){let r=e.nodeType==1?e.nodeName.toLowerCase():null;r&&QR.hasOwnProperty(r)&&n?(n.appendChild(e),e=n):r=="li"?n=e:r&&(n=null)}}function cP(t,e){return(t.matches||t.msMatchesSelector||t.webkitMatchesSelector||t.mozMatchesSelector).call(t,e)}function uP(t){let e=/\s*([\w-]+)\s*:\s*([^;]+)/g,n,r=[];for(;n=e.exec(t);)r.push(n[1],n[2].trim());return r}function SS(t){let e={};for(let n in t)e[n]=t[n];return e}function dP(t,e){let n=e.schema.nodes;for(let r in n){let o=n[r];if(!o.allowsMarkType(t))continue;let i=[],s=l=>{i.push(l);for(let a=0;a{if(i.length||s.marks.length){let l=0,a=0;for(;l=0;o--){let i=this.serializeMark(e.marks[o],e.isInline,n);i&&((i.contentDOM||i.dom).appendChild(r),r=i.dom)}return r}serializeMark(e,n,r={}){let o=this.marks[e.type.name];return o&&Wr.renderSpec(t1(r),o(e,n))}static renderSpec(e,n,r=null){if(typeof n=="string")return{dom:e.createTextNode(n)};if(n.nodeType!=null)return{dom:n};if(n.dom&&n.dom.nodeType!=null)return n;let o=n[0],i=o.indexOf(" ");i>0&&(r=o.slice(0,i),o=o.slice(i+1));let s,l=r?e.createElementNS(r,o):e.createElement(o),a=n[1],u=1;if(a&&typeof a=="object"&&a.nodeType==null&&!Array.isArray(a)){u=2;for(let c in a)if(a[c]!=null){let d=c.indexOf(" ");d>0?l.setAttributeNS(c.slice(0,d),c.slice(d+1),a[c]):l.setAttribute(c,a[c])}}for(let c=u;cu)throw new RangeError("Content hole must be the only child of its parent node");return{dom:l,contentDOM:l}}else{let{dom:h,contentDOM:f}=Wr.renderSpec(e,d,r);if(l.appendChild(h),f){if(s)throw new RangeError("Multiple content holes");s=f}}}return{dom:l,contentDOM:s}}static fromSchema(e){return e.cached.domSerializer||(e.cached.domSerializer=new Wr(this.nodesFromSchema(e),this.marksFromSchema(e)))}static nodesFromSchema(e){let n=CS(e.nodes);return n.text||(n.text=r=>r.text),n}static marksFromSchema(e){return CS(e.marks)}}function CS(t){let e={};for(let n in t){let r=t[n].spec.toDOM;r&&(e[n]=r)}return e}function t1(t){return t.document||window.document}const JR=65535,e2=Math.pow(2,16);function fP(t,e){return t+e*e2}function TS(t){return t&JR}function pP(t){return(t-(t&JR))/e2}const t2=1,n2=2,gp=4,r2=8;class S0{constructor(e,n,r){this.pos=e,this.delInfo=n,this.recover=r}get deleted(){return(this.delInfo&r2)>0}get deletedBefore(){return(this.delInfo&(t2|gp))>0}get deletedAfter(){return(this.delInfo&(n2|gp))>0}get deletedAcross(){return(this.delInfo&gp)>0}}class Hr{constructor(e,n=!1){if(this.ranges=e,this.inverted=n,!e.length&&Hr.empty)return Hr.empty}recover(e){let n=0,r=TS(e);if(!this.inverted)for(let o=0;oe)break;let u=this.ranges[l+i],c=this.ranges[l+s],d=a+u;if(e<=d){let h=u?e==a?-1:e==d?1:n:n,f=a+o+(h<0?0:c);if(r)return f;let p=e==(n<0?a:d)?null:fP(l/3,e-a),g=e==a?n2:e==d?t2:gp;return(n<0?e!=a:e!=d)&&(g|=r2),new S0(f,g,p)}o+=c-u}return r?e+o:new S0(e+o,0,null)}touches(e,n){let r=0,o=TS(n),i=this.inverted?2:1,s=this.inverted?1:2;for(let l=0;le)break;let u=this.ranges[l+i],c=a+u;if(e<=c&&l==o*3)return!0;r+=this.ranges[l+s]-u}return!1}forEach(e){let n=this.inverted?2:1,r=this.inverted?1:2;for(let o=0,i=0;o=0;n--){let o=e.getMirror(n);this.appendMap(e.maps[n].invert(),o!=null&&o>n?r-o-1:void 0)}}invert(){let e=new gc;return e.appendMappingInverted(this),e}map(e,n=1){if(this.mirror)return this._map(e,n,!0);for(let r=this.from;ri&&a!s.isAtom||!l.type.allowsMarkType(this.mark.type)?s:s.mark(this.mark.addToSet(s.marks)),o),n.openStart,n.openEnd);return Kt.fromReplace(e,this.from,this.to,i)}invert(){return new Po(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Ii(n.pos,r.pos,this.mark)}merge(e){return e instanceof Ii&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Ii(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"addMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for AddMarkStep.fromJSON");return new Ii(n.from,n.to,e.markFromJSON(n.mark))}}cn.jsonID("addMark",Ii);class Po extends cn{constructor(e,n,r){super(),this.from=e,this.to=n,this.mark=r}apply(e){let n=e.slice(this.from,this.to),r=new ae(Sb(n.content,o=>o.mark(this.mark.removeFromSet(o.marks)),e),n.openStart,n.openEnd);return Kt.fromReplace(e,this.from,this.to,r)}invert(){return new Ii(this.from,this.to,this.mark)}map(e){let n=e.mapResult(this.from,1),r=e.mapResult(this.to,-1);return n.deleted&&r.deleted||n.pos>=r.pos?null:new Po(n.pos,r.pos,this.mark)}merge(e){return e instanceof Po&&e.mark.eq(this.mark)&&this.from<=e.to&&this.to>=e.from?new Po(Math.min(this.from,e.from),Math.max(this.to,e.to),this.mark):null}toJSON(){return{stepType:"removeMark",mark:this.mark.toJSON(),from:this.from,to:this.to}}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number")throw new RangeError("Invalid input for RemoveMarkStep.fromJSON");return new Po(n.from,n.to,e.markFromJSON(n.mark))}}cn.jsonID("removeMark",Po);class ks extends cn{constructor(e,n){super(),this.pos=e,this.mark=n}apply(e){let n=e.nodeAt(this.pos);if(!n)return Kt.fail("No node at mark step's position");let r=n.type.create(n.attrs,null,this.mark.addToSet(n.marks));return Kt.fromReplace(e,this.pos,this.pos+1,new ae(Q.from(r),0,n.isLeaf?0:1))}invert(e){let n=e.nodeAt(this.pos);if(n){let r=this.mark.addToSet(n.marks);if(r.length==n.marks.length){for(let o=0;or.pos?null:new Yt(n.pos,r.pos,o,i,this.slice,this.insert,this.structure)}toJSON(){let e={stepType:"replaceAround",from:this.from,to:this.to,gapFrom:this.gapFrom,gapTo:this.gapTo,insert:this.insert};return this.slice.size&&(e.slice=this.slice.toJSON()),this.structure&&(e.structure=!0),e}static fromJSON(e,n){if(typeof n.from!="number"||typeof n.to!="number"||typeof n.gapFrom!="number"||typeof n.gapTo!="number"||typeof n.insert!="number")throw new RangeError("Invalid input for ReplaceAroundStep.fromJSON");return new Yt(n.from,n.to,n.gapFrom,n.gapTo,ae.fromJSON(e,n.slice),n.insert,!!n.structure)}}cn.jsonID("replaceAround",Yt);function C0(t,e,n){let r=t.resolve(e),o=n-e,i=r.depth;for(;o>0&&i>0&&r.indexAfter(i)==r.node(i).childCount;)i--,o--;if(o>0){let s=r.node(i).maybeChild(r.indexAfter(i));for(;o>0;){if(!s||s.isLeaf)return!0;s=s.firstChild,o--}}return!1}function gP(t,e,n,r){let o=[],i=[],s,l;t.doc.nodesBetween(e,n,(a,u,c)=>{if(!a.isInline)return;let d=a.marks;if(!r.isInSet(d)&&c.type.allowsMarkType(r.type)){let h=Math.max(u,e),f=Math.min(u+a.nodeSize,n),p=r.addToSet(d);for(let g=0;gt.step(a)),i.forEach(a=>t.step(a))}function mP(t,e,n,r){let o=[],i=0;t.doc.nodesBetween(e,n,(s,l)=>{if(!s.isInline)return;i++;let a=null;if(r instanceof Vh){let u=s.marks,c;for(;c=r.isInSet(u);)(a||(a=[])).push(c),u=c.removeFromSet(u)}else r?r.isInSet(s.marks)&&(a=[r]):a=s.marks;if(a&&a.length){let u=Math.min(l+s.nodeSize,n);for(let c=0;ct.step(new Po(s.from,s.to,s.style)))}function vP(t,e,n,r=n.contentMatch){let o=t.doc.nodeAt(e),i=[],s=e+1;for(let l=0;l=0;l--)t.step(i[l])}function yP(t,e,n){return(e==0||t.canReplace(e,t.childCount))&&(n==t.childCount||t.canReplace(0,n))}function cu(t){let n=t.parent.content.cutByIndex(t.startIndex,t.endIndex);for(let r=t.depth;;--r){let o=t.$from.node(r),i=t.$from.index(r),s=t.$to.indexAfter(r);if(rn;p--)g||r.index(p)>0?(g=!0,c=Q.from(r.node(p).copy(c)),d++):a--;let h=Q.empty,f=0;for(let p=i,g=!1;p>n;p--)g||o.after(p+1)=0;s--){if(r.size){let l=n[s].type.contentMatch.matchFragment(r);if(!l||!l.validEnd)throw new RangeError("Wrapper type given to Transform.wrap does not form valid content of its parent wrapper")}r=Q.from(n[s].type.create(n[s].attrs,r))}let o=e.start,i=e.end;t.step(new Yt(o,i,o,i,new ae(r,0,0),n.length,!0))}function EP(t,e,n,r,o){if(!r.isTextblock)throw new RangeError("Type given to setBlockType should be a textblock");let i=t.steps.length;t.doc.nodesBetween(e,n,(s,l)=>{if(s.isTextblock&&!s.hasMarkup(r,o)&&SP(t.doc,t.mapping.slice(i).map(l),r)){t.clearIncompatible(t.mapping.slice(i).map(l,1),r);let a=t.mapping.slice(i),u=a.map(l,1),c=a.map(l+s.nodeSize,1);return t.step(new Yt(u,c,u+1,c-1,new ae(Q.from(r.create(o,null,s.marks)),0,0),1,!0)),!1}})}function SP(t,e,n){let r=t.resolve(e),o=r.index();return r.parent.canReplaceWith(o,o+1,n)}function CP(t,e,n,r,o){let i=t.doc.nodeAt(e);if(!i)throw new RangeError("No node at given position");n||(n=i.type);let s=n.create(r,null,o||i.marks);if(i.isLeaf)return t.replaceWith(e,e+i.nodeSize,s);if(!n.validContent(i.content))throw new RangeError("Invalid content for node type "+n.name);t.step(new Yt(e,e+i.nodeSize,e+1,e+i.nodeSize-1,new ae(Q.from(s),0,0),1,!0))}function mc(t,e,n=1,r){let o=t.resolve(e),i=o.depth-n,s=r&&r[r.length-1]||o.parent;if(i<0||o.parent.type.spec.isolating||!o.parent.canReplace(o.index(),o.parent.childCount)||!s.type.validContent(o.parent.content.cutByIndex(o.index(),o.parent.childCount)))return!1;for(let u=o.depth-1,c=n-2;u>i;u--,c--){let d=o.node(u),h=o.index(u);if(d.type.spec.isolating)return!1;let f=d.content.cutByIndex(h,d.childCount),p=r&&r[c+1];p&&(f=f.replaceChild(0,p.type.create(p.attrs)));let g=r&&r[c]||d;if(!d.canReplace(h+1,d.childCount)||!g.type.validContent(f))return!1}let l=o.indexAfter(i),a=r&&r[0];return o.node(i).canReplaceWith(l,l,a?a.type:o.node(i+1).type)}function TP(t,e,n=1,r){let o=t.doc.resolve(e),i=Q.empty,s=Q.empty;for(let l=o.depth,a=o.depth-n,u=n-1;l>a;l--,u--){i=Q.from(o.node(l).copy(i));let c=r&&r[u];s=Q.from(c?c.type.create(c.attrs,s):o.node(l).copy(s))}t.step(new vn(e,e,new ae(i.append(s),n,n),!0))}function jh(t,e){let n=t.resolve(e),r=n.index();return AP(n.nodeBefore,n.nodeAfter)&&n.parent.canReplace(r,r+1)}function AP(t,e){return!!(t&&e&&!t.isLeaf&&t.canAppend(e))}function _P(t,e,n){let r=new vn(e-n,e+n,ae.empty,!0);t.step(r)}function o2(t,e,n){let r=t.resolve(e);if(r.parent.canReplaceWith(r.index(),r.index(),n))return e;if(r.parentOffset==0)for(let o=r.depth-1;o>=0;o--){let i=r.index(o);if(r.node(o).canReplaceWith(i,i,n))return r.before(o+1);if(i>0)return null}if(r.parentOffset==r.parent.content.size)for(let o=r.depth-1;o>=0;o--){let i=r.indexAfter(o);if(r.node(o).canReplaceWith(i,i,n))return r.after(o+1);if(i=0;s--){let l=s==r.depth?0:r.pos<=(r.start(s+1)+r.end(s+1))/2?-1:1,a=r.index(s)+(l>0?1:0),u=r.node(s),c=!1;if(i==1)c=u.canReplace(a,a,o);else{let d=u.contentMatchAt(a).findWrapping(o.firstChild.type);c=d&&u.canReplaceWith(a,a,d[0])}if(c)return l==0?r.pos:l<0?r.before(s+1):r.after(s+1)}return null}function Tb(t,e,n=e,r=ae.empty){if(e==n&&!r.size)return null;let o=t.resolve(e),i=t.resolve(n);return i2(o,i,r)?new vn(e,n,r):new MP(o,i,r).fit()}function i2(t,e,n){return!n.openStart&&!n.openEnd&&t.start()==e.start()&&t.parent.canReplace(t.index(),e.index(),n.content)}class MP{constructor(e,n,r){this.$from=e,this.$to=n,this.unplaced=r,this.frontier=[],this.placed=Q.empty;for(let o=0;o<=e.depth;o++){let i=e.node(o);this.frontier.push({type:i.type,match:i.contentMatchAt(e.indexAfter(o))})}for(let o=e.depth;o>0;o--)this.placed=Q.from(e.node(o).copy(this.placed))}get depth(){return this.frontier.length-1}fit(){for(;this.unplaced.size;){let u=this.findFittable();u?this.placeNodes(u):this.openMore()||this.dropNode()}let e=this.mustMoveInline(),n=this.placed.size-this.depth-this.$from.depth,r=this.$from,o=this.close(e<0?this.$to:r.doc.resolve(e));if(!o)return null;let i=this.placed,s=r.depth,l=o.depth;for(;s&&l&&i.childCount==1;)i=i.firstChild.content,s--,l--;let a=new ae(i,s,l);return e>-1?new Yt(r.pos,e,this.$to.pos,this.$to.end(),a,n):a.size||r.pos!=this.$to.pos?new vn(r.pos,o.pos,a):null}findFittable(){let e=this.unplaced.openStart;for(let n=this.unplaced.content,r=0,o=this.unplaced.openEnd;r1&&(o=0),i.type.spec.isolating&&o<=r){e=r;break}n=i.content}for(let n=1;n<=2;n++)for(let r=n==1?e:this.unplaced.openStart;r>=0;r--){let o,i=null;r?(i=r1(this.unplaced.content,r-1).firstChild,o=i.content):o=this.unplaced.content;let s=o.firstChild;for(let l=this.depth;l>=0;l--){let{type:a,match:u}=this.frontier[l],c,d=null;if(n==1&&(s?u.matchType(s.type)||(d=u.fillBefore(Q.from(s),!1)):i&&a.compatibleContent(i.type)))return{sliceDepth:r,frontierDepth:l,parent:i,inject:d};if(n==2&&s&&(c=u.findWrapping(s.type)))return{sliceDepth:r,frontierDepth:l,parent:i,wrap:c};if(i&&u.matchType(i.type))break}}}openMore(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=r1(e,n);return!o.childCount||o.firstChild.isLeaf?!1:(this.unplaced=new ae(e,n+1,Math.max(r,o.size+n>=e.size-r?n+1:0)),!0)}dropNode(){let{content:e,openStart:n,openEnd:r}=this.unplaced,o=r1(e,n);if(o.childCount<=1&&n>0){let i=e.size-n<=n+o.size;this.unplaced=new ae(Uu(e,n-1,1),n-1,i?n-1:r)}else this.unplaced=new ae(Uu(e,n,1),n,r)}placeNodes({sliceDepth:e,frontierDepth:n,parent:r,inject:o,wrap:i}){for(;this.depth>n;)this.closeFrontierNode();if(i)for(let g=0;g1||a==0||g.content.size)&&(d=m,c.push(s2(g.mark(h.allowedMarks(g.marks)),u==1?a:0,u==l.childCount?f:-1)))}let p=u==l.childCount;p||(f=-1),this.placed=Wu(this.placed,n,Q.from(c)),this.frontier[n].match=d,p&&f<0&&r&&r.type==this.frontier[this.depth].type&&this.frontier.length>1&&this.closeFrontierNode();for(let g=0,m=l;g1&&o==this.$to.end(--r);)++o;return o}findCloseLevel(e){e:for(let n=Math.min(this.depth,e.depth);n>=0;n--){let{match:r,type:o}=this.frontier[n],i=n=0;l--){let{match:a,type:u}=this.frontier[l],c=o1(e,l,u,a,!0);if(!c||c.childCount)continue e}return{depth:n,fit:s,move:i?e.doc.resolve(e.after(n+1)):e}}}}close(e){let n=this.findCloseLevel(e);if(!n)return null;for(;this.depth>n.depth;)this.closeFrontierNode();n.fit.childCount&&(this.placed=Wu(this.placed,n.depth,n.fit)),e=n.move;for(let r=n.depth+1;r<=e.depth;r++){let o=e.node(r),i=o.type.contentMatch.fillBefore(o.content,!0,e.index(r));this.openFrontierNode(o.type,o.attrs,i)}return e}openFrontierNode(e,n=null,r){let o=this.frontier[this.depth];o.match=o.match.matchType(e),this.placed=Wu(this.placed,this.depth,Q.from(e.create(n,r))),this.frontier.push({type:e,match:e.contentMatch})}closeFrontierNode(){let n=this.frontier.pop().match.fillBefore(Q.empty,!0);n.childCount&&(this.placed=Wu(this.placed,this.frontier.length,n))}}function Uu(t,e,n){return e==0?t.cutByIndex(n,t.childCount):t.replaceChild(0,t.firstChild.copy(Uu(t.firstChild.content,e-1,n)))}function Wu(t,e,n){return e==0?t.append(n):t.replaceChild(t.childCount-1,t.lastChild.copy(Wu(t.lastChild.content,e-1,n)))}function r1(t,e){for(let n=0;n1&&(r=r.replaceChild(0,s2(r.firstChild,e-1,r.childCount==1?n-1:0))),e>0&&(r=t.type.contentMatch.fillBefore(r).append(r),n<=0&&(r=r.append(t.type.contentMatch.matchFragment(r).fillBefore(Q.empty,!0)))),t.copy(r)}function o1(t,e,n,r,o){let i=t.node(e),s=o?t.indexAfter(e):t.index(e);if(s==i.childCount&&!n.compatibleContent(i.type))return null;let l=r.fillBefore(i.content,!0,s);return l&&!OP(n,i.content,s)?l:null}function OP(t,e,n){for(let r=n;r0;h--,f--){let p=o.node(h).type.spec;if(p.defining||p.definingAsContext||p.isolating)break;s.indexOf(h)>-1?l=h:o.before(h)==f&&s.splice(1,0,-h)}let a=s.indexOf(l),u=[],c=r.openStart;for(let h=r.content,f=0;;f++){let p=h.firstChild;if(u.push(p),f==r.openStart)break;h=p.content}for(let h=c-1;h>=0;h--){let f=u[h],p=IP(f.type);if(p&&!f.sameMarkup(o.node(Math.abs(l)-1)))c=h;else if(p||!f.type.isTextblock)break}for(let h=r.openStart;h>=0;h--){let f=(h+c+1)%(r.openStart+1),p=u[f];if(p)for(let g=0;g=0&&(t.replace(e,n,r),!(t.steps.length>d));h--){let f=s[h];f<0||(e=o.before(f),n=i.after(f))}}function a2(t,e,n,r,o){if(er){let i=o.contentMatchAt(0),s=i.fillBefore(t).append(t);t=s.append(i.matchFragment(s).fillBefore(Q.empty,!0))}return t}function NP(t,e,n,r){if(!r.isInline&&e==n&&t.doc.resolve(e).parent.content.size){let o=o2(t.doc,e,r.type);o!=null&&(e=n=o)}t.replaceRange(e,n,new ae(Q.from(r),0,0))}function $P(t,e,n){let r=t.doc.resolve(e),o=t.doc.resolve(n),i=l2(r,o);for(let s=0;s0&&(a||r.node(l-1).canReplace(r.index(l-1),o.indexAfter(l-1))))return t.delete(r.before(l),o.after(l))}for(let s=1;s<=r.depth&&s<=o.depth;s++)if(e-r.start(s)==r.depth-s&&n>r.end(s)&&o.end(s)-n!=o.depth-s)return t.delete(r.before(s),n);t.delete(e,n)}function l2(t,e){let n=[],r=Math.min(t.depth,e.depth);for(let o=r;o>=0;o--){let i=t.start(o);if(ie.pos+(e.depth-o)||t.node(o).type.spec.isolating||e.node(o).type.spec.isolating)break;(i==e.start(o)||o==t.depth&&o==e.depth&&t.parent.inlineContent&&e.parent.inlineContent&&o&&e.start(o-1)==i-1)&&n.push(o)}return n}class vc extends cn{constructor(e,n,r){super(),this.pos=e,this.attr=n,this.value=r}apply(e){let n=e.nodeAt(this.pos);if(!n)return Kt.fail("No node at attribute step's position");let r=Object.create(null);for(let i in n.attrs)r[i]=n.attrs[i];r[this.attr]=this.value;let o=n.type.create(r,null,n.marks);return Kt.fromReplace(e,this.pos,this.pos+1,new ae(Q.from(o),0,n.isLeaf?0:1))}getMap(){return Hr.empty}invert(e){return new vc(this.pos,this.attr,e.nodeAt(this.pos).attrs[this.attr])}map(e){let n=e.mapResult(this.pos,1);return n.deletedAfter?null:new vc(n.pos,this.attr,this.value)}toJSON(){return{stepType:"attr",pos:this.pos,attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.pos!="number"||typeof n.attr!="string")throw new RangeError("Invalid input for AttrStep.fromJSON");return new vc(n.pos,n.attr,n.value)}}cn.jsonID("attr",vc);class Gd extends cn{constructor(e,n){super(),this.attr=e,this.value=n}apply(e){let n=Object.create(null);for(let o in e.attrs)n[o]=e.attrs[o];n[this.attr]=this.value;let r=e.type.create(n,e.content,e.marks);return Kt.ok(r)}getMap(){return Hr.empty}invert(e){return new Gd(this.attr,e.attrs[this.attr])}map(e){return this}toJSON(){return{stepType:"docAttr",attr:this.attr,value:this.value}}static fromJSON(e,n){if(typeof n.attr!="string")throw new RangeError("Invalid input for DocAttrStep.fromJSON");return new Gd(n.attr,n.value)}}cn.jsonID("docAttr",Gd);let $c=class extends Error{};$c=function t(e){let n=Error.call(this,e);return n.__proto__=t.prototype,n};$c.prototype=Object.create(Error.prototype);$c.prototype.constructor=$c;$c.prototype.name="TransformError";class DP{constructor(e){this.doc=e,this.steps=[],this.docs=[],this.mapping=new gc}get before(){return this.docs.length?this.docs[0]:this.doc}step(e){let n=this.maybeStep(e);if(n.failed)throw new $c(n.failed);return this}maybeStep(e){let n=e.apply(this.doc);return n.failed||this.addStep(e,n.doc),n}get docChanged(){return this.steps.length>0}addStep(e,n){this.docs.push(this.doc),this.steps.push(e),this.mapping.appendMap(e.getMap()),this.doc=n}replace(e,n=e,r=ae.empty){let o=Tb(this.doc,e,n,r);return o&&this.step(o),this}replaceWith(e,n,r){return this.replace(e,n,new ae(Q.from(r),0,0))}delete(e,n){return this.replace(e,n,ae.empty)}insert(e,n){return this.replaceWith(e,e,n)}replaceRange(e,n,r){return LP(this,e,n,r),this}replaceRangeWith(e,n,r){return NP(this,e,n,r),this}deleteRange(e,n){return $P(this,e,n),this}lift(e,n){return bP(this,e,n),this}join(e,n=1){return _P(this,e,n),this}wrap(e,n){return kP(this,e,n),this}setBlockType(e,n=e,r,o=null){return EP(this,e,n,r,o),this}setNodeMarkup(e,n,r=null,o){return CP(this,e,n,r,o),this}setNodeAttribute(e,n,r){return this.step(new vc(e,n,r)),this}setDocAttribute(e,n){return this.step(new Gd(e,n)),this}addNodeMark(e,n){return this.step(new ks(e,n)),this}removeNodeMark(e,n){if(!(n instanceof je)){let r=this.doc.nodeAt(e);if(!r)throw new RangeError("No node at position "+e);if(n=n.isInSet(r.marks),!n)return this}return this.step(new Nc(e,n)),this}split(e,n=1,r){return TP(this,e,n,r),this}addMark(e,n,r){return gP(this,e,n,r),this}removeMark(e,n,r){return mP(this,e,n,r),this}clearIncompatible(e,n,r){return vP(this,e,n,r),this}}const i1=Object.create(null);class Be{constructor(e,n,r){this.$anchor=e,this.$head=n,this.ranges=r||[new PP(e.min(n),e.max(n))]}get anchor(){return this.$anchor.pos}get head(){return this.$head.pos}get from(){return this.$from.pos}get to(){return this.$to.pos}get $from(){return this.ranges[0].$from}get $to(){return this.ranges[0].$to}get empty(){let e=this.ranges;for(let n=0;n=0;i--){let s=n<0?jl(e.node(0),e.node(i),e.before(i+1),e.index(i),n,r):jl(e.node(0),e.node(i),e.after(i+1),e.index(i)+1,n,r);if(s)return s}return null}static near(e,n=1){return this.findFrom(e,n)||this.findFrom(e,-n)||new rr(e.node(0))}static atStart(e){return jl(e,e,0,0,1)||new rr(e)}static atEnd(e){return jl(e,e,e.content.size,e.childCount,-1)||new rr(e)}static fromJSON(e,n){if(!n||!n.type)throw new RangeError("Invalid input for Selection.fromJSON");let r=i1[n.type];if(!r)throw new RangeError(`No selection type ${n.type} defined`);return r.fromJSON(e,n)}static jsonID(e,n){if(e in i1)throw new RangeError("Duplicate use of selection JSON ID "+e);return i1[e]=n,n.prototype.jsonID=e,n}getBookmark(){return Me.between(this.$anchor,this.$head).getBookmark()}}Be.prototype.visible=!0;class PP{constructor(e,n){this.$from=e,this.$to=n}}let _S=!1;function RS(t){!_S&&!t.parent.inlineContent&&(_S=!0,console.warn("TextSelection endpoint not pointing into a node with inline content ("+t.parent.type.name+")"))}class Me extends Be{constructor(e,n=e){RS(e),RS(n),super(e,n)}get $cursor(){return this.$anchor.pos==this.$head.pos?this.$head:null}map(e,n){let r=e.resolve(n.map(this.head));if(!r.parent.inlineContent)return Be.near(r);let o=e.resolve(n.map(this.anchor));return new Me(o.parent.inlineContent?o:r,r)}replace(e,n=ae.empty){if(super.replace(e,n),n==ae.empty){let r=this.$from.marksAcross(this.$to);r&&e.ensureMarks(r)}}eq(e){return e instanceof Me&&e.anchor==this.anchor&&e.head==this.head}getBookmark(){return new pm(this.anchor,this.head)}toJSON(){return{type:"text",anchor:this.anchor,head:this.head}}static fromJSON(e,n){if(typeof n.anchor!="number"||typeof n.head!="number")throw new RangeError("Invalid input for TextSelection.fromJSON");return new Me(e.resolve(n.anchor),e.resolve(n.head))}static create(e,n,r=n){let o=e.resolve(n);return new this(o,r==n?o:e.resolve(r))}static between(e,n,r){let o=e.pos-n.pos;if((!r||o)&&(r=o>=0?1:-1),!n.parent.inlineContent){let i=Be.findFrom(n,r,!0)||Be.findFrom(n,-r,!0);if(i)n=i.$head;else return Be.near(n,r)}return e.parent.inlineContent||(o==0?e=n:(e=(Be.findFrom(e,-r,!0)||Be.findFrom(e,r,!0)).$anchor,e.pos0?0:1);o>0?s=0;s+=o){let l=e.child(s);if(l.isAtom){if(!i&&Oe.isSelectable(l))return Oe.create(t,n-(o<0?l.nodeSize:0))}else{let a=jl(t,l,n+o,o<0?l.childCount:0,o,i);if(a)return a}n+=l.nodeSize*o}return null}function MS(t,e,n){let r=t.steps.length-1;if(r{s==null&&(s=c)}),t.setSelection(Be.near(t.doc.resolve(s),n))}const OS=1,$f=2,IS=4;class FP extends DP{constructor(e){super(e.doc),this.curSelectionFor=0,this.updated=0,this.meta=Object.create(null),this.time=Date.now(),this.curSelection=e.selection,this.storedMarks=e.storedMarks}get selection(){return this.curSelectionFor0}setStoredMarks(e){return this.storedMarks=e,this.updated|=$f,this}ensureMarks(e){return je.sameSet(this.storedMarks||this.selection.$from.marks(),e)||this.setStoredMarks(e),this}addStoredMark(e){return this.ensureMarks(e.addToSet(this.storedMarks||this.selection.$head.marks()))}removeStoredMark(e){return this.ensureMarks(e.removeFromSet(this.storedMarks||this.selection.$head.marks()))}get storedMarksSet(){return(this.updated&$f)>0}addStep(e,n){super.addStep(e,n),this.updated=this.updated&~$f,this.storedMarks=null}setTime(e){return this.time=e,this}replaceSelection(e){return this.selection.replace(this,e),this}replaceSelectionWith(e,n=!0){let r=this.selection;return n&&(e=e.mark(this.storedMarks||(r.empty?r.$from.marks():r.$from.marksAcross(r.$to)||je.none))),r.replaceWith(this,e),this}deleteSelection(){return this.selection.replace(this),this}insertText(e,n,r){let o=this.doc.type.schema;if(n==null)return e?this.replaceSelectionWith(o.text(e),!0):this.deleteSelection();{if(r==null&&(r=n),r=r??n,!e)return this.deleteRange(n,r);let i=this.storedMarks;if(!i){let s=this.doc.resolve(n);i=r==n?s.marks():s.marksAcross(this.doc.resolve(r))}return this.replaceRangeWith(n,r,o.text(e,i)),this.selection.empty||this.setSelection(Be.near(this.selection.$to)),this}}setMeta(e,n){return this.meta[typeof e=="string"?e:e.key]=n,this}getMeta(e){return this.meta[typeof e=="string"?e:e.key]}get isGeneric(){for(let e in this.meta)return!1;return!0}scrollIntoView(){return this.updated|=IS,this}get scrolledIntoView(){return(this.updated&IS)>0}}function LS(t,e){return!e||!t?t:t.bind(e)}class Vu{constructor(e,n,r){this.name=e,this.init=LS(n.init,r),this.apply=LS(n.apply,r)}}const BP=[new Vu("doc",{init(t){return t.doc||t.schema.topNodeType.createAndFill()},apply(t){return t.doc}}),new Vu("selection",{init(t,e){return t.selection||Be.atStart(e.doc)},apply(t){return t.selection}}),new Vu("storedMarks",{init(t){return t.storedMarks||null},apply(t,e,n,r){return r.selection.$cursor?t.storedMarks:null}}),new Vu("scrollToSelection",{init(){return 0},apply(t,e){return t.scrolledIntoView?e+1:e}})];class s1{constructor(e,n){this.schema=e,this.plugins=[],this.pluginsByKey=Object.create(null),this.fields=BP.slice(),n&&n.forEach(r=>{if(this.pluginsByKey[r.key])throw new RangeError("Adding different instances of a keyed plugin ("+r.key+")");this.plugins.push(r),this.pluginsByKey[r.key]=r,r.spec.state&&this.fields.push(new Vu(r.key,r.spec.state,r))})}}class Na{constructor(e){this.config=e}get schema(){return this.config.schema}get plugins(){return this.config.plugins}apply(e){return this.applyTransaction(e).state}filterTransaction(e,n=-1){for(let r=0;rr.toJSON())),e&&typeof e=="object")for(let r in e){if(r=="doc"||r=="selection")throw new RangeError("The JSON fields `doc` and `selection` are reserved");let o=e[r],i=o.spec.state;i&&i.toJSON&&(n[r]=i.toJSON.call(o,this[o.key]))}return n}static fromJSON(e,n,r){if(!n)throw new RangeError("Invalid input for EditorState.fromJSON");if(!e.schema)throw new RangeError("Required config field 'schema' missing");let o=new s1(e.schema,e.plugins),i=new Na(o);return o.fields.forEach(s=>{if(s.name=="doc")i.doc=As.fromJSON(e.schema,n.doc);else if(s.name=="selection")i.selection=Be.fromJSON(i.doc,n.selection);else if(s.name=="storedMarks")n.storedMarks&&(i.storedMarks=n.storedMarks.map(e.schema.markFromJSON));else{if(r)for(let l in r){let a=r[l],u=a.spec.state;if(a.key==s.name&&u&&u.fromJSON&&Object.prototype.hasOwnProperty.call(n,l)){i[s.name]=u.fromJSON.call(a,e,n[l],i);return}}i[s.name]=s.init(e,i)}}),i}}function c2(t,e,n){for(let r in t){let o=t[r];o instanceof Function?o=o.bind(e):r=="handleDOMEvents"&&(o=c2(o,e,{})),n[r]=o}return n}class mi{constructor(e){this.spec=e,this.props={},e.props&&c2(e.props,this,this.props),this.key=e.key?e.key.key:u2("plugin")}getState(e){return e[this.key]}}const a1=Object.create(null);function u2(t){return t in a1?t+"$"+ ++a1[t]:(a1[t]=0,t+"$")}class ml{constructor(e="key"){this.key=u2(e)}get(e){return e.config.pluginsByKey[this.key]}getState(e){return e[this.key]}}var HP=/[A-Z]/g,UP=/^ms-/,l1={};function WP(t){return"-"+t.toLowerCase()}function VP(t){if(l1.hasOwnProperty(t))return l1[t];var e=t.replace(HP,WP);return l1[t]=UP.test(e)?"-"+e:e}function jP(t){return VP(t)}function GP(t,e){return jP(t)+":"+e}function KP(t){var e="";for(var n in t){var r=t[n];typeof r!="string"&&typeof r!="number"||(e&&(e+=";"),e+=GP(n,r))}return e}function d2(){return typeof document<"u"?document:null}function h2(t,e){if(typeof t!="string")return[t];var n=[t];typeof e=="string"||Array.isArray(e)?e={brackets:e}:e||(e={});var r=e.brackets?Array.isArray(e.brackets)?e.brackets:[e.brackets]:["{}","[]","()"],o=e.escape||"___",i=!!e.flat;r.forEach(function(a){var u=new RegExp(["\\",a[0],"[^\\",a[0],"\\",a[1],"]*\\",a[1]].join("")),c=[];function d(h,f,p){var g=n.push(h.slice(a[0].length,-a[1].length))-1;return c.push(g),o+g+o}n.forEach(function(h,f){for(var p,g=0;h!=p;)if(p=h,h=h.replace(u,d),g++>1e4)throw Error("References have circular dependency. Please, check them.");n[f]=h}),c=c.reverse(),n=n.map(function(h){return c.forEach(function(f){h=h.replace(new RegExp("(\\"+o+f+"\\"+o+")","g"),a[0]+"$1"+a[1])}),h})});var s=new RegExp("\\"+o+"([0-9]+)\\"+o);function l(a,u,c){for(var d=[],h,f=0;h=s.exec(a);){if(f++>1e4)throw Error("Circular references in parenthesis");d.push(a.slice(0,h.index)),d.push(l(u[h[1]],u)),a=a.slice(h.index+h[0].length)}return d.push(a),d}return i?n:l(n[0],n)}function f2(t,e){if(e&&e.flat){var n=e&&e.escape||"___",r=t[0],o;if(!r)return"";for(var i=new RegExp("\\"+n+"([0-9]+)\\"+n),s=0;r!=o;){if(s++>1e4)throw Error("Circular references in "+t);o=r,r=r.replace(i,l)}return r}return t.reduce(function a(u,c){return Array.isArray(c)&&(c=c.reduce(a,"")),u+c},"");function l(a,u){if(t[u]==null)throw Error("Reference "+u+"is undefined");return t[u]}}function p2(t,e){return Array.isArray(t)?f2(t,e):h2(t,e)}p2.parse=h2;p2.stringify=f2;const YP={id:"extension.command.copy.label",message:"Copy",comment:"Label for copy command."},XP={id:"extension.command.copy.description",message:"Copy the selected text",comment:"Description for copy command."},qP={id:"extension.command.cut.label",message:"Cut",comment:"Label for cut command."},ZP={id:"extension.command.cut.description",message:"Cut the selected text",comment:"Description for cut command."},QP={id:"extension.command.paste.label",message:"Paste",comment:"Label for paste command."},JP={id:"extension.command.paste.description",message:"Paste content into the editor",comment:"Description for paste command."},e5={id:"extension.command.select-all.label",message:"Select all",comment:"Label for select all command."},t5={id:"extension.command.select-all.description",message:"Select all content within the editor",comment:"Description for select all command."};var Ws=Object.freeze({__proto__:null,COPY_DESCRIPTION:XP,COPY_LABEL:YP,CUT_DESCRIPTION:ZP,CUT_LABEL:qP,PASTE_DESCRIPTION:JP,PASTE_LABEL:QP,SELECT_ALL_DESCRIPTION:t5,SELECT_ALL_LABEL:e5});const n5={id:"keyboard.shortcut.escape",message:"Enter",comment:"Label for escape key in shortcuts."},r5={id:"keyboard.shortcut.command",message:"Command",comment:"Label for command key in shortcuts."},o5={id:"keyboard.shortcut.control",message:"Control",comment:"Label for control key in shortcuts."},i5={id:"keyboard.shortcut.enter",message:"Enter",comment:"Label for enter key in shortcuts."},s5={id:"keyboard.shortcut.shift",message:"Shift",comment:"Label for shift key in shortcuts."},a5={id:"keyboard.shortcut.alt",message:"Alt",comment:"Label for alt key in shortcuts."},l5={id:"keyboard.shortcut.capsLock",message:"Caps Lock",comment:"Label for caps lock key in shortcuts."},c5={id:"keyboard.shortcut.backspace",message:"Backspace",comment:"Label for backspace key in shortcuts."},u5={id:"keyboard.shortcut.tab",message:"Tab",comment:"Label for tab key in shortcuts."},d5={id:"keyboard.shortcut.space",message:"Space",comment:"Label for space key in shortcuts."},h5={id:"keyboard.shortcut.delete",message:"Delete",comment:"Label for delete key in shortcuts."},f5={id:"keyboard.shortcut.pageUp",message:"Page Up",comment:"Label for page up key in shortcuts."},p5={id:"keyboard.shortcut.pageDown",message:"Page Down",comment:"Label for page down key in shortcuts."},g5={id:"keyboard.shortcut.home",message:"Home",comment:"Label for home key in shortcuts."},m5={id:"keyboard.shortcut.end",message:"End",comment:"Label for end key in shortcuts."},v5={id:"keyboard.shortcut.arrowLeft",message:"Arrow Left",comment:"Label for arrow left key in shortcuts."},y5={id:"keyboard.shortcut.arrowRight",message:"Arrow Right",comment:"Label for arrow right key in shortcuts."},b5={id:"keyboard.shortcut.arrowUp",message:"Arrow Up",comment:"Label for arrow up key in shortcuts."},w5={id:"keyboard.shortcut.arrowDown",message:"Arrow Down",comment:"Label for arrowDown key in shortcuts."};var nn=Object.freeze({__proto__:null,ALT_KEY:a5,ARROW_DOWN_KEY:w5,ARROW_LEFT_KEY:v5,ARROW_RIGHT_KEY:y5,ARROW_UP_KEY:b5,BACKSPACE_KEY:c5,CAPS_LOCK_KEY:l5,COMMAND_KEY:r5,CONTROL_KEY:o5,DELETE_KEY:h5,END_KEY:m5,ENTER_KEY:i5,ESCAPE_KEY:n5,HOME_KEY:g5,PAGE_DOWN_KEY:p5,PAGE_UP_KEY:f5,SHIFT_KEY:s5,SPACE_KEY:d5,TAB_KEY:u5});const x5={id:"extension.command.toggle-blockquote.label",message:"Blockquote",comment:"Label for blockquote formatting command."},k5={id:"extension.command.toggle-blockquote.description",message:"Add blockquote formatting to the selected text",comment:"Description for blockquote formatting command."};var NS=Object.freeze({__proto__:null,DESCRIPTION:k5,LABEL:x5});const E5={id:"extension.command.toggle-bold.label",message:"Bold",comment:"Label for bold formatting command."},S5={id:"extension.command.toggle-bold.description",message:"Add bold formatting to the selected text",comment:"Description for bold formatting command."};var $S=Object.freeze({__proto__:null,DESCRIPTION:S5,LABEL:E5});const C5={id:"extension.command.toggle-code-block.label",message:"Codeblock",comment:"Label for the code block command."},T5={id:"extension.command.toggle-code-block.description",message:"Add a code block",comment:"Description for the code block command."};var A5=Object.freeze({__proto__:null,DESCRIPTION:T5,LABEL:C5});const _5={id:"extension.command.toggle-code.label",message:"Code",comment:"Label for the inline code formatting."},R5={id:"extension.command.toggle-code.description",message:"Add inline code formatting to the selected text",comment:"Description for the inline code formatting command."};var M5=Object.freeze({__proto__:null,DESCRIPTION:R5,LABEL:_5});const O5={id:"extension.command.toggle-heading.label",message:`{level, select, 1 {Heading 1}
2 {Heading 2}
3 {Heading 3}
4 {Heading 4}
5 {Heading 5}
6 {Heading 6}
-other {Heading}}`,comment:"Label for heading command with support for levels."};var y5=Object.freeze({__proto__:null,LABEL:v5});const b5={id:"extension.command.undo.label",message:"Undo",comment:"Label for undo."},w5={id:"extension.command.undo.description",message:"Undo the most recent action",comment:"Description for undo."},x5={id:"extension.command.redo.label",message:"Redo",comment:"Label for redo."},k5={id:"extension.command.redo.description",message:"Redo the most recent action",comment:"Description for redo."};var qp=Object.freeze({__proto__:null,REDO_DESCRIPTION:k5,REDO_LABEL:x5,UNDO_DESCRIPTION:w5,UNDO_LABEL:b5});const E5={id:"extension.command.insert-horizontal-rule.label",message:"Divider",comment:"Label for inserting a horizontal rule (divider) command."},S5={id:"extension.command.insert-horizontal-rule.description",message:"Separate content with a diving horizontal line",comment:"Description for inserting a horizontal rule (divider) command."};var TS=Object.freeze({__proto__:null,DESCRIPTION:S5,LABEL:E5});const C5={id:"extension.command.toggle-italic.label",message:"Italic",comment:"Label for italic formatting command."},T5={id:"extension.command.toggle-italic.description",message:"Italicize the selected text",comment:"Description for italic formatting command."};var AS=Object.freeze({__proto__:null,DESCRIPTION:T5,LABEL:C5});const A5={id:"extension.command.toggle-ordered-list.label",message:"Ordered list",comment:"Label for inserting an ordered list into the editor."},_5={id:"extension.command.toggle-bullet-list.description",message:"Bulleted list",comment:"Description for inserting a bullet list into the editor."},R5={id:"extension.command.toggle-task-list.description",message:"Tasked list",comment:"Description for inserting a task list into the editor."};var Sb=Object.freeze({__proto__:null,BULLET_LIST_LABEL:_5,ORDERED_LIST_LABEL:A5,TASK_LIST_LABEL:R5});const M5={id:"extension.command.insert-paragraph.label",message:"Insert Paragraph",comment:"Label for inserting a paragraph."},O5={id:"extension.command.insert-paragraph.description",message:"Insert a new paragraph",comment:"Description for inserting a paragraph."},I5={id:"extension.command.convert-paragraph.label",message:"Convert Paragraph",comment:"Label for converting the current node into a paragraph."},L5={id:"extension.command.convert-paragraph.description",message:"Convert current block into a paragraph block.",comment:"Description for converting a paragraph."};var Zp=Object.freeze({__proto__:null,CONVERT_DESCRIPTION:L5,CONVERT_LABEL:I5,INSERT_DESCRIPTION:O5,INSERT_LABEL:M5});const N5={id:"extension.command.toggle-strike.label",message:"Strikethrough",comment:"Label for strike formatting command."},$5={id:"extension.command.toggle-strike.description",message:"Strikethrough the selected text",comment:"Description for strike formatting command."};var _S=Object.freeze({__proto__:null,DESCRIPTION:$5,LABEL:N5});const D5={id:"extension.command.toggle-underline.label",message:"Underline",comment:"Label for underline formatting command."},P5={id:"extension.command.toggle-underline.description",message:"Underline the selected text",comment:"Description for underline formatting command."};var RS=Object.freeze({__proto__:null,DESCRIPTION:P5,LABEL:D5});class bl{constructor(e,n){this.match=e,this.match=e,this.handler=typeof n=="string"?z5(n):n}}function z5(t){return function(e,n,r,o){let i=t;if(n[1]){let s=n[0].lastIndexOf(n[1]);i+=n[0].slice(s+n[1].length),r+=s;let l=r-o;l>0&&(i=n[0].slice(s-l,s)+i,r=o)}return e.tr.insertText(i,r,o)}}const F5=500;function B5({rules:t}){let e=new yi({state:{init(){return null},apply(n,r){let o=n.getMeta(this);return o||(n.selectionSet||n.docChanged?null:r)}},props:{handleTextInput(n,r,o,i){return MS(n,r,o,i,t,e)},handleDOMEvents:{compositionend:n=>{setTimeout(()=>{let{$cursor:r}=n.state.selection;r&&MS(n,r.pos,r.pos,"",t,e)})}}},isInputRules:!0});return e}function MS(t,e,n,r,o,i){if(t.composing)return!1;let s=t.state,l=s.doc.resolve(e);if(l.parent.type.spec.code)return!1;let a=l.parent.textBetween(Math.max(0,l.parentOffset-F5),l.parentOffset,null,"")+r;for(let u=0;u{let n=t.plugins;for(let r=0;r=0;a--)s.step(l.steps[a].invert(l.docs[a]));if(i.text){let a=s.doc.resolve(i.from).marks();s.replaceWith(i.from,i.to,t.schema.text(i.text,a))}else s.delete(i.from,i.to);e(s)}return!0}}return!1};function dm(t,e,n=null,r){return new bl(t,(o,i,s,l)=>{let a=n instanceof Function?n(i):n,u=o.tr.delete(s,l),c=u.doc.resolve(s),d=c.blockRange(),h=d&&xb(d,e,a);if(!h)return null;u.wrap(d,h);let f=u.doc.resolve(s-1).nodeBefore;return f&&f.type==e&&Vh(u.doc,s-1)&&(!r||r(i,f))&&u.join(s-1),u})}function U5(t,e,n=null){return new bl(t,(r,o,i,s)=>{let l=r.doc.resolve(i),a=n instanceof Function?n(o):n;return l.node(-1).canReplaceWith(l.index(-1),l.indexAfter(-1),e)?r.tr.delete(i,s).setBlockType(i,i,e,a):null})}const rr=function(t){for(var e=0;;e++)if(t=t.previousSibling,!t)return e},Gd=function(t){let e=t.assignedSlot||t.parentNode;return e&&e.nodeType==11?e.host:e};let OS=null;const Ri=function(t,e,n){let r=OS||(OS=document.createRange());return r.setEnd(t,n??t.nodeValue.length),r.setStart(t,e||0),r},Ja=function(t,e,n,r){return n&&(IS(t,e,n,r,-1)||IS(t,e,n,r,1))},W5=/^(img|br|input|textarea|hr)$/i;function IS(t,e,n,r,o){for(;;){if(t==n&&e==r)return!0;if(e==(o<0?0:ni(t))){let i=t.parentNode;if(!i||i.nodeType!=1||Cb(t)||W5.test(t.nodeName)||t.contentEditable=="false")return!1;e=rr(t)+(o<0?0:1),t=i}else if(t.nodeType==1){if(t=t.childNodes[e+(o<0?-1:0)],t.contentEditable=="false")return!1;e=o<0?ni(t):0}else return!1}}function ni(t){return t.nodeType==3?t.nodeValue.length:t.childNodes.length}function V5(t,e,n){for(let r=e==0,o=e==ni(t);r||o;){if(t==n)return!0;let i=rr(t);if(t=t.parentNode,!t)return!1;r=r&&i==0,o=o&&i==ni(t)}}function Cb(t){let e;for(let n=t;n&&!(e=n.pmViewDesc);n=n.parentNode);return e&&e.node&&e.node.isBlock&&(e.dom==t||e.contentDOM==t)}const hm=function(t){return t.focusNode&&Ja(t.focusNode,t.focusOffset,t.anchorNode,t.anchorOffset)};function Na(t,e){let n=document.createEvent("Event");return n.initEvent("keydown",!0,!0),n.keyCode=t,n.key=n.code=e,n}function j5(t){let e=t.activeElement;for(;e&&e.shadowRoot;)e=e.shadowRoot.activeElement;return e}function G5(t,e,n){if(t.caretPositionFromPoint)try{let r=t.caretPositionFromPoint(e,n);if(r)return{node:r.offsetNode,offset:r.offset}}catch{}if(t.caretRangeFromPoint){let r=t.caretRangeFromPoint(e,n);if(r)return{node:r.startContainer,offset:r.startOffset}}}const fi=typeof navigator<"u"?navigator:null,LS=typeof document<"u"?document:null,na=fi&&fi.userAgent||"",E0=/Edge\/(\d+)/.exec(na),o2=/MSIE \d/.exec(na),S0=/Trident\/(?:[7-9]|\d{2,})\..*rv:(\d+)/.exec(na),Sr=!!(o2||S0||E0),Ms=o2?document.documentMode:S0?+S0[1]:E0?+E0[1]:0,Wo=!Sr&&/gecko\/(\d+)/i.test(na);Wo&&+(/Firefox\/(\d+)/.exec(na)||[0,0])[1];const C0=!Sr&&/Chrome\/(\d+)/.exec(na),Yn=!!C0,K5=C0?+C0[1]:0,lr=!Sr&&!!fi&&/Apple Computer/.test(fi.vendor),Pc=lr&&(/Mobile\/\w+/.test(na)||!!fi&&fi.maxTouchPoints>2),co=Pc||(fi?/Mac/.test(fi.platform):!1),Y5=fi?/Win/.test(fi.platform):!1,$o=/Android \d/.test(na),jh=!!LS&&"webkitFontSmoothing"in LS.documentElement.style,X5=jh?+(/\bAppleWebKit\/(\d+)/.exec(navigator.userAgent)||[0,0])[1]:0;function q5(t){return{left:0,right:t.documentElement.clientWidth,top:0,bottom:t.documentElement.clientHeight}}function ki(t,e){return typeof t=="number"?t:t[e]}function Z5(t){let e=t.getBoundingClientRect(),n=e.width/t.offsetWidth||1,r=e.height/t.offsetHeight||1;return{left:e.left,right:e.left+t.clientWidth*n,top:e.top,bottom:e.top+t.clientHeight*r}}function NS(t,e,n){let r=t.someProp("scrollThreshold")||0,o=t.someProp("scrollMargin")||5,i=t.dom.ownerDocument;for(let s=n||t.dom;s;s=Gd(s)){if(s.nodeType!=1)continue;let l=s,a=l==i.body,u=a?q5(i):Z5(l),c=0,d=0;if(e.topu.bottom-ki(r,"bottom")&&(d=e.bottom-e.top>u.bottom-u.top?e.top+ki(o,"top")-u.top:e.bottom-u.bottom+ki(o,"bottom")),e.leftu.right-ki(r,"right")&&(c=e.right-u.right+ki(o,"right")),c||d)if(a)i.defaultView.scrollBy(c,d);else{let h=l.scrollLeft,f=l.scrollTop;d&&(l.scrollTop+=d),c&&(l.scrollLeft+=c);let p=l.scrollLeft-h,g=l.scrollTop-f;e={left:e.left-p,top:e.top-g,right:e.right-p,bottom:e.bottom-g}}if(a||/^(fixed|sticky)$/.test(getComputedStyle(s).position))break}}function Q5(t){let e=t.dom.getBoundingClientRect(),n=Math.max(0,e.top),r,o;for(let i=(e.left+e.right)/2,s=n+1;s=n-20){r=l,o=a.top;break}}return{refDOM:r,refTop:o,stack:i2(t.dom)}}function i2(t){let e=[],n=t.ownerDocument;for(let r=t;r&&(e.push({dom:r,top:r.scrollTop,left:r.scrollLeft}),t!=n);r=Gd(r));return e}function J5({refDOM:t,refTop:e,stack:n}){let r=t?t.getBoundingClientRect().top:0;s2(n,r==0?0:r-e)}function s2(t,e){for(let n=0;n=l){s=Math.max(p.bottom,s),l=Math.min(p.top,l);let g=p.left>e.left?p.left-e.left:p.right=(p.left+p.right)/2?1:0));continue}}else p.top>e.top&&!a&&p.left<=e.left&&p.right>=e.left&&(a=c,u={left:Math.max(p.left,Math.min(p.right,e.left)),top:p.top});!n&&(e.left>=p.right&&e.top>=p.top||e.left>=p.left&&e.top>=p.bottom)&&(i=d+1)}}return!n&&a&&(n=a,o=u,r=0),n&&n.nodeType==3?t3(n,o):!n||r&&n.nodeType==1?{node:t,offset:i}:a2(n,o)}function t3(t,e){let n=t.nodeValue.length,r=document.createRange();for(let o=0;o=(i.left+i.right)/2?1:0)}}return{node:t,offset:0}}function Tb(t,e){return t.left>=e.left-1&&t.left<=e.right+1&&t.top>=e.top-1&&t.top<=e.bottom+1}function n3(t,e){let n=t.parentNode;return n&&/^li$/i.test(n.nodeName)&&e.left(s.left+s.right)/2?1:-1}return t.docView.posFromDOM(r,o,i)}function o3(t,e,n,r){let o=-1;for(let i=e,s=!1;i!=t.dom;){let l=t.docView.nearestDesc(i,!0);if(!l)return null;if(l.dom.nodeType==1&&(l.node.isBlock&&l.parent&&!s||!l.contentDOM)){let a=l.dom.getBoundingClientRect();if(l.node.isBlock&&l.parent&&!s&&(s=!0,a.left>r.left||a.top>r.top?o=l.posBefore:(a.right-1?o:t.docView.posFromDOM(e,n,-1)}function l2(t,e,n){let r=t.childNodes.length;if(r&&n.tope.top&&o++}let u;jh&&o&&r.nodeType==1&&(u=r.childNodes[o-1]).nodeType==1&&u.contentEditable=="false"&&u.getBoundingClientRect().top>=e.top&&o--,r==t.dom&&o==r.childNodes.length-1&&r.lastChild.nodeType==1&&e.top>r.lastChild.getBoundingClientRect().bottom?l=t.state.doc.content.size:(o==0||r.nodeType!=1||r.childNodes[o-1].nodeName!="BR")&&(l=o3(t,r,o,e))}l==null&&(l=r3(t,s,e));let a=t.docView.nearestDesc(s,!0);return{pos:l,inside:a?a.posAtStart-a.border:-1}}function $S(t){return t.top=0&&o==r.nodeValue.length?(a--,c=1):n<0?a--:u++,Tu(us(Ri(r,a,u),c),c<0)}if(!t.state.doc.resolve(e-(i||0)).parent.inlineContent){if(i==null&&o&&(n<0||o==ni(r))){let a=r.childNodes[o-1];if(a.nodeType==1)return i1(a.getBoundingClientRect(),!1)}if(i==null&&o=0)}if(i==null&&o&&(n<0||o==ni(r))){let a=r.childNodes[o-1],u=a.nodeType==3?Ri(a,ni(a)-(s?0:1)):a.nodeType==1&&(a.nodeName!="BR"||!a.nextSibling)?a:null;if(u)return Tu(us(u,1),!1)}if(i==null&&o=0)}function Tu(t,e){if(t.width==0)return t;let n=e?t.left:t.right;return{top:t.top,bottom:t.bottom,left:n,right:n}}function i1(t,e){if(t.height==0)return t;let n=e?t.top:t.bottom;return{top:n,bottom:n,left:t.left,right:t.right}}function u2(t,e,n){let r=t.state,o=t.root.activeElement;r!=e&&t.updateState(e),o!=t.dom&&t.focus();try{return n()}finally{r!=e&&t.updateState(r),o!=t.dom&&o&&o.focus()}}function a3(t,e,n){let r=e.selection,o=n=="up"?r.$from:r.$to;return u2(t,e,()=>{let{node:i}=t.docView.domFromPos(o.pos,n=="up"?-1:1);for(;;){let l=t.docView.nearestDesc(i,!0);if(!l)break;if(l.node.isBlock){i=l.contentDOM||l.dom;break}i=l.dom.parentNode}let s=c2(t,o.pos,1);for(let l=i.firstChild;l;l=l.nextSibling){let a;if(l.nodeType==1)a=l.getClientRects();else if(l.nodeType==3)a=Ri(l,0,l.nodeValue.length).getClientRects();else continue;for(let u=0;uc.top+1&&(n=="up"?s.top-c.top>(c.bottom-s.top)*2:c.bottom-s.bottom>(s.bottom-c.top)*2))return!1}}return!0})}const l3=/[\u0590-\u08ac]/;function c3(t,e,n){let{$head:r}=e.selection;if(!r.parent.isTextblock)return!1;let o=r.parentOffset,i=!o,s=o==r.parent.content.size,l=t.domSelection();return!l3.test(r.parent.textContent)||!l.modify?n=="left"||n=="backward"?i:s:u2(t,e,()=>{let{focusNode:a,focusOffset:u,anchorNode:c,anchorOffset:d}=t.domSelectionRange(),h=l.caretBidiLevel;l.modify("move",n,"character");let f=r.depth?t.docView.domAfterPos(r.before()):t.dom,{focusNode:p,focusOffset:g}=t.domSelectionRange(),m=p&&!f.contains(p.nodeType==1?p:p.parentNode)||a==p&&u==g;try{l.collapse(c,d),a&&(a!=c||u!=d)&&l.extend&&l.extend(a,u)}catch{}return h!=null&&(l.caretBidiLevel=h),m})}let DS=null,PS=null,zS=!1;function u3(t,e,n){return DS==e&&PS==n?zS:(DS=e,PS=n,zS=n=="up"||n=="down"?a3(t,e,n):c3(t,e,n))}const go=0,FS=1,Pa=2,pi=3;class Gh{constructor(e,n,r,o){this.parent=e,this.children=n,this.dom=r,this.contentDOM=o,this.dirty=go,r.pmViewDesc=this}matchesWidget(e){return!1}matchesMark(e){return!1}matchesNode(e,n,r){return!1}matchesHack(e){return!1}parseRule(){return null}stopEvent(e){return!1}get size(){let e=0;for(let n=0;nrr(this.contentDOM);else if(this.contentDOM&&this.contentDOM!=this.dom&&this.dom.contains(this.contentDOM))o=e.compareDocumentPosition(this.contentDOM)&2;else if(this.dom.firstChild){if(n==0)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!1;break}if(i.previousSibling)break}if(o==null&&n==e.childNodes.length)for(let i=e;;i=i.parentNode){if(i==this.dom){o=!0;break}if(i.nextSibling)break}}return o??r>0?this.posAtEnd:this.posAtStart}nearestDesc(e,n=!1){for(let r=!0,o=e;o;o=o.parentNode){let i=this.getDesc(o),s;if(i&&(!n||i.node))if(r&&(s=i.nodeDOM)&&!(s.nodeType==1?s.contains(e.nodeType==1?e:e.parentNode):s==e))r=!1;else return i}}getDesc(e){let n=e.pmViewDesc;for(let r=n;r;r=r.parent)if(r==this)return n}posFromDOM(e,n,r){for(let o=e;o;o=o.parentNode){let i=this.getDesc(o);if(i)return i.localPosFromDOM(e,n,r)}return-1}descAt(e){for(let n=0,r=0;ne||s instanceof h2){o=e-i;break}i=l}if(o)return this.children[r].domFromPos(o-this.children[r].border,n);for(let i;r&&!(i=this.children[r-1]).size&&i instanceof d2&&i.side>=0;r--);if(n<=0){let i,s=!0;for(;i=r?this.children[r-1]:null,!(!i||i.dom.parentNode==this.contentDOM);r--,s=!1);return i&&n&&s&&!i.border&&!i.domAtom?i.domFromPos(i.size,n):{node:this.contentDOM,offset:i?rr(i.dom)+1:0}}else{let i,s=!0;for(;i=r=c&&n<=u-a.border&&a.node&&a.contentDOM&&this.contentDOM.contains(a.contentDOM))return a.parseRange(e,n,c);e=s;for(let d=l;d>0;d--){let h=this.children[d-1];if(h.size&&h.dom.parentNode==this.contentDOM&&!h.emptyChildAt(1)){o=rr(h.dom)+1;break}e-=h.size}o==-1&&(o=0)}if(o>-1&&(u>n||l==this.children.length-1)){n=u;for(let c=l+1;cf&&sn){let f=l;l=a,a=f}let h=document.createRange();h.setEnd(a.node,a.offset),h.setStart(l.node,l.offset),u.removeAllRanges(),u.addRange(h)}}ignoreMutation(e){return!this.contentDOM&&e.type!="selection"}get contentLost(){return this.contentDOM&&this.contentDOM!=this.dom&&!this.dom.contains(this.contentDOM)}markDirty(e,n){for(let r=0,o=0;o=r:er){let l=r+i.border,a=s-i.border;if(e>=l&&n<=a){this.dirty=e==r||n==s?Pa:FS,e==l&&n==a&&(i.contentLost||i.dom.parentNode!=this.contentDOM)?i.dirty=pi:i.markDirty(e-l,n-l);return}else i.dirty=i.dom==i.contentDOM&&i.dom.parentNode==this.contentDOM&&!i.children.length?Pa:pi}r=s}this.dirty=Pa}markParentsDirty(){let e=1;for(let n=this.parent;n;n=n.parent,e++){let r=e==1?Pa:FS;n.dirty{if(!i)return o;if(i.parent)return i.parent.posBeforeChild(i)})),!n.type.spec.raw){if(s.nodeType!=1){let l=document.createElement("span");l.appendChild(s),s=l}s.contentEditable="false",s.classList.add("ProseMirror-widget")}super(e,[],s,null),this.widget=n,this.widget=n,i=this}matchesWidget(e){return this.dirty==go&&e.type.eq(this.widget.type)}parseRule(){return{ignore:!0}}stopEvent(e){let n=this.widget.spec.stopEvent;return n?n(e):!1}ignoreMutation(e){return e.type!="selection"||this.widget.spec.ignoreSelection}destroy(){this.widget.type.destroy(this.dom),super.destroy()}get domAtom(){return!0}get side(){return this.widget.type.side}}class d3 extends Gh{constructor(e,n,r,o){super(e,[],n,null),this.textDOM=r,this.text=o}get size(){return this.text.length}localPosFromDOM(e,n){return e!=this.textDOM?this.posAtStart+(n?this.size:0):this.posAtStart+n}domFromPos(e){return{node:this.textDOM,offset:e}}ignoreMutation(e){return e.type==="characterData"&&e.target.nodeValue==e.oldValue}}class el extends Gh{constructor(e,n,r,o){super(e,[],r,o),this.mark=n}static create(e,n,r,o){let i=o.nodeViews[n.type.name],s=i&&i(n,o,r);return(!s||!s.dom)&&(s=jr.renderSpec(document,n.type.spec.toDOM(n,r))),new el(e,n,s.dom,s.contentDOM||s.dom)}parseRule(){return this.dirty&pi||this.mark.type.spec.reparseInView?null:{mark:this.mark.type.name,attrs:this.mark.attrs,contentElement:this.contentDOM}}matchesMark(e){return this.dirty!=pi&&this.mark.eq(e)}markDirty(e,n){if(super.markDirty(e,n),this.dirty!=go){let r=this.parent;for(;!r.node;)r=r.parent;r.dirty