diff --git a/CHANGELOG.md b/CHANGELOG.md index d1dac178..aa8ec526 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -47,8 +47,11 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/) and this p * `changeExpanded` event is removed from element events, use `changeElementState` event instead; * When exporting the diagram the expanded state is serialized only with `elementState` while using `isExpanded` property when importing the diagram for backward compatibility. - Introduce `ElementTemplate.supports` property for templates to tell its capabilities such as ability to expand/collapse or resized by user. -- Deprecate `DefaultLinkTemplate` and `DefaultLink` and alias them to `StandardLinkTemplate` and `StandardRelation`: - * Change CSS class for default link template from `reactodia-default-link` to `reactodia-standard-link`. +- Use consistent naming for standard element and link templates: + * Deprecate `DefaultLinkTemplate` and `DefaultLink` and alias them to `StandardLinkTemplate` and `StandardRelation`; + * Change CSS class for standard element template from `reactodia-standard-template` to `reactodia-standard-element`; + * Change CSS class for default link template from `reactodia-default-link` to `reactodia-standard-link`; + * Change translation groups from `standard_template` / `default_link_template` to `standard_element` / `standard_link`. - Move "expand/collapse on double click" global element behavior to `StandardEntity` and `ClassicEntity` implementation only. - Add `setTemplateProperty()` utility function to easily set or unset template state property. - Change `MetadataProvider.{createEntity, createRelation}` to return result object with initial template state in addition to the data to customize the created cells (i.e. new elements can be expanded or collapsed). diff --git a/examples/classicWorkspace.tsx b/examples/classicWorkspace.tsx index 99ad28b3..b6fa667a 100644 --- a/examples/classicWorkspace.tsx +++ b/examples/classicWorkspace.tsx @@ -55,11 +55,11 @@ function ClassicWorkspaceExample() { } return undefined; }, - linkTemplateResolver: (linkType, link) => { + linkTemplateResolver: linkType => { if (linkType === 'http://www.w3.org/2000/01/rdf-schema#subClassOf') { return Reactodia.DefaultLinkTemplate; } - return OntologyLinkTemplates(linkType, link); + return OntologyLinkTemplates(linkType); }, }} toolbar={{ diff --git a/i18n/i18n.schema.json b/i18n/i18n.schema.json index af07e03f..260a2937 100644 --- a/i18n/i18n.schema.json +++ b/i18n/i18n.schema.json @@ -116,18 +116,6 @@ "iri_blank": { "$ref": "#/$defs/Value" } } }, - "default_link_template": { - "$ref": "#/$defs/Group", - "additionalProperties": false, - "properties": { - "group_source.title": { "$ref": "#/$defs/Value" }, - "group_source.value": { "$ref": "#/$defs/Value" }, - "group_target.title": { "$ref": "#/$defs/Value" }, - "group_target.value": { "$ref": "#/$defs/Value" }, - "label.title": { "$ref": "#/$defs/Value" }, - "property.title": { "$ref": "#/$defs/Value" } - } - }, "default_workspace": { "$ref": "#/$defs/Group", "additionalProperties": false, @@ -309,7 +297,7 @@ "zoom_to_fit.title": { "$ref": "#/$defs/Value" } } }, - "standard_template": { + "standard_element": { "$ref": "#/$defs/Group", "additionalProperties": false, "properties": { @@ -329,6 +317,18 @@ "ungroup.title": { "$ref": "#/$defs/Value" } } }, + "standard_link": { + "$ref": "#/$defs/Group", + "additionalProperties": false, + "properties": { + "group_source.title": { "$ref": "#/$defs/Value" }, + "group_source.value": { "$ref": "#/$defs/Value" }, + "group_target.title": { "$ref": "#/$defs/Value" }, + "group_target.value": { "$ref": "#/$defs/Value" }, + "label.title": { "$ref": "#/$defs/Value" }, + "property.title": { "$ref": "#/$defs/Value" } + } + }, "toolbar": { "$ref": "#/$defs/Group", "additionalProperties": false, diff --git a/i18n/translations/en.reactodia-translation.json b/i18n/translations/en.reactodia-translation.json index f2825a62..afded461 100644 --- a/i18n/translations/en.reactodia-translation.json +++ b/i18n/translations/en.reactodia-translation.json @@ -84,14 +84,6 @@ "iri": "<{{value}}>", "iri_blank": "(blank node)" }, - "default_link_template": { - "group_source.title": "{{value}} source elements", - "group_source.value": "{{value}}", - "group_target.title": "{{value}} target elements", - "group_target.value": "{{value}}", - "label.title": "{{relation}} {{relationIri}}", - "property.title": "{{property}} {{propertyIri}}" - }, "default_workspace": { "search_section_entities.label": "Entities", "search_section_entities.title": "Entity lookup", @@ -217,7 +209,7 @@ "remove.title_single": "Remove an element from the diagram", "zoom_to_fit.title": "Zoom to fit selected elements into view" }, - "standard_template": { + "standard_element": { "blank_node": "(blank node)", "default_type": "Thing", "delete.label": "Delete", @@ -233,6 +225,14 @@ "property.title": "{{property}} {{propertyIri}}", "ungroup.title": "Ungroup an entity" }, + "standard_link": { + "group_source.title": "{{value}} source elements", + "group_source.value": "{{value}}", + "group_target.title": "{{value}} target elements", + "group_target.value": "{{value}}", + "label.title": "{{relation}} {{relationIri}}", + "property.title": "{{property}} {{propertyIri}}" + }, "toolbar": { "menu_toggle.title": "Open menu" }, diff --git a/src/legacy-styles.tsx b/src/legacy-styles.tsx index 2074cbf4..994013a7 100644 --- a/src/legacy-styles.tsx +++ b/src/legacy-styles.tsx @@ -1,5 +1,5 @@ +import type { LinkTypeIri } from './data/model'; import type { TypeStyleResolver, LinkTemplate } from './diagram/customization'; -import type { TypedLinkResolver } from './widgets/canvas'; const classIcon = require('@images/semantic/class.svg') as string; const objectPropertyIcon = require('@images/semantic/objectProperty.svg') as string; @@ -98,7 +98,9 @@ export function makeLinkStyleShowIri(Reactodia: typeof import('./workspace')): L * * @deprecated These link templates will be removed in later versions */ -export function makeOntologyLinkTemplates(Reactodia: typeof import('./workspace')): TypedLinkResolver { +export function makeOntologyLinkTemplates( + Reactodia: typeof import('./workspace') +): (linkType: LinkTypeIri | undefined) => LinkTemplate | undefined { const LINK_SUB_CLASS_OF: LinkTemplate = { ...Reactodia.StandardLinkTemplate, markerTarget: { diff --git a/src/templates/classicTemplate.tsx b/src/templates/classicTemplate.tsx index cd14f267..21389ba6 100644 --- a/src/templates/classicTemplate.tsx +++ b/src/templates/classicTemplate.tsx @@ -67,7 +67,7 @@ export function ClassicEntity(props: ClassicEntityProps) { const typesLabel = types.length > 0 ? model.locale.formatEntityTypeList(data, model.language) - : t.text('standard_template.default_type'); + : t.text('standard_element.default_type'); const label = model.locale.formatEntityLabel(data, model.language); const imageUrl = model.locale.selectEntityImageUrl(data); @@ -83,7 +83,7 @@ export function ClassicEntity(props: ClassicEntityProps) {
- {t.text('standard_template.iri.label')} + {t.text('standard_element.iri.label')}
@@ -189,6 +189,6 @@ function PropertyList(props: { })}
; } else { - return
{t.text('standard_template.no_properties')}
; + return
{t.text('standard_element.no_properties')}
; } } diff --git a/src/templates/standardTemplate.tsx b/src/templates/standardElement.tsx similarity index 94% rename from src/templates/standardTemplate.tsx rename to src/templates/standardElement.tsx index 806a3bb6..89775c71 100644 --- a/src/templates/standardTemplate.tsx +++ b/src/templates/standardElement.tsx @@ -65,7 +65,7 @@ export interface StandardEntityProps extends TemplateProps { showActions?: boolean; } -const CLASS_NAME = 'reactodia-standard-template'; +const CLASS_NAME = 'reactodia-standard-element'; /** * Default single entity template component. @@ -105,7 +105,7 @@ export function StandardEntity(props: StandardEntityProps) { function renderTypes(data: ElementModel) { if (data.types.length === 0) { - return t.text('standard_template.default_type'); + return t.text('standard_element.default_type'); } return data.types.map((typeIri, index) => { const type = model.getElementType(typeIri); @@ -136,12 +136,12 @@ export function StandardEntity(props: StandardEntityProps) {
{entityContext.editedIri - ? t.text('standard_template.iri.label_modified') - : t.text('standard_template.iri.label')} + ? t.text('standard_element.iri.label_modified') + : t.text('standard_element.iri.label')}
{isEncodedBlank(finalIri) - ? {t.text('standard_template.blank_node')} + ? {t.text('standard_element.blank_node')} : void ungroupSome({ group: target, entities: new Set([data.id]), @@ -441,7 +441,7 @@ function formatEntityTypes( ): string { const {model, translation: t} = workspace; return data.types.length === 0 - ? t.text('standard_template.default_type') + ? t.text('standard_element.default_type') : model.locale.formatEntityTypeList(data, model.language); } @@ -477,7 +477,7 @@ function PropertyList(props: { useKeyedSyncStore(subscribePropertyTypes, propertyIris, model); if (propertyIris.length === 0) { - return
{t.text('standard_template.no_properties')}
; + return
{t.text('standard_element.no_properties')}
; } const properties = propertyIris.map(iri => { @@ -501,7 +501,7 @@ function PropertyList(props: { className={`${CLASS_NAME}__properties-row`}>
@@ -552,13 +552,13 @@ function Actions(props: { 'reactodia-btn reactodia-btn-default' )} title={canDelete - ? t.text('standard_template.delete.title') - : t.text('standard_template.delete.title_disabled')} + ? t.text('standard_element.delete.title') + : t.text('standard_element.delete.title_disabled')} disabled={!canDelete} onClick={onDelete}> {canDelete === undefined ? - : t.text('standard_template.delete.label')} + : t.text('standard_element.delete.label')}
); diff --git a/src/templates/standardRelation.tsx b/src/templates/standardLink.tsx similarity index 94% rename from src/templates/standardRelation.tsx rename to src/templates/standardLink.tsx index 4ec448de..30fcfc9b 100644 --- a/src/templates/standardRelation.tsx +++ b/src/templates/standardLink.tsx @@ -139,7 +139,7 @@ export function StandardRelation(props: StandardRelationProps) { renamedLabel ? `${LABEL_CLASS}--renamed` : undefined, primaryLabelProps?.className )} - title={primaryLabelProps?.title ?? t.text('default_link_template.label.title', { + title={primaryLabelProps?.title ?? t.text('standard_link.label.title', { relation: label, relationIri: model.locale.formatIri(link.typeId), })} @@ -158,20 +158,20 @@ export function StandardRelation(props: StandardRelationProps) { - {t.text('default_link_template.group_source.value', { + {t.text('standard_link.group_source.value', { value: link.itemSources.size, })} - {t.text('default_link_template.group_target.value', { + {t.text('standard_link.group_target.value', { value: link.itemTargets.size, })} @@ -258,7 +258,7 @@ function LinkProperties(props: StandardRelationProps) { line={propertyLabelStartLine + index} textAnchor={route?.labelTextAnchor ?? propertyLabelProps?.textAnchor} className={cx(PROPERTY_CLASS, propertyLabelProps?.className)} - title={propertyLabelProps?.title ?? t.text('default_link_template.property.title', { + title={propertyLabelProps?.title ?? t.text('standard_link.property.title', { property: property.label, propertyIri: model.locale.formatIri(property.iri), })}> diff --git a/src/workspace.ts b/src/workspace.ts index be8ca085..d746068a 100644 --- a/src/workspace.ts +++ b/src/workspace.ts @@ -166,14 +166,14 @@ export { NoteTemplate, NoteAnnotation, NoteEntity, NoteLinkTemplate, NoteLink, } from './templates/noteAnnotation'; export { RoundTemplate, RoundEntity, RoundEntityProps } from './templates/roundTemplate'; -export { - StandardLinkTemplate, StandardRelation, type StandardRelationProps, - DefaultLinkTemplate, DefaultLink, type DefaultLinkProps, -} from './templates/standardRelation'; export { StandardTemplate, StandardEntity, StandardEntityProps, StandardEntityGroup, StandardEntityGroupProps, -} from './templates/standardTemplate'; +} from './templates/standardElement'; +export { + StandardLinkTemplate, StandardRelation, type StandardRelationProps, + DefaultLinkTemplate, DefaultLink, type DefaultLinkProps, +} from './templates/standardLink'; export { DraggableHandle, DraggableHandleProps } from './widgets/utility/draggableHandle'; export { diff --git a/src/workspace/workspace.tsx b/src/workspace/workspace.tsx index df7758cb..05fd8406 100644 --- a/src/workspace/workspace.tsx +++ b/src/workspace/workspace.tsx @@ -33,8 +33,8 @@ import { import { OverlayController } from '../editor/overlayController'; import { NoteTemplate, NoteLinkTemplate } from '../templates/noteAnnotation'; -import { StandardLinkTemplate } from '../templates/standardRelation'; -import { StandardTemplate } from '../templates/standardTemplate'; +import { StandardTemplate } from '../templates/standardElement'; +import { StandardLinkTemplate } from '../templates/standardLink'; import type { CommandBusTopic } from './commandBusTopic'; import { diff --git a/styles/templates/_standardEntity.scss b/styles/templates/_standardEntity.scss index d21acf00..c8f6fe64 100644 --- a/styles/templates/_standardEntity.scss +++ b/styles/templates/_standardEntity.scss @@ -5,7 +5,7 @@ $standard-template-color: var(--reactodia-element-style-color); $standard-template-background: theme.$element-background-color; $standard-new-entity-stripe: theme.$element-background-color; -.reactodia-standard-template { +.reactodia-standard-element { min-width: 180px; max-width: 400px; float: left;