diff --git a/extensions/markdown/CHANGELOG.md b/extensions/markdown/CHANGELOG.md index 5c0647ede..bf65dbef9 100644 --- a/extensions/markdown/CHANGELOG.md +++ b/extensions/markdown/CHANGELOG.md @@ -3,85 +3,104 @@ ## [1.1.0](https://github.com/flarum/markdown/compare/v1.0.1...v1.1.0) ### Added + - Spoiler and strikethrough buttons (https://github.com/flarum/markdown/pulls/30) ### Fixed + - Browser/system shortcuts triggering when applying editor style from shortcut (https://github.com/flarum/markdown/pulls/32) ## [1.0.1](https://github.com/flarum/markdown/compare/v1.0.0...v1.0.1) ### Fixed + - Link button is not visible on the markdown toolbar (https://github.com/flarum/markdown/pull/29) ## [1.0.0](https://github.com/flarum/markdown/compare/v0.1.0-beta.16.1...v1.0.0) ### Changed + - Compatibility with Flarum v1.0.0. - GitHub markdown toolbar moves to flarum/core (https://github.com/flarum/markdown/pull/28) - Simplification of toolbar and button system (https://github.com/flarum/markdown/pull/28) ### Fixed + - Toolbar buttons submits the form - Tooltips generate a deprecation warning ### Removed + - Dropped mdarea (https://github.com/flarum/markdown/pull/28) ## [0.1.0-beta.16.1](https://github.com/flarum/markdown/compare/v0.1.0-beta.16...v0.1.0-beta.16.1) ### Added + - Admin setting to disable mdarea (https://github.com/flarum/markdown/pull/27) ## [0.1.0-beta.16](https://github.com/flarum/markdown/compare/v0.1.0-beta.15...v0.1.0-beta.16) ### Added + - Editor Driver support ([ba3e1fb](https://github.com/flarum/markdown/commit/ba3e1fb528ce7e85bde27753f6c1cce3b03fe9d3)) ### Changed + - Updated admin category from formatting to feature (https://github.com/flarum/markdown/pull/25) - Moved locale files from translation pack to extension (https://github.com/flarum/markdown/pull/21) ### Fixed + - Double quote marks cause inconvenience typing ([6d8ea34](https://github.com/flarum/markdown/commit/6d8ea342061fdd2ab267cee93b9f5ade69149123)) ## [0.1.0-beta.15](https://github.com/flarum/markdown/compare/v0.1.0-beta.14...v0.1.0-beta.15) ### Changed + - Updated composer.json and admin javascript for new admin area. ## [0.1.0-beta.14](https://github.com/flarum/markdown/compare/v0.1.0-beta.13...v0.1.0-beta.14) ### Changed + - Switch image and link defaults (#11) - Updated mithril to version 2 - Load language strings correctly on en-/disable ### Removed + - Support for IE 11 (#18) ## [0.1.0-beta.13](https://github.com/flarum/markdown/compare/v0.1.0-beta.12...v0.1.0-beta.13) ### Changed + - Updated JS dependencies ### Fixed + - Fixed not hiding other html entities than mentions (#14) ## [0.1.0-beta.12](https://github.com/flarum/markdown/compare/v0.1.0-beta.10...v0.1.0-beta.12) ### Fixed + - Mentions could be seen within spoiler blocks (#13) ## [0.1.0-beta.10](https://github.com/flarum/markdown/compare/v0.1.0-beta.9...v0.1.0-beta.10) ### Added + - The toolbar now has an image button (#8) ### Fixed + - Unusable toolbar in IE11 (#8) - Tabbing out of the post composer was not possible (#8) ## [0.1.0-beta.9](https://github.com/flarum/markdown/compare/v0.1.0-beta.8...v0.1.0-beta.9) ### Fixed + - Markdown toolbar did not work on IE11 ([31c064f](https://github.com/flarum/markdown/commit/31c064f0c6c945083bc0ebc50cb3e44a676f40e2) and [e762293](https://github.com/flarum/markdown/commit/e7622938b1422e89a50feeb52c9c9ef7b38db95a)) diff --git a/extensions/markdown/composer.json b/extensions/markdown/composer.json index c2f99a332..2950109c6 100644 --- a/extensions/markdown/composer.json +++ b/extensions/markdown/composer.json @@ -1,39 +1,41 @@ { - "name": "flarum/markdown", - "description": "Allow posts to be formatted with Markdown.", - "type": "flarum-extension", - "keywords": ["formatting"], - "license": "MIT", - "support": { - "issues": "https://github.com/flarum/core/issues", - "source": "https://github.com/flarum/markdown", - "forum": "https://discuss.flarum.org" - }, - "homepage": "https://flarum.org", - "funding": [ - { - "type": "website", - "url": "https://flarum.org/donate/" - } - ], - "require": { - "flarum/core": "^1.1" - }, - "extra": { - "branch-alias": { - "dev-master": "1.x-dev" - }, - "flarum-extension": { - "title": "Markdown", - "category": "feature", - "icon": { - "image": "icon.svg", - "backgroundColor": "#000", - "backgroundSize": "100%", - "backgroundRepeat": "no-repeat", - "backgroundPosition": "center", - "color": "#fff" - } - } + "name": "flarum/markdown", + "description": "Allow posts to be formatted with Markdown.", + "type": "flarum-extension", + "keywords": [ + "formatting" + ], + "license": "MIT", + "support": { + "issues": "https://github.com/flarum/core/issues", + "source": "https://github.com/flarum/markdown", + "forum": "https://discuss.flarum.org" + }, + "homepage": "https://flarum.org", + "funding": [ + { + "type": "website", + "url": "https://flarum.org/donate/" } + ], + "require": { + "flarum/core": "^1.1" + }, + "extra": { + "branch-alias": { + "dev-master": "1.x-dev" + }, + "flarum-extension": { + "title": "Markdown", + "category": "feature", + "icon": { + "image": "icon.svg", + "backgroundColor": "#000", + "backgroundSize": "100%", + "backgroundRepeat": "no-repeat", + "backgroundPosition": "center", + "color": "#fff" + } + } + } } diff --git a/extensions/markdown/js/.prettierignore b/extensions/markdown/js/.prettierignore new file mode 100644 index 000000000..eba06004b --- /dev/null +++ b/extensions/markdown/js/.prettierignore @@ -0,0 +1,2 @@ +.yarn +dist diff --git a/extensions/markdown/js/package.json b/extensions/markdown/js/package.json index e5dbd8512..47aec8a96 100644 --- a/extensions/markdown/js/package.json +++ b/extensions/markdown/js/package.json @@ -1,6 +1,7 @@ { "private": true, "name": "@flarum/markdown", + "prettier": "@flarum/prettier-config", "dependencies": { "flarum-webpack-config": "^1.0.0", "webpack": "^4.46.0", @@ -8,7 +9,13 @@ }, "scripts": { "dev": "webpack --mode development --watch", - "build": "webpack --mode production" + "build": "webpack --mode production", + "format": "prettier --write src", + "format-check": "prettier --check src" }, - "packageManager": "yarn@3.1.1" + "packageManager": "yarn@3.1.1", + "devDependencies": { + "@flarum/prettier-config": "^1.0.0", + "prettier": "^2.5.1" + } } diff --git a/extensions/markdown/js/src/forum/components/MarkdownToolbar.js b/extensions/markdown/js/src/forum/components/MarkdownToolbar.js index cafb55a20..59c073265 100644 --- a/extensions/markdown/js/src/forum/components/MarkdownToolbar.js +++ b/extensions/markdown/js/src/forum/components/MarkdownToolbar.js @@ -2,8 +2,6 @@ import Component from 'flarum/common/Component'; export default class MarkdownToolbar extends Component { view(vnode) { - return
; + return ; } } diff --git a/extensions/markdown/js/src/forum/index.js b/extensions/markdown/js/src/forum/index.js index ce32a7906..429cb809b 100644 --- a/extensions/markdown/js/src/forum/index.js +++ b/extensions/markdown/js/src/forum/index.js @@ -18,33 +18,33 @@ import MarkdownButton from './components/MarkdownButton'; const modifierKey = navigator.userAgent.match(/Macintosh/) ? '⌘' : 'ctrl'; const styles = { - 'header': { prefix: '### ' }, - 'bold': { prefix: '**', suffix: '**', trimFirst: true }, - 'italic': { prefix: '_', suffix: '_', trimFirst: true }, - 'strikethrough': { prefix: '~~', suffix: '~~', trimFirst: true }, - 'quote': { prefix: '> ', multiline: true, surroundWithNewlines: true }, - 'code': { prefix: '`', suffix: '`', blockPrefix: '```', blockSuffix: '```' }, - 'link': { prefix: '[', suffix: '](https://)', replaceNext: 'https://', scanFor: 'https?://' }, - 'image': { prefix: '![', suffix: '](https://)', replaceNext: 'https://', scanFor: 'https?://' }, - 'unordered_list': { prefix: '- ', multiline: true, surroundWithNewlines: true }, - 'ordered_list': { prefix: '1. ', multiline: true, orderedList: true }, - 'spoiler': { prefix: '>!', suffix: '!<', blockPrefix: '>! ', multiline: true, trimFirst: true } -} + header: { prefix: '### ' }, + bold: { prefix: '**', suffix: '**', trimFirst: true }, + italic: { prefix: '_', suffix: '_', trimFirst: true }, + strikethrough: { prefix: '~~', suffix: '~~', trimFirst: true }, + quote: { prefix: '> ', multiline: true, surroundWithNewlines: true }, + code: { prefix: '`', suffix: '`', blockPrefix: '```', blockSuffix: '```' }, + link: { prefix: '[', suffix: '](https://)', replaceNext: 'https://', scanFor: 'https?://' }, + image: { prefix: '![', suffix: '](https://)', replaceNext: 'https://', scanFor: 'https?://' }, + unordered_list: { prefix: '- ', multiline: true, surroundWithNewlines: true }, + ordered_list: { prefix: '1. ', multiline: true, orderedList: true }, + spoiler: { prefix: '>!', suffix: '!<', blockPrefix: '>! ', multiline: true, trimFirst: true }, +}; const applyStyle = (id) => { // This is a nasty hack that breaks encapsulation of the editor. // In future releases, we'll need to tweak the editor driver interface // to support triggering events like this. styleSelectedText(app.composer.editor.el, styles[id]); -} +}; function makeShortcut(id, key) { return function (e) { - if (e.key === key && (e.metaKey && modifierKey === '⌘' || e.ctrlKey && modifierKey === 'ctrl')) { + if (e.key === key && ((e.metaKey && modifierKey === '⌘') || (e.ctrlKey && modifierKey === 'ctrl'))) { e.preventDefault(); applyStyle(id); } - } + }; } app.initializers.add('flarum-markdown', function (app) { @@ -60,14 +60,15 @@ app.initializers.add('flarum-markdown', function (app) { const makeApplyStyle = (id) => { return () => applyStyle(id); - } + }; - items.add('markdown', ( -