@svgrid/enterprise 3.1.73 → 3.1.75
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cdn/svgrid-enterprise.svelte-external.js +1 -1
- package/dist/designer/assets/PinSplitter-PRGGE5GP.js +1 -0
- package/dist/designer/assets/{index-BN-wGfOs.js → index-BOF2h-Nd.js} +3 -3
- package/dist/designer/index.html +1 -1
- package/dist/fields/AutomationAction.svelte +2 -1
- package/dist/fields/FieldInput.svelte +1 -1
- package/dist/fields/LongTextEditor.svelte +22 -15
- package/dist/fields/LongTextEditor.svelte.d.ts +1 -0
- package/dist/fields/MentionInput.svelte +13 -7
- package/dist/fields/MentionInput.svelte.d.ts +4 -1
- package/dist/fields/RecordView.svelte +4 -3
- package/dist/fields/RichTextEditor.svelte +25 -17
- package/dist/fields/RichTextEditor.svelte.d.ts +1 -0
- package/dist/fields/automations.svelte.d.ts +9 -1
- package/dist/fields/automations.svelte.js +6 -1
- package/dist/fields/builtin-types.js +1 -1
- package/dist/fields/index.d.ts +1 -1
- package/dist/fields/index.js +1 -1
- package/dist/fields/mentions.d.ts +31 -3
- package/dist/fields/mentions.js +1 -1
- package/dist/fields/messages/extras.d.ts +2 -0
- package/dist/fields/messages/extras.js +1 -1
- package/dist/fields/messages.svelte.d.ts +2 -0
- package/dist/fields/page/PageEditor.svelte +2 -2
- package/dist/fields/page/PageEditor.svelte.d.ts +3 -0
- package/dist/fields/page/page-editor.d.ts +9 -0
- package/dist/fields/page/page-editor.js +4 -4
- package/dist/fields/rollups.d.ts +2 -0
- package/dist/fields/rollups.js +1 -1
- package/dist/node/studio.js +1 -1
- package/dist/version.d.ts +2 -2
- package/dist/version.js +1 -1
- package/dist/wc/PageEditor-D9pEmMvk.js +12 -0
- package/dist/wc/{PinSplitter-D7UYjmiP.js → PinSplitter-C6SuBrBi.js} +2 -2
- package/dist/wc/PinSplitter-CZx_nlrw.js +11 -0
- package/dist/wc/{embed-url-CGl6lpsT.js → embed-url-CdvhipnX.js} +1 -1
- package/dist/wc/sv-base-element.js +101 -90
- package/dist/wc/sv-sheet-element.js +1 -1
- package/package.json +3 -3
- package/dist/designer/assets/PinSplitter-DFIcNVPE.js +0 -1
- package/dist/wc/PageEditor-0bKgt5ID.js +0 -12
- package/dist/wc/PinSplitter-BmwDy-Ow.js +0 -11
|
@@ -1 +1 @@
|
|
|
1
|
-
export const EXTRAS_MESSAGES={"extras.whenCreated":"When a record is created","extras.whenCreatedWhere":"When a record is created, where {condition}","extras.whenRecordChanges":"When a record changes","extras.whenRecordChangesWhere":"When a record changes, where {condition}","extras.whenFieldsChange":"When {fields} changes","extras.whenFieldsChangeWhere":"When {fields} changes, where {condition}","extras.fieldsOr":" or ","extras.whenMatches":"When a record matches: {condition}","extras.noConditionYet":"no condition yet","extras.whenForm":"When a form is sent","extras.whenFormWhere":"When a form is sent, where {condition}","extras.whenPressed":"When {field} is pressed","extras.onSchedule":"{cron}","extras.onScheduleWhere":"{cron}, for records where {condition}","extras.cronOther":"On a schedule ({cron})","extras.cronEveryMinute":"Every minute","extras.cronEveryMinutes":"Every {n} minutes","extras.cronHourly":"Every hour, on the hour","extras.cronHourlyAt":"Every hour at {minute} past","extras.cronDaily":"Every day at {time}","extras.cronWeekdays":"Every weekday at {time}","extras.cronWeekly0":"Every Sunday at {time}","extras.cronWeekly1":"Every Monday at {time}","extras.cronWeekly2":"Every Tuesday at {time}","extras.cronWeekly3":"Every Wednesday at {time}","extras.cronWeekly4":"Every Thursday at {time}","extras.cronWeekly5":"Every Friday at {time}","extras.cronWeekly6":"Every Saturday at {time}","extras.cronDays":"Every {days} at {time}","extras.cronDay0":"Sunday","extras.cronDay1":"Monday","extras.cronDay2":"Tuesday","extras.cronDay3":"Wednesday","extras.cronDay4":"Thursday","extras.cronDay5":"Friday","extras.cronDay6":"Saturday","extras.cronMonthly":"Day {day} of every month at {time}","extras.actionUpdateRecord":"Update record","extras.actionCreateRecord":"Create record","extras.actionNotify":"Show a notice","extras.actionHighlight":"Color the record","extras.actionWebhook":"Call a webhook","extras.actionEmail":"Send an email","extras.stepStopped":"Stopped","extras.stepLoop":"Automations set each other off {max} times in a row; this one did not run, so they cannot loop.","extras.stepNotice":"Notice","extras.stepWebhook":"Webhook","extras.stepEmail":"Email","extras.stepNotRun":"Not run","extras.stepNoMatch":"The record does not match the condition","extras.stepDone":"Done","extras.noRecordToUpdate":"No record to update","extras.alreadySet":"Already set","extras.noTable":'No table "{table}"',"extras.noAction":'No action "{action}" is registered',"extras.aRecord":"a record","extras.createdIn":"{name} in {table}","extras.saidValue":"{field}: {value}","extras.saidChecked":"{field}: checked","extras.saidUnchecked":"{field}: unchecked","extras.saidEmpty":"empty","extras.title":"Automations in {table}","extras.listLabel":"Automations","extras.untitled":"Untitled","extras.switchOn":"{name} on","extras.noAutomations":"No automations yet. An automation does something when a record is added, changes or matches a condition.","extras.addAutomation":"+ New automation","extras.describeLabel":"Describe what should happen","extras.describePlaceholder":"For example: every Monday at 8:00, e-mail me the tasks that are not done","extras.describeButton":"Draft it","extras.describing":"Drafting...","extras.describeAgain":"Say a little more about what should happen, then try again.","extras.drafted":"Drafted from your words and switched off. Check each part, then switch it on.","extras.newAutomation":"New automation","extras.newRecordMessage":"New record: {{field}}","extras.nameFallback":"Name","extras.runs":"Runs","extras.clearRuns":"Clear this page's runs","extras.serverRunsFailed":"The server's runs did not load: {message}","extras.statusDone":"Done","extras.statusFailed":"Failed","extras.statusStopped":"Stopped","extras.runOn":"on {record}","extras.runIn":"in {table}","extras.serverTag":"Server","extras.noRuns":"Nothing has run yet. Runs show here with what each action did.","extras.name":"Name","extras.runsIn":"Runs in","extras.runsInBrowser":"This browser","extras.runsInServer":"The server","extras.serverHint":"Your server runs it (createAutomationServer): it hears changes from the database, whoever made them, reads secrets and sends email.","extras.browserHint":"It runs in the browser of the person who makes the change, right away.","extras.when":"When","extras.trigger":"Trigger","extras.triggerCreated":"A record is created","extras.triggerUpdated":"A record changes","extras.triggerMatches":"A record matches a condition","extras.triggerForm":"A form is sent","extras.triggerButton":"A button is pressed","extras.triggerScheduled":"At a scheduled time","extras.watchSome":"Only when one of these fields changes:","extras.watchAny":"Any field. Pick fields to watch only those:","extras.form":"Form","extras.anyForm":"Any form of this table","extras.buttonField":"Button field","extras.addButtonFirst":"Add a Button field to the table first.","extras.schedule":"Schedule","extras.customSchedule":"Custom","extras.cronExpression":"Cron expression","extras.scheduleHint":"Runs while the base is open in a browser. With a condition, it runs once for each record that matches at that time.","extras.condition":"Condition","extras.onlyWhere":"Only for records where","extras.startsToMatch":"Runs when a record starts to match","extras.addMatchCondition":"Add the condition a record has to start matching.","extras.everyRecord":"Every record. Add a condition to narrow it.","extras.do":"Do","extras.action":"Action","extras.doUpdateRecord":"Update the record","extras.doCreateRecord":"Create a record","extras.doHighlight":"Color the record while it matches","extras.moveUp":"Move up","extras.moveDown":"Move down","extras.moveStepUp":"Move step {step} up","extras.moveStepDown":"Move step {step} down","extras.removeStep":"Remove step {step}","extras.stepMoved":"Step {from} is now step {to}.","extras.removeAction":"Remove action","extras.message":"Message","extras.notifyPlaceholder":"{{field}} needs a look","extras.kind":"Kind","extras.severityInfo":"Info","extras.severitySuccess":"Success","extras.severityWarning":"Warning","extras.severityError":"Error","extras.notifyHint":"Name a field in braces for its value: {fields}.","extras.notifyTo":"Also send it to the notifications of:","extras.notifyToField":"The people in {field}","extras.highlightNeedsCondition":"Colors records while they match the condition above; add one.","extras.fill":"Fill","extras.text":"Text","extras.sample":"Sample","extras.wholeRow":"Whole row","extras.in":"In","extras.table":"Table","extras.linkBack":"Link it back","extras.linkField":"Link field","extras.noLink":"No link","extras.through":"through {field}","extras.valueOf":"{field} value","extras.valuePlaceholder":"a value, or {Field}","extras.numberPlaceholder":"0, or 100% for a percent","extras.linkPlaceholder":"a record name, or {record}","extras.userPlaceholder":"a name","extras.doNotSet":"Do not set {field}","extras.remove":"Remove","extras.setField":"Set a field","extras.addSetField":"+ Set a field","extras.runsApp":"Runs {action}, an action the app registered.","extras.method":"Method","extras.url":"URL","extras.headers":"Headers","extras.body":"Body","extras.webhookHintServer":"Empty body: the record as JSON. {secret} is read on the server only.","extras.webhookHintBrowser":"Empty body: the record as JSON. {secret} is read on the server only; set Runs in to The server to use one.","extras.emailNeedsServer":"Email is sent by the server: set Runs in to The server.","extras.to":"To","extras.toPlaceholder":"team@example.com, {Owner email}","extras.subject":"Subject","extras.emailText":"Email text","extras.addAction":"Add an action","extras.addActionOption":"+ Add an action","extras.deleteIt":"Delete it?","extras.delete":"Delete","extras.keep":"Keep","extras.deleteAutomation":"Delete automation","extras.triggerEntersView":"A record enters a view","extras.view":"View","extras.pickView":"Pick a view","extras.aView":"a view","extras.entersViewHint":"Runs once when a record starts to show in this view, through its filter, as the view has it then. It runs again only after the record has left the view.","extras.addViewFilterFirst":"First give a view of this table a filter: this trigger runs when a record starts to show in it.","extras.whenEntersView":"When a record enters {view}","extras.whenEntersViewWhere":"When a record enters {view}, where {condition}","extras.doDeleteRecord":"Delete the record","extras.actionDeleteRecord":"Delete record","extras.deleteRecordHint":"Deletes the record that started the automation (inside Find records, each record found). It goes to the trash, where it can be restored for 30 days.","extras.noRecordToDelete":"No record to delete","extras.deletedRecord":"Deleted {name}","extras.cannotDeleteHere":"This table cannot delete records from an automation.","extras.summaryDelete":"Deletes the record","extras.duplicateAutomation":"Duplicate","extras.copyOf":"{name} copy","extras.duplicated":"Copied. The copy is off until you turn it on.","extras.runsOnServer":"Runs on your server when its trigger happens.","extras.tryRecord":"Record to try it on","extras.noRecord":"No record","extras.runNow":"Run now","extras.pickAutomation":"Pick an automation, or add one.","extras.noName":"(no name)","extras.noRecordValue":"(no record)","extras.pageLabel":"Automations of the base","extras.createAutomation":"+ Create automation","extras.runHistory":"Run history","extras.pageEmpty":"No automations yet. An automation does something on its own: when a record is added or changes, a form is sent, a button is pressed or at a time you set.","extras.pickOne":"Pick an automation on the left, or create one.","extras.triggerCard":"Trigger","extras.whenIn":"{when}, in {table}","extras.conditionCard":"Only for records where","extras.conditionEvery":"Every record","extras.conditionCount.one":"{count} condition","extras.conditionCount.other":"{count} conditions","extras.addCondition":"+ Add a condition","extras.actionCard":"Action {n}","extras.insertAction":"Add an action here","extras.addActionPage":"+ Add an action","extras.flowLabel":"What {name} does","extras.summarySet":"Set {fields}","extras.summaryNothing":"No fields set yet","extras.summaryCreate":"A new record in {table}","extras.summaryEmail":"To {to}","extras.summaryNoTo":"No address yet","extras.summaryColor":"While it matches","extras.tableOfTrigger":"Table","extras.tableMoveHint":"Its trigger, condition and fields are for this table: a new table starts them again.","extras.settingsOf":"Settings","extras.testOn":"Test on","extras.test":"Test","extras.testRuns":"Its runs show in the run history.","extras.allRunsOf":"Runs of {name}","extras.allRuns":"All runs","extras.showAllRuns":"Show every automation's runs","extras.whenWebhook":"When a webhook is received","extras.triggerWebhook":"A webhook is received","extras.webhookAddress":"Webhook address","extras.webhookNoUrl":"This automation listens for the token {token}: give it to your server runner (webhookReceived).","extras.webhookHint":"Send a POST with a JSON body to this address. Its values are {webhook.name} in the steps ({webhook.order.id} inside objects). Anyone with the address can start the automation: keep it secret.","extras.newAddress":"Make a new address","extras.copy":"Copy","extras.copied":"Copied","extras.actionChat":"Send a message","extras.actionRepeat":"Find records","extras.actionIf":"If","extras.actionAi":"Ask AI","extras.actionScript":"Run a script","extras.doChat":"Send a Slack, Teams or Google Chat message","extras.doRepeat":"Find records and, for each, do","extras.doIf":"If a condition holds, do","extras.doAi":"Ask AI","extras.doScript":"Run a script","extras.stepChat":"Message","extras.stepIf":"If","extras.stepIfThen":"It matched: the Then steps ran","extras.stepIfElse":"It did not match: the Otherwise steps ran","extras.stepFound":"Find records","extras.foundIn":"{count} in {table}","extras.stepAi":"AI","extras.stepScript":"Script","extras.noAi":"No AI model is set up here.","extras.aiNoPrompt":"The prompt is empty.","extras.scriptFailed":"The script failed.","extras.noField":"No field named {field}.","extras.noRecordId":"No record {id}.","extras.stepKind":"{list}, step {n}","extras.addStep":"+ Add a step","extras.addStepTo":"Add a step to {list}","extras.chatApp":"Chat app","extras.chatUrl":"Webhook address","extras.chatHintSlack":"In Slack: Apps, Incoming Webhooks, Add to a channel; paste the address it gives here.","extras.chatHintTeams":`In Teams: the channel's Workflows, "Post to a channel when a webhook request is received"; paste the address it gives here.`,"extras.chatHintGoogle":"In Google Chat: the space's Apps and integrations, Webhooks, Add webhook; paste the address it gives here.","extras.actionText":"Send a text message","extras.doText":"Send a text message (SMS or Viber)","extras.stepText":"Text message","extras.textNeedsServer":"Text messages are sent by the server: set Runs in to The server.","extras.textBy":"Send by","extras.textSms":"SMS","extras.textViber":"Viber (SMS if not on Viber)","extras.textTo":"To","extras.textToPlaceholder":"+359 88 123 4567, {Phone}","extras.textMessage":"Message","extras.textHint":"Phone numbers with their country code, or a phone field in braces; several apart with commas. The text names fields in braces.","extras.summarySms":"SMS to {to}","extras.summaryViber":"Viber to {to}","extras.summaryNoPhone":"No phone yet","extras.ifHint":"When the record matches this condition the Then steps run, otherwise the Otherwise steps.","extras.ifAlways":"No condition: Then always runs","extras.then":"Then","extras.otherwise":"Otherwise","extras.findIn":"Find in","extras.whichRecords":"Records where","extras.atMost":"At most","extras.forEach":"For each record found","extras.repeatHint":"In these steps {Field} is the found record's field, {trigger.Field} the field of the record that set the automation off, and {found} how many were found.","extras.aiPrompt":"Prompt","extras.aiPlaceholder":"Write a two-line summary of {{field}} for a weekly report.","extras.aiInto":"Put the answer in","extras.aiNowhere":"No field (use {ai} in the next steps)","extras.aiHint":"Name fields in braces. The answer is {ai} in the next steps.","extras.scriptCode":"Script","extras.scriptNeedsBrowser":"A script runs in the browser: set Runs in to The browser.","extras.scriptHint":"JavaScript, as in Airtable: input.config() has the record's fields by name; base.getTable('Name') reads and changes a table (selectRecordsAsync, updateRecordAsync, createRecordAsync, deleteRecordAsync); output.set('name', value) is {script.name} in the next steps; fetch() calls https addresses that allow it. It runs in a sandbox for up to 30 seconds.","extras.scriptInPageHint":"It runs in the page of the person who made the change, with what they may do. A run with no one's page behind it (a schedule, a webhook, a change through the API) stops at this step and says so.","extras.summaryNoText":"Nothing written yet","extras.stepCount.one":"{count} step","extras.stepCount.other":"{count} steps","extras.summaryRepeat":"{steps} for each record in {table}","extras.summaryIf":"Then {then}; otherwise {otherwise}","extras.summaryScript":"{lines} lines"};
|
|
1
|
+
export const EXTRAS_MESSAGES={"extras.whenCreated":"When a record is created","extras.whenCreatedWhere":"When a record is created, where {condition}","extras.whenRecordChanges":"When a record changes","extras.whenRecordChangesWhere":"When a record changes, where {condition}","extras.whenFieldsChange":"When {fields} changes","extras.whenFieldsChangeWhere":"When {fields} changes, where {condition}","extras.fieldsOr":" or ","extras.whenMatches":"When a record matches: {condition}","extras.noConditionYet":"no condition yet","extras.whenForm":"When a form is sent","extras.whenFormWhere":"When a form is sent, where {condition}","extras.whenPressed":"When {field} is pressed","extras.onSchedule":"{cron}","extras.onScheduleWhere":"{cron}, for records where {condition}","extras.cronOther":"On a schedule ({cron})","extras.cronEveryMinute":"Every minute","extras.cronEveryMinutes":"Every {n} minutes","extras.cronHourly":"Every hour, on the hour","extras.cronHourlyAt":"Every hour at {minute} past","extras.cronDaily":"Every day at {time}","extras.cronWeekdays":"Every weekday at {time}","extras.cronWeekly0":"Every Sunday at {time}","extras.cronWeekly1":"Every Monday at {time}","extras.cronWeekly2":"Every Tuesday at {time}","extras.cronWeekly3":"Every Wednesday at {time}","extras.cronWeekly4":"Every Thursday at {time}","extras.cronWeekly5":"Every Friday at {time}","extras.cronWeekly6":"Every Saturday at {time}","extras.cronDays":"Every {days} at {time}","extras.cronDay0":"Sunday","extras.cronDay1":"Monday","extras.cronDay2":"Tuesday","extras.cronDay3":"Wednesday","extras.cronDay4":"Thursday","extras.cronDay5":"Friday","extras.cronDay6":"Saturday","extras.cronMonthly":"Day {day} of every month at {time}","extras.actionUpdateRecord":"Update record","extras.actionCreateRecord":"Create record","extras.actionNotify":"Show a notice","extras.actionHighlight":"Color the record","extras.actionWebhook":"Call a webhook","extras.actionEmail":"Send an email","extras.stepStopped":"Stopped","extras.stepLoop":"Automations set each other off {max} times in a row; this one did not run, so they cannot loop.","extras.stepNotice":"Notice","extras.stepWebhook":"Webhook","extras.stepEmail":"Email","extras.stepNotRun":"Not run","extras.stepNoMatch":"The record does not match the condition","extras.stepDone":"Done","extras.noRecordToUpdate":"No record to update","extras.alreadySet":"Already set","extras.noTable":'No table "{table}"',"extras.noAction":'No action "{action}" is registered',"extras.aRecord":"a record","extras.createdIn":"{name} in {table}","extras.saidValue":"{field}: {value}","extras.saidChecked":"{field}: checked","extras.saidUnchecked":"{field}: unchecked","extras.saidEmpty":"empty","extras.title":"Automations in {table}","extras.listLabel":"Automations","extras.untitled":"Untitled","extras.switchOn":"{name} on","extras.noAutomations":"No automations yet. An automation does something when a record is added, changes or matches a condition.","extras.addAutomation":"+ New automation","extras.describeLabel":"Describe what should happen","extras.describePlaceholder":"For example: every Monday at 8:00, e-mail me the tasks that are not done","extras.describeButton":"Draft it","extras.describing":"Drafting...","extras.describeAgain":"Say a little more about what should happen, then try again.","extras.drafted":"Drafted from your words and switched off. Check each part, then switch it on.","extras.newAutomation":"New automation","extras.newRecordMessage":"New record: {{field}}","extras.nameFallback":"Name","extras.runs":"Runs","extras.clearRuns":"Clear this page's runs","extras.serverRunsFailed":"The server's runs did not load: {message}","extras.statusDone":"Done","extras.statusFailed":"Failed","extras.statusStopped":"Stopped","extras.runOn":"on {record}","extras.runIn":"in {table}","extras.serverTag":"Server","extras.noRuns":"Nothing has run yet. Runs show here with what each action did.","extras.name":"Name","extras.runsIn":"Runs in","extras.runsInBrowser":"This browser","extras.runsInServer":"The server","extras.serverHint":"Your server runs it (createAutomationServer): it hears changes from the database, whoever made them, reads secrets and sends email.","extras.browserHint":"It runs in the browser of the person who makes the change, right away.","extras.when":"When","extras.trigger":"Trigger","extras.triggerCreated":"A record is created","extras.triggerUpdated":"A record changes","extras.triggerMatches":"A record matches a condition","extras.triggerForm":"A form is sent","extras.triggerButton":"A button is pressed","extras.triggerScheduled":"At a scheduled time","extras.watchSome":"Only when one of these fields changes:","extras.watchAny":"Any field. Pick fields to watch only those:","extras.form":"Form","extras.anyForm":"Any form of this table","extras.buttonField":"Button field","extras.addButtonFirst":"Add a Button field to the table first.","extras.schedule":"Schedule","extras.customSchedule":"Custom","extras.cronExpression":"Cron expression","extras.scheduleHint":"Runs while the base is open in a browser. With a condition, it runs once for each record that matches at that time.","extras.condition":"Condition","extras.onlyWhere":"Only for records where","extras.startsToMatch":"Runs when a record starts to match","extras.addMatchCondition":"Add the condition a record has to start matching.","extras.everyRecord":"Every record. Add a condition to narrow it.","extras.do":"Do","extras.action":"Action","extras.doUpdateRecord":"Update the record","extras.doCreateRecord":"Create a record","extras.doHighlight":"Color the record while it matches","extras.moveUp":"Move up","extras.moveDown":"Move down","extras.moveStepUp":"Move step {step} up","extras.moveStepDown":"Move step {step} down","extras.removeStep":"Remove step {step}","extras.stepMoved":"Step {from} is now step {to}.","extras.removeAction":"Remove action","extras.message":"Message","extras.notifyPlaceholder":"{{field}} needs a look","extras.kind":"Kind","extras.severityInfo":"Info","extras.severitySuccess":"Success","extras.severityWarning":"Warning","extras.severityError":"Error","extras.notifyHint":"Name a field in braces for its value: {fields}.","extras.notifyTo":"Also send it to the notifications of:","extras.notifyToField":"The people in {field}","extras.highlightNeedsCondition":"Colors records while they match the condition above; add one.","extras.fill":"Fill","extras.text":"Text","extras.sample":"Sample","extras.wholeRow":"Whole row","extras.in":"In","extras.table":"Table","extras.linkBack":"Link it back","extras.linkField":"Link field","extras.noLink":"No link","extras.through":"through {field}","extras.valueOf":"{field} value","extras.valuePlaceholder":"a value, or {Field}","extras.numberPlaceholder":"0, or 100% for a percent","extras.linkPlaceholder":"a record name, or {record}","extras.userPlaceholder":"a name","extras.doNotSet":"Do not set {field}","extras.remove":"Remove","extras.setField":"Set a field","extras.addSetField":"+ Set a field","extras.runsApp":"Runs {action}, an action the app registered.","extras.method":"Method","extras.url":"URL","extras.headers":"Headers","extras.body":"Body","extras.webhookHintServer":"Empty body: the record as JSON. {secret} is read on the server only.","extras.webhookHintBrowser":"Empty body: the record as JSON. {secret} is read on the server only; set Runs in to The server to use one.","extras.emailNeedsServer":"Email is sent by the server: set Runs in to The server.","extras.to":"To","extras.toPlaceholder":"team@example.com, {Owner email}","extras.subject":"Subject","extras.emailText":"Email text","extras.addAction":"Add an action","extras.addActionOption":"+ Add an action","extras.deleteIt":"Delete it?","extras.delete":"Delete","extras.keep":"Keep","extras.deleteAutomation":"Delete automation","extras.triggerEntersView":"A record enters a view","extras.view":"View","extras.pickView":"Pick a view","extras.aView":"a view","extras.entersViewHint":"Runs once when a record starts to show in this view, through its filter, as the view has it then. It runs again only after the record has left the view.","extras.addViewFilterFirst":"First give a view of this table a filter: this trigger runs when a record starts to show in it.","extras.whenEntersView":"When a record enters {view}","extras.whenEntersViewWhere":"When a record enters {view}, where {condition}","extras.doDeleteRecord":"Delete the record","extras.actionDeleteRecord":"Delete record","extras.deleteRecordHint":"Deletes the record that started the automation (inside Find records, each record found). It goes to the trash, where it can be restored for 30 days.","extras.noRecordToDelete":"No record to delete","extras.deletedRecord":"Deleted {name}","extras.cannotDeleteHere":"This table cannot delete records from an automation.","extras.summaryDelete":"Deletes the record","extras.duplicateAutomation":"Duplicate","extras.copyOf":"{name} copy","extras.duplicated":"Copied. The copy is off until you turn it on.","extras.runsOnServer":"Runs on your server when its trigger happens.","extras.tryRecord":"Record to try it on","extras.noRecord":"No record","extras.runNow":"Run now","extras.pickAutomation":"Pick an automation, or add one.","extras.noName":"(no name)","extras.noRecordValue":"(no record)","extras.pageLabel":"Automations of the base","extras.createAutomation":"+ Create automation","extras.runHistory":"Run history","extras.pageEmpty":"No automations yet. An automation does something on its own: when a record is added or changes, a form is sent, a button is pressed or at a time you set.","extras.pickOne":"Pick an automation on the left, or create one.","extras.triggerCard":"Trigger","extras.whenIn":"{when}, in {table}","extras.conditionCard":"Only for records where","extras.conditionEvery":"Every record","extras.conditionCount.one":"{count} condition","extras.conditionCount.other":"{count} conditions","extras.addCondition":"+ Add a condition","extras.actionCard":"Action {n}","extras.insertAction":"Add an action here","extras.addActionPage":"+ Add an action","extras.flowLabel":"What {name} does","extras.summarySet":"Set {fields}","extras.summaryNothing":"No fields set yet","extras.summaryCreate":"A new record in {table}","extras.summaryEmail":"To {to}","extras.summaryNoTo":"No address yet","extras.summaryColor":"While it matches","extras.tableOfTrigger":"Table","extras.tableMoveHint":"Its trigger, condition and fields are for this table: a new table starts them again.","extras.settingsOf":"Settings","extras.testOn":"Test on","extras.test":"Test","extras.testRuns":"Its runs show in the run history.","extras.allRunsOf":"Runs of {name}","extras.allRuns":"All runs","extras.showAllRuns":"Show every automation's runs","extras.whenWebhook":"When a webhook is received","extras.triggerWebhook":"A webhook is received","extras.webhookAddress":"Webhook address","extras.webhookNoUrl":"This automation listens for the token {token}: give it to your server runner (webhookReceived).","extras.webhookHint":"Send a POST with a JSON body to this address. Its values are {webhook.name} in the steps ({webhook.order.id} inside objects). Anyone with the address can start the automation: keep it secret.","extras.newAddress":"Make a new address","extras.copy":"Copy","extras.copied":"Copied","extras.actionChat":"Send a message","extras.actionRepeat":"Find records","extras.actionIf":"If","extras.actionAi":"Ask AI","extras.actionScript":"Run a script","extras.doChat":"Send a Slack, Teams or Google Chat message","extras.doRepeat":"Find records and, for each, do","extras.doIf":"If a condition holds, do","extras.doAi":"Ask AI","extras.doScript":"Run a script","extras.stepChat":"Message","extras.stepIf":"If","extras.stepIfThen":"It matched: the Then steps ran","extras.stepIfElse":"It did not match: the Otherwise steps ran","extras.stepFound":"Find records","extras.foundIn":"{count} in {table}","extras.stepAi":"AI","extras.stepScript":"Script","extras.noAi":"No AI model is set up here.","extras.aiNoPrompt":"The prompt is empty.","extras.scriptFailed":"The script failed.","extras.noField":"No field named {field}.","extras.noRecordId":"No record {id}.","extras.stepKind":"{list}, step {n}","extras.addStep":"+ Add a step","extras.addStepTo":"Add a step to {list}","extras.chatApp":"Chat app","extras.chatUrl":"Webhook address","extras.chatHintSlack":"In Slack: Apps, Incoming Webhooks, Add to a channel; paste the address it gives here.","extras.chatHintTeams":`In Teams: the channel's Workflows, "Post to a channel when a webhook request is received"; paste the address it gives here.`,"extras.chatHintGoogle":"In Google Chat: the space's Apps and integrations, Webhooks, Add webhook; paste the address it gives here.","extras.actionText":"Send a text message","extras.doText":"Send a text message (SMS or Viber)","extras.stepText":"Text message","extras.textNeedsServer":"Text messages are sent by the server: set Runs in to The server.","extras.textBy":"Send by","extras.textSms":"SMS","extras.textViber":"Viber (SMS if not on Viber)","extras.textTo":"To","extras.textToPlaceholder":"+359 88 123 4567, {Phone}","extras.textMessage":"Message","extras.textHint":"Phone numbers with their country code, or a phone field in braces; several apart with commas. The text names fields in braces.","extras.summarySms":"SMS to {to}","extras.summaryViber":"Viber to {to}","extras.summaryNoPhone":"No phone yet","extras.ifHint":"When the record matches this condition the Then steps run, otherwise the Otherwise steps.","extras.ifAlways":"No condition: Then always runs","extras.then":"Then","extras.otherwise":"Otherwise","extras.findIn":"Find in","extras.whichRecords":"Records where","extras.atMost":"At most","extras.forEach":"For each record found","extras.repeatHint":"In these steps {Field} is the found record's field, {trigger.Field} the field of the record that set the automation off, and {found} how many were found.","extras.aiPrompt":"Prompt","extras.aiPlaceholder":"Write a two-line summary of {{field}} for a weekly report.","extras.aiInto":"Put the answer in","extras.aiNowhere":"No field (use {ai} in the next steps)","extras.aiHint":"Name fields in braces. The answer is {ai} in the next steps.","extras.aiBase":"Send it the whole base","extras.aiBaseHint":'The records of every table go with the prompt, for a letter about all of it ("What should I do this week?").',"extras.scriptCode":"Script","extras.scriptNeedsBrowser":"A script runs in the browser: set Runs in to The browser.","extras.scriptHint":"JavaScript, as in Airtable: input.config() has the record's fields by name; base.getTable('Name') reads and changes a table (selectRecordsAsync, updateRecordAsync, createRecordAsync, deleteRecordAsync); output.set('name', value) is {script.name} in the next steps; fetch() calls https addresses that allow it. It runs in a sandbox for up to 30 seconds.","extras.scriptInPageHint":"It runs in the page of the person who made the change, with what they may do. A run with no one's page behind it (a schedule, a webhook, a change through the API) stops at this step and says so.","extras.summaryNoText":"Nothing written yet","extras.stepCount.one":"{count} step","extras.stepCount.other":"{count} steps","extras.summaryRepeat":"{steps} for each record in {table}","extras.summaryIf":"Then {then}; otherwise {otherwise}","extras.summaryScript":"{lines} lines"};
|
|
@@ -452,6 +452,8 @@ export declare const BASE_MESSAGES: {
|
|
|
452
452
|
readonly 'extras.aiInto': "Put the answer in";
|
|
453
453
|
readonly 'extras.aiNowhere': "No field (use {ai} in the next steps)";
|
|
454
454
|
readonly 'extras.aiHint': "Name fields in braces. The answer is {ai} in the next steps.";
|
|
455
|
+
readonly 'extras.aiBase': "Send it the whole base";
|
|
456
|
+
readonly 'extras.aiBaseHint': "The records of every table go with the prompt, for a letter about all of it (\"What should I do this week?\").";
|
|
455
457
|
readonly 'extras.scriptCode': "Script";
|
|
456
458
|
readonly 'extras.scriptNeedsBrowser': "A script runs in the browser: set Runs in to The browser.";
|
|
457
459
|
readonly 'extras.scriptHint': "JavaScript, as in Airtable: input.config() has the record's fields by name; base.getTable('Name') reads and changes a table (selectRecordsAsync, updateRecordAsync, createRecordAsync, deleteRecordAsync); output.set('name', value) is {script.name} in the next steps; fetch() calls https addresses that allow it. It runs in a sandbox for up to 30 seconds.";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
-
import{onDestroy,onMount,tick}from"svelte";import{createPageEditor,loadPageEditor}from"./page-editor";import{PAGE_COLORS}from"./page-schema";import{bm}from"../messages.svelte";import{portalToBody}from"@svgrid/grid";import{layer,menuPlace}from"./layer";let{html,editable=true,onSave,onUnavailable,upload,preview,onError,records,views,onReady}=$props();let uploading=$state(0);let root=$state(null);let mount=$state(null);let ed=$state.raw(null);let saved=html;let pending=null;let timer;const PAUSE=1500;function changed(next){pending=next;clearTimeout(timer);if(!theirs)timer=setTimeout(flush,PAUSE)}let theirs=$state(null);function keepMine(){const mine=pending??ed?.html()??saved;theirs=null;pending=mine;saved="\0";flush()}function showTheirs(){const t=theirs;theirs=null;pending=null;if(t==null)return;saved=t;ed?.setHtml(t)}function flush(){clearTimeout(timer);if(theirs!=null)return;if(pending==null||pending===saved)return void(pending=null);saved=pending;pending=null;onSave(saved)}onMount(()=>{let gone=false;void loadPageEditor().then(pm=>{if(gone||!mount)return;if(!pm)return onUnavailable?.();ed=createPageEditor(pm,mount,{html,editable,placeholder:bm("record.pagePlaceholder"),onChange:changed,onSlash:s=>void slashChanged(s),onSelection:()=>selTick+=1,upload,records,views,onMention:s=>void mentionChanged(s),onUploading:n=>uploading=n,onError,onEscape:()=>{if(blockMenu){blockMenu=null;return true}if(linking){linking=false;return true}return false}});onReady?.(ed)});return()=>{gone=true}});onDestroy(()=>{flush();ed?.destroy()});$effect(()=>{const now=html;if(!ed||now===saved)return;if(pending==null){saved=now;ed.setHtml(now)}else{clearTimeout(timer);theirs=now}});$effect(()=>{ed?.setEditable(editable)});const ITEMS=$derived([{kind:"text",label:bm("record.blockText"),hint:bm("record.blockTextHint"),words:"text paragraph plain",icon:"T"},{kind:"h1",label:bm("record.blockH1"),hint:bm("record.blockH1Hint"),words:"heading title h1 #",icon:"H1"},{kind:"h2",label:bm("record.blockH2"),hint:bm("record.blockH2Hint"),words:"heading subtitle h2 ##",icon:"H2"},{kind:"h3",label:bm("record.blockH3"),hint:bm("record.blockH3Hint"),words:"heading h3 ###",icon:"H3"},{kind:"bullet",label:bm("record.blockBullet"),hint:bm("record.blockBulletHint"),words:"bulleted list unordered ul -",icon:"•"},{kind:"numbered",label:bm("record.blockNumbered"),hint:bm("record.blockNumberedHint"),words:"numbered list ordered ol 1.",icon:"1."},{kind:"todo",label:bm("record.blockTodo"),hint:bm("record.blockTodoHint"),words:"todo to-do task checkbox check []",icon:"☑"},{kind:"toggle",label:bm("record.blockToggle"),hint:bm("record.blockToggleHint"),words:"toggle fold collapse details",icon:"▸"},{kind:"toggleH1",label:bm("record.blockToggleH1"),hint:bm("record.blockToggleHHint"),words:"toggle heading h1",icon:"▸H1"},{kind:"toggleH2",label:bm("record.blockToggleH2"),hint:bm("record.blockToggleHHint"),words:"toggle heading h2",icon:"▸H2"},{kind:"toggleH3",label:bm("record.blockToggleH3"),hint:bm("record.blockToggleHHint"),words:"toggle heading h3",icon:"▸H3"},{kind:"quote",label:bm("record.blockQuote"),hint:bm("record.blockQuoteHint"),words:"quote blockquote >",icon:"“"},{kind:"callout",label:bm("record.blockCallout"),hint:bm("record.blockCalloutHint"),words:"callout note tip warning box",icon:"💡"},{kind:"divider",label:bm("record.blockDivider"),hint:bm("record.blockDividerHint"),words:"divider line separator hr ---",icon:"—"},{kind:"code",label:bm("record.blockCode"),hint:bm("record.blockCodeHint"),words:"code snippet pre ```",icon:"</>"},{kind:"columns2",label:bm("record.blockColumns2"),hint:bm("record.blockColumnsHint"),words:"columns two side by side layout",icon:"▥"},{kind:"columns3",label:bm("record.blockColumns3"),hint:bm("record.blockColumnsHint"),words:"columns three side by side layout",icon:"▥"},...upload?[{kind:"image",label:bm("record.blockImage"),hint:bm("record.blockImageHint"),words:"image picture photo upload",icon:"🖼"},{kind:"file",label:bm("record.blockFile"),hint:bm("record.blockFileHint"),words:"file upload attachment pdf document",icon:"📎"}]:[],...records?[{kind:"page",label:bm("record.blockPage"),hint:bm("record.blockPageHint"),words:"page subpage sub-page child nested",icon:"📄"}]:[],...views?[{kind:"linkedView",label:bm("record.blockLinkedView"),hint:bm("record.blockLinkedViewHint"),words:"linked view table database records list",icon:"▦"}]:[],{kind:"toc",label:bm("record.blockToc"),hint:bm("record.blockTocHint"),words:"table of contents toc headings outline",icon:"☰"},{kind:"video",label:bm("record.blockVideo"),hint:bm("record.blockVideoHint"),words:"video youtube vimeo loom",icon:"▶"},{kind:"embed",label:bm("record.blockEmbed"),hint:bm("record.blockEmbedHint"),words:"embed google docs sheets maps figma miro spotify calendly",icon:"⧉"},{kind:"bookmark",label:bm("record.blockBookmark"),hint:bm("record.blockBookmarkHint"),words:"bookmark link web page url",icon:"🔖"}]);let choosing=$state(null);let asking=$state(null);let askText=$state("");let askBusy=$state(false);let picker=$state(null);let pickFor=null;async function askDone(e){e.preventDefault();const a=asking;const v=askText.trim();if(!a||!v||!ed)return;const href=/^[a-z][a-z0-9+.-]*:/i.test(v)?v:`https://${v}`;if(a.kind==="bookmark"){askBusy=true;let card={title:href,description:"",site:""};try{if(preview)card=await preview(href)}catch{}askBusy=false;ed.insertBookmark(href,card,a.range)}else ed.insertEmbed(href,a.range);asking=null;askText=""}function picked(e){const input=e.currentTarget;const files=Array.from(input.files??[]);input.value="";if(files.length&&ed&&pickFor)void ed.insertFiles(files,pickFor.range);pickFor=null}let slash=$state(null);let slashAt=$state(null);let slashIndex=$state(0);const found=$derived.by(()=>{const q=(slash?.query??"").trim().toLocaleLowerCase();if(!q)return ITEMS;return ITEMS.filter(i=>i.label.toLocaleLowerCase().includes(q)||i.words.split(" ").some(w=>w.startsWith(q)))});async function slashChanged(s){const opening=s&&!slash;slash=s;if(!s||!ed||!root)return void(slashAt=null);if(opening)slashIndex=0;slashIndex=Math.min(slashIndex,Math.max(0,found.length-1));await tick();slashAt=menuAt(s.from)}function closeSlash(){slash=null;slashAt=null;ed?.closeSlash()}function pick(i){if(!ed||!slash)return;const range={from:slash.from,to:slash.to};if(i.kind==="image"||i.kind==="file"){pickFor={range};if(picker){picker.accept=i.kind==="image"?"image/*":"";picker.click()}closeSlash();return}if(i.kind==="linkedView"){const at2=slashAt??{top:0,left:0,up:false};choosing={range,...at2,list:views?.list()??[]};closeSlash();return}if(i.kind==="page"){closeSlash();void ed.insertSubpage(range);return}if(i.kind==="embed"||i.kind==="video"||i.kind==="bookmark"){const at2=slashAt??{top:0,left:0,up:false};asking={kind:i.kind,range,top:at2.top,left:at2.left,up:at2.up};askText="";closeSlash();return}ed.insertBlock(i.kind,range)}function menuAt(pos,height=320){if(!ed)return null;try{return menuPlace(ed.view.coordsAtPos(pos),height)}catch{return{top:0,left:0,up:false}}}function placeAt(pos){if(!ed||!root)return null;try{const c=ed.view.coordsAtPos(pos);const box=root.getBoundingClientRect();return{top:c.bottom-box.top+4,left:Math.max(0,c.left-box.left)}}catch{return{top:0,left:0}}}let at=$state(null);let atPlace=$state(null);let atIndex=$state(0);const people=$derived(at&&records?records.find(at.query).slice(0,8):[]);async function mentionChanged(s){const opening=s&&!at;at=s;if(!s)return void(atPlace=null);if(opening)atIndex=0;atIndex=Math.min(atIndex,Math.max(0,people.length-1));await tick();atPlace=menuAt(s.from,280)}function name(r){if(!ed||!at)return;ed.insertMention(r,{from:at.from,to:at.to})}function keysFirst(e){if(at){if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault();e.stopPropagation();const n=people.length;if(n)atIndex=(atIndex+(e.key==="ArrowDown"?1:-1)+n)%n;return}if((e.key==="Enter"||e.key==="Tab")&&people.length){e.preventDefault();e.stopPropagation();name(people[atIndex]??people[0]);return}if(e.key==="Escape"){e.preventDefault();e.stopPropagation();ed?.closeMention();return}}if(e.key==="Escape"&&asking){e.preventDefault();e.stopPropagation();asking=null;ed?.view.focus();return}if(e.key==="Escape"&&(slash||blockMenu||linking||colorsOpen)){e.preventDefault();e.stopPropagation();blockMenu=null;linking=false;colorsOpen=false;if(slash)closeSlash();ed?.view.focus();return}if(!slash)return;if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault();e.stopPropagation();const n=found.length;if(n)slashIndex=(slashIndex+(e.key==="ArrowDown"?1:-1)+n)%n}else if((e.key==="Enter"||e.key==="Tab")&&found.length){e.preventDefault();e.stopPropagation();pick(found[slashIndex]??found[0])}}let selTick=$state(0);let focused=$state(false);let linking=$state(false);let linkText=$state("");let colorsOpen=$state(false);const bar=$derived.by(()=>{void selTick;if(!ed||!root||!focused||!editable)return null;const sel=ed.view.state.selection;if(sel.empty||sel.node)return null;const at2=placeAt(sel.from);if(!at2)return null;return{top:Math.max(0,at2.top-48),left:at2.left,marks:ed.marksHere()}});const MARKS=[{mark:"strong",key:"record.markBold",text:"B",style:"font-weight:700"},{mark:"em",key:"record.markItalic",text:"i",style:"font-style:italic;font-family:Georgia,serif"},{mark:"underline",key:"record.markUnderline",text:"U",style:"text-decoration:underline"},{mark:"strike",key:"record.markStrike",text:"S",style:"text-decoration:line-through"},{mark:"code",key:"record.markCode",text:"<>",style:"font-family:monospace;font-size:12px"}];function startLink(){linking=true;linkText="";colorsOpen=false}function saveLink(e){e.preventDefault();const v=linkText.trim();if(v)ed?.setLink(/^[a-z][a-z0-9+.-]*:|^\/|^#/i.test(v)?v:`https://${v}`);linking=false}let handle=$state(null);let blockMenu=$state(null);let grip=$state(null);function moved(e){if(!ed||!editable||blockMenu||e.pointerType==="touch")return;const r=ed.view.dom.getBoundingClientRect();if(e.clientY<r.top||e.clientY>r.bottom)return;const hit=ed.blockAt(r.left+12,e.clientY);if(!hit||!root)return;const b=hit.dom.getBoundingClientRect();handle={pos:hit.pos,top:b.top-root.getBoundingClientRect().top}}const COLOR_KEYS={gray:"record.colorGray",brown:"record.colorBrown",orange:"record.colorOrange",yellow:"record.colorYellow",green:"record.colorGreen",blue:"record.colorBlue",purple:"record.colorPurple",pink:"record.colorPink",red:"record.colorRed"};const TURN=["text","h1","h2","h3","bullet","numbered","todo","toggle","quote","callout","code"];function menuDo(f){f();blockMenu=null}
|
|
2
|
+
import{onDestroy,onMount,tick}from"svelte";import{createPageEditor,loadPageEditor}from"./page-editor";import{PAGE_COLORS}from"./page-schema";import{bm}from"../messages.svelte";import{portalToBody}from"@svgrid/grid";import{layer,menuPlace}from"./layer";let{html,editable=true,onSave,onUnavailable,upload,preview,onError,records,views,links,onReady}=$props();let uploading=$state(0);let root=$state(null);let mount=$state(null);let ed=$state.raw(null);let saved=html;let pending=null;let timer;const PAUSE=1500;function changed(next){pending=next;clearTimeout(timer);if(!theirs)timer=setTimeout(flush,PAUSE)}let theirs=$state(null);function keepMine(){const mine=pending??ed?.html()??saved;theirs=null;pending=mine;saved="\0";flush()}function showTheirs(){const t=theirs;theirs=null;pending=null;if(t==null)return;saved=t;ed?.setHtml(t)}function flush(){clearTimeout(timer);if(theirs!=null)return;if(pending==null||pending===saved)return void(pending=null);saved=pending;pending=null;onSave(saved)}onMount(()=>{let gone=false;void loadPageEditor().then(pm=>{if(gone||!mount)return;if(!pm)return onUnavailable?.();ed=createPageEditor(pm,mount,{html,editable,placeholder:bm("record.pagePlaceholder"),onChange:changed,onSlash:s=>void slashChanged(s),onSelection:()=>selTick+=1,upload,records,views,onMention:s=>void mentionChanged(s),onUploading:n=>uploading=n,onError,onEscape:()=>{if(blockMenu){blockMenu=null;return true}if(linking){linking=false;return true}return false}});onReady?.(ed)});return()=>{gone=true}});onDestroy(()=>{flush();ed?.destroy()});$effect(()=>{const now=html;if(!ed||now===saved)return;if(pending==null){saved=now;ed.setHtml(now)}else{clearTimeout(timer);theirs=now}});$effect(()=>{ed?.setEditable(editable)});const ITEMS=$derived([{kind:"text",label:bm("record.blockText"),hint:bm("record.blockTextHint"),words:"text paragraph plain",icon:"T"},{kind:"h1",label:bm("record.blockH1"),hint:bm("record.blockH1Hint"),words:"heading title h1 #",icon:"H1"},{kind:"h2",label:bm("record.blockH2"),hint:bm("record.blockH2Hint"),words:"heading subtitle h2 ##",icon:"H2"},{kind:"h3",label:bm("record.blockH3"),hint:bm("record.blockH3Hint"),words:"heading h3 ###",icon:"H3"},{kind:"bullet",label:bm("record.blockBullet"),hint:bm("record.blockBulletHint"),words:"bulleted list unordered ul -",icon:"•"},{kind:"numbered",label:bm("record.blockNumbered"),hint:bm("record.blockNumberedHint"),words:"numbered list ordered ol 1.",icon:"1."},{kind:"todo",label:bm("record.blockTodo"),hint:bm("record.blockTodoHint"),words:"todo to-do task checkbox check []",icon:"☑"},{kind:"toggle",label:bm("record.blockToggle"),hint:bm("record.blockToggleHint"),words:"toggle fold collapse details",icon:"▸"},{kind:"toggleH1",label:bm("record.blockToggleH1"),hint:bm("record.blockToggleHHint"),words:"toggle heading h1",icon:"▸H1"},{kind:"toggleH2",label:bm("record.blockToggleH2"),hint:bm("record.blockToggleHHint"),words:"toggle heading h2",icon:"▸H2"},{kind:"toggleH3",label:bm("record.blockToggleH3"),hint:bm("record.blockToggleHHint"),words:"toggle heading h3",icon:"▸H3"},{kind:"quote",label:bm("record.blockQuote"),hint:bm("record.blockQuoteHint"),words:"quote blockquote >",icon:"“"},{kind:"callout",label:bm("record.blockCallout"),hint:bm("record.blockCalloutHint"),words:"callout note tip warning box",icon:"💡"},{kind:"divider",label:bm("record.blockDivider"),hint:bm("record.blockDividerHint"),words:"divider line separator hr ---",icon:"—"},{kind:"code",label:bm("record.blockCode"),hint:bm("record.blockCodeHint"),words:"code snippet pre ```",icon:"</>"},{kind:"columns2",label:bm("record.blockColumns2"),hint:bm("record.blockColumnsHint"),words:"columns two side by side layout",icon:"▥"},{kind:"columns3",label:bm("record.blockColumns3"),hint:bm("record.blockColumnsHint"),words:"columns three side by side layout",icon:"▥"},...upload?[{kind:"image",label:bm("record.blockImage"),hint:bm("record.blockImageHint"),words:"image picture photo upload",icon:"🖼"},{kind:"file",label:bm("record.blockFile"),hint:bm("record.blockFileHint"),words:"file upload attachment pdf document",icon:"📎"}]:[],...records?[{kind:"page",label:bm("record.blockPage"),hint:bm("record.blockPageHint"),words:"page subpage sub-page child nested",icon:"📄"}]:[],...views?[{kind:"linkedView",label:bm("record.blockLinkedView"),hint:bm("record.blockLinkedViewHint"),words:"linked view table database records list",icon:"▦"}]:[],{kind:"toc",label:bm("record.blockToc"),hint:bm("record.blockTocHint"),words:"table of contents toc headings outline",icon:"☰"},{kind:"video",label:bm("record.blockVideo"),hint:bm("record.blockVideoHint"),words:"video youtube vimeo loom",icon:"▶"},{kind:"embed",label:bm("record.blockEmbed"),hint:bm("record.blockEmbedHint"),words:"embed google docs sheets maps figma miro spotify calendly",icon:"⧉"},{kind:"bookmark",label:bm("record.blockBookmark"),hint:bm("record.blockBookmarkHint"),words:"bookmark link web page url",icon:"🔖"}]);let choosing=$state(null);let asking=$state(null);let askText=$state("");let askBusy=$state(false);let picker=$state(null);let pickFor=null;async function askDone(e){e.preventDefault();const a=asking;const v=askText.trim();if(!a||!v||!ed)return;const href=/^[a-z][a-z0-9+.-]*:/i.test(v)?v:`https://${v}`;if(a.kind==="bookmark"){askBusy=true;let card={title:href,description:"",site:""};try{if(preview)card=await preview(href)}catch{}askBusy=false;ed.insertBookmark(href,card,a.range)}else ed.insertEmbed(href,a.range);asking=null;askText=""}function picked(e){const input=e.currentTarget;const files=Array.from(input.files??[]);input.value="";if(files.length&&ed&&pickFor)void ed.insertFiles(files,pickFor.range);pickFor=null}let slash=$state(null);let slashAt=$state(null);let slashIndex=$state(0);const found=$derived.by(()=>{const q=(slash?.query??"").trim().toLocaleLowerCase();if(!q)return ITEMS;return ITEMS.filter(i=>i.label.toLocaleLowerCase().includes(q)||i.words.split(" ").some(w=>w.startsWith(q)))});async function slashChanged(s){const opening=s&&!slash;slash=s;if(!s||!ed||!root)return void(slashAt=null);if(opening)slashIndex=0;slashIndex=Math.min(slashIndex,Math.max(0,found.length-1));await tick();slashAt=menuAt(s.from)}function closeSlash(){slash=null;slashAt=null;ed?.closeSlash()}function pick(i){if(!ed||!slash)return;const range={from:slash.from,to:slash.to};if(i.kind==="image"||i.kind==="file"){pickFor={range};if(picker){picker.accept=i.kind==="image"?"image/*":"";picker.click()}closeSlash();return}if(i.kind==="linkedView"){const at2=slashAt??{top:0,left:0,up:false};choosing={range,...at2,list:views?.list()??[]};closeSlash();return}if(i.kind==="page"){closeSlash();void ed.insertSubpage(range);return}if(i.kind==="embed"||i.kind==="video"||i.kind==="bookmark"){const at2=slashAt??{top:0,left:0,up:false};asking={kind:i.kind,range,top:at2.top,left:at2.left,up:at2.up};askText="";closeSlash();return}ed.insertBlock(i.kind,range)}function menuAt(pos,height=320){if(!ed)return null;try{return menuPlace(ed.view.coordsAtPos(pos),height)}catch{return{top:0,left:0,up:false}}}function placeAt(pos){if(!ed||!root)return null;try{const c=ed.view.coordsAtPos(pos);const box=root.getBoundingClientRect();return{top:c.bottom-box.top+4,left:Math.max(0,c.left-box.left)}}catch{return{top:0,left:0}}}let at=$state(null);let atPlace=$state(null);let atIndex=$state(0);const people=$derived(at&&records?[...records.find(at.query).slice(0,8),...(links?.(at.query)??[]).map(l=>({id:"link:"+l.id,title:l.name,icon:l.icon,kind:l.kind,href:l.href}))]:[]);async function mentionChanged(s){const opening=s&&!at;at=s;if(!s)return void(atPlace=null);if(opening)atIndex=0;atIndex=Math.min(atIndex,Math.max(0,people.length-1));await tick();atPlace=menuAt(s.from,280)}function name(r){if(!ed||!at)return;if(r.href)ed.insertPageLink({title:r.title,href:r.href,icon:r.icon},{from:at.from,to:at.to});else ed.insertMention(r,{from:at.from,to:at.to})}function keysFirst(e){if(at){if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault();e.stopPropagation();const n=people.length;if(n)atIndex=(atIndex+(e.key==="ArrowDown"?1:-1)+n)%n;return}if((e.key==="Enter"||e.key==="Tab")&&people.length){e.preventDefault();e.stopPropagation();name(people[atIndex]??people[0]);return}if(e.key==="Escape"){e.preventDefault();e.stopPropagation();ed?.closeMention();return}}if(e.key==="Escape"&&asking){e.preventDefault();e.stopPropagation();asking=null;ed?.view.focus();return}if(e.key==="Escape"&&(slash||blockMenu||linking||colorsOpen)){e.preventDefault();e.stopPropagation();blockMenu=null;linking=false;colorsOpen=false;if(slash)closeSlash();ed?.view.focus();return}if(!slash)return;if(e.key==="ArrowDown"||e.key==="ArrowUp"){e.preventDefault();e.stopPropagation();const n=found.length;if(n)slashIndex=(slashIndex+(e.key==="ArrowDown"?1:-1)+n)%n}else if((e.key==="Enter"||e.key==="Tab")&&found.length){e.preventDefault();e.stopPropagation();pick(found[slashIndex]??found[0])}}let selTick=$state(0);let focused=$state(false);let linking=$state(false);let linkText=$state("");let colorsOpen=$state(false);const bar=$derived.by(()=>{void selTick;if(!ed||!root||!focused||!editable)return null;const sel=ed.view.state.selection;if(sel.empty||sel.node)return null;const at2=placeAt(sel.from);if(!at2)return null;return{top:Math.max(0,at2.top-48),left:at2.left,marks:ed.marksHere()}});const MARKS=[{mark:"strong",key:"record.markBold",text:"B",style:"font-weight:700"},{mark:"em",key:"record.markItalic",text:"i",style:"font-style:italic;font-family:Georgia,serif"},{mark:"underline",key:"record.markUnderline",text:"U",style:"text-decoration:underline"},{mark:"strike",key:"record.markStrike",text:"S",style:"text-decoration:line-through"},{mark:"code",key:"record.markCode",text:"<>",style:"font-family:monospace;font-size:12px"}];function startLink(){linking=true;linkText="";colorsOpen=false}function saveLink(e){e.preventDefault();const v=linkText.trim();if(v)ed?.setLink(/^[a-z][a-z0-9+.-]*:|^\/|^#/i.test(v)?v:`https://${v}`);linking=false}let handle=$state(null);let blockMenu=$state(null);let grip=$state(null);function moved(e){if(!ed||!editable||blockMenu||e.pointerType==="touch")return;const r=ed.view.dom.getBoundingClientRect();if(e.clientY<r.top||e.clientY>r.bottom)return;const hit=ed.blockAt(r.left+12,e.clientY);if(!hit||!root)return;const b=hit.dom.getBoundingClientRect();handle={pos:hit.pos,top:b.top-root.getBoundingClientRect().top}}const COLOR_KEYS={gray:"record.colorGray",brown:"record.colorBrown",orange:"record.colorOrange",yellow:"record.colorYellow",green:"record.colorGreen",blue:"record.colorBlue",purple:"record.colorPurple",pink:"record.colorPink",red:"record.colorRed"};const TURN=["text","h1","h2","h3","bullet","numbered","todo","toggle","quote","callout","code"];function menuDo(f){f();blockMenu=null}
|
|
3
3
|
</script>
|
|
4
4
|
|
|
5
5
|
|
|
@@ -105,7 +105,7 @@ import{onDestroy,onMount,tick}from"svelte";import{createPageEditor,loadPageEdito
|
|
|
105
105
|
{#each people as r, n (r.id)}
|
|
106
106
|
<button type="button" role="option" aria-selected={n === atIndex} class:is-on={n === atIndex} onmousedown={(e) => e.preventDefault()} onpointerenter={() => (atIndex = n)} onclick={() => name(r)}>
|
|
107
107
|
<span class="sv-pe-ico">{r.icon || '📄'}</span>
|
|
108
|
-
<span class="sv-pe-what"><strong>{r.title}</strong
|
|
108
|
+
<span class="sv-pe-what"><strong>{r.title}</strong>{#if r.kind}<small>{r.kind}</small>{/if}</span>
|
|
109
109
|
</button>
|
|
110
110
|
{:else}
|
|
111
111
|
<p class="sv-pe-none">{bm('record.mentionNone')}</p>
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type LinkCard, type PageEditor, type PageFile, type PageRecords, type PageViewHost } from './page-editor.js';
|
|
2
|
+
import type { MentionLink } from '../mentions.js';
|
|
2
3
|
type $$ComponentProps = {
|
|
3
4
|
html: string;
|
|
4
5
|
editable?: boolean;
|
|
@@ -16,6 +17,8 @@ type $$ComponentProps = {
|
|
|
16
17
|
records?: PageRecords;
|
|
17
18
|
/** Views of the base's tables a page may show ("/linked view"). */
|
|
18
19
|
views?: PageViewHost;
|
|
20
|
+
/** The host's own pages "@" can link to besides the records, such as notes. */
|
|
21
|
+
links?: (query: string) => MentionLink[];
|
|
19
22
|
/** The editor, once it is made (to focus it, or to write into it from outside). */
|
|
20
23
|
onReady?: (editor: PageEditor) => void;
|
|
21
24
|
};
|
|
@@ -122,6 +122,15 @@ export type PageEditor = {
|
|
|
122
122
|
from: number;
|
|
123
123
|
to: number;
|
|
124
124
|
}): void;
|
|
125
|
+
/** A link to one of the host's pages (a note) where the "@" was: its icon and name, linked. */
|
|
126
|
+
insertPageLink(link: {
|
|
127
|
+
title: string;
|
|
128
|
+
href: string;
|
|
129
|
+
icon?: string;
|
|
130
|
+
}, range: {
|
|
131
|
+
from: number;
|
|
132
|
+
to: number;
|
|
133
|
+
}): void;
|
|
125
134
|
/** Close the @ menu, leaving what was typed. */
|
|
126
135
|
closeMention(): void;
|
|
127
136
|
/** Draw the record links again (a record was renamed). */
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import{renderMarkdown as ut,sanitizeHtml as U}from"@svgrid/grid";import{pageSchema as pt,parsePage as j,serializePage as H}from"./page-schema.js";import{embedFrame as ft,embedOf as J}from"./embed-url.js";const mt=/^(?:#{1,6}\s|[-*+]\s|\d+\.\s|>\s?|```|---\s*$|- \[[ xX]\]\s)/m;let G=null;export function loadPageEditor(){return G??(G=Promise.all([import("prosemirror-model"),import("prosemirror-state"),import("prosemirror-view"),import("prosemirror-transform"),import("prosemirror-commands"),import("prosemirror-keymap"),import("prosemirror-history"),import("prosemirror-inputrules"),import("prosemirror-schema-list"),import("prosemirror-dropcursor"),import("prosemirror-gapcursor")]).then(([d,
|
|
1
|
+
import{renderMarkdown as ut,sanitizeHtml as U}from"@svgrid/grid";import{pageSchema as pt,parsePage as j,serializePage as H}from"./page-schema.js";import{embedFrame as ft,embedOf as J}from"./embed-url.js";const mt=/^(?:#{1,6}\s|[-*+]\s|\d+\.\s|>\s?|```|---\s*$|- \[[ xX]\]\s)/m;let G=null;export function loadPageEditor(){return G??(G=Promise.all([import("prosemirror-model"),import("prosemirror-state"),import("prosemirror-view"),import("prosemirror-transform"),import("prosemirror-commands"),import("prosemirror-keymap"),import("prosemirror-history"),import("prosemirror-inputrules"),import("prosemirror-schema-list"),import("prosemirror-dropcursor"),import("prosemirror-gapcursor")]).then(([d,E,p,g,l,u,m,f,M,y,x])=>({model:d,state:E,view:p,transform:g,commands:l,keymap:u,history:m,inputrules:f,lists:M,dropcursor:y,gapcursor:x}),()=>null))}const gt=d=>d==null?"":d<1024?`${d} B`:d<1048576?`${Math.round(d/1024)} KB`:`${(d/1048576).toFixed(1)} MB`,ht=d=>(d.type??"").startsWith("image/")||/\.(png|jpe?g|gif|webp|avif)$/i.test(d.name??""),yt=new Set(["doc","column","toggle_body","callout","blockquote"]),I=new Set(["list_item","todo_item"]);export function markdownToPage(d){const E=[];d=d.replace(/^```([a-z0-9+#-]*)[ \t]*\r?\n([\s\S]*?)\r?\n```[ \t]*$/gim,(u,m,f)=>(E.push({lang:m.toLowerCase(),code:f}),`SVPAGECODE${E.length-1}`));const p=u=>u.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">"),g=ut(d.replace(/^(\s*)[-*+] \[([ xX])\] /gm,(u,m,f)=>`${m}- ${f.trim()?"☑":"☐"} `)),l=document.createElement("div");l.innerHTML=U(g);for(const u of Array.from(l.querySelectorAll("ul"))){const m=Array.from(u.children);if(!(!m.length||!m.every(f=>/^[\u2610\u2611]\s?/.test(f.textContent??"")))){u.className="sv-todo";for(const f of m){(f.textContent??"").startsWith("☑")&&(f.className="sv-done");const x=document.createTreeWalker(f,NodeFilter.SHOW_TEXT).nextNode();x&&(x.data=x.data.replace(/^[\u2610\u2611]\s?/,""))}}}for(const u of Array.from(l.querySelectorAll("p"))){const m=/^SVPAGECODE(\d+)$/.exec((u.textContent??"").trim()),f=m?E[Number(m[1])]:void 0;if(!f)continue;const M=document.createElement("pre");M.innerHTML=`<code${f.lang?` class="language-${p(f.lang)}"`:""}>${p(f.code)}</code>`,u.replaceWith(M)}for(const u of Array.from(l.querySelectorAll("p"))){if(!/^>\s?/.test(u.textContent??""))continue;const m=u.previousElementSibling,f=m?.tagName==="BLOCKQUOTE"?m:document.createElement("blockquote");f!==m&&u.before(f);const y=document.createTreeWalker(u,NodeFilter.SHOW_TEXT).nextNode();y&&(y.data=y.data.replace(/^>\s?/,"")),f.appendChild(u)}return l.innerHTML}export function createPageEditor(d,E,p){const g=pt(d.model),l=g.nodes,u=g.marks,{Plugin:m,PluginKey:f,EditorState:M,TextSelection:y,NodeSelection:x}=d.state,{Decoration:Q,DecorationSet:Y,EditorView:Z}=d.view,{InputRule:V,inputRules:tt,wrappingInputRule:N,textblockTypeInputRule:W}=d.inputrules,{splitListItem:et,liftListItem:q,sinkListItem:rt}=d.lists,v=d.commands,b=new f("page-slash");let T=null;const nt=new m({key:b,state:{init:()=>null,apply(t,e,o,r){const n=t.getMeta(b);if(n==="close")return null;if(n)return n;if(!e)return null;const a=r.selection;if(!a.empty)return null;const i=t.mapping.map(e.from);if(a.from<=i)return null;const c=r.doc.textBetween(i,a.from,`
|
|
2
2
|
`,`
|
|
3
3
|
`);return!c.startsWith("/")||/\s{2}|\n/.test(c)||c.length>30?null:{from:i,to:a.from,query:c.slice(1)}}},props:{handleTextInput(t,e,o,r){if(r!=="/")return!1;const n=t.state.doc.resolve(e),a=n.parent.textBetween(Math.max(0,n.parentOffset-1),n.parentOffset,`
|
|
4
4
|
`,`
|
|
5
|
-
`);if(a&&!/\s/.test(a)||n.parent.type.spec.code)return!1;const i=t.state.tr.insertText("/",e,o);return i.setMeta(b,{from:e,to:e+1,query:""}),t.dispatch(i),!0}}}),
|
|
5
|
+
`);if(a&&!/\s/.test(a)||n.parent.type.spec.code)return!1;const i=t.state.tr.insertText("/",e,o);return i.setMeta(b,{from:e,to:e+1,query:""}),t.dispatch(i),!0}}}),k=new f("page-mention");let _=null;const ot=new m({key:k,state:{init:()=>null,apply(t,e,o,r){const n=t.getMeta(k);if(n==="close")return null;if(n)return n;if(!e)return null;const a=r.selection;if(!a.empty)return null;const i=t.mapping.map(e.from);if(a.from<=i)return null;const c=r.doc.textBetween(i,a.from,`
|
|
6
6
|
`,`
|
|
7
7
|
`);return!c.startsWith("@")||/\s{2}|\n/.test(c)||c.length>40?null:{from:i,to:a.from,query:c.slice(1)}}},props:{handleTextInput(t,e,o,r){if(r!=="@"||!p.records)return!1;const n=t.state.doc.resolve(e),a=n.parent.textBetween(Math.max(0,n.parentOffset-1),n.parentOffset,`
|
|
8
8
|
`,`
|
|
9
|
-
`);if(a&&!/\s/.test(a)||n.parent.type.spec.code)return!1;const i=t.state.tr.insertText("@",e,o);return i.setMeta(S,{from:e,to:e+1,query:""}),t.dispatch(i),!0}}}),st=new m({props:{decorations(t){const{$from:e,empty:o}=t.selection;if(!o)return null;const r=e.parent;if(!r.isTextblock||r.content.size>0||r.type.spec.code)return null;const n=r.type===l.heading?`Heading ${r.attrs.level}`:r.type===l.toggle_title?"Toggle":p.placeholder;return Y.create(t.doc,[Q.node(e.before(),e.after(),{class:"is-empty","data-placeholder":n})])}}}),at=tt({rules:[W(/^(#{1,3})\s$/,l.heading,t=>({level:t[1].length})),N(/^\s*>\s$/,l.blockquote),N(/^\s*([-+*])\s$/,l.bullet_list),N(/^(\d+)\.\s$/,l.ordered_list,t=>({order:+t[1]}),(t,e)=>e.childCount+e.attrs.order===+t[1]),N(/^\s*\[([ xX]?)\]\s$/,l.todo_list),W(/^```([a-z0-9-]*)\s$/i,l.code_block,t=>({language:t[1]??""})),new V(/^---$/,(t,e,o)=>{const r=t.doc.resolve(o);return r.parent.type!==l.paragraph||r.parent.content.size!==3?null:t.tr.replaceRangeWith(r.before(),r.after(),l.horizontal_rule.create()).scrollIntoView()}),A(/\*\*([^*]+)\*\*$/,u.strong),A(/(?<![*\w])\*([^*\s][^*]*)\*$/,u.em),A(/~~([^~]+)~~$/,u.strike),A(/`([^`]+)`$/,u.code)]});function A(t,e){return new V(t,(o,r,n,a)=>{const i=r[1];return o.tr.replaceWith(n,a,h.text(i,[e.create()])).removeStoredMark(e)})}const C=t=>{const{$from:e}=t.selection;for(let o=e.depth;o>0;o--)if(I.has(e.node(o).type.name))return e.node(o).type;return null},ct=d.keymap.keymap({"Mod-z":d.history.undo,"Shift-Mod-z":d.history.redo,"Mod-y":d.history.redo,"Mod-b":v.toggleMark(u.strong),"Mod-i":v.toggleMark(u.em),"Mod-u":v.toggleMark(u.underline),"Mod-Shift-s":v.toggleMark(u.strike),"Mod-e":v.toggleMark(u.code),Enter:(t,e)=>{const o=C(t);if(o&&et(o)(t,e))return!0;const{$from:r,empty:n}=t.selection;if(n&&r.parent.type===l.toggle_title&&r.parentOffset===r.parent.content.size){const a=r.after();if(e){const i=t.tr.insert(a+1,l.paragraph.create());i.setSelection(y.create(i.doc,a+2));const c=r.node(r.depth-1);c.attrs.open||i.setNodeMarkup(r.before(r.depth-1),void 0,{...c.attrs,open:!0}),e(i.scrollIntoView())}return!0}return!1},"Shift-Enter":(t,e)=>(e&&e(t.tr.replaceSelectionWith(l.hard_break.create()).scrollIntoView()),!0),Tab:(t,e)=>{const o=C(t);return o?rt(o)(t,e):!0},"Shift-Tab":(t,e)=>{const o=C(t);return o?q(o)(t,e):!0},Backspace:(t,e)=>{const{$from:o,empty:r}=t.selection;if(!r||o.parentOffset>0)return!1;const n=C(t);return n&&q(n)(t,e)?!0:o.parent.type===l.heading||o.parent.type===l.code_block?v.setBlockType(l.paragraph)(t,e):v.lift(t,e)},"Mod-Enter":(t,e)=>{const{$from:o}=t.selection;for(let r=o.depth;r>0;r--){const n=o.node(r);if(n.type===l.todo_item)return e&&e(t.tr.setNodeMarkup(o.before(r),void 0,{...n.attrs,done:!n.attrs.done})),!0}return!1},Escape:()=>T?(s.dispatch(s.state.tr.setMeta(b,"close")),!0):_?(s.dispatch(s.state.tr.setMeta(S,"close")),!0):p.onEscape?.()??!1}),it={todo_item:(t,e,o)=>{const r=document.createElement("li");r.className=t.attrs.done?"sv-done":"";const n=document.createElement("input");n.type="checkbox",n.className="sv-todo-box",n.checked=!!t.attrs.done,n.contentEditable="false",n.setAttribute("aria-label",t.attrs.done?"Done":"To do"),n.addEventListener("mousedown",i=>i.preventDefault()),n.addEventListener("change",()=>{const i=o();if(i==null||!e.editable)return void(n.checked=!!t.attrs.done);e.dispatch(e.state.tr.setNodeMarkup(i,void 0,{...t.attrs,done:n.checked}))});const a=document.createElement("div");return a.className="sv-todo-text",r.append(n,a),{dom:r,contentDOM:a,update(i){return i.type!==t.type?!1:(t=i,r.className=i.attrs.done?"sv-done":"",n.checked=!!i.attrs.done,n.setAttribute("aria-label",i.attrs.done?"Done":"To do"),!0)},ignoreMutation:i=>i.target===n||i.type==="attributes"&&i.target===r}},toggle:(t,e,o)=>{const r=document.createElement("div"),n=document.createElement("button");n.type="button",n.className="sv-toggle-arrow",n.contentEditable="false";const a=c=>{r.className=["sv-toggle",c.attrs.open?"sv-open":"",c.attrs.color?`sv-c-${c.attrs.color}`:""].filter(Boolean).join(" "),n.setAttribute("aria-expanded",String(!!c.attrs.open)),n.setAttribute("aria-label",c.attrs.open?"Fold":"Unfold")};a(t),n.addEventListener("mousedown",c=>c.preventDefault()),n.addEventListener("click",()=>{const c=o();c!=null&&e.dispatch(e.state.tr.setNodeMarkup(c,void 0,{...t.attrs,open:!t.attrs.open}))});const i=document.createElement("div");return i.className="sv-toggle-inner",r.append(n,i),{dom:r,contentDOM:i,update(c){return c.type!==t.type?!1:(t=c,a(c),!0)},ignoreMutation:c=>c.target===n||c.type==="attributes"&&c.target===r}},image:(t,e,o)=>{const r=document.createElement("div");r.className="sv-page-image";const n=document.createElement("img"),a=document.createElement("span");a.className="sv-page-image-grip",a.setAttribute("aria-hidden","true");const i=c=>{n.src=c.attrs.src,n.alt=c.attrs.alt??"",n.style.width=c.attrs.width?`${c.attrs.width}px`:""};return i(t),a.addEventListener("pointerdown",c=>{if(!e.editable)return;c.preventDefault();const g=c.clientX,k=n.getBoundingClientRect().width,dt=(r.parentElement?.getBoundingClientRect().width??2e3)||2e3,F=L=>n.style.width=`${Math.round(Math.max(80,Math.min(dt,k+L.clientX-g)))}px`,X=()=>{window.removeEventListener("pointermove",F),window.removeEventListener("pointerup",X);const L=o(),K=Math.round(n.getBoundingClientRect().width);L!=null&&K>0&&e.dispatch(e.state.tr.setNodeMarkup(L,void 0,{...t.attrs,width:K}))};window.addEventListener("pointermove",F),window.addEventListener("pointerup",X)}),r.append(n,a),{dom:r,update(c){return c.type!==t.type?!1:(t=c,i(c),!0)},stopEvent:c=>c.target===a,ignoreMutation:()=>!0}},embed:t=>{const e=document.createElement("div");e.className="sv-embed";const o=J(t.attrs.href),r=document.createElement("a");return r.href=t.attrs.href,r.target="_blank",r.rel="noopener noreferrer",r.textContent=o?o.provider:t.attrs.href,r.className="sv-embed-link",o&&e.append(ft(o,t.attrs.href)),e.append(r),{dom:e,ignoreMutation:()=>!0,stopEvent:n=>n.target instanceof HTMLIFrameElement}},subpage:t=>{const e=document.createElement("p");e.className="sv-subpage";const o=document.createElement("a");o.href=`#svrec:${t.attrs.id}`;const r=n=>{const a=p.records?.get(n.attrs.id);o.textContent=`${a?.icon||"📄"} ${a?.title||n.attrs.title||"Untitled"}`,o.dataset.svrec=n.attrs.id};return r(t),o.addEventListener("click",n=>{n.preventDefault(),p.records?.open(t.attrs.id)}),e.append(o),{dom:e,update(n){return n.type!==t.type?!1:(t=n,r(n),!0)},ignoreMutation:()=>!0}},mention:t=>{const e=document.createElement("a");e.className="sv-mention",e.href=`#svrec:${t.attrs.id}`;const o=r=>{const n=p.records?.get(r.attrs.id);e.textContent=n?.title||r.attrs.title||"Untitled",e.dataset.svrec=r.attrs.id};return o(t),e.addEventListener("click",r=>{r.preventDefault(),p.records?.open(t.attrs.id)}),{dom:e,update(r){return r.type!==t.type?!1:(t=r,o(r),!0)},ignoreMutation:()=>!0}},linked_view:t=>{const e=document.createElement("div");e.className="sv-linked-view",e.contentEditable="false";const o=r=>{const n={table:r.attrs.table,view:r.attrs.view,title:r.attrs.title};p.views?p.views.draw(e,n):e.textContent=r.attrs.title};return o(t),{dom:e,update(r){return r.type!==t.type?!1:(t=r,o(r),!0)},ignoreMutation:()=>!0,stopEvent:r=>r.type==="click"||r.type==="mousedown"}},toc:()=>{const t=document.createElement("div");return t.className="sv-toc",t.contentEditable="false",{dom:t,update:e=>e.type===l.toc,ignoreMutation:()=>!0}},callout:(t,e,o)=>{const r=document.createElement("div"),n=document.createElement("button");n.type="button",n.className="sv-callout-icon",n.contentEditable="false";const a=c=>{r.className=["sv-callout",`sv-c-${c.attrs.color??"gray"}`].join(" "),n.textContent=c.attrs.icon};a(t),n.addEventListener("mousedown",c=>c.preventDefault()),n.addEventListener("click",()=>{const c=o();if(c==null||!e.editable)return;const g=["💡","⚠️","✅","📌","❗","ℹ️","🔥","🗒️"],k=g[(g.indexOf(t.attrs.icon)+1)%g.length];e.dispatch(e.state.tr.setNodeMarkup(c,void 0,{...t.attrs,icon:k}))});const i=document.createElement("div");return i.className="sv-callout-body",r.append(n,i),{dom:r,contentDOM:i,update(c){return c.type!==t.type?!1:(t=c,a(c),!0)},ignoreMutation:c=>c.target===n||n.contains(c.target)||c.type==="attributes"&&c.target===r}}},P=M.create({doc:j(d.model,h,p.html),plugins:[nt,ot,at,ct,d.keymap.keymap(v.baseKeymap),d.history.history(),d.dropcursor.dropCursor({color:"var(--sg-accent, #2563eb)",width:3}),d.gapcursor.gapCursor(),st]});let z=H(d.model,P.doc),x=p.editable;const s=new Z(w,{state:P,nodeViews:it,editable:()=>x,attributes:{class:"sv-page-doc",role:"textbox","aria-multiline":"true"},handlePaste(t,e){const o=Array.from(e.clipboardData?.files??[]);return!o.length||!p.upload||!x?!1:(B.insertFiles(o),!0)},handleDrop(t,e,o,r){const n=Array.from(e.dataTransfer?.files??[]);if(r||!n.length||!p.upload||!x)return!1;const a=t.posAtCoords({left:e.clientX,top:e.clientY});return a&&t.dispatch(t.state.tr.setSelection(y.near(t.state.doc.resolve(a.pos)))),e.preventDefault(),B.insertFiles(n),!0},clipboardTextParser(t,e){const o=mt.test(t)?markdownToPage(t):t.split(/\r?\n/).map(n=>`<p>${n.replace(/&/g,"&").replace(/</g,"<")}</p>`).join(""),r=document.createElement("div");return r.innerHTML=U(o),d.model.DOMParser.fromSchema(h).parseSlice(r,{preserveWhitespace:!0,context:e})},dispatchTransaction(t){const e=s.state.apply(t);s.updateState(e);const o=b.getState(e)??null;JSON.stringify(o)!==JSON.stringify(T)&&(T=o,p.onSlash(o));const r=S.getState(e)??null;if(JSON.stringify(r)!==JSON.stringify(_)&&(_=r,p.onMention?.(r)),t.docChanged&&R(),t.docChanged){const n=H(d.model,e.doc);n!==z&&(z=n,p.onChange(n))}(t.selectionSet||t.docChanged)&&p.onSelection?.()}});function O(t,e){const o=n=>l.paragraph.create(null,n),r=e??void 0;switch(t){case"h1":case"h2":case"h3":return l.heading.create({level:Number(t[1])},r);case"bullet":return l.bullet_list.create(null,l.list_item.create(null,o(r)));case"numbered":return l.ordered_list.create(null,l.list_item.create(null,o(r)));case"todo":return l.todo_list.create(null,l.todo_item.create(null,o(r)));case"toggle":case"toggleH1":case"toggleH2":case"toggleH3":return l.toggle.create({open:!0},[l.toggle_title.create({level:t==="toggle"?0:Number(t.slice(-1))},r),l.toggle_body.create()]);case"quote":return l.blockquote.create(null,o(r));case"callout":return l.callout.create({icon:"💡",color:"gray"},o(r));case"divider":return l.horizontal_rule.create();case"code":{const n=r?r.textBetween(0,r.size,`
|
|
10
|
-
`):"";return l.code_block.create(null,n?
|
|
9
|
+
`);if(a&&!/\s/.test(a)||n.parent.type.spec.code)return!1;const i=t.state.tr.insertText("@",e,o);return i.setMeta(k,{from:e,to:e+1,query:""}),t.dispatch(i),!0}}}),st=new m({props:{decorations(t){const{$from:e,empty:o}=t.selection;if(!o)return null;const r=e.parent;if(!r.isTextblock||r.content.size>0||r.type.spec.code)return null;const n=r.type===l.heading?`Heading ${r.attrs.level}`:r.type===l.toggle_title?"Toggle":p.placeholder;return Y.create(t.doc,[Q.node(e.before(),e.after(),{class:"is-empty","data-placeholder":n})])}}}),at=tt({rules:[W(/^(#{1,3})\s$/,l.heading,t=>({level:t[1].length})),N(/^\s*>\s$/,l.blockquote),N(/^\s*([-+*])\s$/,l.bullet_list),N(/^(\d+)\.\s$/,l.ordered_list,t=>({order:+t[1]}),(t,e)=>e.childCount+e.attrs.order===+t[1]),N(/^\s*\[([ xX]?)\]\s$/,l.todo_list),W(/^```([a-z0-9-]*)\s$/i,l.code_block,t=>({language:t[1]??""})),new V(/^---$/,(t,e,o)=>{const r=t.doc.resolve(o);return r.parent.type!==l.paragraph||r.parent.content.size!==3?null:t.tr.replaceRangeWith(r.before(),r.after(),l.horizontal_rule.create()).scrollIntoView()}),A(/\*\*([^*]+)\*\*$/,u.strong),A(/(?<![*\w])\*([^*\s][^*]*)\*$/,u.em),A(/~~([^~]+)~~$/,u.strike),A(/`([^`]+)`$/,u.code)]});function A(t,e){return new V(t,(o,r,n,a)=>{const i=r[1];return o.tr.replaceWith(n,a,g.text(i,[e.create()])).removeStoredMark(e)})}const C=t=>{const{$from:e}=t.selection;for(let o=e.depth;o>0;o--)if(I.has(e.node(o).type.name))return e.node(o).type;return null},ct=d.keymap.keymap({"Mod-z":d.history.undo,"Shift-Mod-z":d.history.redo,"Mod-y":d.history.redo,"Mod-b":v.toggleMark(u.strong),"Mod-i":v.toggleMark(u.em),"Mod-u":v.toggleMark(u.underline),"Mod-Shift-s":v.toggleMark(u.strike),"Mod-e":v.toggleMark(u.code),Enter:(t,e)=>{const o=C(t);if(o&&et(o)(t,e))return!0;const{$from:r,empty:n}=t.selection;if(n&&r.parent.type===l.toggle_title&&r.parentOffset===r.parent.content.size){const a=r.after();if(e){const i=t.tr.insert(a+1,l.paragraph.create());i.setSelection(y.create(i.doc,a+2));const c=r.node(r.depth-1);c.attrs.open||i.setNodeMarkup(r.before(r.depth-1),void 0,{...c.attrs,open:!0}),e(i.scrollIntoView())}return!0}return!1},"Shift-Enter":(t,e)=>(e&&e(t.tr.replaceSelectionWith(l.hard_break.create()).scrollIntoView()),!0),Tab:(t,e)=>{const o=C(t);return o?rt(o)(t,e):!0},"Shift-Tab":(t,e)=>{const o=C(t);return o?q(o)(t,e):!0},Backspace:(t,e)=>{const{$from:o,empty:r}=t.selection;if(!r||o.parentOffset>0)return!1;const n=C(t);return n&&q(n)(t,e)?!0:o.parent.type===l.heading||o.parent.type===l.code_block?v.setBlockType(l.paragraph)(t,e):v.lift(t,e)},"Mod-Enter":(t,e)=>{const{$from:o}=t.selection;for(let r=o.depth;r>0;r--){const n=o.node(r);if(n.type===l.todo_item)return e&&e(t.tr.setNodeMarkup(o.before(r),void 0,{...n.attrs,done:!n.attrs.done})),!0}return!1},Escape:()=>T?(s.dispatch(s.state.tr.setMeta(b,"close")),!0):_?(s.dispatch(s.state.tr.setMeta(k,"close")),!0):p.onEscape?.()??!1}),it={todo_item:(t,e,o)=>{const r=document.createElement("li");r.className=t.attrs.done?"sv-done":"";const n=document.createElement("input");n.type="checkbox",n.className="sv-todo-box",n.checked=!!t.attrs.done,n.contentEditable="false",n.setAttribute("aria-label",t.attrs.done?"Done":"To do"),n.addEventListener("mousedown",i=>i.preventDefault()),n.addEventListener("change",()=>{const i=o();if(i==null||!e.editable)return void(n.checked=!!t.attrs.done);e.dispatch(e.state.tr.setNodeMarkup(i,void 0,{...t.attrs,done:n.checked}))});const a=document.createElement("div");return a.className="sv-todo-text",r.append(n,a),{dom:r,contentDOM:a,update(i){return i.type!==t.type?!1:(t=i,r.className=i.attrs.done?"sv-done":"",n.checked=!!i.attrs.done,n.setAttribute("aria-label",i.attrs.done?"Done":"To do"),!0)},ignoreMutation:i=>i.target===n||i.type==="attributes"&&i.target===r}},toggle:(t,e,o)=>{const r=document.createElement("div"),n=document.createElement("button");n.type="button",n.className="sv-toggle-arrow",n.contentEditable="false";const a=c=>{r.className=["sv-toggle",c.attrs.open?"sv-open":"",c.attrs.color?`sv-c-${c.attrs.color}`:""].filter(Boolean).join(" "),n.setAttribute("aria-expanded",String(!!c.attrs.open)),n.setAttribute("aria-label",c.attrs.open?"Fold":"Unfold")};a(t),n.addEventListener("mousedown",c=>c.preventDefault()),n.addEventListener("click",()=>{const c=o();c!=null&&e.dispatch(e.state.tr.setNodeMarkup(c,void 0,{...t.attrs,open:!t.attrs.open}))});const i=document.createElement("div");return i.className="sv-toggle-inner",r.append(n,i),{dom:r,contentDOM:i,update(c){return c.type!==t.type?!1:(t=c,a(c),!0)},ignoreMutation:c=>c.target===n||c.type==="attributes"&&c.target===r}},image:(t,e,o)=>{const r=document.createElement("div");r.className="sv-page-image";const n=document.createElement("img"),a=document.createElement("span");a.className="sv-page-image-grip",a.setAttribute("aria-hidden","true");const i=c=>{n.src=c.attrs.src,n.alt=c.attrs.alt??"",n.style.width=c.attrs.width?`${c.attrs.width}px`:""};return i(t),a.addEventListener("pointerdown",c=>{if(!e.editable)return;c.preventDefault();const h=c.clientX,w=n.getBoundingClientRect().width,dt=(r.parentElement?.getBoundingClientRect().width??2e3)||2e3,F=L=>n.style.width=`${Math.round(Math.max(80,Math.min(dt,w+L.clientX-h)))}px`,X=()=>{window.removeEventListener("pointermove",F),window.removeEventListener("pointerup",X);const L=o(),K=Math.round(n.getBoundingClientRect().width);L!=null&&K>0&&e.dispatch(e.state.tr.setNodeMarkup(L,void 0,{...t.attrs,width:K}))};window.addEventListener("pointermove",F),window.addEventListener("pointerup",X)}),r.append(n,a),{dom:r,update(c){return c.type!==t.type?!1:(t=c,i(c),!0)},stopEvent:c=>c.target===a,ignoreMutation:()=>!0}},embed:t=>{const e=document.createElement("div");e.className="sv-embed";const o=J(t.attrs.href),r=document.createElement("a");return r.href=t.attrs.href,r.target="_blank",r.rel="noopener noreferrer",r.textContent=o?o.provider:t.attrs.href,r.className="sv-embed-link",o&&e.append(ft(o,t.attrs.href)),e.append(r),{dom:e,ignoreMutation:()=>!0,stopEvent:n=>n.target instanceof HTMLIFrameElement}},subpage:t=>{const e=document.createElement("p");e.className="sv-subpage";const o=document.createElement("a");o.href=`#svrec:${t.attrs.id}`;const r=n=>{const a=p.records?.get(n.attrs.id);o.textContent=`${a?.icon||"📄"} ${a?.title||n.attrs.title||"Untitled"}`,o.dataset.svrec=n.attrs.id};return r(t),o.addEventListener("click",n=>{n.preventDefault(),p.records?.open(t.attrs.id)}),e.append(o),{dom:e,update(n){return n.type!==t.type?!1:(t=n,r(n),!0)},ignoreMutation:()=>!0}},mention:t=>{const e=document.createElement("a");e.className="sv-mention",e.href=`#svrec:${t.attrs.id}`;const o=r=>{const n=p.records?.get(r.attrs.id);e.textContent=n?.title||r.attrs.title||"Untitled",e.dataset.svrec=r.attrs.id};return o(t),e.addEventListener("click",r=>{r.preventDefault(),p.records?.open(t.attrs.id)}),{dom:e,update(r){return r.type!==t.type?!1:(t=r,o(r),!0)},ignoreMutation:()=>!0}},linked_view:t=>{const e=document.createElement("div");e.className="sv-linked-view",e.contentEditable="false";const o=r=>{const n={table:r.attrs.table,view:r.attrs.view,title:r.attrs.title};p.views?p.views.draw(e,n):e.textContent=r.attrs.title};return o(t),{dom:e,update(r){return r.type!==t.type?!1:(t=r,o(r),!0)},ignoreMutation:()=>!0,stopEvent:r=>r.type==="click"||r.type==="mousedown"}},toc:()=>{const t=document.createElement("div");return t.className="sv-toc",t.contentEditable="false",{dom:t,update:e=>e.type===l.toc,ignoreMutation:()=>!0}},callout:(t,e,o)=>{const r=document.createElement("div"),n=document.createElement("button");n.type="button",n.className="sv-callout-icon",n.contentEditable="false";const a=c=>{r.className=["sv-callout",`sv-c-${c.attrs.color??"gray"}`].join(" "),n.textContent=c.attrs.icon};a(t),n.addEventListener("mousedown",c=>c.preventDefault()),n.addEventListener("click",()=>{const c=o();if(c==null||!e.editable)return;const h=["💡","⚠️","✅","📌","❗","ℹ️","🔥","🗒️"],w=h[(h.indexOf(t.attrs.icon)+1)%h.length];e.dispatch(e.state.tr.setNodeMarkup(c,void 0,{...t.attrs,icon:w}))});const i=document.createElement("div");return i.className="sv-callout-body",r.append(n,i),{dom:r,contentDOM:i,update(c){return c.type!==t.type?!1:(t=c,a(c),!0)},ignoreMutation:c=>c.target===n||n.contains(c.target)||c.type==="attributes"&&c.target===r}}},P=M.create({doc:j(d.model,g,p.html),plugins:[nt,ot,at,ct,d.keymap.keymap(v.baseKeymap),d.history.history(),d.dropcursor.dropCursor({color:"var(--sg-accent, #2563eb)",width:3}),d.gapcursor.gapCursor(),st]});let z=H(d.model,P.doc),S=p.editable;const s=new Z(E,{state:P,nodeViews:it,editable:()=>S,attributes:{class:"sv-page-doc",role:"textbox","aria-multiline":"true"},handlePaste(t,e){const o=Array.from(e.clipboardData?.files??[]);return!o.length||!p.upload||!S?!1:(B.insertFiles(o),!0)},handleDrop(t,e,o,r){const n=Array.from(e.dataTransfer?.files??[]);if(r||!n.length||!p.upload||!S)return!1;const a=t.posAtCoords({left:e.clientX,top:e.clientY});return a&&t.dispatch(t.state.tr.setSelection(y.near(t.state.doc.resolve(a.pos)))),e.preventDefault(),B.insertFiles(n),!0},clipboardTextParser(t,e){const o=mt.test(t)?markdownToPage(t):t.split(/\r?\n/).map(n=>`<p>${n.replace(/&/g,"&").replace(/</g,"<")}</p>`).join(""),r=document.createElement("div");return r.innerHTML=U(o),d.model.DOMParser.fromSchema(g).parseSlice(r,{preserveWhitespace:!0,context:e})},dispatchTransaction(t){const e=s.state.apply(t);s.updateState(e);const o=b.getState(e)??null;JSON.stringify(o)!==JSON.stringify(T)&&(T=o,p.onSlash(o));const r=k.getState(e)??null;if(JSON.stringify(r)!==JSON.stringify(_)&&(_=r,p.onMention?.(r)),t.docChanged&&R(),t.docChanged){const n=H(d.model,e.doc);n!==z&&(z=n,p.onChange(n))}(t.selectionSet||t.docChanged)&&p.onSelection?.()}});function O(t,e){const o=n=>l.paragraph.create(null,n),r=e??void 0;switch(t){case"h1":case"h2":case"h3":return l.heading.create({level:Number(t[1])},r);case"bullet":return l.bullet_list.create(null,l.list_item.create(null,o(r)));case"numbered":return l.ordered_list.create(null,l.list_item.create(null,o(r)));case"todo":return l.todo_list.create(null,l.todo_item.create(null,o(r)));case"toggle":case"toggleH1":case"toggleH2":case"toggleH3":return l.toggle.create({open:!0},[l.toggle_title.create({level:t==="toggle"?0:Number(t.slice(-1))},r),l.toggle_body.create()]);case"quote":return l.blockquote.create(null,o(r));case"callout":return l.callout.create({icon:"💡",color:"gray"},o(r));case"divider":return l.horizontal_rule.create();case"code":{const n=r?r.textBetween(0,r.size,`
|
|
10
|
+
`):"";return l.code_block.create(null,n?g.text(n):void 0)}case"toc":return l.toc.create();case"columns2":case"columns3":{const n=t==="columns2"?2:3;return l.columns.create(null,Array.from({length:n},(a,i)=>l.column.create(null,o(i===0?r:void 0))))}default:return o(r)}}function D(t,e){const o=t.doc.resolve(Math.min(e+1,t.doc.content.size)),r=y.findFrom(o,1,!0);r&&t.setSelection(r)}function lt(t){let e;return t.descendants(o=>e?!1:o.isTextblock?(e=o.content,!1):!0),t.isTextblock&&(e=t.content),e}function R(){const t=s?.dom?Array.from(s.dom.querySelectorAll(".sv-toc")):[];if(!t.length)return;const e=[];s.state.doc.descendants((o,r)=>(o.type===l.heading&&e.push({level:o.attrs.level,text:o.textContent,pos:r}),!o.isTextblock));for(const o of t)o.replaceChildren(...e.map(r=>{const n=document.createElement("a");return n.href="#",n.className=`sv-toc-l${r.level}`,n.textContent=r.text||`Heading ${r.level}`,n.addEventListener("mousedown",a=>a.preventDefault()),n.addEventListener("click",a=>{a.preventDefault();const i=s.nodeDOM(r.pos);i instanceof HTMLElement&&i.scrollIntoView({block:"start",behavior:"smooth"})}),n}))}function $(t){const e=s.state.doc.resolve(t.from),o=e.parent.isTextblock&&e.parent.content.size===t.to-t.from&&e.depth>=1,r=s.state.tr.delete(t.from,t.to).setMeta(b,"close");if(o){const n=r.mapping.map(e.before());return r.delete(n,n+r.doc.resolve(n).nodeAfter.nodeSize),s.dispatch(r),n}return s.dispatch(r),s.state.doc.resolve(Math.min(t.from,s.state.doc.content.size)).after(1)}const B={view:s,html:()=>H(d.model,s.state.doc),setHtml(t){if(t===z)return;const e=j(d.model,g,t),o=Math.min(s.state.selection.from,e.content.size),r=s.state.tr.replaceWith(0,s.state.doc.content.size,e.content).setMeta("addToHistory",!1);r.setSelection(y.near(r.doc.resolve(Math.max(0,Math.min(o,r.doc.content.size))))),z=t,s.dispatch(r)},setEditable(t){S=t,s.setProps({editable:()=>S})},closeSlash(){T&&s.dispatch(s.state.tr.setMeta(b,"close"))},async insertFiles(t,e){if(!p.upload||!t.length)return;let o=e?$(e):s.state.selection.from,r=t.length;p.onUploading?.(r);for(const n of t)try{const a=await p.upload(n),i=ht({type:a.type??n.type,name:a.name})?l.image.create({src:a.url,alt:a.name??n.name}):l.file.create({href:a.url,name:a.name||n.name,size:gt(a.size??n.size)});o=Math.min(o,s.state.doc.content.size);const c=s.state.tr.insert(o,i);o+=i.nodeSize,s.dispatch(c.scrollIntoView())}catch(a){p.onError?.(a instanceof Error?a.message:String(a))}finally{p.onUploading?.(r-=1)}},insertEmbed(t,e){const o=e?$(e):s.state.selection.from;s.dispatch(s.state.tr.insert(o,J(t)?l.embed.create({href:t}):l.paragraph.create(null,g.text(t,[u.link.create({href:t})]))).scrollIntoView()),s.focus()},insertBookmark(t,e,o){const r=o?$(o):s.state.selection.from;s.dispatch(s.state.tr.insert(r,l.bookmark.create({href:t,title:e.title||t,description:e.description,site:e.site})).scrollIntoView()),s.focus()},async insertSubpage(t){if(!p.records)return;const e=await p.records.makeSubpage();if(!e)return;const o=$(t);s.dispatch(s.state.tr.insert(Math.min(o,s.state.doc.content.size),l.subpage.create({id:e.id,title:e.title})).scrollIntoView())},insertLinkedView(t,e){const o=$(e);s.dispatch(s.state.tr.insert(Math.min(o,s.state.doc.content.size),l.linked_view.create(t)).scrollIntoView()),s.focus()},insertMention(t,e){const o=s.state.tr.replaceWith(e.from,e.to,[l.mention.create({id:t.id,title:t.title}),g.text(" ")]).setMeta(k,"close");s.dispatch(o),s.focus()},insertPageLink(t,e){const o=(t.icon?t.icon+" ":"")+t.title,r=s.state.tr.replaceWith(e.from,e.to,[g.text(o,[g.marks.link.create({href:t.href})]),g.text(" ")]).setMeta(k,"close");s.dispatch(r),s.focus()},closeMention(){_&&s.dispatch(s.state.tr.setMeta(k,"close"))},refreshRecords(){s.dispatch(s.state.tr.setMeta("refresh",!0));for(const t of Array.from(s.dom.querySelectorAll("[data-svrec]"))){const e=p.records?.get(t.dataset.svrec);e&&(t.textContent=t.classList.contains("sv-mention")?e.title:`${e.icon||"📄"} ${e.title}`)}},insertBlock(t,e){const o=s.state,r=o.doc.resolve(e.from),n=o.tr.delete(e.from,e.to).setMeta(b,"close"),a=r.parent,i=a.isTextblock&&a.content.size===e.to-e.from,c=n.mapping.map(r.before());if(i&&r.depth>=1){const h=O(t);n.replaceWith(c,c+n.doc.resolve(c).nodeAfter.nodeSize,h),t==="divider"&&n.insert(c+h.nodeSize,l.paragraph.create()),D(n,c)}else{const h=n.mapping.map(r.after()),w=O(t);n.insert(h,w),D(n,h)}s.dispatch(n.scrollIntoView()),s.focus()},turnInto(t,e){const o=s.state,r=o.doc.nodeAt(t);if(!r||e==="divider")return;const n=I.has(r.type.name)?o.doc.resolve(t).parent:r,a=I.has(r.type.name)?o.doc.resolve(t).before():t,i=O(e,lt(n)),c=o.tr.replaceWith(a,a+n.nodeSize,i);D(c,a),s.dispatch(c.scrollIntoView()),s.focus()},setBlockColor(t,e){const o=s.state.doc.nodeAt(t);!o||!("color"in o.attrs)||s.dispatch(s.state.tr.setNodeMarkup(t,void 0,{...o.attrs,color:e??(o.type===l.callout?"gray":null)}))},duplicateBlock(t){const e=s.state.doc.nodeAt(t);e&&s.dispatch(s.state.tr.insert(t+e.nodeSize,e.copy(e.content)).scrollIntoView())},deleteBlock(t){const e=s.state.doc.nodeAt(t);if(!e)return;const o=s.state.tr.delete(t,t+e.nodeSize);o.doc.childCount===0&&o.insert(0,l.paragraph.create()),s.dispatch(o.scrollIntoView()),s.focus()},addBelow(t,e=!0){const o=s.state.doc.nodeAt(t);if(!o)return;const r=t+o.nodeSize,n=s.state.tr.insert(r,l.paragraph.create());if(n.setSelection(y.create(n.doc,r+1)),s.dispatch(n.scrollIntoView()),s.focus(),e){const a=s.state.tr.insertText("/",r+1);a.setMeta(b,{from:r+1,to:r+2,query:""}),s.dispatch(a)}},blockAt(t,e){const o=s.posAtCoords({left:t,top:e});if(!o)return null;const r=s.state.doc;if(o.inside>=0){const a=r.nodeAt(o.inside),i=s.nodeDOM(o.inside);if(a&&a.isBlock&&a.isAtom&&i instanceof HTMLElement)return{pos:o.inside,dom:i}}const n=r.resolve(o.pos);for(let a=n.depth;a>=1;a--){const i=n.node(a),c=n.node(a-1);if(I.has(i.type.name)||yt.has(c.type.name)&&i.type!==l.column){const h=n.before(a),w=s.nodeDOM(h);if(w instanceof HTMLElement)return{pos:h,dom:w}}}return null},dragBlock(t,e){const o=x.create(s.state.doc,t);s.dispatch(s.state.tr.setSelection(o));const r=o.content();s.dragging={slice:r,move:!0};const n=s.nodeDOM(t);e.dataTransfer&&(e.dataTransfer.effectAllowed="move",e.dataTransfer.setData("text/plain",o.node.textContent),n instanceof HTMLElement&&e.dataTransfer.setDragImage(n,0,0))},toggleMark(t){v.toggleMark(u[t])(s.state,s.dispatch),s.focus()},setLink(t){const{from:e,to:o,empty:r}=s.state.selection;if(r)return;const n=s.state.tr.removeMark(e,o,u.link);t&&n.addMark(e,o,u.link.create({href:t})),s.dispatch(n),s.focus()},setTextColor(t,e=!1){const{from:o,to:r,empty:n}=s.state.selection;if(n)return;const a=e?u.highlight:u.color,i=s.state.tr.removeMark(o,r,u.color).removeMark(o,r,u.highlight);t&&i.addMark(o,r,a.create({color:t})),s.dispatch(i),s.focus()},marksHere(){const{from:t,to:e,empty:o,$from:r}=s.state.selection,n=new Set;if(o)for(const a of s.state.storedMarks??r.marks())n.add(a.type.name);else s.state.doc.nodesBetween(t,e,a=>{a.marks.forEach(i=>n.add(i.type.name))});return n},destroy(){s.destroy()}};return R(),B}
|
package/dist/fields/rollups.d.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** The moment a date value stands for: a Date, or text that starts as one (2026-11-15, 2026-11-15T10:30:00Z); else null. */
|
|
2
|
+
export declare function dateTimeOf(x: unknown): number | null;
|
|
1
3
|
/** A rollup's aggregation over the linked records' values. */
|
|
2
4
|
export declare const ROLLUPS: Record<string, (vals: unknown[]) => unknown>;
|
|
3
5
|
/** Field types whose value is worked out from the record, never stored. */
|
package/dist/fields/rollups.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toNumber as
|
|
1
|
+
import{toNumber as o}from"./format.js";import{maxOf as a,minOf as s}from"../extent.js";export function dateTimeOf(e){if(e instanceof Date)return Number.isNaN(e.getTime())?null:e.getTime();if(typeof e!="string"||!/^\d{4}-\d{2}-\d{2}/.test(e))return null;const t=Date.parse(e.length===10?`${e}T00:00:00`:e);return Number.isNaN(t)?null:t}function u(e,t){let n=null,r=0;for(const i of e){const l=dateTimeOf(i);l!=null&&(n==null||(t?l>r:l<r))&&(n=i,r=l)}return n}const f=e=>e.filter(t=>!(t instanceof Date)).map(o).filter(t=>t!=null);export const ROLLUPS={SUM:e=>e.reduce((t,n)=>t+(o(n)??0),0),AVERAGE:e=>{const t=e.map(o).filter(n=>n!=null);return t.length?t.reduce((n,r)=>n+r,0)/t.length:null},MIN:e=>{const t=f(e);return t.length?s(t):u(e,!1)},MAX:e=>{const t=f(e);return t.length?a(t):u(e,!0)},COUNT:e=>e.filter(t=>typeof t=="number").length,COUNTA:e=>e.filter(t=>t!=null&&t!=="").length,COUNTALL:e=>e.length,ARRAYJOIN:e=>e.filter(t=>t!=null&&t!=="").map(String).join(", "),ARRAYUNIQUE:e=>[...new Set(e.filter(t=>t!=null&&t!=="").map(String))].join(", "),CONCATENATE:e=>e.map(t=>t==null?"":String(t)).join(""),AND:e=>e.every(Boolean),OR:e=>e.some(Boolean)},COMPUTED_TYPES=new Set(["formula","lookup","rollup","count"]);export function fieldNameMap(e){const t={};for(const n of e){const r=String(n.field??n.id??"");r&&(t[r.toLowerCase()]=r,typeof n.header=="string"&&(t[n.header.trim().toLowerCase()]=r))}return t}
|
package/dist/node/studio.js
CHANGED
|
@@ -913,7 +913,7 @@ ${E}
|
|
|
913
913
|
@keyframes st-home-spin { to { transform: rotate(360deg); } }
|
|
914
914
|
</style>
|
|
915
915
|
`}}function Ka(e){for(const r of e)je(r);const t=new Map(e.map(r=>[r.name,r])),a=e.map(r=>{const o=Eu(r,t);return{schema:Fu(r,o),infos:o}});return{entries:a,seed:Du(a)}}function fo(e,t={}){const{entries:a,seed:r}=Ka(e),{file:o,needs:n}=em(a,r,t.sources,t.supabaseConn,t.serverMemory),i=[Lu(a),o];(n.supabase||t.supabaseAuth)&&!n.supabaseUrl&&(t.supabaseConn?.url||t.supabaseConn?.key)&&(n.supabaseUrl=t.supabaseConn.url,n.supabaseKey=t.supabaseConn.key),(n.supabase||t.supabaseAuth)&&i.push(tm(n));for(const s of n.sqlRoutes)i.push(Hu(s.schema,s.table,s.dialect,{access:t.accessEnabled,audit:t.auditEnabled,screenIds:t.screensByEntity?.get(s.schema.name)??[],triggers:t.triggers?.[s.schema.name],dbSchema:s.dbSchema,tenantField:t.tenantField&&t.tenantScoped?.(s.schema.name)!==!1?t.tenantField:void 0}));if(n.memoryRoutes.length){i.push(Gu(n.memoryRoutes));for(const s of n.memoryRoutes)i.push(Vu(s.schema,{access:t.accessEnabled,audit:t.auditEnabled,screenIds:t.screensByEntity?.get(s.schema.name)??[],triggers:t.triggers?.[s.schema.name],tenantField:t.tenantField&&t.tenantScoped?.(s.schema.name)!==!1?t.tenantField:void 0}))}return{files:i,prepared:a.map(s=>s.schema)}}function am(e){if(e.length===0)throw new Error("emitStudioApp: no schemas to emit");const{files:t,prepared:a}=fo(e),r=a.map(n=>{const i=z(n);return{href:`/${i.route}`,label:i.label}}),o={path:"src/custom.css",description:"Your custom styles (imported after app.css so it overrides).",userOwned:!0,contents:`/* Your custom styles. Imported after app.css, so these rules override the defaults. */
|
|
916
|
-
`};return[...t,...a.map(n=>Ni(n)),Mi(r),ji(r),o]}function rm(e){return e.fields.some(t=>!!t.when&&(!!t.when.visible||!!t.when.disabled||!!t.when.required))}var om="3.1.
|
|
916
|
+
`};return[...t,...a.map(n=>Ni(n)),Mi(r),ji(r),o]}function rm(e){return e.fields.some(t=>!!t.when&&(!!t.when.visible||!!t.when.disabled||!!t.when.required))}var om="3.1.75",nm="3.0.43",V=(e,t)=>e.some(a=>a.config.kind===t),qi=e=>`activeTab_${e.replace(/[^a-zA-Z0-9_$]/g,"_")}`,aa=(e,t)=>`${e}-${t}`,zi=e=>`accOpen_${e.replace(/[^a-zA-Z0-9_$]/g,"_")}`,ra=(e,t)=>`${e}-s${t}`,oa=e=>`md_${e.replace(/[^a-zA-Z0-9]/g,"_")}_rows`;function im(e){switch(e.type){case"number":{const t=e.decimals;return t!=null?`{ type: 'number', options: { minimumFractionDigits: ${t}, maximumFractionDigits: ${t} } }`:"{ type: 'number' }"}case"currency":return`{ type: 'currency', currency: ${S(e.currency||"USD")} }`;case"percent":{const t=["type: 'percent'"];return e.valueIsPercentPoints&&t.push("valueIsPercentPoints: true"),e.decimals!=null&&t.push(`options: { minimumFractionDigits: ${e.decimals}, maximumFractionDigits: ${e.decimals} }`),`{ ${t.join(", ")} }`}case"date":case"datetime":return e.pattern?`{ type: '${e.type}', pattern: ${S(e.pattern)} }`:`{ type: '${e.type}' }`}}function sm(e,t,a,r){if(t.config.kind!=="grid")return`schemaToColumns(${e})`;const o=t.config,n=t.id.replace(/-/g,"_"),i=o.columns.filter(b=>b.show),s=new Set(i.map(b=>b.field)),d=new Set,l=i.map(b=>{const y=r?.get(b.field);return{c:b,col:y&&!s.has(y)?y:b.field}}).filter(b=>!d.has(b.col)&&!!d.add(b.col)),c=o.editing==="inline"?"":", editable: false";if(l.length===0)return c?`schemaToColumns(${e}).map((c) => ({ ...c${c} }))`:`schemaToColumns(${e})`;const p=l.map(b=>`'${b.col}'`),u=l.map(({c:b,col:y})=>{const w=[];return b.header&&w.push(`header: ${JSON.stringify(b.header)}`),b.width!=null&&w.push(`width: ${b.width}`),b.align&&w.push(`align: '${b.align}'`),b.aggregate&&w.push(`aggregate: '${b.aggregate}'`),o.treeData&&b.field===o.treeData.labelField&&a?w.push(`cell: (ctx: CellContext<${a}>) => renderSnippet(treeCell_${n}, { value: ctx.getValue(), row: ctx.row.original })`):b.cellType&&a?w.push(`cell: (ctx: CellContext<${a}>) => renderSnippet(${Gi(n,b.field)}, { value: ctx.getValue() })`):b.format&&w.push(`format: ${im(b.format)}`),w.length?`'${y}': { ${w.join(", ")} }`:null}).filter(b=>!!b),m=u.length?` const ov: Record<string, Partial<(typeof all)[number]>> = { ${u.join(", ")} };`:"",g=u.length?", ...(ov[String(c.field)] ?? {})":"",h=`[${p.join(", ")}].map((f) => all.find((c) => c.field === f)).filter((c): c is (typeof all)[number] => !!c)`;return`(() => { const all = schemaToColumns(${e});${m} return ${c||g?`${h}.map((c) => ({ ...c${c}${g} }))`:h} })()`}function Ae(e,t){const a=[`grid-column: span ${ei(e)}`,"min-width: 0"];t&&a.push(t);const r=ti(e.style);return r&&a.push(r),`style="${a.join("; ")}"`}var lm=e=>e&&e.replace(/[^#a-zA-Z0-9(),.%\s_-]/g,"").slice(0,40)||"var(--sg-accent)";function Ue(e,t){const a=[t,Xn(e)].filter(Boolean).join(" ");return a?` class="${a}"`:""}function Ha(e){const t=Ta(e.className);return t?` ${t}`:""}function dm(e){const t=Fe(e);if(t==="grid"){const a=ui(e),r=a.maxWidth?` max-width: ${a.maxWidth}px; margin-inline: auto;`:"";return` .st-screen { grid-template-columns: repeat(12, 1fr); gap: ${a.rowGap}px ${a.colGap}px; align-items: ${a.align};${r} }
|
|
917
917
|
@media (max-width: ${a.mobileBreakpoint}px) { .st-screen { grid-template-columns: 1fr; gap: 12px; } }
|
|
918
918
|
`}if(t==="stack"){const a=mi(e),r=a.maxWidth?` max-width: ${a.maxWidth}px;${a.align==="center"?" margin-inline: auto;":""}`:"",o=a.minHeight?`
|
|
919
919
|
.st-stack > * { min-height: ${a.minHeight}px; }`:"",n=a.dividers?`
|
package/dist/version.d.ts
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
*
|
|
11
11
|
* `version.test.ts` asserts this matches `package.json`, so the two cannot drift.
|
|
12
12
|
*/
|
|
13
|
-
export declare const SVGRID_VERSION = "3.1.
|
|
13
|
+
export declare const SVGRID_VERSION = "3.1.75";
|
|
14
14
|
/**
|
|
15
15
|
* The version of `@svgrid/grid`, which releases on its own line: enterprise is
|
|
16
16
|
* on 3.1.x while the grid is on 3.0.x.
|
|
@@ -23,4 +23,4 @@ export declare const SVGRID_VERSION = "3.1.73";
|
|
|
23
23
|
*
|
|
24
24
|
* `version.test.ts` asserts this matches packages/grid/package.json.
|
|
25
25
|
*/
|
|
26
|
-
export declare const GRID_VERSION = "3.0.
|
|
26
|
+
export declare const GRID_VERSION = "3.0.43";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SVGRID_VERSION="3.1.
|
|
1
|
+
export const SVGRID_VERSION="3.1.75",GRID_VERSION="3.0.43";
|