mirror of
https://github.com/outline/outline.git
synced 2026-11-24 23:00:18 +03:00
* fix: prevent list conversion inside heading nodes Fixes a bug where typing list syntax (e.g., "1. ", "* ", "[ ]") inside heading nodes would incorrectly trigger list conversion. Previously, when a user selected H1 from the "/" menu and typed "1. " followed by a space, the OrderedList inputRule would attempt to convert the heading into an ordered list, causing a conflict since headings can only contain inline content. Changes: - Add isInHeading utility to detect if selection is inside a heading - Create safeWrappingInputRule wrapper that prevents list conversion when inside heading nodes - Apply the fix to OrderedList, BulletList, and CheckboxList nodes This ensures that list markdown syntax is preserved as plain text when typed within headings, matching expected editor behavior. * refactor: extract listWrappingInputRule to shared helper Refactored duplicated safeWrappingInputRule implementations across BulletList, OrderedList, and CheckboxList into a single shared helper function named listWrappingInputRule in shared/editor/lib/listInputRule.ts. This reduces code duplication and follows the same pattern as other input rule helpers like markInputRule. Changes: - Create shared/editor/lib/listInputRule.ts with listWrappingInputRule - Update BulletList.ts to use shared helper - Update OrderedList.ts to use shared helper - Update CheckboxList.ts to use shared helper - Restore .env.development file Co-Authored-By: huiseo <hui.seo@gmail.com>
19 lines
456 B
TypeScript
19 lines
456 B
TypeScript
import { EditorState } from "prosemirror-state";
|
|
import { isNodeActive } from "./isNodeActive";
|
|
|
|
/**
|
|
* Returns true if the selection is inside a heading node.
|
|
*
|
|
* @param state The editor state.
|
|
* @returns True if the selection is inside a heading node.
|
|
*/
|
|
export function isInHeading(state: EditorState): boolean {
|
|
const { nodes } = state.schema;
|
|
|
|
if (nodes.heading && isNodeActive(nodes.heading)(state)) {
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|