chore(editor): remove page block feature flag (#10251)
This commit is contained in:
@@ -36,7 +36,6 @@ import { property } from 'lit/decorators.js';
|
|||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
import { NoteConfigExtension } from '../config';
|
import { NoteConfigExtension } from '../config';
|
||||||
import { isPageBlock } from '../utils';
|
|
||||||
import * as styles from './edgeless-note-background.css';
|
import * as styles from './edgeless-note-background.css';
|
||||||
|
|
||||||
@requiredProperties({
|
@requiredProperties({
|
||||||
@@ -162,7 +161,7 @@ export class EdgelessNoteBackground extends SignalWatcher(
|
|||||||
@pointerdown=${stopPropagation}
|
@pointerdown=${stopPropagation}
|
||||||
@click=${this._handleClickAtBackground}
|
@click=${this._handleClickAtBackground}
|
||||||
>
|
>
|
||||||
${isPageBlock(this.std, this.note) ? this._renderHeader() : nothing}
|
${this.note.isPageBlock() ? this._renderHeader() : nothing}
|
||||||
</div>`;
|
</div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ import { html } from 'lit';
|
|||||||
import { property } from 'lit/decorators.js';
|
import { property } from 'lit/decorators.js';
|
||||||
|
|
||||||
import { NoteConfigExtension } from '../config';
|
import { NoteConfigExtension } from '../config';
|
||||||
import { isPageBlock } from '../utils';
|
|
||||||
import * as styles from './edgeless-page-block-title.css';
|
import * as styles from './edgeless-page-block-title.css';
|
||||||
|
|
||||||
@requiredProperties({
|
@requiredProperties({
|
||||||
@@ -22,7 +21,7 @@ export class EdgelessPageBlockTitle extends SignalWatcher(
|
|||||||
WithDisposable(ShadowlessElement)
|
WithDisposable(ShadowlessElement)
|
||||||
) {
|
) {
|
||||||
override render() {
|
override render() {
|
||||||
if (!isPageBlock(this.std, this.note)) return;
|
if (!this.note.isPageBlock()) return;
|
||||||
|
|
||||||
const title = this.std
|
const title = this.std
|
||||||
.getOptional(NoteConfigExtension.identifier)
|
.getOptional(NoteConfigExtension.identifier)
|
||||||
|
|||||||
@@ -6,4 +6,3 @@ export * from './note-block';
|
|||||||
export * from './note-edgeless-block';
|
export * from './note-edgeless-block';
|
||||||
export * from './note-service';
|
export * from './note-service';
|
||||||
export * from './note-spec';
|
export * from './note-spec';
|
||||||
export { isPageBlock } from './utils';
|
|
||||||
|
|||||||
@@ -12,10 +12,10 @@ import { ifDefined } from 'lit/directives/if-defined.js';
|
|||||||
import { styleMap } from 'lit/directives/style-map.js';
|
import { styleMap } from 'lit/directives/style-map.js';
|
||||||
|
|
||||||
import { MoreIndicator } from './components/more-indicator';
|
import { MoreIndicator } from './components/more-indicator';
|
||||||
|
import { NoteConfigExtension } from './config';
|
||||||
import { NoteBlockComponent } from './note-block';
|
import { NoteBlockComponent } from './note-block';
|
||||||
import { ACTIVE_NOTE_EXTRA_PADDING } from './note-edgeless-block.css';
|
import { ACTIVE_NOTE_EXTRA_PADDING } from './note-edgeless-block.css';
|
||||||
import * as styles from './note-edgeless-block.css';
|
import * as styles from './note-edgeless-block.css';
|
||||||
import { isPageBlock } from './utils';
|
|
||||||
|
|
||||||
export const AFFINE_EDGELESS_NOTE = 'affine-edgeless-note';
|
export const AFFINE_EDGELESS_NOTE = 'affine-edgeless-note';
|
||||||
|
|
||||||
@@ -219,6 +219,9 @@ export class EdgelessNoteBlockComponent extends toGfxBlockComponent(
|
|||||||
? this._noteFullHeight < height
|
? this._noteFullHeight < height
|
||||||
: !!collapsedHeight && collapsedHeight < height;
|
: !!collapsedHeight && collapsedHeight < height;
|
||||||
|
|
||||||
|
const hasHeader = !!this.std.getOptional(NoteConfigExtension.identifier)
|
||||||
|
?.edgelessNoteHeader;
|
||||||
|
|
||||||
return html`
|
return html`
|
||||||
<div
|
<div
|
||||||
class=${styles.edgelessNoteContainer}
|
class=${styles.edgelessNoteContainer}
|
||||||
@@ -260,7 +263,7 @@ export class EdgelessNoteBlockComponent extends toGfxBlockComponent(
|
|||||||
.editing=${this._editing}
|
.editing=${this._editing}
|
||||||
></edgeless-note-mask>
|
></edgeless-note-mask>
|
||||||
|
|
||||||
${isCollapsable && !isPageBlock(this.std, this.model)
|
${isCollapsable && (!this.model.isPageBlock() || !hasHeader)
|
||||||
? html`<div
|
? html`<div
|
||||||
class="${classMap({
|
class="${classMap({
|
||||||
[styles.collapseButton]: true,
|
[styles.collapseButton]: true,
|
||||||
|
|||||||
@@ -1,18 +0,0 @@
|
|||||||
import { NoteBlockModel, NoteDisplayMode } from '@blocksuite/affine-model';
|
|
||||||
import { FeatureFlagService } from '@blocksuite/affine-shared/services';
|
|
||||||
import { matchModels } from '@blocksuite/affine-shared/utils';
|
|
||||||
import type { BlockStdScope } from '@blocksuite/block-std';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* We define a note block as a page block if it is the first visible note
|
|
||||||
*/
|
|
||||||
export function isPageBlock(std: BlockStdScope, note: NoteBlockModel) {
|
|
||||||
return (
|
|
||||||
std.get(FeatureFlagService).getFlag('enable_page_block') &&
|
|
||||||
note.parent?.children.find(
|
|
||||||
child =>
|
|
||||||
matchModels(child, [NoteBlockModel]) &&
|
|
||||||
child.displayMode !== NoteDisplayMode.EdgelessOnly
|
|
||||||
) === note
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -154,4 +154,17 @@ export class NoteBlockModel
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* We define a note block as a page block if it is the first visible note
|
||||||
|
*/
|
||||||
|
isPageBlock() {
|
||||||
|
return (
|
||||||
|
this.parent?.children.find(
|
||||||
|
child =>
|
||||||
|
child instanceof NoteBlockModel &&
|
||||||
|
child.displayMode !== NoteDisplayMode.EdgelessOnly
|
||||||
|
) === this
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ export interface BlockSuiteFlags {
|
|||||||
enable_shape_shadow_blur: boolean;
|
enable_shape_shadow_blur: boolean;
|
||||||
enable_mobile_keyboard_toolbar: boolean;
|
enable_mobile_keyboard_toolbar: boolean;
|
||||||
enable_mobile_linked_doc_menu: boolean;
|
enable_mobile_linked_doc_menu: boolean;
|
||||||
enable_page_block: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export class FeatureFlagService extends StoreExtension {
|
export class FeatureFlagService extends StoreExtension {
|
||||||
@@ -41,7 +40,6 @@ export class FeatureFlagService extends StoreExtension {
|
|||||||
enable_shape_shadow_blur: false,
|
enable_shape_shadow_blur: false,
|
||||||
enable_mobile_keyboard_toolbar: false,
|
enable_mobile_keyboard_toolbar: false,
|
||||||
enable_mobile_linked_doc_menu: false,
|
enable_mobile_linked_doc_menu: false,
|
||||||
enable_page_block: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
setFlag(key: keyof BlockSuiteFlags, value: boolean) {
|
setFlag(key: keyof BlockSuiteFlags, value: boolean) {
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import {
|
|||||||
DocModeProvider,
|
DocModeProvider,
|
||||||
EditorSettingProvider,
|
EditorSettingProvider,
|
||||||
EditPropsStore,
|
EditPropsStore,
|
||||||
FeatureFlagService,
|
|
||||||
FontLoaderService,
|
FontLoaderService,
|
||||||
ThemeProvider,
|
ThemeProvider,
|
||||||
} from '@blocksuite/affine-shared/services';
|
} from '@blocksuite/affine-shared/services';
|
||||||
@@ -399,11 +398,7 @@ export class EdgelessRootBlockComponent extends BlockComponent<
|
|||||||
const run = () => {
|
const run = () => {
|
||||||
const storedViewport = std.get(EditPropsStore).getStorage('viewport');
|
const storedViewport = std.get(EditPropsStore).getStorage('viewport');
|
||||||
if (!storedViewport) {
|
if (!storedViewport) {
|
||||||
const enablePageBlock = this.std
|
if (!pageBlockViewportFitAnimation()) {
|
||||||
.get(FeatureFlagService)
|
|
||||||
.getFlag('enable_page_block');
|
|
||||||
|
|
||||||
if (!(enablePageBlock && pageBlockViewportFitAnimation())) {
|
|
||||||
this.gfx.fitToScreen();
|
this.gfx.fitToScreen();
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
changeNoteDisplayMode,
|
changeNoteDisplayMode,
|
||||||
isPageBlock,
|
NoteConfigExtension,
|
||||||
} from '@blocksuite/affine-block-note';
|
} from '@blocksuite/affine-block-note';
|
||||||
import { EdgelessCRUDIdentifier } from '@blocksuite/affine-block-surface';
|
import { EdgelessCRUDIdentifier } from '@blocksuite/affine-block-surface';
|
||||||
import type {
|
import type {
|
||||||
@@ -149,10 +149,6 @@ export class EdgelessChangeNoteButton extends WithDisposable(LitElement) {
|
|||||||
.getFlag('enable_advanced_block_visibility');
|
.getFlag('enable_advanced_block_visibility');
|
||||||
}
|
}
|
||||||
|
|
||||||
private get _pageBlockEnabled() {
|
|
||||||
return this.doc.get(FeatureFlagService).getFlag('enable_page_block');
|
|
||||||
}
|
|
||||||
|
|
||||||
private get doc() {
|
private get doc() {
|
||||||
return this.edgeless.doc;
|
return this.edgeless.doc;
|
||||||
}
|
}
|
||||||
@@ -348,6 +344,10 @@ export class EdgelessChangeNoteButton extends WithDisposable(LitElement) {
|
|||||||
const onlyOne = len === 1;
|
const onlyOne = len === 1;
|
||||||
const isDocOnly = displayMode === NoteDisplayMode.DocOnly;
|
const isDocOnly = displayMode === NoteDisplayMode.DocOnly;
|
||||||
|
|
||||||
|
const hasPageBlockHeader = !!this.edgeless.std.getOptional(
|
||||||
|
NoteConfigExtension.identifier
|
||||||
|
)?.edgelessNoteHeader;
|
||||||
|
|
||||||
const theme = this.edgeless.std.get(ThemeProvider).theme;
|
const theme = this.edgeless.std.get(ThemeProvider).theme;
|
||||||
const buttonIconSize = { width: '20px', height: '20px' };
|
const buttonIconSize = { width: '20px', height: '20px' };
|
||||||
const buttons = [
|
const buttons = [
|
||||||
@@ -378,10 +378,7 @@ export class EdgelessChangeNoteButton extends WithDisposable(LitElement) {
|
|||||||
`
|
`
|
||||||
: nothing,
|
: nothing,
|
||||||
|
|
||||||
onlyOne &&
|
onlyOne && !note.isPageBlock() && !this._advancedVisibilityEnabled
|
||||||
!isPageBlock(this.edgeless.std, note) &&
|
|
||||||
this._pageBlockEnabled &&
|
|
||||||
!this._advancedVisibilityEnabled
|
|
||||||
? html`<editor-icon-button
|
? html`<editor-icon-button
|
||||||
aria-label="Display In Page"
|
aria-label="Display In Page"
|
||||||
.showTooltip=${displayMode === NoteDisplayMode.DocAndEdgeless}
|
.showTooltip=${displayMode === NoteDisplayMode.DocAndEdgeless}
|
||||||
@@ -536,7 +533,7 @@ export class EdgelessChangeNoteButton extends WithDisposable(LitElement) {
|
|||||||
|
|
||||||
onlyOne ? this.quickConnectButton : nothing,
|
onlyOne ? this.quickConnectButton : nothing,
|
||||||
|
|
||||||
!isPageBlock(this.edgeless.std, this.notes[0])
|
!this.notes[0].isPageBlock() || !hasPageBlockHeader
|
||||||
? html`<editor-icon-button
|
? html`<editor-icon-button
|
||||||
aria-label="Size"
|
aria-label="Size"
|
||||||
data-testid="edgeless-note-auto-height"
|
data-testid="edgeless-note-auto-height"
|
||||||
|
|||||||
@@ -3,18 +3,13 @@ import { useSharingUrl } from '@affine/core/components/hooks/affine/use-share-ur
|
|||||||
import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
|
import { WorkspaceDialogService } from '@affine/core/modules/dialogs';
|
||||||
import { DocService } from '@affine/core/modules/doc';
|
import { DocService } from '@affine/core/modules/doc';
|
||||||
import { EditorService } from '@affine/core/modules/editor';
|
import { EditorService } from '@affine/core/modules/editor';
|
||||||
import { FeatureFlagService } from '@affine/core/modules/feature-flag';
|
|
||||||
import { useInsidePeekView } from '@affine/core/modules/peek-view/view/modal-container';
|
import { useInsidePeekView } from '@affine/core/modules/peek-view/view/modal-container';
|
||||||
import { WorkspaceService } from '@affine/core/modules/workspace';
|
import { WorkspaceService } from '@affine/core/modules/workspace';
|
||||||
import { extractEmojiIcon } from '@affine/core/utils';
|
import { extractEmojiIcon } from '@affine/core/utils';
|
||||||
import { useI18n } from '@affine/i18n';
|
import { useI18n } from '@affine/i18n';
|
||||||
import { track } from '@affine/track';
|
import { track } from '@affine/track';
|
||||||
import { GfxControllerIdentifier } from '@blocksuite/affine/block-std/gfx';
|
import { GfxControllerIdentifier } from '@blocksuite/affine/block-std/gfx';
|
||||||
import {
|
import { type NoteBlockModel } from '@blocksuite/affine/blocks';
|
||||||
matchModels,
|
|
||||||
NoteBlockModel,
|
|
||||||
NoteDisplayMode,
|
|
||||||
} from '@blocksuite/affine/blocks';
|
|
||||||
import { Bound } from '@blocksuite/affine/global/utils';
|
import { Bound } from '@blocksuite/affine/global/utils';
|
||||||
import {
|
import {
|
||||||
InformationIcon,
|
InformationIcon,
|
||||||
@@ -184,19 +179,9 @@ const LinkButton = ({ note }: { note: NoteBlockModel }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const EdgelessNoteHeader = ({ note }: { note: NoteBlockModel }) => {
|
export const EdgelessNoteHeader = ({ note }: { note: NoteBlockModel }) => {
|
||||||
const flags = useService(FeatureFlagService).flags;
|
|
||||||
const insidePeekView = useInsidePeekView();
|
const insidePeekView = useInsidePeekView();
|
||||||
|
|
||||||
if (!flags.enable_page_block) return null;
|
if (!note.isPageBlock()) return null;
|
||||||
|
|
||||||
const isFirstVisibleNote =
|
|
||||||
note.parent?.children.find(
|
|
||||||
child =>
|
|
||||||
matchModels(child, [NoteBlockModel]) &&
|
|
||||||
child.displayMode === NoteDisplayMode.DocAndEdgeless
|
|
||||||
) === note;
|
|
||||||
|
|
||||||
if (!isFirstVisibleNote) return null;
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.header} data-testid="edgeless-page-block-header">
|
<div className={styles.header} data-testid="edgeless-page-block-header">
|
||||||
|
|||||||
@@ -231,17 +231,6 @@ export const AFFINE_FLAGS = {
|
|||||||
configurable: true,
|
configurable: true,
|
||||||
defaultState: isCanaryBuild,
|
defaultState: isCanaryBuild,
|
||||||
},
|
},
|
||||||
// TODO(@L-Sun): remove this flag when ready
|
|
||||||
enable_page_block: {
|
|
||||||
category: 'blocksuite',
|
|
||||||
bsFlag: 'enable_page_block',
|
|
||||||
displayName:
|
|
||||||
'com.affine.settings.workspace.experimental-features.enable-page-block-header.name',
|
|
||||||
description:
|
|
||||||
'com.affine.settings.workspace.experimental-features.enable-page-block-header.description',
|
|
||||||
configurable: isCanaryBuild,
|
|
||||||
defaultState: isCanaryBuild,
|
|
||||||
},
|
|
||||||
enable_editor_rtl: {
|
enable_editor_rtl: {
|
||||||
category: 'affine',
|
category: 'affine',
|
||||||
displayName:
|
displayName:
|
||||||
|
|||||||
@@ -5437,14 +5437,6 @@ export function useAFFiNEI18N(): {
|
|||||||
* `Once enabled, you can preview PDF in embed view.`
|
* `Once enabled, you can preview PDF in embed view.`
|
||||||
*/
|
*/
|
||||||
["com.affine.settings.workspace.experimental-features.enable-pdf-embed-preview.description"](): string;
|
["com.affine.settings.workspace.experimental-features.enable-pdf-embed-preview.description"](): string;
|
||||||
/**
|
|
||||||
* `Page Block Header`
|
|
||||||
*/
|
|
||||||
["com.affine.settings.workspace.experimental-features.enable-page-block-header.name"](): string;
|
|
||||||
/**
|
|
||||||
* `Once enabled, the header of page block will be displayed.`
|
|
||||||
*/
|
|
||||||
["com.affine.settings.workspace.experimental-features.enable-page-block-header.description"](): string;
|
|
||||||
/**
|
/**
|
||||||
* `Editor RTL`
|
* `Editor RTL`
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -1357,8 +1357,6 @@
|
|||||||
"com.affine.settings.workspace.experimental-features.enable-mobile-edgeless-editing.description": "Once enabled, users can edit edgeless canvas.",
|
"com.affine.settings.workspace.experimental-features.enable-mobile-edgeless-editing.description": "Once enabled, users can edit edgeless canvas.",
|
||||||
"com.affine.settings.workspace.experimental-features.enable-pdf-embed-preview.name": "PDF embed preview",
|
"com.affine.settings.workspace.experimental-features.enable-pdf-embed-preview.name": "PDF embed preview",
|
||||||
"com.affine.settings.workspace.experimental-features.enable-pdf-embed-preview.description": "Once enabled, you can preview PDF in embed view.",
|
"com.affine.settings.workspace.experimental-features.enable-pdf-embed-preview.description": "Once enabled, you can preview PDF in embed view.",
|
||||||
"com.affine.settings.workspace.experimental-features.enable-page-block-header.name": "Page Block Header",
|
|
||||||
"com.affine.settings.workspace.experimental-features.enable-page-block-header.description": "Once enabled, the header of page block will be displayed.",
|
|
||||||
"com.affine.settings.workspace.experimental-features.enable-editor-rtl.name": "Editor RTL",
|
"com.affine.settings.workspace.experimental-features.enable-editor-rtl.name": "Editor RTL",
|
||||||
"com.affine.settings.workspace.experimental-features.enable-editor-rtl.description": "Once enabled, the editor will be displayed in RTL mode.",
|
"com.affine.settings.workspace.experimental-features.enable-editor-rtl.description": "Once enabled, the editor will be displayed in RTL mode.",
|
||||||
"com.affine.settings.workspace.not-owner": "Only an owner can edit the workspace avatar and name. Changes will be shown for everyone.",
|
"com.affine.settings.workspace.not-owner": "Only an owner can edit the workspace avatar and name. Changes will be shown for everyone.",
|
||||||
|
|||||||
Reference in New Issue
Block a user