Skip to content

Commit

Permalink
Making further changes
Browse files Browse the repository at this point in the history
  • Loading branch information
LoveDuckie committed Jun 24, 2024
1 parent 3c3f229 commit 32c8c13
Show file tree
Hide file tree
Showing 12 changed files with 73 additions and 68 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import React from 'react';

import ReactDOM from 'react-dom';

import ReactSimpleMDE from 'react-simplemde-editor';
import SimpleMdeReact from 'react-simplemde-editor';
import jQuery from 'jquery';
import ShortcodeParser from '../ShortCodeParser/ShortCodeParser';
import ShortCodeParser from '../ShortCodeParser/ShortCodeParser';

const SimpleMDE = require('simplemde');
// const SimpleMDE = require('simplemde');
const EasyMDE = require('easymde');

const parser = new ShortcodeParser();
const parser = new ShortCodeParser();

const ss = typeof window.ss !== 'undefined' ? window.ss : {};
if (typeof ss.markdownConfigs === 'undefined') {
Expand All @@ -17,16 +18,19 @@ if (typeof ss.markdownConfigs === 'undefined') {

ss.markdownConfigs.readToolbarConfigs = function (data) {
const toolbar = [];
for (const key in data) {
for (let i = 0; i < data.length; i++) {
// for (const key in data) {
const key = data[i];
const element = data[key];

if (typeof element === 'string') {
toolbar.push(element);
} else {
const action = element.action;
if (typeof SimpleMDE[element.action] !== 'undefined') {
if (typeof EasyMDE[element.action] !== 'undefined') {
toolbar.push({
name: element.name,
action: SimpleMDE[element.action],
action: EasyMDE[element.action],
className: element.className,
title: element.title,
});
Expand Down Expand Up @@ -86,7 +90,7 @@ class MarkdownEditorField extends React.Component {
render() {
return (
<div className="editor-container">
<ReactSimpleMDE
<SimpleMdeReact
value={this.props.textarea.value}
onChange={this.handleChange.bind(this)}
options={{
Expand Down Expand Up @@ -130,7 +134,7 @@ jQuery.entwine('ss', ($) => {
dialog.setElement(editor);
dialog.open();
} else {
SimpleMDE.drawImage(editor);
EasyMDE.drawImage(editor);
}
});

Expand Down Expand Up @@ -160,4 +164,4 @@ jQuery.entwine('ss', ($) => {
});
});

export default { MarkdownEditorField };
export default MarkdownEditorField;
7 changes: 4 additions & 3 deletions client/src/components/ShortCodeParser/ShortCodeParser.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class ShortCodeParser {

parseShortcode(name, buf, inline) {
let regex;
let match;
let match = null;
let attr = {};

if (inline) {
Expand All @@ -65,8 +65,8 @@ class ShortCodeParser {
'i'
);
}

while ((match = buf.match(regex)) !== null) {
match = buf.match(regex);
while (match !== null) {
const key = match[3] || match[2];
const val = match[4] || match[3];
const pattern = match[1];
Expand All @@ -77,6 +77,7 @@ class ShortCodeParser {
} else {
break;
}
match = buf.match(regex);
}

attr = Object.keys(attr)
Expand Down
14 changes: 14 additions & 0 deletions client/src/entwine/Markdown_ssmedia.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* global jQuery */
import jQuery from 'jquery';
import React from 'react';
import ReactDOM from 'react-dom';

import { ApolloProvider } from 'react-apollo';
import { provideInjector } from 'lib/Injector';
const InjectableInsertEmbedModal = window.InsertEmbedModal ? provideInjector(window.InsertEmbedModal.default) : null;

(function ($) {
$(document).ready(() => {
// your code here.
});
}(jQuery));
7 changes: 0 additions & 7 deletions client/src/entwine/example-file.js

This file was deleted.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
},
"dependencies": {
"core-js": "^3.26.0",
"easymde": "^2.18.0",
"jquery": "^3.7.1",
"react": "^18.2.0",
"react-simplemde-editor": "^5.2.0"
Expand Down
8 changes: 0 additions & 8 deletions src/Database/MarkdownText.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
<?php
/**
* Created by Nivanka Fonseka ([email protected]).
* User: nivankafonseka
* Date: 4/18/15
* Time: 11:11 AM
* To change this template use File | Settings | File Templates.
*/

namespace LoveDuckie\SilverStripe\Markdown\Database;

use cebe\markdown\GithubMarkdown;
Expand Down
7 changes: 0 additions & 7 deletions src/Extensions/MarkdownDataObjectExtension.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
<?php
/**
* Created by PhpStorm.
* User: Nivanka Fonseka
* Date: 24/09/2017
* Time: 00:02
*/

namespace LoveDuckie\SilverStripe\Markdown\extensions;

use SilverStripe\Core\Config\Config;
Expand Down
8 changes: 0 additions & 8 deletions src/Extensions/MarkdownFieldExtension.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
<?php
/**
* Created by Nivanka Fonseka ([email protected]).
* User: nivankafonseka
* Date: 9/23/17
* Time: 6:30 AM
* To change this template use File | Settings | File Templates.
*/

namespace LoveDuckie\SilverStripe\Markdown\extensions;

use SilverStripe\Core\Extension;
Expand Down
8 changes: 0 additions & 8 deletions src/Forms/MarkdownEditorConfig.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,4 @@
<?php
/**
* Created by Nivanka Fonseka ([email protected]).
* User: nivankafonseka
* Date: 10/24/17
* Time: 10:27 AM
* To change this template use File | Settings | File Templates.
*/

namespace LoveDuckie\SilverStripe\Markdown\Forms;

use LogicException;
Expand Down
7 changes: 0 additions & 7 deletions src/Forms/MarkdownEditorField.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
<?php
/**
* Created by Nivanka Fonseka ([email protected]).
* User: nivankafonseka
* Date: 4/18/15
* Time: 11:12 AM
* To change this template use File | Settings | File Templates.
*/
namespace LoveDuckie\SilverStripe\Markdown\Forms;

use SilverStripe\Forms\TextareaField;
Expand Down
10 changes: 1 addition & 9 deletions src/ShortCodes/MarkdownImageShortcodeProvider.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,5 @@
<?php
/**
* Created by Nivanka Fonseka ([email protected]).
* User: nivankafonseka
* Date: 10/17/17
* Time: 3:12 PM
* To change this template use File | Settings | File Templates.
*/

namespace SilverStripers\markdown\shortcodes;
namespace LoveDuckie\SilverStripe\Markdown\Shortcodes;

use SilverStripe\Assets\Image;
use SilverStripe\Core\Convert;
Expand Down
40 changes: 39 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1711,7 +1711,7 @@
dependencies:
"@babel/types" "^7.20.7"

"@types/codemirror@~5.60.5":
"@types/codemirror@^5.60.4", "@types/codemirror@~5.60.5":
version "5.60.15"
resolved "https://registry.yarnpkg.com/@types/codemirror/-/codemirror-5.60.15.tgz#0f82be6f4126d1e59cf4c4830e56dcd49d3c3e8a"
integrity sha512-dTOvwEQ+ouKJ/rE9LT1Ue2hmP6H1mZv5+CCnNWu2qtiOe2LQa9lCprEY20HxiDmV/Bxh+dXjywmy5aKvoGjULA==
Expand Down Expand Up @@ -1784,6 +1784,11 @@
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==

"@types/marked@^4.0.7":
version "4.3.2"
resolved "https://registry.yarnpkg.com/@types/marked/-/marked-4.3.2.tgz#e2e0ad02ebf5626bd215c5bae2aff6aff0ce9eac"
integrity sha512-a79Yc3TOk6dGdituy8hmTTJXjOkZ7zsFYV10L337ttq/rec8lRMDBpV7fL3uLx6TgbFCa5DU/h8FmIBQPSbU0w==

"@types/node@*":
version "20.14.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-20.14.8.tgz#45c26a2a5de26c3534a9504530ddb3b27ce031ac"
Expand Down Expand Up @@ -2696,6 +2701,18 @@ co@^4.6.0:
resolved "https://registry.yarnpkg.com/co/-/co-4.6.0.tgz#6ea6bdf3d853ae54ccb8e47bfa0bf3f9031fb184"
integrity sha512-QVb0dM5HvG+uaxitm8wONl7jltx8dqhfU33DcqtOZcLSVIKSDDLDi7+0LbAKiyI8hD9u42m2YxXSkMGWThaecQ==

[email protected]:
version "1.1.2"
resolved "https://registry.yarnpkg.com/codemirror-spell-checker/-/codemirror-spell-checker-1.1.2.tgz#1c660f9089483ccb5113b9ba9ca19c3f4993371e"
integrity sha512-2Tl6n0v+GJRsC9K3MLCdLaMOmvWL0uukajNJseorZJsslaxZyZMgENocPU8R0DyoTAiKsyqiemSOZo7kjGV0LQ==
dependencies:
typo-js "*"

codemirror@^5.63.1:
version "5.65.16"
resolved "https://registry.yarnpkg.com/codemirror/-/codemirror-5.65.16.tgz#efc0661be6bf4988a6a1c2fe6893294638cdb334"
integrity sha512-br21LjYmSlVL0vFCPWPfhzUCT34FM/pAdK7rRIZwa0rrtrIdotvP4Oh4GUHsu2E3IrQMCfRkL/fN3ytMNxVQvg==

collect-v8-coverage@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/collect-v8-coverage/-/collect-v8-coverage-1.0.2.tgz#c0b29bcd33bcd0779a1344c2136051e6afd3d9e9"
Expand Down Expand Up @@ -3123,6 +3140,17 @@ duplexer@^0.1.2:
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6"
integrity sha512-jtD6YG370ZCIi/9GTaJKQxWTZD045+4R4hTk/x1UyoqadyJ9x9CgSi1RlVDQF8U2sxLLSnFkCaMihqljHIWgMg==

easymde@^2.18.0:
version "2.18.0"
resolved "https://registry.yarnpkg.com/easymde/-/easymde-2.18.0.tgz#ff1397d07329b1a7b9187d2d0c20766fa16b3b1b"
integrity sha512-IxVVUxNWIoXLeqtBU4BLc+eS/ScYhT1Dcb6yF5Wchoj1iXAV+TIIDWx+NCaZhY7RcSHqDPKllbYq7nwGKILnoA==
dependencies:
"@types/codemirror" "^5.60.4"
"@types/marked" "^4.0.7"
codemirror "^5.63.1"
codemirror-spell-checker "1.1.2"
marked "^4.1.0"

electron-to-chromium@^1.4.796:
version "1.4.810"
resolved "https://registry.yarnpkg.com/electron-to-chromium/-/electron-to-chromium-1.4.810.tgz#7dee01b090b9e048e6db752f7b30921790230654"
Expand Down Expand Up @@ -5387,6 +5415,11 @@ markdown-it@^13.0.1:
mdurl "^1.0.1"
uc.micro "^1.0.5"

marked@^4.1.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/marked/-/marked-4.3.0.tgz#796362821b019f734054582038b116481b456cf3"
integrity sha512-PRsaiG84bK+AMvxziE/lCFss8juXjNaWzVbN5tXAm4XjeaS9NAHhop+PjQxz2A9h8Q4M/xGmzP8vqNwy6JeK0A==

mathml-tag-names@^2.1.3:
version "2.1.3"
resolved "https://registry.yarnpkg.com/mathml-tag-names/-/mathml-tag-names-2.1.3.tgz#4ddadd67308e780cf16a47685878ee27b736a0a3"
Expand Down Expand Up @@ -7352,6 +7385,11 @@ typed-array-length@^1.0.6:
is-typed-array "^1.1.13"
possible-typed-array-names "^1.0.0"

typo-js@*:
version "1.2.4"
resolved "https://registry.yarnpkg.com/typo-js/-/typo-js-1.2.4.tgz#0e009c289a966dd51dc80a75580289a381cc607f"
integrity sha512-Oy/k+tFle5NAA3J/yrrYGfvEnPVrDZ8s8/WCwjUE75k331QyKIsFss7byQ/PzBmXLY6h1moRnZbnaxWBe3I3CA==

uc.micro@^1.0.1, uc.micro@^1.0.5:
version "1.0.6"
resolved "https://registry.yarnpkg.com/uc.micro/-/uc.micro-1.0.6.tgz#9c411a802a409a91fc6cf74081baba34b24499ac"
Expand Down

0 comments on commit 32c8c13

Please sign in to comment.