Concept is a term describing different kind of "tags" that can be linked to an article. Concepts can be of different types which ads a way to separate tags (or metadata) for different needs.
An article can be linked to zero, one or many concepts, with different types. And each link points to a specific concept item in the backend repository.
Each linked concept is represented as a link tag in the article document.
All communication with the article document object dealing with concepts should go through the ConceptService class imported directly from the writer.
// Import the ConceptServiceimport { ConceptService } from'writer'// Get all current concepts from the article, of a specific typeconstarticleConcepts=ConceptService.getArticleConceptsByType('x-im/author')// Get all concepts of a specific type from repositoryconstrepositoryConcepts=ConceptService.getRemoteConceptsByType('x-im/category')// Get all additional properties like broader, assiciated-with, long and short description etc for a conceptconstenhancedConcept=awaitConceptService.fetchConceptItemProperties({ uuid:'xyz' })// text-search for conceptSuggestionsconst conceptSuggestions = await ConceptService.searchForConceptSuggestions('x-im/category', 'searchterm', subtypesArray = [])
constconceptSuggestions=awaitConceptService.searchForConceptSuggestions('x-im/place','Kalmar',/* <-- this is where the search term goes */ subtypesArray = ['x-im/position','x-im/polygon'])/** * Create a new concept and add it to the document * * You will need to use the propertyMap to e sure that you object * gets the configured properties for the current backend **/constpropertyMap=ConceptService.getPropertyMap()constnewConceptItem= {}newConceptItem[propertyMap.uuid] ='uuid'newConceptItem[propertyMap.ConceptImTypeFull] ='x-im/channel'newConceptItem[propertyMap.ConceptName] ='My new channel'// Add the new conceptConceptService.addArticleConcept(newConceptItem)// Or update an existing oneConceptService.updateArticleConcept(updatedConceptItem)// Or remove itConceptService.removeArticleConceptItem(conceptItem)
Operations
The ConceptService exposes an API to perform Concept related operation, like searching for concepts in the backend repository, or adding, updating or removing concepts in the article document.
Events
To hook into the different life cycle events of concepts, ConceptsService exposes a way to register callback functions on a specific type and event (here called operations).
Example of how to bind a callback function that will be fired after a new Category concept has been added to the article can be seen below. The callback will receive the new concept object as argument.