@vertexvis/ui 0.1.0-canary.14 → 0.1.0-canary.16
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/dist/cjs/{icon-b6383789.js → icon-69910290.js} +1 -1
- package/dist/cjs/{icon-button-f32c3cc8.js → icon-button-ab196f5e.js} +1 -1
- package/dist/cjs/{icon-helper-0e14d7cc.js → icon-helper-2ba6caba.js} +11 -0
- package/dist/cjs/index.cjs.js +4 -4
- package/dist/cjs/{search-bar-91cbcd07.js → search-bar-2e7ee35a.js} +130 -24
- package/dist/cjs/vertex-icon-button.cjs.entry.js +2 -2
- package/dist/cjs/vertex-icon.cjs.entry.js +2 -2
- package/dist/cjs/vertex-search-bar.cjs.entry.js +1 -1
- package/dist/collection/components/icon/icon-helper.js +6 -0
- package/dist/collection/components/icon/icon.js +1 -1
- package/dist/collection/components/icon/icons/cube-stack.js +2 -0
- package/dist/collection/components/icon/icons/plus-with-arrow.js +2 -0
- package/dist/collection/components/icon-button/icon-button.js +1 -1
- package/dist/collection/components/search-bar/dom.js +17 -0
- package/dist/collection/components/search-bar/lib.js +45 -4
- package/dist/collection/components/search-bar/search-bar.js +76 -23
- package/dist/collection/types/icon.js +2 -0
- package/dist/components/components.esm.js +1 -1
- package/dist/components/index.esm.js +1 -1
- package/dist/components/p-25d771c9.js +1 -0
- package/dist/components/p-4ae5fe4f.entry.js +1 -0
- package/dist/components/p-6a49c365.entry.js +1 -0
- package/dist/components/p-6b6c2260.js +1 -0
- package/dist/components/{p-438990ec.js → p-7e722888.js} +1 -1
- package/dist/components/{p-d51b8fb1.js → p-c8f9c9be.js} +1 -1
- package/dist/components/p-f51227a8.entry.js +1 -0
- package/dist/esm/{icon-74bf5afb.js → icon-4ad6e234.js} +1 -1
- package/dist/esm/{icon-button-d15ffd10.js → icon-button-354ed8fa.js} +1 -1
- package/dist/esm/{icon-helper-805b317d.js → icon-helper-fe57c558.js} +11 -0
- package/dist/esm/index.js +4 -4
- package/dist/esm/{search-bar-f12a3599.js → search-bar-8d18626e.js} +130 -24
- package/dist/esm/vertex-icon-button.entry.js +2 -2
- package/dist/esm/vertex-icon.entry.js +2 -2
- package/dist/esm/vertex-search-bar.entry.js +1 -1
- package/dist/types/components/icon/icons/cube-stack.d.ts +3 -0
- package/dist/types/components/icon/icons/plus-with-arrow.d.ts +3 -0
- package/dist/types/components/search-bar/dom.d.ts +5 -0
- package/dist/types/components/search-bar/lib.d.ts +9 -2
- package/dist/types/components/search-bar/search-bar.d.ts +1 -0
- package/dist/types/types/icon.d.ts +2 -0
- package/package.json +2 -2
- package/dist/components/p-213670fa.js +0 -1
- package/dist/components/p-8567289c.entry.js +0 -1
- package/dist/components/p-cfe369bf.entry.js +0 -1
- package/dist/components/p-db34f10c.js +0 -1
- package/dist/components/p-f100f918.entry.js +0 -1
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const index = require('./index-6a92256c.js');
|
|
4
4
|
const index$1 = require('./index-e1b40fa6.js');
|
|
5
|
-
const iconHelper = require('./icon-helper-
|
|
5
|
+
const iconHelper = require('./icon-helper-2ba6caba.js');
|
|
6
6
|
|
|
7
7
|
const iconCss = ".container{display:flex;justify-content:center;align-items:center;width:100%;height:100%}.icon{display:flex;justify-content:center;align-items:center;fill:currentColor}.xs{height:var(--icon-size, 0.75rem);width:var(--icon-size, 0.75rem)}.sm{height:var(--icon-size, 1rem);width:var(--icon-size, 1rem)}.md{height:var(--icon-size, 1.5rem);width:var(--icon-size, 1.5rem)}.lg{height:var(--icon-size, 2rem);width:var(--icon-size, 2rem)}svg{position:relative;width:100%}";
|
|
8
8
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
const index = require('./index-6a92256c.js');
|
|
4
4
|
const index$1 = require('./index-e1b40fa6.js');
|
|
5
|
-
const iconHelper = require('./icon-helper-
|
|
5
|
+
const iconHelper = require('./icon-helper-2ba6caba.js');
|
|
6
6
|
|
|
7
7
|
const iconButtonCss = "button{border:none;background-color:transparent;font-family:var(--vertex-ui-font-family);font-size:0.875rem;padding:0}:host{--enabled-cursor:pointer;--disabled-cursor:not-allowed;--hover-background-color:var(--vertex-ui-neutral-300);--active-background-color:var(--vertex-ui-neutral-400);--focus-background-color:var(--vertex-ui-neutral-400);--hover-box-shadow:0 2px 2px rgb(0 0 0 / 20%);--active-box-shadow:none;--focus-box-shadow:0 0 0 1px var(--vertex-ui-neutral-900);--icon-margin:0px}.container{display:flex;justify-content:center;align-items:center;outline:none;fill:currentColor;color:currentColor;cursor:var(--enabled-cursor)}.container:not(.plain){border-radius:4px;padding:0.25rem}.icon-button{display:flex;position:relative;justify-content:center;align-items:center;fill:currentColor;height:var(--icon-size, 1.5rem);width:var(--icon-size, 1.5rem)}.icon-button svg{width:100%;height:100%;margin:var(--icon-margin, 0px)}.badge{position:absolute;top:0px;right:4px;justify-content:flex-end;align-items:flex-end}.floating{background-color:var(--vertex-ui-neutral-100);box-shadow:var(--vertex-ui-overlay-shadow);color:var(--vertex-ui-neutral-700);fill:var(--vertex-ui-neutral-700);opacity:0.95}.floating.disabled{color:var(--vertex-ui-neutral-400);cursor:var(--disabled-cursor)}.container:not(.disabled):not(.plain):hover{background-color:var(--hover-background-color);box-shadow:var(--hover-box-shadow)}.container:not(.disabled):not(.plain):active{background-color:var(--active-background-color);box-shadow:var(--active-box-shadow)}.container:not(.disabled):not(.plain):focus-visible{background-color:var(--focus-background-color);box-shadow:var(--focus-box-shadow);color:var(--vertex-ui-neutral-900)}.container.disabled:not(.floating){cursor:var(--disabled-cursor);color:var(--vertex-ui-neutral-400)}.container.primary:not(.disabled){color:var(--vertex-ui-blue-700)}.container.secondary:not(.disabled){color:var(--vertex-ui-neutral-800)}.xs{height:var(--icon-size, 0.75rem);width:var(--icon-size, 0.75rem)}.sm{height:var(--icon-size, 1rem);width:var(--icon-size, 1rem)}.md{height:var(--icon-size, 1.5rem);width:var(--icon-size, 1.5rem)}.lg{height:var(--icon-size, 2rem);width:var(--icon-size, 2rem)}";
|
|
8
8
|
|
|
@@ -159,6 +159,9 @@ const CubeOrthographic = () => (index.h("svg", { xmlns: "http://www.w3.org/2000/
|
|
|
159
159
|
const CubePerspective = () => (index.h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", "data-testid": "cube-perspective" },
|
|
160
160
|
index.h("path", { d: "M13.72,4.05l-6-3a.49.49,0,0,0-.44,0l-6,3A.51.51,0,0,0,1,4.5v7a.51.51,0,0,0,.28.45l6,3a.49.49,0,0,0,.44,0l6-3A.51.51,0,0,0,14,11.5v-7A.51.51,0,0,0,13.72,4.05ZM7,13.69l-5-2.5V5.31l5,2.5Zm.5-6.75L2.62,4.5,7.5,2.06,12.38,4.5ZM13,11.19l-5,2.5V7.81l5-2.5Z" })));
|
|
161
161
|
|
|
162
|
+
const CubeStack = () => (index.h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", "data-testid": "cube-stack" },
|
|
163
|
+
index.h("path", { d: "M13.72 2.52 10.22.77a.508.508 0 0 0-.45 0l-3.5 1.75a.5.5 0 0 0-.28.45v3.81c-.08 0-.15.02-.22.05l-3.5 1.75a.5.5 0 0 0-.28.45v4.08c0 .19.11.36.28.45l3.5 1.75c.07.04.15.05.22.05s.16-.02.23-.05l7.52-3.82c.15-.1.25-.25.25-.43V2.97c0-.19-.11-.36-.28-.45ZM13 6.74l-2.46 1.23V5.03L13 3.8v2.94Zm-7.46 7.33L3 12.8V9.82l2.54 1.27v2.98Zm.5-3.85-2.4-1.2 2.37-1.18 2.4 1.2-2.37 1.18ZM9 12.78l-2.46 1.25v-2.94L9 9.86v2.92Zm.54-4.77L7 6.74V3.76l2.54 1.27v2.98ZM7.63 2.96 10 1.78l2.4 1.2-2.37 1.18-2.4-1.2Zm2.91 6.13L13 7.86v2.88l-2.46 1.25v-2.9Z" })));
|
|
164
|
+
|
|
162
165
|
const Delete = () => (index.h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", "data-testid": "delete" },
|
|
163
166
|
index.h("path", { d: "M6.5,12a.5.5,0,0,0,.5-.5v-5a.5.5,0,0,0-1,0v5A.5.5,0,0,0,6.5,12Zm3,0a.5.5,0,0,0,.5-.5v-5a.5.5,0,0,0-1,0v5A.5.5,0,0,0,9.5,12Zm4-10H10V1.5a.47.47,0,0,0-.15-.35A.47.47,0,0,0,9.5,1h-3a.47.47,0,0,0-.35.15A.47.47,0,0,0,6,1.5V2H2.5a.5.5,0,0,0,0,1H3v9.5A2.5,2.5,0,0,0,5.5,15h5A2.5,2.5,0,0,0,13,12.5V3h.5a.5.5,0,0,0,0-1ZM12,12.5A1.5,1.5,0,0,1,10.5,14h-5A1.5,1.5,0,0,1,4,12.5V4h8Z" })));
|
|
164
167
|
|
|
@@ -320,6 +323,10 @@ const PinTextSquare = () => (index.h("svg", { xmlns: "http://www.w3.org/2000/svg
|
|
|
320
323
|
const Plus = () => (index.h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", "data-testid": "plus" },
|
|
321
324
|
index.h("path", { d: "M14.36,7.5H8.5V1.64a.5.5,0,0,0-1,0V7.5H1.64a.5.5,0,0,0,0,1H7.5v5.86a.5.5,0,0,0,1,0V8.5h5.86a.5.5,0,0,0,0-1Z" })));
|
|
322
325
|
|
|
326
|
+
const PlusWithArrow = () => (index.h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", "data-testid": "plus-with-arrow" },
|
|
327
|
+
index.h("path", { d: "M8.58 1.46c-3.58 0-6.5 2.92-6.5 6.5H.59l2 3 2-3h-1.5c0-3.03 2.47-5.5 5.5-5.5s5.5 2.47 5.5 5.5-2.47 5.5-5.5 5.5c-1.19 0-2.32-.37-3.27-1.08a.505.505 0 0 0-.7.1c-.17.22-.12.53.1.7 1.13.84 2.46 1.28 3.87 1.28 3.58 0 6.5-2.92 6.5-6.5s-2.92-6.5-6.51-6.5Z" }),
|
|
328
|
+
index.h("path", { d: "M8.5 5.53c-.28 0-.5.22-.5.5v1.49H6.51c-.28 0-.5.22-.5.5s.22.5.5.5H8v1.51c0 .28.22.5.5.5s.5-.22.5-.5V8.52h1.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5H9V6.03c0-.28-.22-.5-.5-.5Z" })));
|
|
329
|
+
|
|
323
330
|
const PMI = () => (index.h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", "data-testid": "pmi" },
|
|
324
331
|
index.h("path", { d: "M14.49 6.03 4.5 6c-.28 0-.5-.22-.5-.5v-3c0-.13.05-.26.15-.35A.51.51 0 0 1 4.5 2l9.99.03c.28 0 .5.22.5.5v3c0 .13-.05.26-.15.35a.51.51 0 0 1-.35.15ZM5 5l8.99.03v-2L5 3v2Z" }),
|
|
325
332
|
index.h("path", { d: "M9.5 12.01H4.55c-.28 0-.5-.22-.5-.5s.22-.5.5-.5H9V6.02c0-.28.22-.5.5-.5s.5.22.5.5v5.49c0 .28-.22.5-.5.5Z" }),
|
|
@@ -496,6 +503,8 @@ function getSvg(name) {
|
|
|
496
503
|
return index.h(CubeOrthographic, null);
|
|
497
504
|
case 'cube-perspective':
|
|
498
505
|
return index.h(CubePerspective, null);
|
|
506
|
+
case 'cube-stack':
|
|
507
|
+
return index.h(CubeStack, null);
|
|
499
508
|
case 'delete':
|
|
500
509
|
return index.h(Delete, null);
|
|
501
510
|
case 'download':
|
|
@@ -580,6 +589,8 @@ function getSvg(name) {
|
|
|
580
589
|
return index.h(PinTextSquare, null);
|
|
581
590
|
case 'plus':
|
|
582
591
|
return index.h(Plus, null);
|
|
592
|
+
case 'plus-with-arrow':
|
|
593
|
+
return index.h(PlusWithArrow, null);
|
|
583
594
|
case 'pmi':
|
|
584
595
|
return index.h(PMI, null);
|
|
585
596
|
case 'precise-measurement':
|
package/dist/cjs/index.cjs.js
CHANGED
|
@@ -21,8 +21,8 @@ const draggablePopover = require('./draggable-popover-edf23d3a.js');
|
|
|
21
21
|
const dropdownMenu = require('./dropdown-menu-5ae03a72.js');
|
|
22
22
|
const expandable = require('./expandable-b1cd4f0b.js');
|
|
23
23
|
const helpTooltip = require('./help-tooltip-f72eccc7.js');
|
|
24
|
-
const icon = require('./icon-
|
|
25
|
-
const iconButton = require('./icon-button-
|
|
24
|
+
const icon = require('./icon-69910290.js');
|
|
25
|
+
const iconButton = require('./icon-button-ab196f5e.js');
|
|
26
26
|
const logoLoading = require('./logo-loading-4d49fedf.js');
|
|
27
27
|
const menu = require('./menu-d1ecf43b.js');
|
|
28
28
|
const menuDivider = require('./menu-divider-5bdebe5d.js');
|
|
@@ -32,7 +32,7 @@ const radio = require('./radio-bff991d2.js');
|
|
|
32
32
|
const radioGroup = require('./radio-group-d628f631.js');
|
|
33
33
|
const resizable = require('./resizable-e4248256.js');
|
|
34
34
|
const resultList = require('./result-list-241ffe8d.js');
|
|
35
|
-
const searchBar = require('./search-bar-
|
|
35
|
+
const searchBar = require('./search-bar-2e7ee35a.js');
|
|
36
36
|
const select = require('./select-5f8aecfe.js');
|
|
37
37
|
const slider = require('./slider-13594e49.js');
|
|
38
38
|
const spinner = require('./spinner-bb990a42.js');
|
|
@@ -45,7 +45,7 @@ const tooltip = require('./tooltip-9ac797a0.js');
|
|
|
45
45
|
require('./index-6a92256c.js');
|
|
46
46
|
require('./slots-fb5ac359.js');
|
|
47
47
|
require('./index-e1b40fa6.js');
|
|
48
|
-
require('./icon-helper-
|
|
48
|
+
require('./icon-helper-2ba6caba.js');
|
|
49
49
|
require('./templates-e7b3ffbb.js');
|
|
50
50
|
require('./tslib.es6-838fd860.js');
|
|
51
51
|
require('./dom-b6c5fbf4.js');
|
|
@@ -55,12 +55,24 @@ const getWindowSelection = () => {
|
|
|
55
55
|
}
|
|
56
56
|
return undefined;
|
|
57
57
|
};
|
|
58
|
+
const nodeHasChildNodes = (node) => {
|
|
59
|
+
return node.hasChildNodes();
|
|
60
|
+
};
|
|
58
61
|
const createDocumentRange = () => {
|
|
59
62
|
return document.createRange();
|
|
60
63
|
};
|
|
61
64
|
const createTextNode = (text) => {
|
|
62
65
|
return new Text(text);
|
|
63
66
|
};
|
|
67
|
+
const createBreak = () => {
|
|
68
|
+
return document.createElement('br');
|
|
69
|
+
};
|
|
70
|
+
const isHtmlElement = (node) => {
|
|
71
|
+
return node instanceof HTMLElement;
|
|
72
|
+
};
|
|
73
|
+
const isBrElement = (node) => {
|
|
74
|
+
return node instanceof HTMLBRElement;
|
|
75
|
+
};
|
|
64
76
|
|
|
65
77
|
const createResultUri = (result) => {
|
|
66
78
|
return `${result.type}:${result.id}`;
|
|
@@ -71,15 +83,56 @@ const createSearchResultReplacement = (result, before, after) => {
|
|
|
71
83
|
before: createTextNode(before),
|
|
72
84
|
beforeSpace: createTextNode(createHairSpace()),
|
|
73
85
|
result: createTextNode(urn),
|
|
74
|
-
afterSpace: after != null
|
|
86
|
+
afterSpace: after != null
|
|
87
|
+
? createTextNode(createNoBreakSpace())
|
|
88
|
+
: createTextNode(createHairSpace()),
|
|
75
89
|
after: after != null ? createTextNode(after) : undefined,
|
|
76
90
|
};
|
|
77
91
|
};
|
|
78
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Newline characters and spaces are represented slightly differently within a
|
|
94
|
+
* content editable element between browsers. This method standardizes the
|
|
95
|
+
* representation of those characters to avoid having to write branching logic
|
|
96
|
+
* to support each individual browser.
|
|
97
|
+
*/
|
|
98
|
+
const standardizeNewlinesAndSpaces = (node) => {
|
|
99
|
+
const content = node.textContent;
|
|
100
|
+
if (content === '\n') {
|
|
101
|
+
return [createBreak()];
|
|
102
|
+
}
|
|
103
|
+
else if (content != null && content.includes('\n')) {
|
|
104
|
+
const split = content.split('\n');
|
|
105
|
+
return split.reduce((res, substr, i) => {
|
|
106
|
+
const previous = split[i - 1];
|
|
107
|
+
// Ignore the empty string if the prior element was converted
|
|
108
|
+
// to a breaking element to prevent duplication of newlines.
|
|
109
|
+
if (substr === '' && previous !== '') {
|
|
110
|
+
return res;
|
|
111
|
+
}
|
|
112
|
+
return [
|
|
113
|
+
...res,
|
|
114
|
+
// Standard spaces are not always respected with in `Text`
|
|
115
|
+
// elements when appended to a contenteditable element. This
|
|
116
|
+
// conversion preserves that spacing.
|
|
117
|
+
createTextNode(substr.replace(/ /g, createNoBreakSpace())),
|
|
118
|
+
createBreak(),
|
|
119
|
+
];
|
|
120
|
+
}, []);
|
|
121
|
+
}
|
|
122
|
+
return [node];
|
|
123
|
+
};
|
|
124
|
+
const getNodesForSearchResultReplacement = (replacement, isBreaking = false) => {
|
|
79
125
|
const keys = Object.keys(replacement);
|
|
80
|
-
|
|
126
|
+
const replacementElements = keys
|
|
81
127
|
.map((key) => replacement[key])
|
|
82
128
|
.filter((node) => node != null);
|
|
129
|
+
// If the element is intended to replace a breaking element such
|
|
130
|
+
// as a `<div>` wrapper, a newline is required alongside the standard
|
|
131
|
+
// replacement elements.
|
|
132
|
+
if (isBreaking) {
|
|
133
|
+
return [createTextNode('\n'), ...replacementElements];
|
|
134
|
+
}
|
|
135
|
+
return replacementElements;
|
|
83
136
|
};
|
|
84
137
|
/**
|
|
85
138
|
* We leverage a couple unique spaces to represent mentions, allowing for
|
|
@@ -114,13 +167,34 @@ const SearchBar = class {
|
|
|
114
167
|
this.inputFocus = index.createEvent(this, "inputFocus", 7);
|
|
115
168
|
this.inputBlur = index.createEvent(this, "inputBlur", 7);
|
|
116
169
|
this.rawElements = [];
|
|
170
|
+
this.attemptReplaceElement = (child, other, replacement, isBreaking = false) => {
|
|
171
|
+
// In the case that the child we're evaluating has its own children
|
|
172
|
+
// (often a wrapper `<div>`), we want to evaluate whether any of its
|
|
173
|
+
// children is the target to replace.
|
|
174
|
+
if (nodeHasChildNodes(child) &&
|
|
175
|
+
Array.from(child.childNodes).some((c) => nodeHasChildNodes(c) || this.isIdenticalElement(c, other))) {
|
|
176
|
+
return Array.from(child.childNodes).reduce((res, c) => [
|
|
177
|
+
...res,
|
|
178
|
+
...this.attemptReplaceElement(c, other, replacement,
|
|
179
|
+
// If the element we're evaluating is a wrapper, we want to
|
|
180
|
+
// consider it a breaking element and add a newline to the
|
|
181
|
+
// replaced element only if the previous node is a `Text` node.
|
|
182
|
+
!isHtmlElement(child.previousSibling)),
|
|
183
|
+
], []);
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
return this.isIdenticalElement(child, other)
|
|
187
|
+
? getNodesForSearchResultReplacement(replacement, isBreaking)
|
|
188
|
+
: [child];
|
|
189
|
+
}
|
|
190
|
+
};
|
|
117
191
|
this.isIdenticalElement = (child, other) => {
|
|
118
192
|
return (child === this.triggeredElement ||
|
|
119
193
|
this.getTextContent(child) === this.getTextContent(other));
|
|
120
194
|
};
|
|
121
195
|
this.getTextContent = (node) => {
|
|
122
196
|
var _a;
|
|
123
|
-
if (node
|
|
197
|
+
if (isHtmlElement(node)) {
|
|
124
198
|
return node.innerText;
|
|
125
199
|
}
|
|
126
200
|
return (_a = node.textContent) !== null && _a !== void 0 ? _a : '';
|
|
@@ -197,21 +271,54 @@ const SearchBar = class {
|
|
|
197
271
|
selection.addRange(range);
|
|
198
272
|
}
|
|
199
273
|
};
|
|
200
|
-
this.getContentAsString = () => {
|
|
201
|
-
if (
|
|
202
|
-
|
|
274
|
+
this.getContentAsString = (element) => {
|
|
275
|
+
if (element != null) {
|
|
276
|
+
const res = trimNonstandardSpaces(Array.from(element.childNodes).reduce((res, n) => {
|
|
203
277
|
var _a;
|
|
204
|
-
|
|
205
|
-
|
|
278
|
+
const previousSiblingIsBlock = n.previousSibling == null || isHtmlElement(n.previousSibling);
|
|
279
|
+
if (isHtmlElement(n) && n.getAttribute('data-replaced') === 'true') {
|
|
280
|
+
/**
|
|
281
|
+
* If an element has been replaced visually, append the original
|
|
282
|
+
* value prior to being replaced.
|
|
283
|
+
*/
|
|
206
284
|
return `${res}${n.getAttribute('data-original')}`;
|
|
207
285
|
}
|
|
208
|
-
else if (n
|
|
209
|
-
|
|
286
|
+
else if (isHtmlElement(n) && n.childElementCount > 0) {
|
|
287
|
+
/**
|
|
288
|
+
* If an element is a wrapper, we want to treat it as a block element,
|
|
289
|
+
* ensuring newlines before and after the content.
|
|
290
|
+
* Additionally, we want to evaluate each of its children independently.
|
|
291
|
+
* Some browsers will conditionally wrap content in additional wrapper
|
|
292
|
+
* elements we need to unravel.
|
|
293
|
+
*/
|
|
294
|
+
return `${res}${previousSiblingIsBlock ? '' : '\n'}${this.getContentAsString(n)}`;
|
|
295
|
+
}
|
|
296
|
+
else if (isBrElement(n)) {
|
|
297
|
+
/**
|
|
298
|
+
* If an element is a `<br>` element, we want to simply represent
|
|
299
|
+
* it as a newline in the returned string.
|
|
300
|
+
*/
|
|
301
|
+
return `${res}\n`;
|
|
302
|
+
}
|
|
303
|
+
else if (isHtmlElement(n)) {
|
|
304
|
+
/**
|
|
305
|
+
* If an element is a wrapper, we want to treat it as a block element,
|
|
306
|
+
* ensuring newlines before and after the content.
|
|
307
|
+
* If the prior element is also to be treated as a block format, we
|
|
308
|
+
* will omit the newline before the content to avoid duplicating the
|
|
309
|
+
* behavior.
|
|
310
|
+
*/
|
|
311
|
+
return `${res}${previousSiblingIsBlock ? '' : '\n'}${n.innerText}\n`;
|
|
210
312
|
}
|
|
211
313
|
else {
|
|
314
|
+
/**
|
|
315
|
+
* If a node is simply a `Text` node, we just want to append the text
|
|
316
|
+
* if defined.
|
|
317
|
+
*/
|
|
212
318
|
return `${res}${(_a = n.textContent) !== null && _a !== void 0 ? _a : ''}`;
|
|
213
319
|
}
|
|
214
320
|
}, ''));
|
|
321
|
+
return res;
|
|
215
322
|
}
|
|
216
323
|
return '';
|
|
217
324
|
};
|
|
@@ -287,12 +394,13 @@ const SearchBar = class {
|
|
|
287
394
|
replacement.before,
|
|
288
395
|
replacement.beforeSpace,
|
|
289
396
|
replacement.result,
|
|
397
|
+
replacement.afterSpace,
|
|
290
398
|
];
|
|
291
399
|
}
|
|
292
400
|
return res;
|
|
293
401
|
}, [])
|
|
294
402
|
: [];
|
|
295
|
-
this.rawElements = [...parts, createTextNode(nextSubstr)];
|
|
403
|
+
this.rawElements = [...parts, createTextNode(nextSubstr)].reduce((res, p) => [...res, ...standardizeNewlinesAndSpaces(p)], []);
|
|
296
404
|
this.updateContent(this.replacements);
|
|
297
405
|
}
|
|
298
406
|
}
|
|
@@ -300,7 +408,7 @@ const SearchBar = class {
|
|
|
300
408
|
if (this.contentEl != null && !fastDeepEqual(newValue, oldValue)) {
|
|
301
409
|
this.contentEl.innerHTML = '';
|
|
302
410
|
this.displayedElements = this.rawElements.map((el) => {
|
|
303
|
-
const raw = el
|
|
411
|
+
const raw = isHtmlElement(el) ? el.innerText : el.textContent;
|
|
304
412
|
const replacement = this.replacements.find((r) => raw === null || raw === void 0 ? void 0 : raw.includes(createResultUri(r)));
|
|
305
413
|
if (raw != null && replacement != null) {
|
|
306
414
|
const replacementElement = this.createReplacedElement(raw, replacement);
|
|
@@ -315,7 +423,7 @@ const SearchBar = class {
|
|
|
315
423
|
if (this.lastReplacedSpace != null) {
|
|
316
424
|
this.moveCursorToNodeEnd(this.lastReplacedSpace);
|
|
317
425
|
}
|
|
318
|
-
this.inputChanged.emit(this.getContentAsString());
|
|
426
|
+
this.inputChanged.emit(this.getContentAsString(this.contentEl));
|
|
319
427
|
}
|
|
320
428
|
}
|
|
321
429
|
render() {
|
|
@@ -327,7 +435,7 @@ const SearchBar = class {
|
|
|
327
435
|
blank: this.variant === 'blank',
|
|
328
436
|
disabled: this.disabled,
|
|
329
437
|
});
|
|
330
|
-
return (index.h(index.Host, null, index.h("div", { class: classes }, index.h("span", { class: "content-input", role: "textbox", contentEditable: "true", "aria-multiline": "true", "data-placeholder": this.placeholder, ref: (el) => (this.contentEl = el), onKeyDown: this.handleKeyDown, onKeyUp: this.
|
|
438
|
+
return (index.h(index.Host, null, index.h("div", { class: classes }, index.h("span", { class: "content-input", role: "textbox", contentEditable: "true", "aria-multiline": "true", "data-placeholder": this.placeholder, ref: (el) => (this.contentEl = el), onKeyDown: this.handleKeyDown, onKeyUp: this.handleKeyUp, onClick: this.handleCursorPositionUpdate, onInput: this.handleInput, onFocus: this.handleFocus, onBlur: this.handleBlur })), index.h("vertex-result-list", { position: this.cursorPosition, placement: this.placement, open: this.hasTriggered &&
|
|
331
439
|
this.resultItems != null &&
|
|
332
440
|
this.resultItems.length > 0, items: (_a = this.resultItems) !== null && _a !== void 0 ? _a : [], onEnterPressed: this.handleResultClick, onResultClick: this.handleResultClick }, index.h("slot", { name: "results" })), index.h("slot", { name: "replaced" })));
|
|
333
441
|
}
|
|
@@ -343,13 +451,13 @@ const SearchBar = class {
|
|
|
343
451
|
this.cursorPosition = this.getCursorPosition();
|
|
344
452
|
}
|
|
345
453
|
async handleInput() {
|
|
346
|
-
this.inputChanged.emit(this.getContentAsString());
|
|
454
|
+
this.inputChanged.emit(this.getContentAsString(this.contentEl));
|
|
347
455
|
}
|
|
348
456
|
handleClick() {
|
|
349
457
|
this.handleCursorPositionUpdate();
|
|
350
458
|
}
|
|
351
459
|
handleWindowClick(event) {
|
|
352
|
-
if (event.target
|
|
460
|
+
if (isHtmlElement(event.target) &&
|
|
353
461
|
event.target.getAttribute('data-replaced') === 'true' &&
|
|
354
462
|
event.target.nextSibling != null) {
|
|
355
463
|
this.moveCursorToNodeEnd(event.target.nextSibling, true);
|
|
@@ -366,7 +474,7 @@ const SearchBar = class {
|
|
|
366
474
|
var _a;
|
|
367
475
|
const triggeredRange = this.triggeredRange;
|
|
368
476
|
const triggeredElement = this.triggeredElement;
|
|
369
|
-
const value = triggeredElement
|
|
477
|
+
const value = isHtmlElement(triggeredElement)
|
|
370
478
|
? triggeredElement.innerText
|
|
371
479
|
: triggeredElement === null || triggeredElement === void 0 ? void 0 : triggeredElement.textContent;
|
|
372
480
|
if (this.contentEl != null &&
|
|
@@ -380,12 +488,10 @@ const SearchBar = class {
|
|
|
380
488
|
const replacement = createSearchResultReplacement(event.detail, before, after);
|
|
381
489
|
this.lastReplacedSpace = replacement.afterSpace;
|
|
382
490
|
this.rawElements = Array.from(this.contentEl.childNodes).reduce((re, e) => {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
return [...re, e];
|
|
388
|
-
}
|
|
491
|
+
return [
|
|
492
|
+
...re,
|
|
493
|
+
...this.attemptReplaceElement(e, triggeredElement, replacement),
|
|
494
|
+
];
|
|
389
495
|
}, []);
|
|
390
496
|
this.hasTriggered = false;
|
|
391
497
|
this.resultReplaced.emit(event.detail);
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const iconButton = require('./icon-button-
|
|
5
|
+
const iconButton = require('./icon-button-ab196f5e.js');
|
|
6
6
|
require('./index-6a92256c.js');
|
|
7
7
|
require('./index-e1b40fa6.js');
|
|
8
|
-
require('./icon-helper-
|
|
8
|
+
require('./icon-helper-2ba6caba.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const icon = require('./icon-
|
|
5
|
+
const icon = require('./icon-69910290.js');
|
|
6
6
|
require('./index-6a92256c.js');
|
|
7
7
|
require('./index-e1b40fa6.js');
|
|
8
|
-
require('./icon-helper-
|
|
8
|
+
require('./icon-helper-2ba6caba.js');
|
|
9
9
|
|
|
10
10
|
|
|
11
11
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const searchBar = require('./search-bar-
|
|
5
|
+
const searchBar = require('./search-bar-2e7ee35a.js');
|
|
6
6
|
require('./index-6a92256c.js');
|
|
7
7
|
require('./index-e1b40fa6.js');
|
|
8
8
|
require('./templates-e7b3ffbb.js');
|
|
@@ -46,6 +46,7 @@ import { Copy } from './icons/copy';
|
|
|
46
46
|
import { CrossSection } from './icons/cross-section';
|
|
47
47
|
import { CubeOrthographic } from './icons/cube-orthographic';
|
|
48
48
|
import { CubePerspective } from './icons/cube-perspective';
|
|
49
|
+
import { CubeStack } from './icons/cube-stack';
|
|
49
50
|
import { Delete } from './icons/delete';
|
|
50
51
|
import { Download } from './icons/download';
|
|
51
52
|
import { DragIndicator } from './icons/drag-indicator';
|
|
@@ -88,6 +89,7 @@ import { PinText } from './icons/pin-text';
|
|
|
88
89
|
import { PinTextFill } from './icons/pin-text-fill';
|
|
89
90
|
import { PinTextSquare } from './icons/pin-text-square';
|
|
90
91
|
import { Plus } from './icons/plus';
|
|
92
|
+
import { PlusWithArrow } from './icons/plus-with-arrow';
|
|
91
93
|
import { PMI } from './icons/pmi';
|
|
92
94
|
import { PreciseMeasurement } from './icons/precise-measurement';
|
|
93
95
|
import { Rabbit } from './icons/rabbit';
|
|
@@ -206,6 +208,8 @@ export function getSvg(name) {
|
|
|
206
208
|
return h(CubeOrthographic, null);
|
|
207
209
|
case 'cube-perspective':
|
|
208
210
|
return h(CubePerspective, null);
|
|
211
|
+
case 'cube-stack':
|
|
212
|
+
return h(CubeStack, null);
|
|
209
213
|
case 'delete':
|
|
210
214
|
return h(Delete, null);
|
|
211
215
|
case 'download':
|
|
@@ -290,6 +294,8 @@ export function getSvg(name) {
|
|
|
290
294
|
return h(PinTextSquare, null);
|
|
291
295
|
case 'plus':
|
|
292
296
|
return h(Plus, null);
|
|
297
|
+
case 'plus-with-arrow':
|
|
298
|
+
return h(PlusWithArrow, null);
|
|
293
299
|
case 'pmi':
|
|
294
300
|
return h(PMI, null);
|
|
295
301
|
case 'precise-measurement':
|
|
@@ -33,7 +33,7 @@ export class Icon {
|
|
|
33
33
|
"mutable": false,
|
|
34
34
|
"complexType": {
|
|
35
35
|
"original": "IconName",
|
|
36
|
-
"resolved": "\"compare\" | \"help\" | \"open\" | \"info\" | \"copy\" | \"menu\" | \"ellipse\" | \"line\" | \"download\" | \"rotate\" | \"close\" | \"flip\" | \"reset\" | \"resize\" | \"search\" | \"caret-down\" | \"caret-up\" | \"adjustments\" | \"align-to-global\" | \"align-to-part\" | \"align-to-surface\" | \"align-view-to-plane\" | \"annotation\" | \"arrow-filled\" | \"arrow-line-left\" | \"arrow-line-right\" | \"arrow-partial\" | \"arrow-triangle-left\" | \"arrow-triangle-right\" | \"arrow-up-circled\" | \"attachment\" | \"axis-x\" | \"axis-y\" | \"axis-z\" | \"back\" | \"box-cursor\" | \"box-select\" | \"camera\" | \"caret-left\" | \"check\" | \"check-circle\" | \"caret-right\" | \"chevron-down\" | \"chevron-left\" | \"chevron-right\" | \"chevron-up\" | \"circle-outline\" | \"close-circle-fill\" | \"close-circle\" | \"collapse-all\" | \"columns\" | \"comment-add\" | \"comment-filled\" | \"comment-reopen\" | \"comment-resolve\" | \"comment-show\" | \"cross-section\" | \"cube-orthographic\" | \"cube-perspective\" | \"delete\" | \"drag-indicator\" | \"error-circle\" | \"expand-all\" | \"export\" | \"file\" | \"file-pdf\" | \"fit-all\" | \"fit-selected\" | \"folder-plus\" | \"forward\" | \"gear\" | \"invert\" | \"line-dot-left\" | \"line-dot-right\" | \"line-hash-left\" | \"line-hash-right\" | \"locate\" | \"markup\" | \"notification\" | \"open-window\" | \"pan\" | \"pencil\" | \"person-height\" | \"person-run\" | \"person-short\" | \"person-tall\" | \"person-walk\" | \"pin-fill\" | \"pin-line\" | \"pin-text\" | \"pin-text-fill\" | \"pin-text-square\" | \"plus\" | \"pmi\" | \"precise-measurement\" | \"rabbit\" | \"ruler\" | \"show-only-nearby\" | \"snapshots\" | \"star\" | \"tape-measure\" | \"teleport-and-align\" | \"teleport-toward\" | \"teleport\" | \"turtle\" | \"version-history\" | \"views\" | \"visibility-hidden\" | \"visibility-partial\" | \"visibility-visible\" | \"zoom\"",
|
|
36
|
+
"resolved": "\"compare\" | \"help\" | \"open\" | \"info\" | \"copy\" | \"menu\" | \"ellipse\" | \"line\" | \"download\" | \"rotate\" | \"close\" | \"flip\" | \"reset\" | \"resize\" | \"search\" | \"caret-down\" | \"caret-up\" | \"adjustments\" | \"align-to-global\" | \"align-to-part\" | \"align-to-surface\" | \"align-view-to-plane\" | \"annotation\" | \"arrow-filled\" | \"arrow-line-left\" | \"arrow-line-right\" | \"arrow-partial\" | \"arrow-triangle-left\" | \"arrow-triangle-right\" | \"arrow-up-circled\" | \"attachment\" | \"axis-x\" | \"axis-y\" | \"axis-z\" | \"back\" | \"box-cursor\" | \"box-select\" | \"camera\" | \"caret-left\" | \"check\" | \"check-circle\" | \"caret-right\" | \"chevron-down\" | \"chevron-left\" | \"chevron-right\" | \"chevron-up\" | \"circle-outline\" | \"close-circle-fill\" | \"close-circle\" | \"collapse-all\" | \"columns\" | \"comment-add\" | \"comment-filled\" | \"comment-reopen\" | \"comment-resolve\" | \"comment-show\" | \"cross-section\" | \"cube-orthographic\" | \"cube-perspective\" | \"cube-stack\" | \"delete\" | \"drag-indicator\" | \"error-circle\" | \"expand-all\" | \"export\" | \"file\" | \"file-pdf\" | \"fit-all\" | \"fit-selected\" | \"folder-plus\" | \"forward\" | \"gear\" | \"invert\" | \"line-dot-left\" | \"line-dot-right\" | \"line-hash-left\" | \"line-hash-right\" | \"locate\" | \"markup\" | \"notification\" | \"open-window\" | \"pan\" | \"pencil\" | \"person-height\" | \"person-run\" | \"person-short\" | \"person-tall\" | \"person-walk\" | \"pin-fill\" | \"pin-line\" | \"pin-text\" | \"pin-text-fill\" | \"pin-text-square\" | \"plus\" | \"plus-with-arrow\" | \"pmi\" | \"precise-measurement\" | \"rabbit\" | \"ruler\" | \"show-only-nearby\" | \"snapshots\" | \"star\" | \"tape-measure\" | \"teleport-and-align\" | \"teleport-toward\" | \"teleport\" | \"turtle\" | \"version-history\" | \"views\" | \"visibility-hidden\" | \"visibility-partial\" | \"visibility-visible\" | \"zoom\"",
|
|
37
37
|
"references": {
|
|
38
38
|
"IconName": {
|
|
39
39
|
"location": "import",
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
export const CubeStack = () => (h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", "data-testid": "cube-stack" }, h("path", { d: "M13.72 2.52 10.22.77a.508.508 0 0 0-.45 0l-3.5 1.75a.5.5 0 0 0-.28.45v3.81c-.08 0-.15.02-.22.05l-3.5 1.75a.5.5 0 0 0-.28.45v4.08c0 .19.11.36.28.45l3.5 1.75c.07.04.15.05.22.05s.16-.02.23-.05l7.52-3.82c.15-.1.25-.25.25-.43V2.97c0-.19-.11-.36-.28-.45ZM13 6.74l-2.46 1.23V5.03L13 3.8v2.94Zm-7.46 7.33L3 12.8V9.82l2.54 1.27v2.98Zm.5-3.85-2.4-1.2 2.37-1.18 2.4 1.2-2.37 1.18ZM9 12.78l-2.46 1.25v-2.94L9 9.86v2.92Zm.54-4.77L7 6.74V3.76l2.54 1.27v2.98ZM7.63 2.96 10 1.78l2.4 1.2-2.37 1.18-2.4-1.2Zm2.91 6.13L13 7.86v2.88l-2.46 1.25v-2.9Z" })));
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { h } from '@stencil/core';
|
|
2
|
+
export const PlusWithArrow = () => (h("svg", { xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 16 16", "data-testid": "plus-with-arrow" }, h("path", { d: "M8.58 1.46c-3.58 0-6.5 2.92-6.5 6.5H.59l2 3 2-3h-1.5c0-3.03 2.47-5.5 5.5-5.5s5.5 2.47 5.5 5.5-2.47 5.5-5.5 5.5c-1.19 0-2.32-.37-3.27-1.08a.505.505 0 0 0-.7.1c-.17.22-.12.53.1.7 1.13.84 2.46 1.28 3.87 1.28 3.58 0 6.5-2.92 6.5-6.5s-2.92-6.5-6.51-6.5Z" }), h("path", { d: "M8.5 5.53c-.28 0-.5.22-.5.5v1.49H6.51c-.28 0-.5.22-.5.5s.22.5.5.5H8v1.51c0 .28.22.5.5.5s.5-.22.5-.5V8.52h1.5c.28 0 .5-.22.5-.5s-.22-.5-.5-.5H9V6.03c0-.28-.22-.5-.5-.5Z" })));
|
|
@@ -50,7 +50,7 @@ export class IconButton {
|
|
|
50
50
|
"mutable": false,
|
|
51
51
|
"complexType": {
|
|
52
52
|
"original": "IconName",
|
|
53
|
-
"resolved": "\"compare\" | \"help\" | \"open\" | \"info\" | \"copy\" | \"menu\" | \"ellipse\" | \"line\" | \"download\" | \"rotate\" | \"close\" | \"flip\" | \"reset\" | \"resize\" | \"search\" | \"caret-down\" | \"caret-up\" | \"adjustments\" | \"align-to-global\" | \"align-to-part\" | \"align-to-surface\" | \"align-view-to-plane\" | \"annotation\" | \"arrow-filled\" | \"arrow-line-left\" | \"arrow-line-right\" | \"arrow-partial\" | \"arrow-triangle-left\" | \"arrow-triangle-right\" | \"arrow-up-circled\" | \"attachment\" | \"axis-x\" | \"axis-y\" | \"axis-z\" | \"back\" | \"box-cursor\" | \"box-select\" | \"camera\" | \"caret-left\" | \"check\" | \"check-circle\" | \"caret-right\" | \"chevron-down\" | \"chevron-left\" | \"chevron-right\" | \"chevron-up\" | \"circle-outline\" | \"close-circle-fill\" | \"close-circle\" | \"collapse-all\" | \"columns\" | \"comment-add\" | \"comment-filled\" | \"comment-reopen\" | \"comment-resolve\" | \"comment-show\" | \"cross-section\" | \"cube-orthographic\" | \"cube-perspective\" | \"delete\" | \"drag-indicator\" | \"error-circle\" | \"expand-all\" | \"export\" | \"file\" | \"file-pdf\" | \"fit-all\" | \"fit-selected\" | \"folder-plus\" | \"forward\" | \"gear\" | \"invert\" | \"line-dot-left\" | \"line-dot-right\" | \"line-hash-left\" | \"line-hash-right\" | \"locate\" | \"markup\" | \"notification\" | \"open-window\" | \"pan\" | \"pencil\" | \"person-height\" | \"person-run\" | \"person-short\" | \"person-tall\" | \"person-walk\" | \"pin-fill\" | \"pin-line\" | \"pin-text\" | \"pin-text-fill\" | \"pin-text-square\" | \"plus\" | \"pmi\" | \"precise-measurement\" | \"rabbit\" | \"ruler\" | \"show-only-nearby\" | \"snapshots\" | \"star\" | \"tape-measure\" | \"teleport-and-align\" | \"teleport-toward\" | \"teleport\" | \"turtle\" | \"version-history\" | \"views\" | \"visibility-hidden\" | \"visibility-partial\" | \"visibility-visible\" | \"zoom\"",
|
|
53
|
+
"resolved": "\"compare\" | \"help\" | \"open\" | \"info\" | \"copy\" | \"menu\" | \"ellipse\" | \"line\" | \"download\" | \"rotate\" | \"close\" | \"flip\" | \"reset\" | \"resize\" | \"search\" | \"caret-down\" | \"caret-up\" | \"adjustments\" | \"align-to-global\" | \"align-to-part\" | \"align-to-surface\" | \"align-view-to-plane\" | \"annotation\" | \"arrow-filled\" | \"arrow-line-left\" | \"arrow-line-right\" | \"arrow-partial\" | \"arrow-triangle-left\" | \"arrow-triangle-right\" | \"arrow-up-circled\" | \"attachment\" | \"axis-x\" | \"axis-y\" | \"axis-z\" | \"back\" | \"box-cursor\" | \"box-select\" | \"camera\" | \"caret-left\" | \"check\" | \"check-circle\" | \"caret-right\" | \"chevron-down\" | \"chevron-left\" | \"chevron-right\" | \"chevron-up\" | \"circle-outline\" | \"close-circle-fill\" | \"close-circle\" | \"collapse-all\" | \"columns\" | \"comment-add\" | \"comment-filled\" | \"comment-reopen\" | \"comment-resolve\" | \"comment-show\" | \"cross-section\" | \"cube-orthographic\" | \"cube-perspective\" | \"cube-stack\" | \"delete\" | \"drag-indicator\" | \"error-circle\" | \"expand-all\" | \"export\" | \"file\" | \"file-pdf\" | \"fit-all\" | \"fit-selected\" | \"folder-plus\" | \"forward\" | \"gear\" | \"invert\" | \"line-dot-left\" | \"line-dot-right\" | \"line-hash-left\" | \"line-hash-right\" | \"locate\" | \"markup\" | \"notification\" | \"open-window\" | \"pan\" | \"pencil\" | \"person-height\" | \"person-run\" | \"person-short\" | \"person-tall\" | \"person-walk\" | \"pin-fill\" | \"pin-line\" | \"pin-text\" | \"pin-text-fill\" | \"pin-text-square\" | \"plus\" | \"plus-with-arrow\" | \"pmi\" | \"precise-measurement\" | \"rabbit\" | \"ruler\" | \"show-only-nearby\" | \"snapshots\" | \"star\" | \"tape-measure\" | \"teleport-and-align\" | \"teleport-toward\" | \"teleport\" | \"turtle\" | \"version-history\" | \"views\" | \"visibility-hidden\" | \"visibility-partial\" | \"visibility-visible\" | \"zoom\"",
|
|
54
54
|
"references": {
|
|
55
55
|
"IconName": {
|
|
56
56
|
"location": "import",
|
|
@@ -4,9 +4,26 @@ export const getWindowSelection = () => {
|
|
|
4
4
|
}
|
|
5
5
|
return undefined;
|
|
6
6
|
};
|
|
7
|
+
export const nodeHasChildNodes = (node) => {
|
|
8
|
+
return node.hasChildNodes();
|
|
9
|
+
};
|
|
7
10
|
export const createDocumentRange = () => {
|
|
8
11
|
return document.createRange();
|
|
9
12
|
};
|
|
10
13
|
export const createTextNode = (text) => {
|
|
11
14
|
return new Text(text);
|
|
12
15
|
};
|
|
16
|
+
export const createBreak = () => {
|
|
17
|
+
return document.createElement('br');
|
|
18
|
+
};
|
|
19
|
+
export const createWrappingDiv = (nodes) => {
|
|
20
|
+
const el = document.createElement('div');
|
|
21
|
+
el.append(...nodes);
|
|
22
|
+
return el;
|
|
23
|
+
};
|
|
24
|
+
export const isHtmlElement = (node) => {
|
|
25
|
+
return node instanceof HTMLElement;
|
|
26
|
+
};
|
|
27
|
+
export const isBrElement = (node) => {
|
|
28
|
+
return node instanceof HTMLBRElement;
|
|
29
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createTextNode } from './dom';
|
|
1
|
+
import { createBreak, createTextNode } from './dom';
|
|
2
2
|
export const createResultUri = (result) => {
|
|
3
3
|
return `${result.type}:${result.id}`;
|
|
4
4
|
};
|
|
@@ -8,15 +8,56 @@ export const createSearchResultReplacement = (result, before, after) => {
|
|
|
8
8
|
before: createTextNode(before),
|
|
9
9
|
beforeSpace: createTextNode(createHairSpace()),
|
|
10
10
|
result: createTextNode(urn),
|
|
11
|
-
afterSpace: after != null
|
|
11
|
+
afterSpace: after != null
|
|
12
|
+
? createTextNode(createNoBreakSpace())
|
|
13
|
+
: createTextNode(createHairSpace()),
|
|
12
14
|
after: after != null ? createTextNode(after) : undefined,
|
|
13
15
|
};
|
|
14
16
|
};
|
|
15
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Newline characters and spaces are represented slightly differently within a
|
|
19
|
+
* content editable element between browsers. This method standardizes the
|
|
20
|
+
* representation of those characters to avoid having to write branching logic
|
|
21
|
+
* to support each individual browser.
|
|
22
|
+
*/
|
|
23
|
+
export const standardizeNewlinesAndSpaces = (node) => {
|
|
24
|
+
const content = node.textContent;
|
|
25
|
+
if (content === '\n') {
|
|
26
|
+
return [createBreak()];
|
|
27
|
+
}
|
|
28
|
+
else if (content != null && content.includes('\n')) {
|
|
29
|
+
const split = content.split('\n');
|
|
30
|
+
return split.reduce((res, substr, i) => {
|
|
31
|
+
const previous = split[i - 1];
|
|
32
|
+
// Ignore the empty string if the prior element was converted
|
|
33
|
+
// to a breaking element to prevent duplication of newlines.
|
|
34
|
+
if (substr === '' && previous !== '') {
|
|
35
|
+
return res;
|
|
36
|
+
}
|
|
37
|
+
return [
|
|
38
|
+
...res,
|
|
39
|
+
// Standard spaces are not always respected with in `Text`
|
|
40
|
+
// elements when appended to a contenteditable element. This
|
|
41
|
+
// conversion preserves that spacing.
|
|
42
|
+
createTextNode(substr.replace(/ /g, createNoBreakSpace())),
|
|
43
|
+
createBreak(),
|
|
44
|
+
];
|
|
45
|
+
}, []);
|
|
46
|
+
}
|
|
47
|
+
return [node];
|
|
48
|
+
};
|
|
49
|
+
export const getNodesForSearchResultReplacement = (replacement, isBreaking = false) => {
|
|
16
50
|
const keys = Object.keys(replacement);
|
|
17
|
-
|
|
51
|
+
const replacementElements = keys
|
|
18
52
|
.map((key) => replacement[key])
|
|
19
53
|
.filter((node) => node != null);
|
|
54
|
+
// If the element is intended to replace a breaking element such
|
|
55
|
+
// as a `<div>` wrapper, a newline is required alongside the standard
|
|
56
|
+
// replacement elements.
|
|
57
|
+
if (isBreaking) {
|
|
58
|
+
return [createTextNode('\n'), ...replacementElements];
|
|
59
|
+
}
|
|
60
|
+
return replacementElements;
|
|
20
61
|
};
|
|
21
62
|
/**
|
|
22
63
|
* We leverage a couple unique spaces to represent mentions, allowing for
|