Skip to content

Commit

Permalink
Add typedoc-plugin-rename-defaults and start updating docs
Browse files Browse the repository at this point in the history
  • Loading branch information
etrepum committed May 9, 2024
1 parent 4714f92 commit 0756b25
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 2 deletions.
39 changes: 39 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ describe('LexicalComposer tests', () => {
});
expect(editors.size).toBe(size);
[...editors].forEach((editor, i) => {
// This confirms that editorState() was only called once per editor,
// otherwise you could see 'initial stateinitial state'.
expect([
i,
editor.getEditorState().read(() => $getRoot().getTextContent()),
Expand Down
8 changes: 8 additions & 0 deletions packages/lexical-react/src/useLexicalEditable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ function subscription(editor: LexicalEditor): LexicalSubscription<boolean> {
};
}

/**
* Get the current value for {@link LexicalEditor.isEditable}
* using {@link useLexicalSubscription}.
* You should prefer this over manually observing the value with
* {@link LexicalEditor.registerEditableListener},
* which is a bit tricky to do correctly, particularly when using
* React StrictMode (the default for development) or concurrency.
*/
export default function useLexicalEditable(): boolean {
return useLexicalSubscription(subscription);
}
1 change: 1 addition & 0 deletions packages/lexical-react/src/useLexicalSubscription.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export type LexicalSubscription<T> = {

/**
* Shortcut to Lexical subscriptions when values are used for render.
* @param subscription - The function to create the {@link LexicalSubscription}. This function's identity must be stable (e.g. defined at module scope or with useCallback).
*/
export default function useLexicalSubscription<T>(
subscription: (editor: LexicalEditor) => LexicalSubscription<T>,
Expand Down
1 change: 1 addition & 0 deletions packages/lexical-website/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ const docusaurusPluginTypedocConfig = {
plugin: [
'./src/plugins/lexical-typedoc-plugin-no-inherit',
'./src/plugins/lexical-typedoc-plugin-module-name',
'typedoc-plugin-rename-defaults',
],
sidebar: {
autoConfiguration: false,
Expand Down
1 change: 1 addition & 0 deletions packages/lexical-website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"react-dom": "^18.2.0",
"remark-import-partial": "^0.0.2",
"typedoc-plugin-markdown": "^3.17.1",
"typedoc-plugin-rename-defaults": "^0.7.0",
"unist-util-visit": "^5.0.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@
* LICENSE file in the root directory of this source tree.
*
*/
// @ts-check
const typedoc = require('typedoc');

exports.load = function (/** @type typedoc.Application */ app) {
exports.load = function (/** @type {import('typedoc').Application} */ app) {
app.converter.on(
typedoc.Converter.EVENT_RESOLVE_BEGIN,
(/** @type typedoc.Context */ context) => {
(/** @type {import('typedoc').Context} */ context) => {
context.project
.getReflectionsByKind(typedoc.ReflectionKind.Module)
.forEach((reflection) => {
Expand Down

0 comments on commit 0756b25

Please sign in to comment.