Comments (2)
Hey,
sorry, I took a bit of a cowboy approach and implemented quite a hacky solution. I decided to drop it her in case someone else needs the same thing.
So, in order to replace the autocomplete with just buttons I believe we have to touch the node_modules/@recogito/recogito-client-core/src/editor/widgets/tag/TagWidget.jsx
file. That's because we don't want to have a new widget but want to replace the default ones. I did the change myself directly into the node_modules
folder and compiled a new version of the library. You can find the newly generated recogito.min.js
file here https://github.com/krasimir/recogito-js/tree/main/dist
I changed the TagWidget
's render method to return the following:
return (
<div className="r6o-widget r6o-tag">
<ul className="r6o-taglist">
{
props.vocabulary.map(word => {
const styleButton = {
border: 'none',
padding: '0.5em 1em',
fontSize: '0.9em',
fontFamily: 'inherit',
cursor: 'pointer',
background: 'none',
display: 'block',
height: '100%'
};
const styleSelected = {
background: '#4483c4',
color: '#FFF'
}
const tag = tags.find(t => word === tagValue(t));
if (tag) {
return (
<li key={tagValue(tag)} onClick={toggle(tag)}>
<span className="r6o-label" style={styleSelected}>โ {tagValue(tag)}</span>
{!props.readOnly &&
<CSSTransition in={showDelete === tag} timeout={200} classNames="r6o-delete">
<span className="r6o-delete-wrapper" onClick={onDelete(tag)}>
<span className="r6o-delete">
<CloseIcon width={12} />
</span>
</span>
</CSSTransition>
}
</li>
);
}
return (
<li>
<button key={word} style={styleButton} onClick={(e) => {
e.preventDefault();
onSubmit(word);
}}>{word}</button>
</li>
);
})
}
</ul>
</div>
)
Or in other words, printing all the available tags and marking the ones that are selected.
Here's how it works:
My.Movie.2.mp4
For the relations mode I had to touch src/relations/editor/RelationEditor.jsx
and amend the render method to:
render() {
const styleButton = {
border: 'none',
padding: '0.5em 1em',
fontSize: '0.9em',
fontFamily: 'inherit',
cursor: 'pointer',
background: 'none',
display: 'block',
height: '100%'
};
return(
<div className="r6o-relation-editor" ref={this.element}>
<div className="input-wrapper r6o-widget r6o-tag" style={{ marginRight: '34px' }}>
<ul className="r6o-taglist">
{
(this.props.vocabulary || []).map(word => {
const isSelected = getContent(this.props.relation) === word;
const style = Object.assign(
{},
styleButton,
isSelected ? { background: '#4483c4', color: '#FFF' } : null
);
return (
<li>
<button key={word} style={style} onClick={(e) => {
e.preventDefault();
this.onSubmit(word);
}}>{word}</button>
</li>
);
})
}
</ul>
</div>
<div className="buttons">
<span
className="r6o-icon delete"
onClick={this.onDelete}>
<TrashIcon width={14} />
</span>
</div>
</div>
)
}
from recogito-js.
There is no commercial product :-) But you are probably referring to the Recogito platform, a system we built in a past project, and parts of which became the precursor to RecogitoJS and Annotorious.
In Annotorious, you would need to create your own Editor widget plugin to have a similar row of buttons. (The docs are for Annotorious. But plugins work in both systems.)
Luckily, such a three button plugin is about as easy as it gets as far as plugins are concerned. I have some existing code here if it helps:
https://github.com/machines-reading-maps/mrm-recogito-ui/blob/main/src/widgets/ClassifyWidget.jsx
https://github.com/machines-reading-maps/mrm-recogito-ui/blob/main/src/widgets/ClassifyWidget.scss
The only tricky bit about doing your own plugins (especially in React) is the build process. Things need to look different if you are using Recogito inside a React project or not, for example. Do shout out if you have problems with that, and I'll try to help.
from recogito-js.
Related Issues (20)
- Using custom formatters HOT 4
- Possible glitch when reloading annotations HOT 5
- Prevent overlapping annotations HOT 5
- Raise error when double clicking at the end of the paragraph HOT 1
- Unknown file extension ".css" HOT 4
- Not recognizing specific characters such as ยง HOT 2
- Choose annotatable items, not all wrapped items
- ERROR in ./node_modules/@recogito/recogito-js/dist/recogito.min.css HOT 1
- Support for Vue and Typescript? HOT 1
- getAnnotations doesn't work when annotating content in iframe
- Highlighting collapses completely HOT 5
- Two annotations on the exact same piece of text HOT 4
- Dropdown closes even if the input has content HOT 3
- Raise external 'cancelAnnotation' event
- "mouseup" event considered even for context menu action HOT 1
- Prevent creation of zero-width SPANs HOT 2
- Rendering highlights becomes painfully slow for longer documents HOT 1
- Autocomplete for relations does not work as intended HOT 1
- Adding read-only mode in the demo
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from recogito-js.