Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: LEAP-523: Return region's text to item in a list #5323

Merged
merged 13 commits into from
Jan 26, 2024
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web/dist/apps/labelstudio/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/apps/labelstudio/main.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/libs/datamanager/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/libs/datamanager/main.js.map

Large diffs are not rendered by default.

42 changes: 28 additions & 14 deletions web/dist/libs/editor/3rdpartylicenses.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1627,20 +1627,34 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


d3-color
ISC
Copyright 2010-2022 Mike Bostock

Permission to use, copy, modify, and/or distribute this software for any purpose
with or without fee is hereby granted, provided that the above copyright notice
and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF
THIS SOFTWARE.
BSD-3-Clause
Copyright 2010-2016 Mike Bostock
All rights reserved.

Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.

* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.

* Neither the name of the author nor the names of contributors may be used to
endorse or promote products derived from this software without specific prior
written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.


d3-contour
Expand Down
2 changes: 1 addition & 1 deletion web/dist/libs/editor/main.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/libs/editor/main.css.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/libs/editor/main.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion web/dist/libs/editor/main.js.map

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions web/libs/editor/src/components/Node/Node.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ const NodeDebug: FC<any> = observer(({ className, node }) => {
const Node: FC<any> = observer(({ className, node }) => {
const name = useNodeName(node);

if (!(name in NodeViews)) {
if (!name || !(name in NodeViews)) {
console.error(`No ${name} in NodeView`);
return null;
}
Expand All @@ -138,9 +138,9 @@ const Node: FC<any> = observer(({ className, node }) => {
return (
<Block name="node" tag="span" className={className}>
{labelName}
{node?.isDrawing && (
{node.isDrawing && (
<Elem tag="span" name="incomplete">
<Tooltip title="Incomplete polygon">
<Tooltip title={`Incomplete ${node.type?.replace('region', '') ?? 'region'}`}>
<IconWarning />
</Tooltip>
</Elem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,9 @@ export const RegionDetailsMain: FC<{region: any}> = observer(({
{region?.text ? (
<Block name="region-meta">
<Elem name="item">
<Elem
name="content"
mod={{ type: 'text' }}
dangerouslySetInnerHTML={{
__html: region.text.replace(/\\n/g, '\n'),
}}
/>
<Elem name="content" mod={{ type: 'text' }}>
{region.text.replace(/\\n/g, '\n')}
</Elem>
</Elem>
</Block>
) : null}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ export const RegionItem: FC<RegionItemProps> = observer(({
{withIds && <span>{region.cleanId}</span>}
</Elem>
{MainDetails && <Elem name="content"><MainDetails region={region}/></Elem>}
{region?.isDrawing && (
{region.isDrawing && (
<Elem name="warning">
<IconWarning />
<Elem name="warning-text">Incomplete {region.type.replace('region', '')}</Elem>
<Elem name="warning-text">Incomplete {region.type?.replace('region', '') ?? 'region'}</Elem>
</Elem>
)}
{withActions && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ const NodeIconComponent: FC<any> = observer(({ node }) => {
});

const RootTitle: FC<any> = observer(({
item,
item, // can be undefined for group titles in Labels or Tools mode
label,
isArea,
...props
Expand Down Expand Up @@ -437,9 +437,10 @@ const RootTitle: FC<any> = observer(({
{!props.isGroup && <Elem name="index">{props.idx + 1}</Elem>}
<Elem name="title">
{label}
{item?.text && <Elem name="text">{item.text.replace(/\\n/g, '\n')}</Elem>}
{item?.isDrawing && (
<Elem tag="span" name="incomplete">
<Tooltip title="Incomplete polygon">
<Tooltip title={`Incomplete ${item.type?.replace('region', '') ?? 'region'}$`}>
<IconWarning />
</Tooltip>
</Elem>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
&-title
flex 1
padding-left 5px
min-width 0

.labels-list
display inline-block
Expand Down Expand Up @@ -117,6 +118,14 @@
display inline-flex
flex 1
color var(--text-color, #000)
min-width 0

&__text
margin-left 5px
color #000
overflow hidden
white-space nowrap
text-overflow ellipsis

&__incomplete
display inline-flex
Expand Down
2 changes: 1 addition & 1 deletion web/libs/editor/src/tags/object/RichText/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ const Model = types
// nodes count better be the same, so replace them with stubs
// we should not sanitize text tasks because we already have htmlEscape in view.js
if (isFF(FF_SAFE_TEXT) && self.type === 'text') {
self._value = String(val);
self._value = val;
} else {
self._value = sanitizeHtml(String(val));
}
Expand Down
8 changes: 4 additions & 4 deletions web/libs/editor/src/utils/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ export const parseValue = (value, task) => {

// value can refer to structures, not only texts, so just replace wouldn't be enough
if (value.match(reVar)?.[0] === value) {
return get(task, value.slice(1)) ?? '';
return get(task, value.substr(1)) ?? '';
}

return value.replace(reVar, (v) => get(task, v.slice(1) ?? ''));
return value.replace(reVar, (v) => get(task, v.substr(1) ?? ''));
};

/**
Expand Down Expand Up @@ -72,9 +72,9 @@ export const parseCSV = (text, separator = 'auto') => {

const re = new RegExp(
[
'"(?:""|[^"])*"', // quoted text with possible quoted quotes inside it ("not a ""value""")
'"(""|[^"]+)*"', // quoted text with possible quoted quotes inside it ("not a ""value""")
`[^"${separator}]+`, // usual value, no quotes, between separators
`(?=${separator}(?:${separator}|$))`, // empty value in the middle or at the end of string
`(?=${separator}(${separator}|$))`, // empty value in the middle or at the end of string
`^(?=${separator})`, // empty value at the start of the string
].join('|'),
'g',
Expand Down
Loading