Skip to content

Commit e277e68

Browse files
committed
Fix monaco editor.
1 parent d770bc6 commit e277e68

File tree

6 files changed

+29
-33
lines changed

6 files changed

+29
-33
lines changed

dn-monaco-editor/sdk/php/gui/monaco/Editor.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ public function revealPosition(int $lineNumber, int $type = 0): void
9090
{
9191
}
9292

93+
public function trigger(string $action)
94+
{
95+
}
96+
9397
public function focus()
9498
{
9599
}

dn-monaco-editor/src-jvm/main/java/eu/mihosoft/monacofx/Editor.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,10 @@ public void focus() {
259259
callEditorMethod("focus");
260260
}
261261

262+
public void trigger(String action) {
263+
window.call("trigger", action);
264+
}
265+
262266
public void undo() {
263267
window.call("undo");
264268
}

dn-monaco-editor/src-jvm/main/java/eu/mihosoft/monacofx/MonacoFX.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ public MonacoFX() {
103103
}
104104
});
105105
thread.start();
106-
107106
}
108107
});
109108

dn-monaco-editor/src-jvm/main/java/org/develnext/monaco/classes/WrapEditor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ interface WrappedInterface {
7373
void revealLineInCenterIfOutsideViewport(int lineNumber);
7474
void revealLineInCenterIfOutsideViewport(int lineNumber, int type);
7575

76+
void trigger(String action);
7677
boolean copy();
7778
boolean cut();
7879
boolean paste();

dn-monaco-editor/src-jvm/main/resources/eu/mihosoft/monacofx/monaco-editor-0.20.0/index.html

Lines changed: 10 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -49,50 +49,23 @@
4949
}
5050
});
5151

52-
const initialVersion = editor.getModel().getAlternativeVersionId();
53-
let currentVersion = initialVersion;
54-
let lastVersion = initialVersion;
55-
5652
if (editorCreatedCallback != null) {
57-
editorCreatedCallback.apply([editorView]);
53+
editorCreatedCallback.apply(null, [editorView]);
5854
}
5955

6056
editorView.onDidChangeModelContent((ev) => {
6157
if (contentChangeListener != null) {
62-
contentChangeListener.apply([ev]);
63-
}
64-
65-
const versionId = editorView.getModel().getAlternativeVersionId();
66-
// undoing
67-
if (versionId < currentVersion) {
68-
//enableRedoButton();
69-
// no more undo possible
70-
if (versionId === initialVersion) {
71-
//disableUndoButton();
72-
}
73-
} else {
74-
// redoing
75-
if (versionId <= lastVersion) {
76-
// redoing the last change
77-
if (versionId === lastVersion) {
78-
//disableRedoButton();
79-
}
80-
} else { // adding new change, disable redo when adding new changes
81-
//disableRedoButton();
82-
if (currentVersion > lastVersion) {
83-
lastVersion = currentVersion;
84-
}
85-
}
86-
//enableUndoButton();
58+
contentChangeListener.apply(null, [ev]);
8759
}
88-
currentVersion = versionId;
8960
});
9061

9162
editorView.onDidScrollChange((ev) => {
9263
if (scrollChangeListener != null) {
93-
scrollChangeListener.apply([ev]);
64+
scrollChangeListener.apply(null, [ev]);
9465
}
9566
});
67+
68+
return editorView;
9669
});
9770

9871
function getEditorView() {
@@ -221,6 +194,11 @@
221194
const editor = getEditorView();
222195
editor.trigger('source','editor.action.clipboardPasteAction');
223196
}
197+
198+
function trigger(action) {
199+
const editor = getEditorView();
200+
editor.trigger('source', action);
201+
}
224202
</script>
225203
</body>
226204
</html>

ide/src/ide/editors/MonacoCodeEditor.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,4 +165,14 @@ public function jumpToLine(int $line, int $offset = 0)
165165
{
166166
$this->editor->getEditor()->revealLineInCenter($line);
167167
}
168+
169+
public function showFindDialog()
170+
{
171+
$this->editor->getEditor()->trigger('actions.find');
172+
}
173+
174+
public function showReplaceDialog()
175+
{
176+
$this->editor->getEditor()->trigger('actions.find');
177+
}
168178
}

0 commit comments

Comments
 (0)