wunderbaum 0.0.1 → 0.0.4
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/README.md +4 -3
- package/dist/wunderbaum.css +1 -1
- package/dist/wunderbaum.d.ts +738 -174
- package/dist/wunderbaum.esm.js +1123 -647
- package/dist/wunderbaum.esm.min.js +30 -20
- package/dist/wunderbaum.esm.min.js.map +1 -1
- package/dist/wunderbaum.umd.js +1125 -649
- package/dist/wunderbaum.umd.min.js +34 -25
- package/dist/wunderbaum.umd.min.js.map +1 -1
- package/package.json +29 -30
- package/src/common.ts +46 -6
- package/src/deferred.ts +12 -2
- package/src/drag_observer.ts +169 -0
- package/src/util.ts +129 -16
- package/src/wb_ext_dnd.ts +144 -3
- package/src/wb_ext_edit.ts +10 -1
- package/src/wb_ext_filter.ts +35 -35
- package/src/wb_ext_grid.ts +45 -0
- package/src/wb_ext_keynav.ts +8 -4
- package/src/wb_extension_base.ts +3 -3
- package/src/wb_node.ts +359 -214
- package/src/wb_options.ts +173 -26
- package/src/wunderbaum.scss +114 -28
- package/src/wunderbaum.ts +504 -338
package/src/wb_ext_filter.ts
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
escapeHtml,
|
|
10
10
|
escapeRegex,
|
|
11
11
|
extend,
|
|
12
|
-
extractHtmlText,
|
|
13
12
|
onEvent,
|
|
14
13
|
} from "./util";
|
|
15
14
|
import { NodeFilterCallback, NodeStatusType } from "./common";
|
|
@@ -79,7 +78,7 @@ export class FilterExtension extends WunderbaumExtension {
|
|
|
79
78
|
count = 0,
|
|
80
79
|
tree = this.tree,
|
|
81
80
|
treeOpts = tree.options,
|
|
82
|
-
escapeTitles = treeOpts.escapeTitles,
|
|
81
|
+
// escapeTitles = treeOpts.escapeTitles,
|
|
83
82
|
prevAutoCollapse = treeOpts.autoCollapse,
|
|
84
83
|
opts = extend({}, treeOpts.filter, _opts),
|
|
85
84
|
hideMode = opts.mode === "hide",
|
|
@@ -118,35 +117,36 @@ export class FilterExtension extends WunderbaumExtension {
|
|
|
118
117
|
if (!node.title) {
|
|
119
118
|
return false;
|
|
120
119
|
}
|
|
121
|
-
let text = escapeTitles ? node.title : extractHtmlText(node.title);
|
|
120
|
+
// let text = escapeTitles ? node.title : extractHtmlText(node.title);
|
|
121
|
+
let text = node.title;
|
|
122
122
|
// `.match` instead of `.test` to get the capture groups
|
|
123
123
|
let res = text.match(re);
|
|
124
124
|
|
|
125
125
|
if (res && opts.highlight) {
|
|
126
|
-
if (escapeTitles) {
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
} else {
|
|
130
|
-
// #740: we must not apply the marks to escaped entity names, e.g. `"`
|
|
131
|
-
// Use some exotic characters to mark matches:
|
|
132
|
-
temp = text.replace(reHighlight, function (s) {
|
|
133
|
-
return START_MARKER + s + END_MARKER;
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
// now we can escape the title...
|
|
137
|
-
node.titleWithHighlight = escapeHtml(temp)
|
|
138
|
-
// ... and finally insert the desired `<mark>` tags
|
|
139
|
-
.replace(RE_START_MARKER, "<mark>")
|
|
140
|
-
.replace(RE_END_MARTKER, "</mark>");
|
|
126
|
+
// if (escapeTitles) {
|
|
127
|
+
if (opts.fuzzy) {
|
|
128
|
+
temp = _markFuzzyMatchedChars(text, res, true);
|
|
141
129
|
} else {
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
});
|
|
148
|
-
}
|
|
130
|
+
// #740: we must not apply the marks to escaped entity names, e.g. `"`
|
|
131
|
+
// Use some exotic characters to mark matches:
|
|
132
|
+
temp = text.replace(reHighlight, function (s) {
|
|
133
|
+
return START_MARKER + s + END_MARKER;
|
|
134
|
+
});
|
|
149
135
|
}
|
|
136
|
+
// now we can escape the title...
|
|
137
|
+
node.titleWithHighlight = escapeHtml(temp)
|
|
138
|
+
// ... and finally insert the desired `<mark>` tags
|
|
139
|
+
.replace(RE_START_MARKER, "<mark>")
|
|
140
|
+
.replace(RE_END_MARTKER, "</mark>");
|
|
141
|
+
// } else {
|
|
142
|
+
// if (opts.fuzzy) {
|
|
143
|
+
// node.titleWithHighlight = _markFuzzyMatchedChars(text, res);
|
|
144
|
+
// } else {
|
|
145
|
+
// node.titleWithHighlight = text.replace(reHighlight, function (s) {
|
|
146
|
+
// return "<mark>" + s + "</mark>";
|
|
147
|
+
// });
|
|
148
|
+
// }
|
|
149
|
+
// }
|
|
150
150
|
// node.debug("filter", escapeTitles, text, node.titleWithHighlight);
|
|
151
151
|
}
|
|
152
152
|
return !!res;
|
|
@@ -266,9 +266,9 @@ export class FilterExtension extends WunderbaumExtension {
|
|
|
266
266
|
* [ext-filter] Reset the filter.
|
|
267
267
|
*/
|
|
268
268
|
clearFilter() {
|
|
269
|
-
let tree = this.tree
|
|
270
|
-
|
|
271
|
-
|
|
269
|
+
let tree = this.tree;
|
|
270
|
+
// statusNode = tree.root.findDirectChild(KEY_NODATA),
|
|
271
|
+
// escapeTitles = tree.options.escapeTitles;
|
|
272
272
|
// enhanceTitle = tree.options.enhanceTitle,
|
|
273
273
|
tree.enableUpdate(false);
|
|
274
274
|
|
|
@@ -284,11 +284,11 @@ export class FilterExtension extends WunderbaumExtension {
|
|
|
284
284
|
if (node.match && node._rowElem) {
|
|
285
285
|
// #491, #601
|
|
286
286
|
let titleElem = node._rowElem.querySelector("span.wb-title")!;
|
|
287
|
-
if (escapeTitles) {
|
|
288
|
-
|
|
289
|
-
} else {
|
|
290
|
-
|
|
291
|
-
}
|
|
287
|
+
// if (escapeTitles) {
|
|
288
|
+
titleElem.textContent = node.title;
|
|
289
|
+
// } else {
|
|
290
|
+
// titleElem.innerHTML = node.title;
|
|
291
|
+
// }
|
|
292
292
|
node._callEvent("enhanceTitle", { titleElem: titleElem });
|
|
293
293
|
}
|
|
294
294
|
delete node.match;
|
|
@@ -330,7 +330,7 @@ export class FilterExtension extends WunderbaumExtension {
|
|
|
330
330
|
function _markFuzzyMatchedChars(
|
|
331
331
|
text: string,
|
|
332
332
|
matches: RegExpMatchArray,
|
|
333
|
-
escapeTitles =
|
|
333
|
+
escapeTitles = true
|
|
334
334
|
) {
|
|
335
335
|
let matchingIndices = [];
|
|
336
336
|
// get the indices of matched characters (Iterate through `RegExpMatchArray`)
|
|
@@ -350,7 +350,7 @@ function _markFuzzyMatchedChars(
|
|
|
350
350
|
// Map each `text` char to its position and store in `textPoses`.
|
|
351
351
|
let textPoses = text.split("");
|
|
352
352
|
if (escapeTitles) {
|
|
353
|
-
// If escaping the title, then wrap the
|
|
353
|
+
// If escaping the title, then wrap the matching char within exotic chars
|
|
354
354
|
matchingIndices.forEach(function (v) {
|
|
355
355
|
textPoses[v] = START_MARKER + textPoses[v] + END_MARKER;
|
|
356
356
|
});
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Wunderbaum - ext-grid
|
|
3
|
+
* Copyright (c) 2021-2022, Martin Wendt. Released under the MIT license.
|
|
4
|
+
* @VERSION, @DATE (https://github.com/mar10/wunderbaum)
|
|
5
|
+
*/
|
|
6
|
+
import { Wunderbaum } from "./wunderbaum";
|
|
7
|
+
import { WunderbaumExtension } from "./wb_extension_base";
|
|
8
|
+
import { DragCallbackArgType, DragObserver } from "./drag_observer";
|
|
9
|
+
|
|
10
|
+
export class GridExtension extends WunderbaumExtension {
|
|
11
|
+
protected observer: DragObserver;
|
|
12
|
+
|
|
13
|
+
constructor(tree: Wunderbaum) {
|
|
14
|
+
super(tree, "grid", {
|
|
15
|
+
// throttle: 200,
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
this.observer = new DragObserver({
|
|
19
|
+
root: window.document,
|
|
20
|
+
selector: "span.wb-col-resizer",
|
|
21
|
+
thresh: 4,
|
|
22
|
+
// throttle: 400,
|
|
23
|
+
dragstart: (e) => {
|
|
24
|
+
return this.tree.element.contains(e.dragElem);
|
|
25
|
+
},
|
|
26
|
+
drag: (e) => {
|
|
27
|
+
// TODO: throttle
|
|
28
|
+
return this.handleDrag(e);
|
|
29
|
+
},
|
|
30
|
+
dragstop: (e) => {
|
|
31
|
+
return this.handleDrag(e);
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
init() {
|
|
37
|
+
super.init();
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
protected handleDrag(e: DragCallbackArgType): void {
|
|
41
|
+
const info = Wunderbaum.getEventInfo(e.event);
|
|
42
|
+
// this.tree.options.
|
|
43
|
+
this.tree.log(`${e.type}(${e.dx})`, e, info);
|
|
44
|
+
}
|
|
45
|
+
}
|
package/src/wb_ext_keynav.ts
CHANGED
|
@@ -94,7 +94,7 @@ export class KeynavExtension extends WunderbaumExtension {
|
|
|
94
94
|
if (!node.expanded && (node.children || node.lazy)) {
|
|
95
95
|
eventName = "Add"; // expand
|
|
96
96
|
} else if (navModeOption === NavigationModeOption.startRow) {
|
|
97
|
-
tree.
|
|
97
|
+
tree.setNavigationMode(NavigationMode.cellNav);
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
100
|
break;
|
|
@@ -133,6 +133,8 @@ export class KeynavExtension extends WunderbaumExtension {
|
|
|
133
133
|
case "Home":
|
|
134
134
|
case "Control+End":
|
|
135
135
|
case "Control+Home":
|
|
136
|
+
case "Meta+ArrowDown":
|
|
137
|
+
case "Meta+ArrowUp":
|
|
136
138
|
case "PageDown":
|
|
137
139
|
case "PageUp":
|
|
138
140
|
node.navigate(eventName, { activate: activate, event: event });
|
|
@@ -164,10 +166,10 @@ export class KeynavExtension extends WunderbaumExtension {
|
|
|
164
166
|
break;
|
|
165
167
|
case "Escape":
|
|
166
168
|
if (tree.navMode === NavigationMode.cellEdit) {
|
|
167
|
-
tree.
|
|
169
|
+
tree.setNavigationMode(NavigationMode.cellNav);
|
|
168
170
|
handled = true;
|
|
169
171
|
} else if (tree.navMode === NavigationMode.cellNav) {
|
|
170
|
-
tree.
|
|
172
|
+
tree.setNavigationMode(NavigationMode.row);
|
|
171
173
|
handled = true;
|
|
172
174
|
}
|
|
173
175
|
break;
|
|
@@ -176,7 +178,7 @@ export class KeynavExtension extends WunderbaumExtension {
|
|
|
176
178
|
tree.setColumn(tree.activeColIdx - 1);
|
|
177
179
|
handled = true;
|
|
178
180
|
} else if (navModeOption !== NavigationModeOption.cell) {
|
|
179
|
-
tree.
|
|
181
|
+
tree.setNavigationMode(NavigationMode.row);
|
|
180
182
|
handled = true;
|
|
181
183
|
}
|
|
182
184
|
break;
|
|
@@ -193,6 +195,8 @@ export class KeynavExtension extends WunderbaumExtension {
|
|
|
193
195
|
case "Home":
|
|
194
196
|
case "Control+End":
|
|
195
197
|
case "Control+Home":
|
|
198
|
+
case "Meta+ArrowDown":
|
|
199
|
+
case "Meta+ArrowUp":
|
|
196
200
|
case "PageDown":
|
|
197
201
|
case "PageUp":
|
|
198
202
|
node.navigate(eventName, { activate: activate, event: event });
|
package/src/wb_extension_base.ts
CHANGED
|
@@ -38,14 +38,14 @@ export abstract class WunderbaumExtension {
|
|
|
38
38
|
this.tree.element.classList.add("wb-ext-" + this.id);
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
// protected callEvent(
|
|
42
|
-
// let func = this.extensionOpts[
|
|
41
|
+
// protected callEvent(type: string, extra?: any): any {
|
|
42
|
+
// let func = this.extensionOpts[type];
|
|
43
43
|
// if (func) {
|
|
44
44
|
// return func.call(
|
|
45
45
|
// this.tree,
|
|
46
46
|
// util.extend(
|
|
47
47
|
// {
|
|
48
|
-
// event: this.id + "." +
|
|
48
|
+
// event: this.id + "." + type,
|
|
49
49
|
// },
|
|
50
50
|
// extra
|
|
51
51
|
// )
|