tiagobento commented on code in PR #2491:
URL:
https://github.com/apache/incubator-kie-tools/pull/2491#discussion_r1695575258
##########
packages/kie-editors-standalone/README.md:
##########
@@ -15,14 +15,16 @@
under the License.
-->
-## BPMN and DMN Standalone Editors
+## BPMN and Legacy DMN Standalone Editors
Review Comment:
```suggestion
## BPMN and DMN Standalone Editors (classic)
```
##########
packages/dmn-editor-standalone/stories/DevWebApp.stories.tsx:
##########
@@ -0,0 +1,231 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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. You may obtain a copy of the License at
+ *
+ * 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 * as React from "react";
+import type { Meta, StoryObj } from "@storybook/react";
+import { useRef, useState, useEffect, useCallback } from "react";
+import "@patternfly/react-core/dist/styles/base.css";
+import { Page, PageSection } from
"@patternfly/react-core/dist/js/components/Page";
+import * as DmnEditor from "../dist/index";
+import { DmnEditorStandaloneApi } from "../dist/DmnEditorStandaloneApi";
+import { Flex } from "@patternfly/react-core/dist/js/layouts/Flex/Flex";
+import { FlexItem } from
"@patternfly/react-core/dist/js/layouts/Flex/FlexItem";
+import { Text, TextVariants } from
"@patternfly/react-core/dist/js/components/Text";
+
+const droppingFileStyle = {
+ position: "absolute",
+ top: 0,
+ left: 0,
+ display: "flex",
+ alignItems: "center",
+ flex: "1 0 100%",
+ justifyContent: "center",
+ margin: "8px",
+ width: "calc(100% - 16px)",
+ height: "calc(100% - 16px)",
+ backdropFilter: "blur(2px)",
+ backgroundColor: "rgba(255, 255, 255, 0.9)",
+ border: "5px dashed lightgray",
+ borderRadius: "16px",
+ pointerEvents: "none",
+ zIndex: 999,
+} as React.CSSProperties;
+
+function DevWebApp() {
+ const [editCount, setEditCount] = useState(0);
+ const editorRef = useRef<DmnEditorStandaloneApi>(null);
+ const editorContainerRef = useRef<HTMLDivElement>(null);
+ const downloadRef = useRef<HTMLAnchorElement>(null);
+ const [isDroppingFile, setIsDroppingFile] = useState(false);
+
+ useEffect(() => {
+ const editor = DmnEditor.open({
+ container: editorContainerRef.current!,
+ initialFileNormalizedPosixPathRelativeToTheWorkspaceRoot:
"path1/subpath/newModel1.dmn",
+ initialContent: Promise.resolve(""),
+ readOnly: false,
+ resources: new Map(),
+ origin: "*",
+ });
+
+ editor.subscribeToContentChanges(() => setEditCount((currentCount) =>
currentCount + 1));
+
+ (editorRef as any).current = editor;
+
+ console.log(editor);
+
+ return () => {
+ editor.close();
+ setEditCount(0);
+ };
+ }, []);
+
+ const onUndo = useCallback(() => {
+ setEditCount((currentCount) => {
+ if (currentCount > 0) {
+ editorRef.current?.undo();
+ // -2 because undoing will generateg a contentChange notification.
Review Comment:
```suggestion
// -2 because undoing will generate a contentChange notification.
```
##########
packages/dmn-editor-standalone/tests-e2e/api/getContent.spec.ts:
##########
@@ -0,0 +1,96 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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. You may obtain a copy of the License at
+ *
+ * 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 { test, expect } from "../__fixtures__/base";
+import { loanPreQualificationDmn } from "../__fixtures__/externalModels";
+import prettier from "prettier";
+
+test.describe("Dmn Editor - API", () => {
+ test.describe("getContent", () => {
+ test.beforeEach(async ({ editor }) => {
+ await editor.open();
+ });
+
+ test("should get DMN contents of inputted DMN file", async ({ page, editor
}) => {
Review Comment:
```suggestion
test("should get DMN contents of input DMN file", async ({ page, editor
}) => {
```
##########
packages/kie-editors-standalone/README.md:
##########
@@ -15,14 +15,16 @@
under the License.
-->
-## BPMN and DMN Standalone Editors
+## BPMN and Legacy DMN Standalone Editors
### Description
This library provides standalone DMN and BPMN Editors (one all-in-one
JavaScript file each) that can be embedded into any web application.
A comprehensive API is also provided for setup and interaction with the Editor.
+For the updated DMN Editor, check the
[`@kie-tools/dmn-editor-standalone`](../dmn-editor-standalone/) package.
Review Comment:
```suggestion
For the new DMN Editor, check the
[`@kie-tools/dmn-editor-standalone`](../dmn-editor-standalone/) package.
```
##########
packages/dmn-editor-standalone/stories/DevWebApp.stories.tsx:
##########
@@ -0,0 +1,231 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF 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. You may obtain a copy of the License at
+ *
+ * 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 * as React from "react";
+import type { Meta, StoryObj } from "@storybook/react";
+import { useRef, useState, useEffect, useCallback } from "react";
+import "@patternfly/react-core/dist/styles/base.css";
+import { Page, PageSection } from
"@patternfly/react-core/dist/js/components/Page";
+import * as DmnEditor from "../dist/index";
+import { DmnEditorStandaloneApi } from "../dist/DmnEditorStandaloneApi";
+import { Flex } from "@patternfly/react-core/dist/js/layouts/Flex/Flex";
+import { FlexItem } from
"@patternfly/react-core/dist/js/layouts/Flex/FlexItem";
+import { Text, TextVariants } from
"@patternfly/react-core/dist/js/components/Text";
+
+const droppingFileStyle = {
+ position: "absolute",
+ top: 0,
+ left: 0,
+ display: "flex",
+ alignItems: "center",
+ flex: "1 0 100%",
+ justifyContent: "center",
+ margin: "8px",
+ width: "calc(100% - 16px)",
+ height: "calc(100% - 16px)",
+ backdropFilter: "blur(2px)",
+ backgroundColor: "rgba(255, 255, 255, 0.9)",
+ border: "5px dashed lightgray",
+ borderRadius: "16px",
+ pointerEvents: "none",
+ zIndex: 999,
+} as React.CSSProperties;
+
+function DevWebApp() {
+ const [editCount, setEditCount] = useState(0);
+ const editorRef = useRef<DmnEditorStandaloneApi>(null);
+ const editorContainerRef = useRef<HTMLDivElement>(null);
+ const downloadRef = useRef<HTMLAnchorElement>(null);
+ const [isDroppingFile, setIsDroppingFile] = useState(false);
+
+ useEffect(() => {
+ const editor = DmnEditor.open({
+ container: editorContainerRef.current!,
+ initialFileNormalizedPosixPathRelativeToTheWorkspaceRoot:
"path1/subpath/newModel1.dmn",
+ initialContent: Promise.resolve(""),
+ readOnly: false,
+ resources: new Map(),
+ origin: "*",
+ });
+
+ editor.subscribeToContentChanges(() => setEditCount((currentCount) =>
currentCount + 1));
+
+ (editorRef as any).current = editor;
+
+ console.log(editor);
Review Comment:
Lefover?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]