-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Lexical: Added base context toolbar logic
- Loading branch information
1 parent
517c578
commit c9a03c5
Showing
4 changed files
with
106 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import {EditorContainerUiElement, EditorUiElement} from "./core"; | ||
import {el} from "../../helpers"; | ||
|
||
export type EditorContextToolbarDefinition = { | ||
selector: string; | ||
content: EditorUiElement[], | ||
displayTargetLocator?: (originalTarget: HTMLElement) => HTMLElement; | ||
}; | ||
|
||
export class EditorContextToolbar extends EditorContainerUiElement { | ||
|
||
protected buildDOM(): HTMLElement { | ||
return el('div', { | ||
class: 'editor-context-toolbar', | ||
}, this.getChildren().map(child => child.getDOMElement())); | ||
} | ||
|
||
attachTo(target: HTMLElement) { | ||
// Todo - attach to target position | ||
console.log('attaching context toolbar to', target); | ||
} | ||
|
||
insert(children: EditorUiElement[]) { | ||
this.addChildren(...children); | ||
const dom = this.getDOMElement(); | ||
dom.append(...children.map(child => child.getDOMElement())); | ||
} | ||
|
||
empty() { | ||
const children = this.getChildren(); | ||
for (const child of children) { | ||
child.getDOMElement().remove(); | ||
} | ||
this.removeChildren(...children); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters