Lexical References
Track block relationships and backfill lexicalReferences
Lexical references store relationship/upload IDs used inside Lexical blocks as tags in a hidden field (default: lexicalReferences). This enables reverse lookups during revalidation without scanning all documents.
Enable or disable
Lexical references are enabled by default. You can disable globally or per collection:
import { adsignPlugin } from '@adsign/payload-adsign-plugin';
adsignPlugin({
siteName: 'My Site',
domain: 'example.com',
lexicalReferences: {
enabled: true,
collections: {
pages: true,
articles: false,
},
},
});Backfill existing documents
To populate lexicalReferences for existing documents, use the migration helper:
import type { MigrateUpArgs } from '@payloadcms/db-mongodb';
import { migrateLexicalReferences } from '@adsign/payload-adsign-plugin';
export async function up({ payload, req }: MigrateUpArgs): Promise<void> {
await migrateLexicalReferences({
payload,
req,
batchSize: 200,
// collections: ['pages', 'articles'],
// fieldName: 'lexicalReferences',
// dryRun: true,
});
}Notes:
- The migrator only touches collections that already have the
lexicalReferencesfield and at least onerichTextfield. - The update is skipped if tags are unchanged.