@worktile/theia 14.1.7 → 14.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/esm2020/queries/is-empty-content-filter.mjs +12 -12
- package/fesm2015/worktile-theia.mjs +10 -11
- package/fesm2015/worktile-theia.mjs.map +1 -1
- package/fesm2020/worktile-theia.mjs +10 -11
- package/fesm2020/worktile-theia.mjs.map +1 -1
- package/package.json +1 -1
- package/queries/is-empty-content-filter.d.ts +1 -1
|
@@ -1950,26 +1950,25 @@ const isGlobalCollapsed = (editor) => {
|
|
|
1950
1950
|
return editor && editor.selection && Range.isCollapsed(editor.selection);
|
|
1951
1951
|
};
|
|
1952
1952
|
|
|
1953
|
-
const isEmptyContentByFilter = (editor, rules
|
|
1953
|
+
const isEmptyContentByFilter = (editor, rules) => {
|
|
1954
1954
|
const { children } = editor;
|
|
1955
1955
|
if (children.length < 1) {
|
|
1956
1956
|
return true;
|
|
1957
1957
|
}
|
|
1958
|
+
const defaultTypes = [ElementKinds.code, ElementKinds.table, ElementKinds.image];
|
|
1959
|
+
const containTypes = rules?.containTypes ? [...defaultTypes, ...rules.containTypes] : defaultTypes;
|
|
1960
|
+
const textSpace = rules?.textSpace !== undefined ? rules.textSpace : true;
|
|
1961
|
+
const filterNodes = Array.from(Node.elements(editor));
|
|
1962
|
+
if (filterNodes.some(n => n[0]?.type && containTypes.includes(n[0].type))) {
|
|
1963
|
+
return false;
|
|
1964
|
+
}
|
|
1958
1965
|
const nodesEntry = Node.texts(editor);
|
|
1959
1966
|
const nodes = Array.from(nodesEntry);
|
|
1960
1967
|
const allText = nodes.reduce((total, text) => (total += text[0].text), '');
|
|
1961
|
-
const filterText =
|
|
1968
|
+
const filterText = textSpace ? allText.replace(/\s+/g, '') : allText;
|
|
1962
1969
|
const textLength = filterText?.length ?? 0;
|
|
1963
1970
|
const isEmptyText = textLength <= 0;
|
|
1964
|
-
|
|
1965
|
-
let isEmpty = false;
|
|
1966
|
-
if (isEmptyText) {
|
|
1967
|
-
isEmpty = true;
|
|
1968
|
-
}
|
|
1969
|
-
if (rules.void && hasVoid) {
|
|
1970
|
-
isEmpty = false;
|
|
1971
|
-
}
|
|
1972
|
-
return isEmpty;
|
|
1971
|
+
return isEmptyText;
|
|
1973
1972
|
};
|
|
1974
1973
|
|
|
1975
1974
|
var index$1 = /*#__PURE__*/Object.freeze({
|