Skip to content

Commit

Permalink
small fix
Browse files Browse the repository at this point in the history
  • Loading branch information
BryanValverdeU committed Jun 29, 2023
1 parent 6ca2b46 commit f835ea6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions packages/roosterjs-editor-core/lib/coreApi/selectTable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const CONTENT_DIV_ID = 'contentDiv_';
const STYLE_ID = 'tableStyle';
const SELECTED_CSS_RULE =
'{background-color: rgb(198,198,198) !important; caret-color: transparent}';
const MAX_RULE_SELECTOR_LENGTH = 9000;

/**
* @internal
Expand Down Expand Up @@ -72,7 +73,6 @@ export const selectTable: SelectTable = (
return null;
};

const MAX_RULE_SELECTOR_LENGTH = 8000;
function buildCss(
table: HTMLTableElement,
coordinates: TableSelection,
Expand All @@ -93,7 +93,10 @@ function buildCss(
let currentRules: string = '';
while (selectors.length > 0) {
currentRules += (currentRules.length > 0 ? ',' : '') + selectors.shift() || '';
if (currentRules.length > MAX_RULE_SELECTOR_LENGTH || selectors.length == 0) {
if (
currentRules.length + (selectors[0]?.length || 0) > MAX_RULE_SELECTOR_LENGTH ||
selectors.length == 0
) {
cssRules.push(currentRules + ' ' + SELECTED_CSS_RULE);
currentRules = '';
}
Expand Down

0 comments on commit f835ea6

Please sign in to comment.