Merge pull request #302 from toeverything/refactor/variable
refactor: change activatable to editable in BaseVeiw
This commit is contained in:
@@ -16,7 +16,7 @@ import { ComponentType } from 'react';
|
|||||||
export class CodeBlock extends BaseView {
|
export class CodeBlock extends BaseView {
|
||||||
type = Protocol.Block.Type.code;
|
type = Protocol.Block.Type.code;
|
||||||
public override selectable = true;
|
public override selectable = true;
|
||||||
public override activatable = false;
|
public override editable = false;
|
||||||
// View = CodeView;
|
// View = CodeView;
|
||||||
View = CodeView;
|
View = CodeView;
|
||||||
override async onCreate(block: AsyncBlock): Promise<AsyncBlock> {
|
override async onCreate(block: AsyncBlock): Promise<AsyncBlock> {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { EmbedLinkView } from './EmbedLinkView';
|
|||||||
|
|
||||||
export class EmbedLinkBlock extends BaseView {
|
export class EmbedLinkBlock extends BaseView {
|
||||||
public override selectable = true;
|
public override selectable = true;
|
||||||
public override activatable = false;
|
public override editable = false;
|
||||||
type = Protocol.Block.Type.embedLink;
|
type = Protocol.Block.Type.embedLink;
|
||||||
View = EmbedLinkView;
|
View = EmbedLinkView;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { FigmaView } from './FigmaView';
|
|||||||
|
|
||||||
export class FigmaBlock extends BaseView {
|
export class FigmaBlock extends BaseView {
|
||||||
public override selectable = true;
|
public override selectable = true;
|
||||||
public override activatable = false;
|
public override editable = false;
|
||||||
type = Protocol.Block.Type.figma;
|
type = Protocol.Block.Type.figma;
|
||||||
View = FigmaView;
|
View = FigmaView;
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import { FileView } from './FileView';
|
|||||||
|
|
||||||
export class FileBlock extends BaseView {
|
export class FileBlock extends BaseView {
|
||||||
public override selectable = true;
|
public override selectable = true;
|
||||||
public override activatable = false;
|
public override editable = false;
|
||||||
type = Protocol.Block.Type.file;
|
type = Protocol.Block.Type.file;
|
||||||
View = FileView;
|
View = FileView;
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { GridItemRender } from './GridItemRender';
|
|||||||
|
|
||||||
export class GridItemBlock extends BaseView {
|
export class GridItemBlock extends BaseView {
|
||||||
public override selectable = false;
|
public override selectable = false;
|
||||||
public override activatable = false;
|
public override editable = false;
|
||||||
public override allowPendant = false;
|
public override allowPendant = false;
|
||||||
public override layoutOnly = true;
|
public override layoutOnly = true;
|
||||||
|
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export { GRID_PROPERTY_KEY, removePercent } from './Grid';
|
|||||||
|
|
||||||
export class GridBlock extends BaseView {
|
export class GridBlock extends BaseView {
|
||||||
public override selectable = false;
|
public override selectable = false;
|
||||||
public override activatable = false;
|
public override editable = false;
|
||||||
public override allowPendant = false;
|
public override allowPendant = false;
|
||||||
public override layoutOnly = true;
|
public override layoutOnly = true;
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ import { GroupView } from './GroupView';
|
|||||||
|
|
||||||
export class Group extends BaseView {
|
export class Group extends BaseView {
|
||||||
public override selectable = true;
|
public override selectable = true;
|
||||||
public override activatable = false;
|
public override editable = false;
|
||||||
public override allowPendant = false;
|
public override allowPendant = false;
|
||||||
|
|
||||||
type = Protocol.Block.Type.group;
|
type = Protocol.Block.Type.group;
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { ImageView } from './ImageView';
|
|||||||
|
|
||||||
export class ImageBlock extends BaseView {
|
export class ImageBlock extends BaseView {
|
||||||
public override selectable = true;
|
public override selectable = true;
|
||||||
public override activatable = false;
|
public override editable = false;
|
||||||
type = Protocol.Block.Type.image;
|
type = Protocol.Block.Type.image;
|
||||||
View = ImageView;
|
View = ImageView;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import { YoutubeView } from './YoutubeView';
|
|||||||
|
|
||||||
export class YoutubeBlock extends BaseView {
|
export class YoutubeBlock extends BaseView {
|
||||||
public override selectable = true;
|
public override selectable = true;
|
||||||
public override activatable = false;
|
public override editable = false;
|
||||||
type = Protocol.Block.Type.youtube;
|
type = Protocol.Block.Type.youtube;
|
||||||
View = YoutubeView;
|
View = YoutubeView;
|
||||||
|
|
||||||
|
|||||||
@@ -408,13 +408,13 @@ export class SelectionManager implements VirgoSelection {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* get previous activatable blockNode
|
* get previous editable blockNode
|
||||||
* @private
|
* @private
|
||||||
* @param {AsyncBlock} node
|
* @param {AsyncBlock} node
|
||||||
* @return {*} {(Promise<AsyncBlock | null>)}
|
* @return {*} {(Promise<AsyncBlock | null>)}
|
||||||
* @memberof SelectionManager
|
* @memberof SelectionManager
|
||||||
*/
|
*/
|
||||||
private async _getPreviousActivatableBlockNode(
|
private async _getPreviousEditableBlockNode(
|
||||||
node: AsyncBlock
|
node: AsyncBlock
|
||||||
): Promise<AsyncBlock | null> {
|
): Promise<AsyncBlock | null> {
|
||||||
const preNode = await node.physicallyPerviousSibling();
|
const preNode = await node.physicallyPerviousSibling();
|
||||||
@@ -422,8 +422,8 @@ export class SelectionManager implements VirgoSelection {
|
|||||||
if (!preNode) {
|
if (!preNode) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
const { activatable, selectable } = this._editor.getView(preNode.type);
|
const { editable, selectable } = this._editor.getView(preNode.type);
|
||||||
if (activatable) {
|
if (editable) {
|
||||||
this.setSelectedNodesIds([]);
|
this.setSelectedNodesIds([]);
|
||||||
return preNode;
|
return preNode;
|
||||||
}
|
}
|
||||||
@@ -432,18 +432,18 @@ export class SelectionManager implements VirgoSelection {
|
|||||||
(document.activeElement as HTMLInputElement)?.blur();
|
(document.activeElement as HTMLInputElement)?.blur();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return this._getPreviousActivatableBlockNode(preNode);
|
return this._getPreviousEditableBlockNode(preNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* get next activatable blockNode
|
* get next editable blockNode
|
||||||
* @private
|
* @private
|
||||||
* @param {AsyncBlock} node
|
* @param {AsyncBlock} node
|
||||||
* @return {*} {(Promise<AsyncBlock | null>)}
|
* @return {*} {(Promise<AsyncBlock | null>)}
|
||||||
* @memberof SelectionManager
|
* @memberof SelectionManager
|
||||||
*/
|
*/
|
||||||
private async _getNextActivatableBlockNode(
|
private async _getNextEditableBlockNode(
|
||||||
node: AsyncBlock,
|
node: AsyncBlock,
|
||||||
ignoreSelf = true
|
ignoreSelf = true
|
||||||
): Promise<AsyncBlock | null> {
|
): Promise<AsyncBlock | null> {
|
||||||
@@ -482,8 +482,8 @@ export class SelectionManager implements VirgoSelection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const { activatable, selectable } = this._editor.getView(nextNode.type);
|
const { editable, selectable } = this._editor.getView(nextNode.type);
|
||||||
if (activatable) {
|
if (editable) {
|
||||||
this.setSelectedNodesIds([]);
|
this.setSelectedNodesIds([]);
|
||||||
return nextNode;
|
return nextNode;
|
||||||
}
|
}
|
||||||
@@ -492,7 +492,7 @@ export class SelectionManager implements VirgoSelection {
|
|||||||
(document.activeElement as HTMLInputElement)?.blur();
|
(document.activeElement as HTMLInputElement)?.blur();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return this._getNextActivatableBlockNode(nextNode);
|
return this._getNextEditableBlockNode(nextNode);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -513,7 +513,7 @@ export class SelectionManager implements VirgoSelection {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
preNode = await this._getPreviousActivatableBlockNode(node);
|
preNode = await this._getPreviousEditableBlockNode(node);
|
||||||
if (preNode) {
|
if (preNode) {
|
||||||
this.activeNodeByNodeId(preNode.id, position);
|
this.activeNodeByNodeId(preNode.id, position);
|
||||||
}
|
}
|
||||||
@@ -622,7 +622,7 @@ export class SelectionManager implements VirgoSelection {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nextNode = await this._getNextActivatableBlockNode(node);
|
nextNode = await this._getNextEditableBlockNode(node);
|
||||||
if (nextNode) {
|
if (nextNode) {
|
||||||
this.activeNodeByNodeId(nextNode.id, position);
|
this.activeNodeByNodeId(nextNode.id, position);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,10 +36,10 @@ export abstract class BaseView {
|
|||||||
abstract type: string;
|
abstract type: string;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* activatable means can be focused
|
* editable means can be focused
|
||||||
* @memberof BaseView
|
* @memberof BaseView
|
||||||
*/
|
*/
|
||||||
public activatable = true;
|
public editable = true;
|
||||||
|
|
||||||
public selectable = true;
|
public selectable = true;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user