Comparing version 1.0.2 to 1.1.0
@@ -6,5 +6,2 @@ 'use strict'; | ||
}); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
exports.default = createRenderer; | ||
@@ -26,8 +23,2 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function createRenderer(tracker, options) { | ||
@@ -91,51 +82,10 @@ var overrides = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {}; | ||
var CodeComponent = function (_React$Component) { | ||
_inherits(CodeComponent, _React$Component); | ||
function CodeComponent() { | ||
return _react2.default.createElement( | ||
'pre', | ||
{ className: 'language-' + language }, | ||
_react2.default.createElement('code', { className: 'language-' + language, dangerouslySetInnerHTML: { __html: Prism.highlight(code, Prism.languages[language]) } }) | ||
); | ||
} | ||
function CodeComponent() { | ||
_classCallCheck(this, CodeComponent); | ||
return _possibleConstructorReturn(this, (CodeComponent.__proto__ || Object.getPrototypeOf(CodeComponent)).apply(this, arguments)); | ||
} | ||
_createClass(CodeComponent, [{ | ||
key: 'componentDidMount', | ||
value: function componentDidMount() { | ||
if (typeof Prism === 'undefined') { | ||
console.warn('You do not have Prism included as a global object'); | ||
return; | ||
} | ||
Prism.highlightElement(this.node); | ||
} | ||
}, { | ||
key: 'componentDidUpdate', | ||
value: function componentDidUpdate() { | ||
if (typeof Prism === 'undefined') { | ||
console.warn('You do not have Prism included as a global object'); | ||
return; | ||
} | ||
Prism.highlightElement(this.node); | ||
} | ||
}, { | ||
key: 'render', | ||
value: function render() { | ||
var _this2 = this; | ||
return _react2.default.createElement( | ||
'pre', | ||
null, | ||
_react2.default.createElement( | ||
'code', | ||
{ ref: function ref(node) { | ||
return _this2.node = node; | ||
}, className: 'language-' + language }, | ||
code | ||
) | ||
); | ||
} | ||
}]); | ||
return CodeComponent; | ||
}(_react2.default.Component); | ||
tracker.elements[elementId] = _react2.default.createElement(CodeComponent, { key: elementId }); | ||
@@ -142,0 +92,0 @@ |
{ | ||
"name": "marksy", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "Convert markdown into react components", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -81,3 +81,3 @@ # marksy | ||
## Code highlighting | ||
To enable code highlighting the [Prism](http://prismjs.com/) project needs to be available on window. | ||
To enable code highlighting the [Prism](http://prismjs.com/) project needs to be available on window. This also works on server side. Just make sure the Prism CSS is instantly available on server side rendering. | ||
@@ -84,0 +84,0 @@ ## Developing |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31680
254