File tree Expand file tree Collapse file tree 1 file changed +12
-7
lines changed
packages/super-editor/src/extensions/linked-styles Expand file tree Collapse file tree 1 file changed +12
-7
lines changed Original file line number Diff line number Diff line change @@ -66,15 +66,20 @@ export const getMarksStyle = (attrs) => {
6666 return styles . trim ( ) ;
6767} ;
6868
69+ /**
70+ * Get a sorted list of paragraph quick-format styles from the editor.
71+ * @param {import('../../core/Editor.js').Editor } editor - The editor instance.
72+ * @returns {Array } Sorted list of styles.
73+ */
6974export const getQuickFormatList = ( editor ) => {
70- if ( ! editor ?. converter ) return [ ] ;
71- const styles = editor . converter . linkedStyles || [ ] ;
72- return styles
73- . filter ( ( style ) => {
74- return style . type === 'paragraph' && style . definition . attrs ;
75- } )
75+ if ( ! editor ?. converter ?. linkedStyles ) return [ ] ;
76+
77+ return editor . converter . linkedStyles
78+ . filter ( ( style ) => style . type === 'paragraph' && style . definition ?. attrs )
7679 . sort ( ( a , b ) => {
77- return a . definition . attrs ?. name . localeCompare ( b . definition . attrs ?. name ) ;
80+ const nameA = a . definition . attrs ?. name ?? '' ;
81+ const nameB = b . definition . attrs ?. name ?? '' ;
82+ return nameA . localeCompare ( nameB ) ;
7883 } ) ;
7984} ;
8085
You can’t perform that action at this time.
0 commit comments