Skip to content

Commit

Permalink
Adds undo support. Bump to 1.0.0-alpha.4
Browse files Browse the repository at this point in the history
  • Loading branch information
mmikkel committed Jul 10, 2023
1 parent b69856d commit 2c9544e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "vaersaagod/aimate",
"description": "Ai ai, mate.",
"type": "craft-plugin",
"version": "1.0.0-alpha.3",
"version": "1.0.0-alpha.4",
"require": {
"php": "^8.1.0",
"craftcms/cms": "^4.4.0",
Expand Down
10 changes: 8 additions & 2 deletions src/templates/button.twig
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,19 @@ $(() => {
if (!ckEditorInstance) {
throw new Error('Unable to find CKEditor instance in DOM');
}
ckEditorInstance.setData(data.text);
ckEditorInstance.focus();
ckEditorInstance.execute('selectAll');
const viewFragment = ckEditorInstance.data.processor.toView(data.text);
const modelFragment = ckEditorInstance.data.toModel(viewFragment);
ckEditorInstance.model.insertContent(modelFragment);
} else if (fieldType === 'craft\\redactor\\Field') {
$R(`#${input.id}`, 'source.setCode', data.text);
} else {
input.value = data.text;
input.focus();
input.select();
if (!document.execCommand('insertText', false, data.text)) {
input.setRangeText(data.text);
}
}
if (elementEditor) {
elementEditor.checkForm();
Expand Down

0 comments on commit 2c9544e

Please sign in to comment.