mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-04 16:44:56 +00:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
512a908fd4 | ||
|
|
71be1d424a |
@@ -60,7 +60,7 @@ export class OIDCProvider extends OAuthProvider {
|
||||
const validate = async () => {
|
||||
this.#endpoints = null;
|
||||
|
||||
if (this.configured) {
|
||||
if (super.configured) {
|
||||
const config = this.config as OAuthOIDCProviderConfig;
|
||||
try {
|
||||
const res = await fetch(
|
||||
@@ -73,7 +73,6 @@ export class OIDCProvider extends OAuthProvider {
|
||||
|
||||
if (res.ok) {
|
||||
this.#endpoints = OIDCConfigurationSchema.parse(await res.json());
|
||||
super.setup();
|
||||
} else {
|
||||
this.logger.error(`Invalid OIDC issuer ${config.issuer}`);
|
||||
}
|
||||
@@ -81,6 +80,8 @@ export class OIDCProvider extends OAuthProvider {
|
||||
this.logger.error('Failed to validate OIDC configuration', e);
|
||||
}
|
||||
}
|
||||
|
||||
super.setup();
|
||||
};
|
||||
|
||||
validate().catch(() => {
|
||||
|
||||
@@ -208,7 +208,18 @@ export function actionToHandler<T extends keyof BlockSuitePresets.AIActions>(
|
||||
if (!blocks || blocks.length === 0) return;
|
||||
const block = blocks.at(-1);
|
||||
if (!block) return;
|
||||
aiPanel.toggle(block, '');
|
||||
if (
|
||||
blocks.length === 1 &&
|
||||
block.model.flavour === 'affine:image' &&
|
||||
id === 'createImage'
|
||||
) {
|
||||
// if only one image block is selected, and the action is createImage
|
||||
// toggle panel to allow user to enter text prompt
|
||||
aiPanel.toggle(block, 'input');
|
||||
} else {
|
||||
// generate the answer
|
||||
aiPanel.toggle(block, 'generate');
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -232,7 +243,7 @@ export function handleInlineAskAIAction(
|
||||
});
|
||||
|
||||
if (!actionGroups) {
|
||||
panel.toggle(block);
|
||||
panel.toggle(block, 'input');
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -252,7 +263,7 @@ export function handleInlineAskAIAction(
|
||||
clear();
|
||||
};
|
||||
|
||||
panel.toggle(block);
|
||||
panel.toggle(block, 'input');
|
||||
|
||||
setTimeout(() => {
|
||||
abortController = new AbortController();
|
||||
|
||||
@@ -457,7 +457,7 @@ export function actionToHandler<T extends keyof BlockSuitePresets.AIActions>(
|
||||
|
||||
togglePanel()
|
||||
.then(isEmpty => {
|
||||
aiPanel.toggle(referenceElement, isEmpty ? undefined : '', false);
|
||||
aiPanel.toggle(referenceElement, isEmpty ? 'input' : 'generate');
|
||||
})
|
||||
.catch(console.error);
|
||||
};
|
||||
|
||||
@@ -333,20 +333,14 @@ export class AffineAIPanelWidget extends WidgetComponent {
|
||||
}
|
||||
};
|
||||
|
||||
toggle = (
|
||||
reference: Element,
|
||||
input?: string,
|
||||
shouldTriggerCallback?: boolean
|
||||
) => {
|
||||
if (typeof input === 'string') {
|
||||
this._inputText = input;
|
||||
toggle = (reference: Element, type: 'input' | 'generate') => {
|
||||
if (type === 'generate') {
|
||||
this._inputText = '';
|
||||
this.generate();
|
||||
} else {
|
||||
// reset state
|
||||
this.hide(shouldTriggerCallback);
|
||||
} else if (type === 'input') {
|
||||
this.hide();
|
||||
this.state = 'input';
|
||||
}
|
||||
|
||||
this._autoUpdatePosition(reference);
|
||||
};
|
||||
|
||||
|
||||
@@ -551,9 +551,11 @@ export class EditorUtils {
|
||||
explainImage: this.createAction(page, () =>
|
||||
page.getByTestId('action-explain-image').click()
|
||||
),
|
||||
generateImage: this.createAction(page, () =>
|
||||
page.getByTestId('action-generate-image').click()
|
||||
),
|
||||
generateImage: this.createAction(page, async () => {
|
||||
await page.getByTestId('action-generate-image').click();
|
||||
await page.keyboard.type('generate an image');
|
||||
await page.getByTestId('ai-panel-input-send').click();
|
||||
}),
|
||||
generateCaption: this.createAction(page, () =>
|
||||
page.getByTestId('action-generate-caption').click()
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user