Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix checkbox UL rendering issue #11060

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Assets/TinyMCE/JoplinLists/src/main/ts/core/NormalizeLists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ import * as NodeType from './NodeType';

const DOM = DOMUtils.DOM;

const isCheckboxList = function (ul) {
return ul.classList && ul.classList.contains('joplin-checklist');
};

const normalizeList = function (dom, ul) {
let sibling;
const parentNode = ul.parentNode;
Expand Down Expand Up @@ -40,7 +44,11 @@ const normalizeList = function (dom, ul) {

const normalizeLists = function (dom, element) {
Tools.each(Tools.grep(dom.select('ol,ul', element)), function (ul) {
normalizeList(dom, ul);
if (isCheckboxList(ul)) {
// Handle checkbox lists separately if needed
} else {
normalizeList(dom, ul);
}
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export function findContainerListTypeFromEvent(event) {

export function findContainerListTypeFromElement(element) {
while (element) {
if (element.nodeName === 'UL' || element.nodName === 'OL') {
if (element.nodeName === 'UL' || element.nodeName === 'OL') {
return isCheckboxListItem(element) ? 'joplinChecklist' : 'regular';
}
element = element.parentNode;
Expand Down Expand Up @@ -45,4 +45,4 @@ export function addJoplinChecklistCommands(editor, ToggleList) {
detail = { ...detail, listType: 'joplinChecklist' };
ToggleList.toggleList(editor, 'UL', detail);
});
}
}
18 changes: 13 additions & 5 deletions Assets/TinyMCE/JoplinLists/src/main/ts/listModel/ParseLists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Arr, Cell, Option } from '@ephox/katamari';
import { Compare, Element, Traverse } from '@ephox/sugar';
import { createEntry, Entry } from './Entry';
import { isList } from './Util';
import { isCheckboxListItem } from './JoplinListUtil';

type Parser = (depth: number, itemSelection: Option<ItemSelection>, selectionState: Cell<boolean>, element: Element) => Entry[];

Expand Down Expand Up @@ -62,10 +63,17 @@ const parseLists = (lists: Element[], itemSelection: Option<ItemSelection>): Ent
const selectionState = Cell(false);
const initialDepth = 0;

return Arr.map(lists, (list) => ({
sourceList: list,
entries: parseList(initialDepth, itemSelection, selectionState, list)
}));
return Arr.map(lists, (list) => {
const entries = parseList(initialDepth, itemSelection, selectionState, list);
const isCheckboxList = isCheckboxListItem(list.dom());
return {
sourceList: list,
entries: entries.map(entry => ({
...entry,
listType: isCheckboxList ? 'joplinChecklist' : entry.listType,
})),
};
});
};

export { parseLists };
export { parseLists };
Loading