Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
4 changes: 2 additions & 2 deletions examples/classicWorkspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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={{
Expand Down
26 changes: 13 additions & 13 deletions i18n/i18n.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -309,7 +297,7 @@
"zoom_to_fit.title": { "$ref": "#/$defs/Value" }
}
},
"standard_template": {
"standard_element": {
"$ref": "#/$defs/Group",
"additionalProperties": false,
"properties": {
Expand All @@ -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,
Expand Down
18 changes: 9 additions & 9 deletions i18n/translations/en.reactodia-translation.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand All @@ -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"
},
Expand Down
6 changes: 4 additions & 2 deletions src/legacy-styles.tsx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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: {
Expand Down
8 changes: 4 additions & 4 deletions src/templates/classicTemplate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -83,7 +83,7 @@ export function ClassicEntity(props: ClassicEntityProps) {
<div>
<div className={`${CLASS_NAME}__expander`}>
<div className={`${CLASS_NAME}__iri-heading`}>
{t.text('standard_template.iri.label')}
{t.text('standard_element.iri.label')}
</div>
<div className={`${CLASS_NAME}__iri-container`}>
<a className={`${CLASS_NAME}__iri`}
Expand Down Expand Up @@ -174,7 +174,7 @@ function PropertyList(props: {
<div key={iri} className={`${CLASS_NAME}__property-row`}>
<WithFetchStatus type='propertyType' target={iri}>
<div className={`${CLASS_NAME}__property-label`}
title={t.text('standard_template.property.title', {
title={t.text('standard_element.property.title', {
property: label,
propertyIri: model.locale.formatIri(iri),
})}>
Expand All @@ -189,6 +189,6 @@ function PropertyList(props: {
})}
</div>;
} else {
return <div>{t.text('standard_template.no_properties')}</div>;
return <div>{t.text('standard_element.no_properties')}</div>;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -136,12 +136,12 @@ export function StandardEntity(props: StandardEntityProps) {
<div className={`${CLASS_NAME}__iri`}>
<div className={`${CLASS_NAME}__iri-key`}>
{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')}
</div>
<div className={`${CLASS_NAME}__iri-value`}>
{isEncodedBlank(finalIri)
? <span>{t.text('standard_template.blank_node')}</span>
? <span>{t.text('standard_element.blank_node')}</span>
: <a href={finalIri}
target='_blank'
rel='noreferrer'
Expand Down Expand Up @@ -378,7 +378,7 @@ function StandardEntityGroupItem(props: StandardEntityGroupItemProps) {
const label = model.locale.formatEntityLabel(data, model.language);
const iri = model.locale.formatIri(data.id);
const typesLabel = formatEntityTypes(data, workspace);
const title = t.text('standard_template.group_item.title', {
const title = t.text('standard_element.group_item.title', {
entity: label,
entityIri: iri,
entityTypes: typesLabel,
Expand All @@ -405,7 +405,7 @@ function StandardEntityGroupItem(props: StandardEntityGroupItemProps) {
'reactodia-btn reactodia-btn-default'
)}
data-reactodia-no-export='true'
title={t.text('standard_template.ungroup.title')}
title={t.text('standard_element.ungroup.title')}
onClick={() => void ungroupSome({
group: target,
entities: new Set([data.id]),
Expand Down Expand Up @@ -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);
}

Expand Down Expand Up @@ -477,7 +477,7 @@ function PropertyList(props: {
useKeyedSyncStore(subscribePropertyTypes, propertyIris, model);

if (propertyIris.length === 0) {
return <div>{t.text('standard_template.no_properties')}</div>;
return <div>{t.text('standard_element.no_properties')}</div>;
}

const properties = propertyIris.map(iri => {
Expand All @@ -501,7 +501,7 @@ function PropertyList(props: {
className={`${CLASS_NAME}__properties-row`}>
<WithFetchStatus type='propertyType' target={iri}>
<div className={`${CLASS_NAME}__properties-key`}
title={t.text('standard_template.property.title', {
title={t.text('standard_element.property.title', {
property: label,
propertyIri: model.locale.formatIri(iri),
})}>
Expand Down Expand Up @@ -552,27 +552,27 @@ 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
? <HtmlSpinner width={SPINNER_WIDTH} height={SPINNER_HEIGHT} />
: t.text('standard_template.delete.label')}
: t.text('standard_element.delete.label')}
</button>
<button type='button'
className={cx(
`${CLASS_NAME}__edit-button`,
'reactodia-btn reactodia-btn-default'
)}
title={canEdit
? t.text('standard_template.edit.title')
: t.text('standard_template.edit.title_disabled')}
? t.text('standard_element.edit.title')
: t.text('standard_element.edit.title_disabled')}
disabled={!canEdit}
onClick={() => onEdit(target)}>
{canEdit === undefined
? <HtmlSpinner width={SPINNER_WIDTH} height={SPINNER_HEIGHT} />
: t.text('standard_template.edit.label')}
: t.text('standard_element.edit.label')}
</button>
</div>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
})}
Expand All @@ -158,20 +158,20 @@ export function StandardRelation(props: StandardRelationProps) {
<LinkLabel className={`${CLASS_NAME}__source-count`}
link={link}
position={getPathPosition(0.1)}
title={t.text('default_link_template.group_source.title', {
title={t.text('standard_link.group_source.title', {
value: link.itemSources.size,
})}>
{t.text('default_link_template.group_source.value', {
{t.text('standard_link.group_source.value', {
value: link.itemSources.size,
})}
</LinkLabel>
<LinkLabel className={`${CLASS_NAME}__target-count`}
link={link}
position={getPathPosition(0.9)}
title={t.text('default_link_template.group_target.title', {
title={t.text('standard_link.group_target.title', {
value: link.itemTargets.size,
})}>
{t.text('default_link_template.group_target.value', {
{t.text('standard_link.group_target.value', {
value: link.itemTargets.size,
})}
</LinkLabel>
Expand Down Expand Up @@ -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),
})}>
Expand Down
10 changes: 5 additions & 5 deletions src/workspace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/workspace/workspace.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion styles/templates/_standardEntity.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down