+}
+
+export const detailsEditLabel: EditorButtonDefinition = {
+ label: 'Edit label',
+ icon: tagIcon,
+ action(context: EditorUiContext) {
+ context.editor.getEditorState().read(() => {
+ const details = $getNodeFromSelection($getSelection(), $isDetailsNode);
+ if ($isDetailsNode(details)) {
+ $showDetailsForm(details, context);
+ }
+ })
+ },
+ isActive(selection: BaseSelection | null): boolean {
+ return false;
+ }
+}
+
+export const detailsToggle: EditorButtonDefinition = {
+ label: 'Toggle open/closed',
+ icon: detailsToggleIcon,
+ action(context: EditorUiContext) {
+ context.editor.update(() => {
+ const details = $getNodeFromSelection($getSelection(), $isDetailsNode);
+ if ($isDetailsNode(details)) {
+ details.setOpen(!details.getOpen());
+ context.manager.triggerLayoutUpdate();
+ }
+ })
+ },
+ isActive(selection: BaseSelection | null): boolean {
+ return false;
+ }
+}
+
+export const detailsUnwrap: EditorButtonDefinition = {
+ label: 'Unwrap',
+ icon: tableDeleteIcon,
+ action(context: EditorUiContext) {
+ context.editor.update(() => {
+ const details = $getNodeFromSelection($getSelection(), $isDetailsNode);
+ if ($isDetailsNode(details)) {
+ const children = details.getChildren();
+ for (const child of children) {
+ details.insertBefore(child);
+ }
+ details.remove();
+ context.manager.triggerLayoutUpdate();
+ }
+ })
+ },
+ isActive(selection: BaseSelection | null): boolean {
+ return false;
+ }