Concept interaction
Overview
<link rel="subject" title="Elitserien" type="x-im/category" uuid="b3c8f46f-00db-4e23-a98f-69494582aacc" />Interacting with concepts
// Import the ConceptService
import { ConceptService } from 'writer'
// Get all current concepts from the article, of a specific type
const articleConcepts = ConceptService.getArticleConceptsByType('x-im/author')
// Get all concepts of a specific type from repository
const repositoryConcepts = ConceptService.getRemoteConceptsByType('x-im/category')
// Get all additional properties like broader, assiciated-with, long and short description etc for a concept
const enhancedConcept = await ConceptService.fetchConceptItemProperties({ uuid: 'xyz' })
// text-search for conceptSuggestions
const conceptSuggestions = await ConceptService.searchForConceptSuggestions('x-im/category', 'searchterm', subtypesArray = [])
const conceptSuggestions = await ConceptService.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
**/
const propertyMap = ConceptService.getPropertyMap()
const newConceptItem = {}
newConceptItem[propertyMap.uuid] = 'uuid'
newConceptItem[propertyMap.ConceptImTypeFull] = 'x-im/channel'
newConceptItem[propertyMap.ConceptName] = 'My new channel'
// Add the new concept
ConceptService.addArticleConcept(newConceptItem)
// Or update an existing one
ConceptService.updateArticleConcept(updatedConceptItem)
// Or remove it
ConceptService.removeArticleConceptItem(conceptItem)Operations
Events
Last updated