diff --git a/inception/inception-diam-editor/src/main/ts/src/AnnotationsByLabelList.svelte b/inception/inception-diam-editor/src/main/ts/src/AnnotationsByLabelList.svelte index 38dea64fb45..d422178aee9 100644 --- a/inception/inception-diam-editor/src/main/ts/src/AnnotationsByLabelList.svelte +++ b/inception/inception-diam-editor/src/main/ts/src/AnnotationsByLabelList.svelte @@ -24,7 +24,7 @@ } from "@inception-project/inception-js-api"; import LabelBadge from "./LabelBadge.svelte"; import SpanText from "./SpanText.svelte"; - import { groupRelationsByLabel, groupSpansByLabel, uniqueLabels, uniqueOffsets } from "./Utils"; + import { groupRelationsByLabel, groupSpansByLabel, uniqueLabels } from "./Utils"; export let ajaxClient: DiamAjax; export let data: AnnotatedText; diff --git a/inception/inception-js-api/marker-wicket-module b/inception/inception-js-api/marker-wicket-module new file mode 100644 index 00000000000..44dcaf8bea4 --- /dev/null +++ b/inception/inception-js-api/marker-wicket-module @@ -0,0 +1 @@ +Marker file which activates the profile "wicket-module" from the parent POM. diff --git a/inception/inception-js-api/pom.xml b/inception/inception-js-api/pom.xml index db6bccfcc94..2a039ee8249 100644 --- a/inception/inception-js-api/pom.xml +++ b/inception/inception-js-api/pom.xml @@ -26,4 +26,11 @@ inception-js-api INCEpTION - JavaScript API JavaScript APIs for INCEpTION + + + + org.apache.wicket + wicket-core + + diff --git a/inception/inception-js-api/src/main/java/de/tudarmstadt/ukp/inception/diam/editor/api/resources/InceptionJsApiResourceReference.java b/inception/inception-js-api/src/main/java/de/tudarmstadt/ukp/inception/diam/editor/api/resources/InceptionJsApiResourceReference.java new file mode 100644 index 00000000000..273528b6427 --- /dev/null +++ b/inception/inception-js-api/src/main/java/de/tudarmstadt/ukp/inception/diam/editor/api/resources/InceptionJsApiResourceReference.java @@ -0,0 +1,47 @@ +/* + * Licensed to the Technische Universität Darmstadt under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The Technische Universität Darmstadt + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package de.tudarmstadt.ukp.inception.diam.editor.api.resources; + +import org.apache.wicket.request.resource.JavaScriptResourceReference; + +public class InceptionJsApiResourceReference + extends JavaScriptResourceReference +{ + private static final long serialVersionUID = 1L; + + private static final InceptionJsApiResourceReference INSTANCE = // + new InceptionJsApiResourceReference(); + + /** + * Gets the instance of the resource reference + * + * @return the single instance of the resource reference + */ + public static InceptionJsApiResourceReference get() + { + return INSTANCE; + } + + /** + * Private constructor + */ + private InceptionJsApiResourceReference() + { + super(InceptionJsApiResourceReference.class, "InceptionJsAPI.min.js"); + } +} diff --git a/inception/inception-js-api/src/main/ts/build.mjs b/inception/inception-js-api/src/main/ts/build.mjs new file mode 100644 index 00000000000..4cbe5e2f235 --- /dev/null +++ b/inception/inception-js-api/src/main/ts/build.mjs @@ -0,0 +1,57 @@ +/* + * Licensed to the Technische Universität Darmstadt under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The Technische Universität Darmstadt + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import yargs from 'yargs/yargs' +import { hideBin } from 'yargs/helpers' +import esbuild from 'esbuild' +import { sassPlugin } from 'esbuild-sass-plugin' +import fs from 'fs-extra' + +const argv = yargs(hideBin(process.argv)).argv + +const packagePath = 'de/tudarmstadt/ukp/inception/diam/editor/api/resources/' + +let outbase = `../../../target/js/${packagePath}` + +const defaults = { + bundle: true, + sourcemap: true, + minify: !argv.live, + target: 'es6', + loader: { '.ts': 'ts' }, + logLevel: 'info', + plugins: [sassPlugin()] +} + +if (argv.live) { + defaults.watch = { + onRebuild (error, result) { + if (error) console.error('watch build failed:', error) + else console.log('watch build succeeded:', result) + } + } + outbase = `../../../target/classes/${packagePath}` +} else { + fs.emptyDirSync(outbase) +} +fs.mkdirsSync(`${outbase}`) + +esbuild.build(Object.assign({ + entryPoints: ['index.ts'], + outfile: `${outbase}/InceptionJsAPI.min.js`, + globalName: 'InceptionJsAPI' +}, defaults)) diff --git a/inception/inception-js-api/src/main/ts/dist/index.js b/inception/inception-js-api/src/main/ts/dist/index.js deleted file mode 100644 index 75ffa89e504..00000000000 --- a/inception/inception-js-api/src/main/ts/dist/index.js +++ /dev/null @@ -1,2 +0,0 @@ -(()=>{var a=class{};var n=class{constructor(){this.layers=new Map}__getOrCreateLayer(t){let o=this.layers.get(t);return o||(o=new a,o.id=t,this.layers.set(t,o)),o}};var p=class{};var m=class{};var i=class{};var s=class{};var c=class{};function x(r){let t=new i;return t.type=r[0],t.vid=r[1],t}function u(r){let t=new a;return t.id=r.id,t.name=r.name,t}function A(r){let t=new c;return t.target=r[0],t.label=r[1],t}function l(r,t){let o=new p;return o.layer=r.__getOrCreateLayer(t[0]),o.vid=t[1],o.arguments=t[2].map(A),o.color=t[3]?.c,o.label=t[3]?.l,o}function y(r,t){let o=new m;return o.layer=r.__getOrCreateLayer(t[0]),o.vid=t[1],o.offsets=t[2],o.color=t[3]?.c,o.label=t[3]?.l,o.clippingFlags=t[3]?.cl,o}function C(r){let t=new s;return t.type=r[0],t.offsets=r[1],t}function k(r){let t=new n;t.text=r.text,t.window=r.window,r.layers?.forEach(e=>t.layers.set(e.id,u(e))),t.spans=r.spans?.map(e=>y(t,e))||[],t.relations=r.relations?.map(e=>l(t,e))||[];let o=r.annotationMarkers?.map(x);return t.annotationMarkers=d(o),t.textMarkers=r.textMarkers?.map(C)||[],t}function d(r){let t=new Map;return r&&r.forEach(o=>{o[1].forEach(e=>{let f=t.get(e);f||(f=[],t.set(e,f)),f.push(o)})}),t}})(); -//# sourceMappingURL=index.js.map diff --git a/inception/inception-js-api/src/main/ts/dist/index.js.map b/inception/inception-js-api/src/main/ts/dist/index.js.map deleted file mode 100644 index 30a4ee9af28..00000000000 --- a/inception/inception-js-api/src/main/ts/dist/index.js.map +++ /dev/null @@ -1,7 +0,0 @@ -{ - "version": 3, - "sources": ["../src/model/Layer.ts", "../src/model/AnnotatedText.ts", "../src/model/Relation.ts", "../src/model/Span.ts", "../src/model/AnnotationMarker.ts", "../src/model/TextMarker.ts", "../src/model/Argument.ts", "../src/model/compact_v2/CompactAnnotationMarker.ts", "../src/model/compact_v2/CompactLayer.ts", "../src/model/compact_v2/CompactArgument.ts", "../src/model/compact_v2/CompactRelation.ts", "../src/model/compact_v2/CompactSpan.ts", "../src/model/compact_v2/CompactTextMarker.ts", "../src/model/compact_v2/CompactAnnotatedText.ts"], - "sourcesContent": ["/*\n * Licensed to the Technische Universit\u00E4t Darmstadt under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The Technische Universit\u00E4t Darmstadt\n * licenses this file to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License.\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nexport class Layer {\n id: number\n name: string\n}\n", "/*\n * Licensed to the Technische Universit\u00E4t Darmstadt under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The Technische Universit\u00E4t Darmstadt\n * licenses this file to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License.\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Offsets } from './Offsets'\nimport { VID } from './VID'\nimport { AnnotationMarker } from './AnnotationMarker'\nimport { Relation } from './Relation'\nimport { Span } from './Span'\nimport { TextMarker } from './TextMarker'\nimport { Layer } from './Layer'\n\nexport class AnnotatedText {\n window: Offsets\n text?: string\n layers: Map = new Map()\n relations: Array\n spans: Array\n annotationMarkers: Map\n textMarkers: TextMarker[]\n\n __getOrCreateLayer (id: number): Layer {\n let layer = this.layers.get(id)\n if (!layer) {\n layer = new Layer()\n layer.id = id\n this.layers.set(id, layer)\n }\n return layer\n }\n}\n", "/*\n * Licensed to the Technische Universit\u00E4t Darmstadt under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The Technische Universit\u00E4t Darmstadt\n * licenses this file to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License.\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Annotation, VID } from '.'\nimport { Argument } from './Argument'\nimport { Layer } from './Layer'\n\nexport class Relation implements Annotation {\n layer: Layer\n vid: VID\n color?: string\n label?: string\n arguments: Array\n}\n", "/*\n * Licensed to the Technische Universit\u00E4t Darmstadt under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The Technische Universit\u00E4t Darmstadt\n * licenses this file to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License.\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Annotation, Offsets, VID } from '.'\nimport { Layer } from './Layer'\n\nexport type ClippingStatus = undefined | 's' | 'e' | 'se'\n\nexport class Span implements Annotation {\n layer: Layer\n vid: VID\n offsets: Array\n color?: string\n label?: string\n\n /**\n * Clipping status (optional)\n */\n clippingFlags?: ClippingStatus\n}\n", "/*\n * Licensed to the Technische Universit\u00E4t Darmstadt under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The Technische Universit\u00E4t Darmstadt\n * licenses this file to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License.\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { VID } from '.'\n\nexport class AnnotationMarker {\n type: string\n vid: Array\n}\n", "/*\n * Licensed to the Technische Universit\u00E4t Darmstadt under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The Technische Universit\u00E4t Darmstadt\n * licenses this file to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License.\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Offsets } from './Offsets'\n\nexport class TextMarker {\n type: string\n offsets: Array\n}\n", "/*\n * Licensed to the Technische Universit\u00E4t Darmstadt under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The Technische Universit\u00E4t Darmstadt\n * licenses this file to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License.\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { VID } from '.'\n\n/**\n * Represents the endpoint of a relation.\n */\nexport class Argument {\n target: VID\n label?: string\n}\n", "/*\n * Licensed to the Technische Universit\u00E4t Darmstadt under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The Technische Universit\u00E4t Darmstadt\n * licenses this file to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License.\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { VID, AnnotationMarker } from '..'\n\nexport type CompactAnnotationMarker = [\n type: string,\n vid: Array\n]\n\nexport function unpackCompactAnnotationMarker (raw: CompactAnnotationMarker): AnnotationMarker {\n const cooked = new AnnotationMarker()\n cooked.type = raw[0]\n cooked.vid = raw[1]\n return cooked\n}\n", "/*\n * Licensed to the Technische Universit\u00E4t Darmstadt under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The Technische Universit\u00E4t Darmstadt\n * licenses this file to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License.\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport { Layer } from '../Layer'\n\nexport type CompactLayer = {\n id: number,\n name: string\n}\n\nexport function unpackCompactLayer (raw: CompactLayer): Layer {\n const cooked = new Layer()\n cooked.id = raw.id\n cooked.name = raw.name\n return cooked\n}\n", "/*\n * Licensed to the Technische Universit\u00E4t Darmstadt under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The Technische Universit\u00E4t Darmstadt\n * licenses this file to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License.\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { VID, Argument } from '..'\n\n/**\n * Represents the endpoint of an arc.\n */\nexport type CompactArgument = [\n target: VID,\n label?: string\n]\n\nexport function unpackCompactArgument (raw: CompactArgument): Argument {\n const cooked = new Argument()\n cooked.target = raw[0]\n cooked.label = raw[1]\n return cooked\n}\n", "/*\n * Licensed to the Technische Universit\u00E4t Darmstadt under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The Technische Universit\u00E4t Darmstadt\n * licenses this file to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License.\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { VID, Relation, AnnotatedText } from '..'\nimport { CompactArgument, unpackCompactArgument } from './CompactArgument'\nimport { CompactRelationAttributes } from './CompactRelationAttributes'\n\nexport type CompactRelation = [\n layerId: number,\n vid: VID,\n arguments: Array,\n attributes?: CompactRelationAttributes\n]\n\nexport function unpackCompactRelation (doc: AnnotatedText, raw: CompactRelation): Relation {\n const cooked = new Relation()\n cooked.layer = doc.__getOrCreateLayer(raw[0])\n cooked.vid = raw[1]\n cooked.arguments = raw[2].map(unpackCompactArgument)\n cooked.color = raw[3]?.c\n cooked.label = raw[3]?.l\n return cooked\n}\n", "/*\n * Licensed to the Technische Universit\u00E4t Darmstadt under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The Technische Universit\u00E4t Darmstadt\n * licenses this file to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License.\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { Offsets, Span, VID, AnnotatedText } from '..'\nimport { CompactSpanAttributes } from './CompactSpanAttributes'\n\nexport type CompactSpan = [\n layerId: number,\n vid: VID,\n offsets: Array,\n attributes?: CompactSpanAttributes\n]\n\nexport function unpackCompactSpan (doc: AnnotatedText, raw: CompactSpan): Span {\n const cooked = new Span()\n cooked.layer = doc.__getOrCreateLayer(raw[0])\n cooked.vid = raw[1]\n cooked.offsets = raw[2]\n cooked.color = raw[3]?.c\n cooked.label = raw[3]?.l\n cooked.clippingFlags = raw[3]?.cl\n return cooked\n}\n", "/*\n * Licensed to the Technische Universit\u00E4t Darmstadt under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The Technische Universit\u00E4t Darmstadt\n * licenses this file to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License.\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { TextMarker, Offsets } from '..'\n\nexport type CompactTextMarker = [\n type: string,\n offsets: Array\n]\n\nexport function unpackCompactTextMarker (raw: CompactTextMarker): TextMarker {\n const cooked = new TextMarker()\n cooked.type = raw[0]\n cooked.offsets = raw[1]\n return cooked\n}\n", "/*\n * Licensed to the Technische Universit\u00E4t Darmstadt under one\n * or more contributor license agreements. See the NOTICE file\n * distributed with this work for additional information\n * regarding copyright ownership. The Technische Universit\u00E4t Darmstadt\n * licenses this file to you under the Apache License, Version 2.0 (the\n * \"License\"); you may not use this file except in compliance\n * with the License.\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\nimport { AnnotatedText, Offsets, VID } from '..'\nimport { CompactAnnotationMarker, unpackCompactAnnotationMarker } from './CompactAnnotationMarker'\nimport { CompactLayer, unpackCompactLayer } from './CompactLayer'\nimport { CompactRelation, unpackCompactRelation } from './CompactRelation'\nimport { CompactSpan, unpackCompactSpan } from './CompactSpan'\nimport { CompactTextMarker, unpackCompactTextMarker } from './CompactTextMarker'\n\nexport interface CompactAnnotatedText {\n text?: string\n layers?: Array\n window: Offsets\n relations?: Array\n spans?: Array\n annotationMarkers?: Array\n textMarkers?: Array\n}\n\nexport function unpackCompactAnnotatedText (raw: CompactAnnotatedText): AnnotatedText {\n const cooked = new AnnotatedText()\n cooked.text = raw.text\n cooked.window = raw.window\n raw.layers?.forEach(layer => cooked.layers.set(layer.id, unpackCompactLayer(layer)))\n cooked.spans = raw.spans?.map(span => unpackCompactSpan(cooked, span)) || []\n cooked.relations = raw.relations?.map(rel => unpackCompactRelation(cooked, rel)) || []\n const annotationMarkers = raw.annotationMarkers?.map(unpackCompactAnnotationMarker)\n cooked.annotationMarkers = makeMarkerMap(annotationMarkers)\n cooked.textMarkers = raw.textMarkers?.map(unpackCompactTextMarker) || []\n return cooked\n}\n\n/**\n * Converts a list of {@link CompactAnnotationMarker}s to an easily accessible map using the {@link VID}\n * as key and the set of markers on that annotation as values.\n *\n * @param markerList a list of {@link CompactAnnotationMarker}s\n * @returns the map\n */\nexport function makeMarkerMap (markerList: T[] | undefined): Map> {\n const markerMap = new Map>()\n if (markerList) {\n markerList.forEach(marker => {\n marker[1].forEach(vid => {\n let ms = markerMap.get(vid)\n if (!ms) {\n ms = []\n markerMap.set(vid, ms)\n }\n ms.push(marker)\n })\n })\n }\n return markerMap\n}\n"], - "mappings": "MAiBO,IAAMA,EAAN,KAAY,CAGnB,ECKO,IAAMC,EAAN,KAAoB,CAApB,cAGL,YAA6B,IAAI,IAMjC,mBAAoBC,EAAmB,CACrC,IAAIC,EAAQ,KAAK,OAAO,IAAID,CAAE,EAC9B,OAAKC,IACHA,EAAQ,IAAIC,EACZD,EAAM,GAAKD,EACX,KAAK,OAAO,IAAIA,EAAIC,CAAK,GAEpBA,CACT,CACF,ECtBO,IAAME,EAAN,KAAqC,CAM5C,ECLO,IAAMC,EAAN,KAAiC,CAWxC,ECdO,IAAMC,EAAN,KAAuB,CAG9B,ECHO,IAAMC,EAAN,KAAiB,CAGxB,ECAO,IAAMC,EAAN,KAAe,CAGtB,ECDO,SAASC,EAA+BC,EAAgD,CAC7F,IAAMC,EAAS,IAAIC,EACnB,OAAAD,EAAO,KAAOD,EAAI,GAClBC,EAAO,IAAMD,EAAI,GACVC,CACT,CCJO,SAASE,EAAoBC,EAA0B,CAC5D,IAAMC,EAAS,IAAIC,EACnB,OAAAD,EAAO,GAAKD,EAAI,GAChBC,EAAO,KAAOD,EAAI,KACXC,CACT,CCHO,SAASE,EAAuBC,EAAgC,CACrE,IAAMC,EAAS,IAAIC,EACnB,OAAAD,EAAO,OAASD,EAAI,GACpBC,EAAO,MAAQD,EAAI,GACZC,CACT,CCJO,SAASE,EAAuBC,EAAoBC,EAAgC,CACzF,IAAMC,EAAS,IAAIC,EACnB,OAAAD,EAAO,MAAQF,EAAI,mBAAmBC,EAAI,EAAE,EAC5CC,EAAO,IAAMD,EAAI,GACjBC,EAAO,UAAYD,EAAI,GAAG,IAAIG,CAAqB,EACnDF,EAAO,MAAQD,EAAI,IAAI,EACvBC,EAAO,MAAQD,EAAI,IAAI,EAChBC,CACT,CCTO,SAASG,EAAmBC,EAAoBC,EAAwB,CAC7E,IAAMC,EAAS,IAAIC,EACnB,OAAAD,EAAO,MAAQF,EAAI,mBAAmBC,EAAI,EAAE,EAC5CC,EAAO,IAAMD,EAAI,GACjBC,EAAO,QAAUD,EAAI,GACrBC,EAAO,MAAQD,EAAI,IAAI,EACvBC,EAAO,MAAQD,EAAI,IAAI,EACvBC,EAAO,cAAgBD,EAAI,IAAI,GACxBC,CACT,CCZO,SAASE,EAAyBC,EAAoC,CAC3E,IAAMC,EAAS,IAAIC,EACnB,OAAAD,EAAO,KAAOD,EAAI,GAClBC,EAAO,QAAUD,EAAI,GACdC,CACT,CCKO,SAASE,EAA4BC,EAA0C,CACpF,IAAMC,EAAS,IAAIC,EACnBD,EAAO,KAAOD,EAAI,KAClBC,EAAO,OAASD,EAAI,OACpBA,EAAI,QAAQ,QAAQG,GAASF,EAAO,OAAO,IAAIE,EAAM,GAAIC,EAAmBD,CAAK,CAAC,CAAC,EACnFF,EAAO,MAAQD,EAAI,OAAO,IAAIK,GAAQC,EAAkBL,EAAQI,CAAI,CAAC,GAAK,CAAC,EAC3EJ,EAAO,UAAYD,EAAI,WAAW,IAAIO,GAAOC,EAAsBP,EAAQM,CAAG,CAAC,GAAK,CAAC,EACrF,IAAME,EAAoBT,EAAI,mBAAmB,IAAIU,CAA6B,EAClF,OAAAT,EAAO,kBAAoBU,EAAcF,CAAiB,EAC1DR,EAAO,YAAcD,EAAI,aAAa,IAAIY,CAAuB,GAAK,CAAC,EAChEX,CACT,CASO,SAASU,EAAkBE,EAAiD,CACjF,IAAMC,EAAY,IAAI,IACtB,OAAID,GACFA,EAAW,QAAQE,GAAU,CAC3BA,EAAO,GAAG,QAAQC,GAAO,CACvB,IAAIC,EAAKH,EAAU,IAAIE,CAAG,EACrBC,IACHA,EAAK,CAAC,EACNH,EAAU,IAAIE,EAAKC,CAAE,GAEvBA,EAAG,KAAKF,CAAM,CAChB,CAAC,CACH,CAAC,EAEID,CACT", - "names": ["Layer", "AnnotatedText", "id", "layer", "Layer", "Relation", "Span", "AnnotationMarker", "TextMarker", "Argument", "unpackCompactAnnotationMarker", "raw", "cooked", "AnnotationMarker", "unpackCompactLayer", "raw", "cooked", "Layer", "unpackCompactArgument", "raw", "cooked", "Argument", "unpackCompactRelation", "doc", "raw", "cooked", "Relation", "unpackCompactArgument", "unpackCompactSpan", "doc", "raw", "cooked", "Span", "unpackCompactTextMarker", "raw", "cooked", "TextMarker", "unpackCompactAnnotatedText", "raw", "cooked", "AnnotatedText", "layer", "unpackCompactLayer", "span", "unpackCompactSpan", "rel", "unpackCompactRelation", "annotationMarkers", "unpackCompactAnnotationMarker", "makeMarkerMap", "unpackCompactTextMarker", "markerList", "markerMap", "marker", "vid", "ms"] -} diff --git a/inception/inception-js-api/src/main/ts/index.ts b/inception/inception-js-api/src/main/ts/index.ts index 2bd2bb85e4b..f6cd59e53fb 100644 --- a/inception/inception-js-api/src/main/ts/index.ts +++ b/inception/inception-js-api/src/main/ts/index.ts @@ -15,6 +15,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ +import './src/style/InceptionEditorColors.scss' + export * from './src/diam' export * from './src/editor' export * from './src/model' diff --git a/inception/inception-js-api/src/main/ts/src/model/AnnotatedText.ts b/inception/inception-js-api/src/main/ts/src/model/AnnotatedText.ts index 7ddb6a8628c..cfd4548c5a5 100644 --- a/inception/inception-js-api/src/main/ts/src/model/AnnotatedText.ts +++ b/inception/inception-js-api/src/main/ts/src/model/AnnotatedText.ts @@ -22,6 +22,7 @@ import { Relation } from './Relation' import { Span } from './Span' import { TextMarker } from './TextMarker' import { Layer } from './Layer' +import { MarkerType } from './Marker' export class AnnotatedText { window: Offsets @@ -30,6 +31,7 @@ export class AnnotatedText { relations: Map = new Map() spans: Map = new Map() annotationMarkers: Map + markedAnnotations: Map textMarkers: TextMarker[] __getOrCreateLayer (id: number): Layer { diff --git a/inception/inception-js-api/src/main/ts/src/model/AnnotationMarker.ts b/inception/inception-js-api/src/main/ts/src/model/AnnotationMarker.ts index a5aa96a05c3..c1dc15fec70 100644 --- a/inception/inception-js-api/src/main/ts/src/model/AnnotationMarker.ts +++ b/inception/inception-js-api/src/main/ts/src/model/AnnotationMarker.ts @@ -22,3 +22,26 @@ export class AnnotationMarker { type: MarkerType vid: Array } + +/** + * Groups the given markers by the VID to which they apply. + * + * @param markerList a list of markers. + * @returns the grouped markers. + */ +export function groupMarkers (markerList: T[] | undefined): Map> { + const markerMap = new Map>() + if (markerList) { + markerList.forEach(marker => { + marker[1].forEach(vid => { + let ms = markerMap.get(vid) + if (!ms) { + ms = [] + markerMap.set(vid, ms) + } + ms.push(marker) + }) + }) + } + return markerMap +} diff --git a/inception/inception-js-api/src/main/ts/src/model/compact_v2/CompactAnnotatedText.ts b/inception/inception-js-api/src/main/ts/src/model/compact_v2/CompactAnnotatedText.ts index 4dfa428f00b..a93d0e12159 100644 --- a/inception/inception-js-api/src/main/ts/src/model/compact_v2/CompactAnnotatedText.ts +++ b/inception/inception-js-api/src/main/ts/src/model/compact_v2/CompactAnnotatedText.ts @@ -15,8 +15,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import { AnnotationMarker } from '@inception-project/inception-js-api' -import { AnnotatedText, Offsets, VID } from '..' +import { AnnotatedText, Offsets, VID, AnnotationMarker } from '..' +import { MarkerType } from '../Marker' import { CompactAnnotationMarker, unpackCompactAnnotationMarker } from './CompactAnnotationMarker' import { CompactLayer, unpackCompactLayer } from './CompactLayer' import { CompactRelation, unpackCompactRelation } from './CompactRelation' @@ -51,10 +51,28 @@ export function unpackCompactAnnotatedText (raw: CompactAnnotatedText): Annotate const annotationMarkers = raw.annotationMarkers?.map(unpackCompactAnnotationMarker) cooked.annotationMarkers = makeMarkerMap(annotationMarkers) + cooked.markedAnnotations = makeMarkedAnnotationsMap(annotationMarkers) cooked.textMarkers = raw.textMarkers?.map(unpackCompactTextMarker) || [] return cooked } +function makeMarkedAnnotationsMap (annotationMarkers?: AnnotationMarker[]) : Map { + const markedAnnotations = new Map() + if (annotationMarkers) { + for (const marker of annotationMarkers) { + for (const vid of marker.vid) { + let ms = markedAnnotations.get(marker.type) + if (!ms) { + ms = [] + markedAnnotations.set(marker.type, ms) + } + ms.push(vid) + } + } + } + return markedAnnotations +} + /** * Converts a list of {@link CompactAnnotationMarker}s to an easily accessible map using the {@link VID} * as key and the set of markers on that annotation as values. @@ -62,7 +80,7 @@ export function unpackCompactAnnotatedText (raw: CompactAnnotatedText): Annotate * @param markerList a list of {@link CompactAnnotationMarker}s * @returns the map */ -export function makeMarkerMap (markerList: AnnotationMarker[] | undefined): Map> { +export function makeMarkerMap (markerList: AnnotationMarker[] | undefined): Map> { const markerMap = new Map>() if (markerList) { markerList.forEach(marker => { diff --git a/inception/inception-js-api/src/main/ts/src/model/compact_v2/index.ts b/inception/inception-js-api/src/main/ts/src/model/compact_v2/index.ts index ec2526894b6..e7fbc3d3f35 100644 --- a/inception/inception-js-api/src/main/ts/src/model/compact_v2/index.ts +++ b/inception/inception-js-api/src/main/ts/src/model/compact_v2/index.ts @@ -21,3 +21,5 @@ export { CompactArgument } from './CompactArgument' export { CompactRelationAttributes } from './CompactRelationAttributes' export { CompactSpan } from './CompactSpan' export { CompactSpanAttributes } from './CompactSpanAttributes' +export { CompactTextMarker } from './CompactTextMarker' +export { CompactAnnotationMarker } from './CompactAnnotationMarker' diff --git a/inception/inception-js-api/src/main/ts/src/style/InceptionEditorColors.scss b/inception/inception-js-api/src/main/ts/src/style/InceptionEditorColors.scss new file mode 100644 index 00000000000..a754c1aae1c --- /dev/null +++ b/inception/inception-js-api/src/main/ts/src/style/InceptionEditorColors.scss @@ -0,0 +1,26 @@ +/* + * Licensed to the Technische Universität Darmstadt under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The Technische Universität Darmstadt + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +$i7n-focus-color: rgba(255,165,0); +$i7n-focus-bounds-color: rgb(255, 106, 0); +$i7n-match-focus-color: rgb(0, 217, 255); + +:root { + --i7n-focus-color: #{$i7n-focus-color}; + --i7n-focus-bounds-color: #{$i7n-focus-bounds-color}; + --i7n-match-focus-color: #{$i7n-match-focus-color}; +} diff --git a/inception/inception-js-api/src/main/ts/src/util/Coloring.ts b/inception/inception-js-api/src/main/ts/src/util/Coloring.ts index 922d5cb0fc3..59b41207dad 100644 --- a/inception/inception-js-api/src/main/ts/src/util/Coloring.ts +++ b/inception/inception-js-api/src/main/ts/src/util/Coloring.ts @@ -1,4 +1,20 @@ - +/* + * Licensed to the Technische Universität Darmstadt under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The Technische Universität Darmstadt + * licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ export type ColorCode = string // http://24ways.org/2010/calculating-color-contrast/ diff --git a/inception/inception-js-api/src/main/ts_template/package.json b/inception/inception-js-api/src/main/ts_template/package.json index fa35ef5e0e1..2bba157477c 100644 --- a/inception/inception-js-api/src/main/ts_template/package.json +++ b/inception/inception-js-api/src/main/ts_template/package.json @@ -9,7 +9,7 @@ "url": "https://github.com/inception-project/issues" }, "scripts": { - "build": "esbuild --bundle index.ts --outdir=dist --minify --sourcemap" + "build": "node build.mjs" }, "dependencies": { "@stomp/stompjs": "${stomp-stompjs.version}",