Skip to content

Commit 9bc95b9

Browse files
author
kyrylo.kireiev
committed
docs: [AILab-146] Improve quality of description
1 parent ea61e5b commit 9bc95b9

8 files changed

Lines changed: 49 additions & 8 deletions

File tree

src/plugin-slots/ProblemEditorPluginSlot/README.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,26 @@ It is a **generic extension point** that can host any React component, such as:
2929
Your component is responsible for interacting with the editor state (if needed) using
3030
Redux, `window.tinymce`, CodeMirror, or other utilities provided by `frontend-app-authoring`.
3131

32+
#### Interacting with Editor State (Reading State from Redux)
33+
34+
```jsx
35+
import { useSelector } from 'react-redux';
36+
import { selectors } from 'CourseAuthoring/editors/data/redux';
37+
38+
const MyComponent = ({ blockType }) => {
39+
// Read problem state
40+
const problemState = useSelector(selectors.problem.completeState);
41+
const learningContextId = useSelector(selectors.app.learningContextId);
42+
const showRawEditor = useSelector(selectors.app.showRawEditor);
43+
44+
// Access problem data
45+
const question = problemState?.question || '';
46+
const answers = problemState?.answers || [];
47+
48+
return <div>Question: {question}</div>;
49+
};
50+
```
51+
3252
## Examples
3353
3454
### Default content
-62.9 KB
Loading
-35.6 KB
Loading
-55.2 KB
Loading

src/plugin-slots/TextEditorPluginSlot/README.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,44 @@
1111

1212
## Description
1313

14-
The `TextEditorPluginSlot` is rendered inside the Text Editor modal window for HTML XBlocks.
14+
The `TextEditorPluginSlot` is rendered inside the Text Editor modal window for HTML XBlocks.
15+
By default, the slot is **empty**.
1516
It is intended as a generic extension point that can host **any React component** – for example:
1617

1718
- **Contextual helpers** (tips, validation messages, writing guides)
1819
- **Content utilities** (templates, reusable snippets, glossary insert tools)
1920
- **Integrations** (linking to external systems, analytics, metadata editors)
2021

21-
By default, the slot is **empty**. Widgets are attached via `env.config.jsx` using the
22-
`@openedx/frontend-plugin-framework`.
23-
24-
The only prop your component receives from the slot is:
25-
26-
- `blockType` – the current editor block type (for this slot it will typically be `html`).
27-
2822
Your component is responsible for interacting with the editor (if needed) using Redux state,
2923
DOM APIs, or other utilities provided by `frontend-app-authoring`.
3024

25+
#### Interacting with Editor State
26+
27+
```jsx
28+
import { useSelector } from 'react-redux';
29+
import { selectors } from 'CourseAuthoring/editors/data/redux';
30+
31+
const MyComponent = ({ blockType }) => {
32+
// Read editor state
33+
const showRawEditor = useSelector(selectors.app.showRawEditor);
34+
const blockValue = useSelector(selectors.app.blockValue);
35+
36+
// Update CodeMirror (raw editor)
37+
const updateRawContent = (content) => {
38+
const cm = document.querySelector('.CodeMirror')?.CodeMirror;
39+
if (cm?.dispatch) {
40+
cm.dispatch(cm.state.update({
41+
changes: { from: 0, to: cm.state.doc.length, insert: content }
42+
}));
43+
}
44+
};
45+
46+
return <button onClick={() => showRawEditor ? updateRawContent('<p>New content</p>') : updateContent('<p>New content</p>')}>
47+
Update Editor
48+
</button>;
49+
};
50+
```
51+
3152
## Examples
3253
3354
### Default content
-45.4 KB
Loading
-74 KB
Loading
-74.3 KB
Loading

0 commit comments

Comments
 (0)