SCEditor icon indicating copy to clipboard operation
SCEditor copied to clipboard

hardcoded decision in dom.isInline

Open abetis opened this issue 6 years ago • 3 comments

There is a hardcoded decision in dom.isInline function for <code> element. Is there another way? Can't it use handler's configuration somehow?

If it should be done on dom level, so why only code is there? Shouldn't comments behave the same?

export function isInline(elm, includeCodeAsBlock) {
	var tagName,
		nodeType = (elm || {}).nodeType || TEXT_NODE;

	if (nodeType !== ELEMENT_NODE) {
		return nodeType === TEXT_NODE;
	}

	tagName = elm.tagName.toLowerCase();

	if (tagName === 'code') {
		return !includeCodeAsBlock;
	}

	return blockLevelList.indexOf('|' + tagName + '|') < 0;
}

abetis avatar Apr 09 '18 14:04 abetis

IIRC, there's a comment from @samclarke some time ago exactly about that. I forgot when it is

brunoais avatar Apr 09 '18 15:04 brunoais

Found related TODO in SCEditor.js:

		// TODO: make configurable
		// don't apply any commands to code elements
		if (dom.closest(rangeHelper.parentNode(), 'code')) {
			return;
		}

abetis avatar Apr 10 '18 10:04 abetis

I believe you can create a PR solving that. I can then review and merge it if all checks out.

brunoais avatar Apr 10 '18 12:04 brunoais