Skip to content

Commit

Permalink
Merge pull request #30 from ProWorksCorporation/feature/TINY-18-upgra…
Browse files Browse the repository at this point in the history
…de-v12-latest

Feature/tiny 18 upgrade v12 latest
  • Loading branch information
protherj authored Mar 12, 2024
2 parents eb52ed7 + cfe9df8 commit db2c11a
Show file tree
Hide file tree
Showing 12 changed files with 69 additions and 12 deletions.
5 changes: 3 additions & 2 deletions src/TinyMCE.Umbraco.Premium/Composers/TinyMceComposer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -280,8 +280,9 @@ public ServerVariablesParsingNotificationHandler(IOptions<TinyMceConfig> tinyMce
/// <inheritdoc />
public void Handle(ServerVariablesParsingNotification notification) => notification.ServerVariables.Add("tinymcepremium", new
{
apiKey = _tinyMceConfig != null ? _tinyMceConfig.apikey : "",
});
apiKey = _tinyMceConfig != null ? _tinyMceConfig.apikey : "",
openAiApikey = _tinyMceConfig != null ? _tinyMceConfig.openAiApikey : "",
});
}
}

Expand Down
1 change: 1 addition & 0 deletions src/TinyMCE.Umbraco.Premium/Options/TinyMceConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace TinyMCE.Umbraco.Premium.Options
public class TinyMceConfig
{
public string apikey { get; set; } = "";
public string openAiApikey { get; set; } = "";
public string[] pluginsToExclude { get; set; } = new string[] { };
public Dictionary<string, object> customConfig { get; set; } = new Dictionary<string, object>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ public IEnumerable<UmbracoEntityReference> GetReferences(object? value)

// [Obsolete("Use the overload with the 'availableCultures' parameter instead, scheduled for removal in v14")]
// public IEnumerable<KeyValuePair<string, IEnumerable<object?>>> GetIndexValues(IProperty property, string? culture, string? segment, bool published)
// => GetIndexValues(property, culture, segment, published);
// => GetIndexValues(property, culture, segment, published, Enumerable.Empty<string>());
//}
}
}
6 changes: 3 additions & 3 deletions src/TinyMCE.Umbraco.Premium/TinyMCE.Umbraco.Premium.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<PackageId>tinymce.umbraco.premium</PackageId>
<Product>TinyMCE.Umbraco.Premium</Product>
<Title>TinyMCE.Umbraco.Premium</Title>
<Version>12.0.0</Version>
<Version>12.3.7</Version>
<Description>Umbraco CMS package that enables the TinyMCE-based Rich Text Editor (RTE) in Umbraco versions 12+ to be licensed to access the paid Premium features in TinyMCE.</Description>
<PackageTags>umbraco plugin package tinymce</PackageTags>
<Authors>jasonproworks</Authors>
Expand All @@ -21,8 +21,8 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Umbraco.Cms.Web.Website" Version="12.0.0" />
<PackageReference Include="Umbraco.Cms.Web.BackOffice" Version="12.0.0" />
<PackageReference Include="Umbraco.Cms.Web.Website" Version="12.3.7" />
<PackageReference Include="Umbraco.Cms.Web.BackOffice" Version="12.3.7" />
</ItemGroup>

