@udecode/plate-indent-list
Advanced tools
Comparing version 31.2.0 to 31.2.2
import * as _udecode_plate_core from '@udecode/plate-core'; | ||
import * as _udecode_slate from '@udecode/slate'; | ||
import { EElement, Value, TNodeEntry, EElementOrText, TNode, TEditor, EElementEntry, TElement, PlateEditor, InjectComponentProps, InjectComponentReturnType, ENodeEntry, WithPlatePlugin, KeyboardHandlerReturnType } from '@udecode/plate-common'; | ||
import { EElement, Value, TNodeEntry, EElementOrText, TNode, TEditor, EElementEntry, PlateRenderElementProps, TElement, InjectComponentProps, InjectComponentReturnType, ENodeEntry, PlateEditor, WithPlatePlugin, KeyboardHandlerReturnType } from '@udecode/plate-common'; | ||
import { SetIndentOptions } from '@udecode/plate-indent'; | ||
@@ -29,10 +29,35 @@ import { Path } from 'slate'; | ||
declare enum ListStyleType { | ||
Armenian = "armenian", | ||
Circle = "circle", | ||
CjkIdeographic = "cjk-ideographic", | ||
Decimal = "decimal", | ||
DecimalLeadingZero = "decimal-leading-zero", | ||
Disc = "disc", | ||
ArabicIndic = "arabic-indic", | ||
Armenian = "armenian", | ||
UpperArmenian = "upper-armenian", | ||
LowerArmenian = "lower-armenian", | ||
Bengali = "bengali", | ||
Cambodian = "cambodian", | ||
Khmer = "khmer", | ||
CjkDecimal = "cjk-decimal", | ||
Devanagari = "devanagari", | ||
Georgian = "georgian", | ||
Gujarati = "gujarati", | ||
Gurmukhi = "gurmukhi", | ||
Hebrew = "hebrew", | ||
Kannada = "kannada", | ||
Lao = "lao", | ||
Malayalam = "malayalam", | ||
Mongolian = "mongolian", | ||
Myanmar = "myanmar", | ||
Oriya = "oriya", | ||
Persian = "persian", | ||
LowerRoman = "lower-roman", | ||
UpperRoman = "upper-roman", | ||
Tamil = "tamil", | ||
Telugu = "telugu", | ||
Thai = "thai", | ||
Tibetan = "tibetan", | ||
LowerAlpha = "lower-alpha", | ||
LowerLatin = "lower-latin", | ||
UpperAlpha = "upper-alpha", | ||
UpperLatin = "upper-latin", | ||
LowerGreek = "lower-greek", | ||
Hiragana = "hiragana", | ||
@@ -42,23 +67,24 @@ HiraganaIroha = "hiragana-iroha", | ||
KatakanaIroha = "katakana-iroha", | ||
LowerAlpha = "lower-alpha", | ||
LowerGreek = "lower-greek", | ||
LowerLatin = "lower-latin", | ||
LowerRoman = "lower-roman", | ||
CjkEarthlyBranch = "cjk-earthly-branch", | ||
CjkHeavenlyStem = "cjk-heavenly-stem", | ||
JapaneseInformal = "japanese-informal", | ||
JapaneseFormal = "japanese-formal", | ||
KoreanHangulFormal = "korean-hangul-formal", | ||
KoreanHanjaInformal = "korean-hanja-informal", | ||
KoreanHanjaFormal = "korean-hanja-formal", | ||
SimpChineseInformal = "simp-chinese-informal", | ||
SimpChineseFormal = "simp-chinese-formal", | ||
TradChineseInformal = "trad-chinese-informal", | ||
TradChineseFormal = "trad-chinese-formal", | ||
EthiopicNumeric = "ethiopic-numeric", | ||
DisclosureOpen = "disclosure-open", | ||
DisclosureClosed = "disclosure-closed", | ||
None = "none", | ||
Circle = "circle", | ||
Disc = "disc", | ||
Square = "square", | ||
UpperAlpha = "upper-alpha", | ||
UpperLatin = "upper-latin", | ||
UpperRoman = "upper-roman", | ||
Initial = "initial", | ||
Inherit = "inherit" | ||
} | ||
interface LiComponentProps { | ||
element: TElement; | ||
children: any; | ||
} | ||
interface MarkerComponentProps { | ||
onChange?: (checked: boolean) => void; | ||
element: TElement; | ||
editor: PlateEditor<Value>; | ||
} | ||
declare const ULIST_STYLE_TYPES: readonly [ListStyleType.Disc, ListStyleType.Circle, ListStyleType.Square, ListStyleType.DisclosureOpen, ListStyleType.DisclosureClosed]; | ||
@@ -70,2 +96,4 @@ declare const KEY_LIST_STYLE_TYPE = "listStyleType"; | ||
declare const KEY_TODO_STYLE_TYPE = "todo"; | ||
type MarkerFC = React.FC<Omit<PlateRenderElementProps, 'children'>>; | ||
type LiFC = React.FC<PlateRenderElementProps>; | ||
interface IndentListPlugin { | ||
@@ -79,5 +107,5 @@ getSiblingIndentListOptions?: GetSiblingIndentListOptions<TElement>; | ||
type: string; | ||
markerComponent?: React.FC<MarkerComponentProps>; | ||
liComponent?: React.FC<LiComponentProps>; | ||
isNumbered?: boolean; | ||
markerComponent?: MarkerFC; | ||
liComponent?: LiFC; | ||
isOrdered?: boolean; | ||
}>; | ||
@@ -87,3 +115,3 @@ } | ||
declare const injectIndentListComponent: (props: InjectComponentProps) => InjectComponentReturnType; | ||
declare const injectIndentListComponent: (injectProps: InjectComponentProps) => InjectComponentReturnType; | ||
@@ -227,2 +255,2 @@ declare const normalizeIndentList: <V extends Value>(editor: TEditor<V>, { getSiblingIndentListOptions }?: IndentListPlugin) => ([node, path]: ENodeEntry<V>) => void; | ||
export { type GetIndentListSiblingsOptions, type GetSiblingIndentListOptions, type IndentListOptions, type IndentListPlugin, KEY_LIST_CHECKED, KEY_LIST_RESTART, KEY_LIST_START, KEY_LIST_STYLE_TYPE, KEY_TODO_STYLE_TYPE, type LiComponentProps, ListStyleType, type MarkerComponentProps, areEqListStyleType, createIndentListPlugin, getIndentListSiblings, getNextIndentList, getPreviousIndentList, getSiblingIndentList, getSiblingListStyleType, indentList, indentTodo, injectIndentListComponent, normalizeFirstIndentListStart, normalizeIndentList, normalizeIndentListNotIndented, normalizeIndentListStart, normalizeNextIndentListStart, onKeyDownIndentList, outdentList, setIndentListNode, setIndentListNodes, setIndentListSiblingNodes, setIndentTodoNode, someIndentList, toggleIndentList, toggleIndentListSet, toggleIndentListUnset, useIndentListToolbarButton, useIndentListToolbarButtonState, useIndentTodoToolBarButton, useIndentTodoToolBarButtonState, withIndentList }; | ||
export { type GetIndentListSiblingsOptions, type GetSiblingIndentListOptions, type IndentListOptions, type IndentListPlugin, KEY_LIST_CHECKED, KEY_LIST_RESTART, KEY_LIST_START, KEY_LIST_STYLE_TYPE, KEY_TODO_STYLE_TYPE, type LiFC, ListStyleType, type MarkerFC, ULIST_STYLE_TYPES, areEqListStyleType, createIndentListPlugin, getIndentListSiblings, getNextIndentList, getPreviousIndentList, getSiblingIndentList, getSiblingListStyleType, indentList, indentTodo, injectIndentListComponent, normalizeFirstIndentListStart, normalizeIndentList, normalizeIndentListNotIndented, normalizeIndentListStart, normalizeNextIndentListStart, onKeyDownIndentList, outdentList, setIndentListNode, setIndentListNodes, setIndentListSiblingNodes, setIndentTodoNode, someIndentList, toggleIndentList, toggleIndentListSet, toggleIndentListUnset, useIndentListToolbarButton, useIndentListToolbarButtonState, useIndentTodoToolBarButton, useIndentTodoToolBarButtonState, withIndentList }; |
@@ -68,2 +68,3 @@ "use strict"; | ||
ListStyleType: () => ListStyleType, | ||
ULIST_STYLE_TYPES: () => ULIST_STYLE_TYPES, | ||
areEqListStyleType: () => areEqListStyleType, | ||
@@ -109,4 +110,75 @@ createIndentListPlugin: () => createIndentListPlugin, | ||
var import_clsx = require("clsx"); | ||
var injectIndentListComponent = (props) => { | ||
const { element } = props; | ||
// src/types.ts | ||
var ListStyleType = /* @__PURE__ */ ((ListStyleType2) => { | ||
ListStyleType2["Decimal"] = "decimal"; | ||
ListStyleType2["DecimalLeadingZero"] = "decimal-leading-zero"; | ||
ListStyleType2["ArabicIndic"] = "arabic-indic"; | ||
ListStyleType2["Armenian"] = "armenian"; | ||
ListStyleType2["UpperArmenian"] = "upper-armenian"; | ||
ListStyleType2["LowerArmenian"] = "lower-armenian"; | ||
ListStyleType2["Bengali"] = "bengali"; | ||
ListStyleType2["Cambodian"] = "cambodian"; | ||
ListStyleType2["Khmer"] = "khmer"; | ||
ListStyleType2["CjkDecimal"] = "cjk-decimal"; | ||
ListStyleType2["Devanagari"] = "devanagari"; | ||
ListStyleType2["Georgian"] = "georgian"; | ||
ListStyleType2["Gujarati"] = "gujarati"; | ||
ListStyleType2["Gurmukhi"] = "gurmukhi"; | ||
ListStyleType2["Hebrew"] = "hebrew"; | ||
ListStyleType2["Kannada"] = "kannada"; | ||
ListStyleType2["Lao"] = "lao"; | ||
ListStyleType2["Malayalam"] = "malayalam"; | ||
ListStyleType2["Mongolian"] = "mongolian"; | ||
ListStyleType2["Myanmar"] = "myanmar"; | ||
ListStyleType2["Oriya"] = "oriya"; | ||
ListStyleType2["Persian"] = "persian"; | ||
ListStyleType2["LowerRoman"] = "lower-roman"; | ||
ListStyleType2["UpperRoman"] = "upper-roman"; | ||
ListStyleType2["Tamil"] = "tamil"; | ||
ListStyleType2["Telugu"] = "telugu"; | ||
ListStyleType2["Thai"] = "thai"; | ||
ListStyleType2["Tibetan"] = "tibetan"; | ||
ListStyleType2["LowerAlpha"] = "lower-alpha"; | ||
ListStyleType2["LowerLatin"] = "lower-latin"; | ||
ListStyleType2["UpperAlpha"] = "upper-alpha"; | ||
ListStyleType2["UpperLatin"] = "upper-latin"; | ||
ListStyleType2["LowerGreek"] = "lower-greek"; | ||
ListStyleType2["Hiragana"] = "hiragana"; | ||
ListStyleType2["HiraganaIroha"] = "hiragana-iroha"; | ||
ListStyleType2["Katakana"] = "katakana"; | ||
ListStyleType2["KatakanaIroha"] = "katakana-iroha"; | ||
ListStyleType2["CjkEarthlyBranch"] = "cjk-earthly-branch"; | ||
ListStyleType2["CjkHeavenlyStem"] = "cjk-heavenly-stem"; | ||
ListStyleType2["JapaneseInformal"] = "japanese-informal"; | ||
ListStyleType2["JapaneseFormal"] = "japanese-formal"; | ||
ListStyleType2["KoreanHangulFormal"] = "korean-hangul-formal"; | ||
ListStyleType2["KoreanHanjaInformal"] = "korean-hanja-informal"; | ||
ListStyleType2["KoreanHanjaFormal"] = "korean-hanja-formal"; | ||
ListStyleType2["SimpChineseInformal"] = "simp-chinese-informal"; | ||
ListStyleType2["SimpChineseFormal"] = "simp-chinese-formal"; | ||
ListStyleType2["TradChineseInformal"] = "trad-chinese-informal"; | ||
ListStyleType2["TradChineseFormal"] = "trad-chinese-formal"; | ||
ListStyleType2["EthiopicNumeric"] = "ethiopic-numeric"; | ||
ListStyleType2["DisclosureOpen"] = "disclosure-open"; | ||
ListStyleType2["DisclosureClosed"] = "disclosure-closed"; | ||
ListStyleType2["None"] = "none"; | ||
ListStyleType2["Circle"] = "circle"; | ||
ListStyleType2["Disc"] = "disc"; | ||
ListStyleType2["Square"] = "square"; | ||
ListStyleType2["Initial"] = "initial"; | ||
ListStyleType2["Inherit"] = "inherit"; | ||
return ListStyleType2; | ||
})(ListStyleType || {}); | ||
var ULIST_STYLE_TYPES = [ | ||
"disc" /* Disc */, | ||
"circle" /* Circle */, | ||
"square" /* Square */, | ||
"disclosure-open" /* DisclosureOpen */, | ||
"disclosure-closed" /* DisclosureClosed */ | ||
]; | ||
// src/injectIndentListComponent.tsx | ||
var injectIndentListComponent = (injectProps) => { | ||
const { element } = injectProps; | ||
const listStyleType = element[KEY_LIST_STYLE_TYPE]; | ||
@@ -122,4 +194,5 @@ const listStart = element[KEY_LIST_START]; | ||
}; | ||
return function Ul({ editor, children }) { | ||
var _a; | ||
return function Component(_a) { | ||
var _b = _a, { children } = _b, props = __objRest(_b, ["children"]); | ||
const { editor } = props; | ||
const { listStyleTypes = {} } = (0, import_plate_common.getPluginOptions)( | ||
@@ -129,15 +202,19 @@ editor, | ||
); | ||
const targetList = (_a = listStyleTypes[listStyleType]) != null ? _a : {}; | ||
const isNumbered = targetList ? targetList.isNumbered : false; | ||
className = isNumbered ? (0, import_clsx.clsx)(className, "slate-list-number") : (0, import_clsx.clsx)(className, "slate-list-bullet"); | ||
let listOptions = listStyleTypes[listStyleType]; | ||
let isOrdered = true; | ||
if (listOptions) { | ||
isOrdered = !!listOptions.isOrdered; | ||
} else { | ||
if (ULIST_STYLE_TYPES.includes(listStyleType)) { | ||
isOrdered = false; | ||
} | ||
listOptions = {}; | ||
} | ||
className = isOrdered ? (0, import_clsx.clsx)(className, "slate-ol") : (0, import_clsx.clsx)(className, "slate-ul"); | ||
const List = isOrdered ? "ol" : "ul"; | ||
const { | ||
markerComponent = null, | ||
// eslint-disable-next-line @typescript-eslint/no-shadow | ||
liComponent = ({ children: children2 }) => /* @__PURE__ */ import_react.default.createElement("li", null, children2) | ||
} = targetList; | ||
const Wrap = isNumbered ? "ol" : "ul"; | ||
return /* @__PURE__ */ import_react.default.createElement(Wrap, { style, className, start: listStart }, markerComponent && markerComponent({ editor, element }), liComponent({ | ||
children, | ||
element | ||
})); | ||
markerComponent: Marker = () => null, | ||
liComponent: Li = (liProps) => /* @__PURE__ */ import_react.default.createElement("li", null, liProps.children) | ||
} = listOptions; | ||
return /* @__PURE__ */ import_react.default.createElement(List, { style, className, start: listStart }, /* @__PURE__ */ import_react.default.createElement(Marker, __spreadValues({}, props)), /* @__PURE__ */ import_react.default.createElement(Li, __spreadValues({}, props), children)); | ||
}; | ||
@@ -152,32 +229,2 @@ } | ||
var import_plate_indent = require("@udecode/plate-indent"); | ||
// src/types.ts | ||
var ListStyleType = /* @__PURE__ */ ((ListStyleType2) => { | ||
ListStyleType2["Armenian"] = "armenian"; | ||
ListStyleType2["Circle"] = "circle"; | ||
ListStyleType2["CjkIdeographic"] = "cjk-ideographic"; | ||
ListStyleType2["Decimal"] = "decimal"; | ||
ListStyleType2["DecimalLeadingZero"] = "decimal-leading-zero"; | ||
ListStyleType2["Disc"] = "disc"; | ||
ListStyleType2["Georgian"] = "georgian"; | ||
ListStyleType2["Hebrew"] = "hebrew"; | ||
ListStyleType2["Hiragana"] = "hiragana"; | ||
ListStyleType2["HiraganaIroha"] = "hiragana-iroha"; | ||
ListStyleType2["Katakana"] = "katakana"; | ||
ListStyleType2["KatakanaIroha"] = "katakana-iroha"; | ||
ListStyleType2["LowerAlpha"] = "lower-alpha"; | ||
ListStyleType2["LowerGreek"] = "lower-greek"; | ||
ListStyleType2["LowerLatin"] = "lower-latin"; | ||
ListStyleType2["LowerRoman"] = "lower-roman"; | ||
ListStyleType2["None"] = "none"; | ||
ListStyleType2["Square"] = "square"; | ||
ListStyleType2["UpperAlpha"] = "upper-alpha"; | ||
ListStyleType2["UpperLatin"] = "upper-latin"; | ||
ListStyleType2["UpperRoman"] = "upper-roman"; | ||
ListStyleType2["Initial"] = "initial"; | ||
ListStyleType2["Inherit"] = "inherit"; | ||
return ListStyleType2; | ||
})(ListStyleType || {}); | ||
// src/transforms/indentList.ts | ||
var indentList = (editor, _a = {}) => { | ||
@@ -1064,2 +1111,3 @@ var _b = _a, { listStyleType = "disc" /* Disc */ } = _b, options = __objRest(_b, ["listStyleType"]); | ||
ListStyleType, | ||
ULIST_STYLE_TYPES, | ||
areEqListStyleType, | ||
@@ -1066,0 +1114,0 @@ createIndentListPlugin, |
{ | ||
"name": "@udecode/plate-indent-list", | ||
"version": "31.2.0", | ||
"version": "31.2.2", | ||
"description": "Indent list plugin for Plate", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
229133
2412