-
Notifications
You must be signed in to change notification settings - Fork 326
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#### New documentation panel: - Shows documentation of currently-entered method. - Open/close with Ctrl+D or the extended menu. - Renders markdown; supports WYSIWYG editing. - Formatting can be added by typing the same markdown special characters that will appear in the source code, e.g.: - `# Heading` - `## Subheading` - `*emphasis*` - Panel left edge can be dragged to resize similarly to visualization container. https://github.com/enso-org/enso/assets/1047859/6feb5d23-1525-48f7-933e-c9371312decf #### Node comments are now markdown:  #### Top bar extended menu improvements: - Now closes after any menu action except +/- buttons, and on defocus/Esc. - Editor/doc-panel buttons now colored to indicate whether editor/panel is open. https://github.com/enso-org/enso/assets/1047859/345af322-c1a8-4717-8ffc-a5c919494fed Closes #9786. # Important Notes New APIs: - `DocumentationEditor` component: Lazily-loads and instantiates the implementation component (`MilkdownEditor`). - `AstDocumentation` component: Connects a `DocumentationEditor` to the documentation of an `Ast` node. - `ResizeHandles` component: Supports reuse of the resize handles used by the visualization container. - `graphStore.undoManager`: Facade for the Y.UndoManager in the project store.
- Loading branch information
Showing
28 changed files
with
1,862 additions
and
384 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { expect, test } from 'playwright/test' | ||
import * as actions from './actions' | ||
import { CONTROL_KEY } from './keyboard' | ||
|
||
test('Main method documentation', async ({ page }) => { | ||
await actions.goToGraph(page) | ||
|
||
// Documentation panel hotkey opens right-dock. | ||
await expect(page.getByTestId('rightDock')).not.toBeVisible() | ||
await page.keyboard.press(`${CONTROL_KEY}+D`) | ||
await expect(page.getByTestId('rightDock')).toBeVisible() | ||
|
||
// Right-dock displays main method documentation. | ||
await expect(page.getByTestId('rightDock')).toHaveText('The main method') | ||
|
||
// Documentation hotkey closes right-dock.p | ||
await page.keyboard.press(`${CONTROL_KEY}+D`) | ||
await expect(page.getByTestId('rightDock')).not.toBeVisible() | ||
}) |
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
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
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,44 @@ | ||
<script setup lang="ts"> | ||
import DocumentationEditor from '@/components/DocumentationEditor.vue' | ||
import { useGraphStore } from '@/stores/graph' | ||
import { Ast } from '@/util/ast' | ||
import { computed } from 'vue' | ||
const editing = defineModel<boolean>('editing', { default: false }) | ||
const props = defineProps<{ | ||
ast: Ast.Ast | undefined | ||
/** If provided, this property will be read to obtain the current documentation text instead of finding it in the AST. | ||
* This can be used to reduce reactive dependencies. */ | ||
documentation?: string | ||
/** If set, the Enter key will end editing instead of inserting a newline, unless the Shift key is held. */ | ||
preferSingleLine?: boolean | undefined | ||
}>() | ||
const graphStore = useGraphStore() | ||
const documentation = computed({ | ||
get: () => | ||
props?.documentation != null ? | ||
props.documentation | ||
: props.ast?.documentingAncestor()?.documentation() ?? '', | ||
set: (value) => { | ||
const ast = props.ast | ||
if (!ast) return | ||
if (value.trimStart() !== '') { | ||
graphStore.edit((edit) => | ||
edit.getVersion(ast).getOrInitDocumentation().setDocumentationText(value), | ||
) | ||
} else { | ||
// Remove the documentation node. | ||
const documented = props.ast?.documentingAncestor() | ||
if (documented && documented.expression) | ||
graphStore.edit((edit) => | ||
edit.getVersion(documented).update((documented) => documented.expression!.take()), | ||
) | ||
} | ||
}, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<DocumentationEditor v-model="documentation" v-model:editing="editing" :preferSingleLine /> | ||
</template> |
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
File renamed without changes.
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,26 @@ | ||
<script setup lang="ts"> | ||
import { MilkdownProvider } from '@milkdown/vue' | ||
import { defineAsyncComponent } from 'vue' | ||
const documentation = defineModel<string>({ required: true }) | ||
const editing = defineModel<boolean>('editing', { default: false }) | ||
const props = defineProps<{ | ||
preferSingleLine?: boolean | undefined | ||
}>() | ||
const LazyMilkdownEditor = defineAsyncComponent( | ||
() => import('@/components/DocumentationEditor/MilkdownEditor.vue'), | ||
) | ||
</script> | ||
|
||
<template> | ||
<Suspense> | ||
<MilkdownProvider> | ||
<LazyMilkdownEditor | ||
v-model="documentation" | ||
v-model:editing="editing" | ||
:preferSingleLine="props.preferSingleLine" | ||
/> | ||
</MilkdownProvider> | ||
</Suspense> | ||
</template> |
Oops, something went wrong.