</Project>
2 changes: 1 addition & 1 deletion src/TinyMCE.Umbraco.Premium/package.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="12.0" encoding="utf-8"?>
<?xml version="12.3.7" encoding="utf-8"?>
<umbPackage>
<info>
<package>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
(function (config, undefined) {

config.ai_request = {
ai_request: (request, respondWith) => {
const openAiOptions = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${Umbraco.Sys.ServerVariables.tinymcepremium.openAiApikey}`
},
body: JSON.stringify({
model: 'gpt-3.5-turbo',
temperature: 0.7,
max_tokens: 800,
messages: [{ role: 'user', content: request.prompt }],
})
};
respondWith.string((signal) => window.fetch('https://api.openai.com/v1/chat/completions', { signal, ...openAiOptions })
.then(async (response) => {
if (response) {
const data = await response.json();
if (data.error) {
throw new Error(`${data.error.type}: ${data.error.message}`);
} else if (response.ok) {
// Extract the response content from the data returned by the API
return data?.choices[0]?.message?.content?.trim();
}
} else {
throw new Error('Failed to communicate with the ChatGPT API');
}
})
);
}
};
}(window.tinymcepremium.Config = window.tinymcepremium.Config || {}));
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"~/App_Plugins/TinyMCE.Umbraco.Premium/PreValues/tinymce.rte.prevalues.controller.js",
"~/App_Plugins/TinyMCE.Umbraco.Premium/premium.rte.controller.js",
"~/App_Plugins/TinyMCE.Umbraco.Premium/Defaults/advtemplate.templates.js",
"~/App_Plugins/TinyMCE.Umbraco.Premium/Defaults/mergetags.templates.js"
"~/App_Plugins/TinyMCE.Umbraco.Premium/Defaults/mergetags.templates.js",
"~/App_Plugins/TinyMCE.Umbraco.Premium/Defaults/ai.templates.js"
],
"bundleOptions": "None"
}
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,15 @@
mode: "Selection"
}
},
{
name: "AI Assistant Shortcuts (Premium Plugin)",
alias: "ai",
command: {
alias: "aishortcuts aidialog",
name: "AI Assistant (Premium Plugin)",
mode: "Insert"
}
},
{
name: "Case Change (Premium Plugin)",
alias: "casechange",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,13 @@
}
}
}
if (standardConfig.plugins.indexOf("ai")) {
if (_.indexOf(standardConfigKeys, "ai_request") < 0) {
if (window.tinymcepremium.Config.ai_request != null) {
Utilities.extend(standardConfig, window.tinymcepremium.Config.ai_request);
}
}
}
if (standardConfig.plugins.indexOf("powerpaste")) {
// remove the "paste" plugin per TinyMCE docs
standardConfig.plugins = _.without(standardConfig.plugins, "paste");
Expand Down
4 changes: 2 additions & 2 deletions src/Umbraco.Cms.Demo/Umbraco.Cms.Demo.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Umbraco.Cms" Version="12.0.0" />
<PackageReference Include="Umbraco.Cms" Version="12.3.7" />
</ItemGroup>

<ItemGroup>
<!-- Opt-in to app-local ICU to ensure consistent globalization APIs across different platforms -->
<PackageReference Include="Microsoft.ICU.ICU4C.Runtime" Version="68.2.0.9" />
<PackageReference Include="uSync" Version="12.2.2" />
<PackageReference Include="uSync" Version="12.2.3" />
<ProjectReference Include="..\TinyMCE.Umbraco.Premium\TinyMCE.Umbraco.Premium.csproj" />
<RuntimeHostConfigurationOption Include="System.Globalization.AppLocalIcu" Value="68.2.0.9" Condition="$(RuntimeIdentifier.StartsWith('linux')) or $(RuntimeIdentifier.StartsWith('win')) or ('$(RuntimeIdentifier)' == '' and !$([MSBuild]::IsOSPlatform('osx')))" />
</ItemGroup>
Expand Down
1 change: 1 addition & 0 deletions src/Umbraco.Cms.Demo/appsettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
},
"TinyMceConfig": {
"apikey": "Add To User Secrets",
"openAiApikey": "Add To User Secrets",
"pluginsToExclude": [],
"customConfig": {
"spellchecker_ignore_list": [ "senectus", "malesuada" ],
Expand Down
6 changes: 4 additions & 2 deletions src/Umbraco.Cms.Demo/uSync/v9/DataTypes/TinyMcePremium.config
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"a11ycheck",
"tableofcontents",
"inserttemplate",
"aishortcuts aidialog",
"media"
],
"stylesheets": [
Expand Down Expand Up @@ -69,16 +70,17 @@
"advcode",
"advtable",
"advtemplate",
"ai",
"mediaembed",
"linkchecker",
"powerpaste",
"autocorrect"
],
"pluginsToExclude": [
"typography",
"formatpainter",
"mergetags",
"tableofcontents",
"formatpainter"
"tableofcontents"
],
"customConfigAsString": "{\n\t\"entity_encoding\": \"raw\",\n\t\"advcode_inline\": \"True\",\n\t\"spellchecker_language\": \"en\",\n\t\"test\": \"test\",\n\t\"advtemplate_templates\": \"[{\\\"title\\\":\\\"Quick replies\\\",\\\"items\\\":[{\\\"title\\\":\\\"Message received\\\",\\\"content\\\":\\\"\\\\u003Cp dir=\\\\u0022ltr\\\\u0022\\\\u003EHey {{Customer.FirstName}}!\\\\u003C/p\\\\u003E\\\\n\\\\u003Cp dir=\\\\u0022ltr\\\\u0022\\\\u003EJust a quick note to say we\\\\u0026rsquo;ve received your message, and will get back to you within 48 hours.\\\\u003C/p\\\\u003E\\\\n\\\\u003Cp dir=\\\\u0022ltr\\\\u0022\\\\u003EFor reference, your ticket number is: {{Ticket.Number}}\\\\u003C/p\\\\u003E\\\\n\\\\u003Cp dir=\\\\u0022ltr\\\\u0022\\\\u003EShould you have any questions in the meantime, just reply to this email and it will be attached to this ticket.\\\\u003C/p\\\\u003E\\\\n\\\\u003Cp\\\\u003E\\\\u003Cstrong\\\\u003E\\\\u0026nbsp;\\\\u003C/strong\\\\u003E\\\\u003C/p\\\\u003E\\\\n\\\\u003Cp dir=\\\\u0022ltr\\\\u0022\\\\u003ERegards,\\\\u003C/p\\\\u003E\\\\n\\\\u003Cp dir=\\\\u0022ltr\\\\u0022\\\\u003E{{Agent.FirstName}}\\\\u003C/p\\\\u003E\\\"},{\\\"title\\\":\\\"Thanks for the feedback\\\",\\\"content\\\":\\\"\\\\u003Cp dir=\\\\u0022ltr\\\\u0022\\\\u003EHi {{Customer.FirstName}},\\\\u003C/p\\\\u003E\\\\n\\\\u003Cp dir=\\\\u0022ltr\\\\u0022\\\\u003EWe appreciate you taking the time to provide feedback on {{Product.Name}}.\\\\u003C/p\\\\u003E\\\\n\\\\u003Cp dir=\\\\u0022ltr\\\\u0022\\\\u003EIt sounds like it wasn\\\\u0026rsquo;t able to fully meet your expectations, for which we apologize. Rest assured our team looks at each piece of feedback and uses it to decide what to focus on next with {{Product.Name}}.\\\\u003C/p\\\\u003E\\\\n\\\\u003Cp dir=\\\\u0022ltr\\\\u0022\\\\u003E\\\\u003Cstrong\\\\u003E\\\\u0026nbsp;\\\\u003C/strong\\\\u003E\\\\u003C/p\\\\u003E\\\\n\\\\u003Cp dir=\\\\u0022ltr\\\\u0022\\\\u003EAll the best, and let us know if there\\\\u0026rsquo;s anything else we can do to help.\\\\u003C/p\\\\u003E\\\\n\\\\u003Cp dir=\\\\u0022ltr\\\\u0022\\\\u003E-{{Agent.FirstName}}\\\\u003C/p\\\\u003E\\\"},{\\\"title\\\":\\\"Still working on case\\\",\\\"content\\\":\\\"\\\\u003Cp dir=\\\\u0022ltr\\\\u0022\\\\u003EHi {{Customer.FirstName}},\\\\u003C/p\\\\u003E\\\\n\\\\u003Cp dir=\\\\u0022ltr\\\\u0022\\\\u003EJust a quick note to let you know we\\\\u0026rsquo;re still working on your case. It\\\\u0026rsquo;s taking a bit longer than we hoped, but we\\\\u0026rsquo;re aiming to get you an answer in the next 48 hours.\\\\u003C/p\\\\u003E\\\\n\\\\u003Cp dir=\\\\u0022ltr\\\\u0022\\\\u003EStay tuned,\\\\u003C/p\\\\u003E\\\\n\\\\u003Cp dir=\\\\u0022ltr\\\\u0022\\\\u003E{{Agent.FirstName}}\\\\u003C/p\\\\u003E\\\"}]}]\",\n\t\"spellchecker_ignore_list\": \"[\\\"senectus\\\",\\\"malesuada\\\"]\"\n}"
},
Expand Down

0 comments on commit db2c11a

Please sign in to comment.